| | |
| | | using NPOI.HSSF.UserModel; |
| | | using Newtonsoft.Json.Linq; |
| | | using NPOI.HSSF.UserModel; |
| | | using NPOI.SS.UserModel; |
| | | using Pub_Class; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.IO; |
| | | using System.Net; |
| | | using System.Net.Http; |
| | | using System.Net.Http.Headers; |
| | | using System.Runtime.InteropServices; |
| | | using System.Web; |
| | | using System.Web.Http; |
| | | using System.Windows.Forms; |
| | | using WebAPI.Models; |
| | | //using Excel = Microsoft.Office.Interop.Excel; |
| | | |
| | | |
| | | namespace WebAPI.Controllers.åºç¡èµæ.åºç¡èµæ |
| | | { |
| | | public class Gy_SOPBillController : ApiController |
| | |
| | | private json objJsonResult = new json(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | DataSet ds; |
| | | DAL.ClsGy_SOPBill oBill = new DAL.ClsGy_SOPBill(); |
| | | |
| | | public DAL.ClsGy_SOPBill BillNew = new DAL.ClsGy_SOPBill(); |
| | | public DAL.ClsGy_SOPBill BillOld = new DAL.ClsGy_SOPBill(); |
| | | public bool BillChange; // |
| | | public DataGridView grdMain = new System.Windows.Forms.DataGridView(); |
| | | ClsGridViewSum oSumGrid = new ClsGridViewSum(); |
| | | |
| | | #region ä½ä¸æå¯¼ä¹¦å表 |
| | | [Route("Gy_SOPBill/list")] |
| | | [HttpGet] |
| | | public object getSOPBillList(string sWhere, string user) |
| | | //å®ä¹ |
| | | public const Int16 HTagCol = 0; |
| | | public const Int16 HSnoCol = 1; |
| | | public const Int16 HProcNoCol = 2; |
| | | public const Int16 HProcIDCol = 3; |
| | | public const Int16 HProcNumberCol = 4; |
| | | public const Int16 HProcNameCol = 5; |
| | | public const Int16 HWorkStationIDCol = 6; |
| | | public const Int16 HWorkStationNumberCol = 7; |
| | | public const Int16 HWorkStationNameCol = 8; |
| | | public const Int16 HCenterIDCol = 9; |
| | | public const Int16 HCenterNumberCol = 10; |
| | | public const Int16 HCenterNameCol = 11; |
| | | public const Int16 HRemarkCol = 12; |
| | | public const Int16 HEntryIDCol = 13; |
| | | |
| | | DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View(); |
| | | DAL.ClsIF_Unit_View oUnit = new DAL.ClsIF_Unit_View(); |
| | | DAL.ClsIF_Process_View oProc = new DAL.ClsIF_Process_View(); |
| | | DAL.ClsGy_WorkStation_View oStation = new DAL.ClsGy_WorkStation_View(); |
| | | DAL.ClsGy_WorkCenter_View oCenter = new DAL.ClsGy_WorkCenter_View(); |
| | | |
| | | #region 读åç±» |
| | | //æ¾ç¤ºåæ® |
| | | public void Sub_ShowBill() |
| | | { |
| | | DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View(); |
| | | DAL.ClsIF_Unit_View oUnit = new DAL.ClsIF_Unit_View(); |
| | | DAL.ClsIF_Process_View oProc = new DAL.ClsIF_Process_View(); |
| | | DAL.ClsGy_WorkStation_View oStation = new DAL.ClsGy_WorkStation_View(); |
| | | DAL.ClsGy_WorkCenter_View oCenter = new DAL.ClsGy_WorkCenter_View(); |
| | | //ClsGy_SourceHlp oSource = new ClsGy_SourceHlp(); |
| | | //夿æ¯å¦åå¨åæ® |
| | | if (BillOld.ShowBill(BillOld.omodel.HInterID, ref ClsPub.sExeReturnInfo) == false) |
| | | { |
| | | MessageBox.Show(ClsPub.sExeReturnInfo, "æç¤º"); |
| | | return; |
| | | } |
| | | //gridç¦æ¢å·æ° |
| | | |
| | | |
| | | //å è½½è¡¨ä½ |
| | | int i = 0; |
| | | foreach (Model.ClsGy_SOPBillSub oSub in BillOld.DetailColl) |
| | | { |
| | | if (i >= grdMain.RowCount - 1) |
| | | grdMain.Rows.Add(); |
| | | grdMain.Rows[i].Cells[HTagCol].Value = "*"; |
| | | |
| | | grdMain.Rows[i].Cells[HProcIDCol].Value = oSub.HProcID.ToString(); |
| | | if (oProc.GetInfoByID(oSub.HProcID)) |
| | | { |
| | | grdMain.Rows[i].Cells[HProcNumberCol].Value = oProc.omodel.HNumber; |
| | | grdMain.Rows[i].Cells[HProcNameCol].Value = oProc.omodel.HName; |
| | | } |
| | | else |
| | | { |
| | | grdMain.Rows[i].Cells[HProcNumberCol].Value = ""; |
| | | grdMain.Rows[i].Cells[HProcNameCol].Value = ""; |
| | | } |
| | | // |
| | | grdMain.Rows[i].Cells[HCenterIDCol].Value = oSub.HCenterID.ToString(); |
| | | if (oCenter.GetInfoByID(oSub.HCenterID)) |
| | | { |
| | | grdMain.Rows[i].Cells[HCenterNumberCol].Value = oCenter.omodel.HNumber; |
| | | grdMain.Rows[i].Cells[HCenterNameCol].Value = oCenter.omodel.HName; |
| | | } |
| | | else |
| | | { |
| | | grdMain.Rows[i].Cells[HCenterNameCol].Value = ""; |
| | | grdMain.Rows[i].Cells[HCenterNumberCol].Value = ""; |
| | | } |
| | | // |
| | | grdMain.Rows[i].Cells[HWorkStationIDCol].Value = oSub.HWorkStationID.ToString(); |
| | | if (oStation.GetInfoByID(oSub.HWorkStationID)) |
| | | { |
| | | grdMain.Rows[i].Cells[HWorkStationNumberCol].Value = oStation.omodel.HNumber; |
| | | grdMain.Rows[i].Cells[HWorkStationNameCol].Value = oStation.omodel.HName; |
| | | } |
| | | else |
| | | { |
| | | grdMain.Rows[i].Cells[HWorkStationNumberCol].Value = ""; |
| | | grdMain.Rows[i].Cells[HWorkStationNameCol].Value = ""; |
| | | } |
| | | // |
| | | grdMain.Rows[i].Cells[HProcNoCol].Value = oSub.HProcNo.ToString(); |
| | | |
| | | grdMain.Rows[i].Cells[HRemarkCol].Value = oSub.HRemark; |
| | | grdMain.Rows[i].Cells[HEntryIDCol].Value = oSub.HEntryID; |
| | | i = i + 1; |
| | | } |
| | | //GRIDå
è®¸å·æ° |
| | | DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid); |
| | | // |
| | | //Sub_OperStatus(); |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region ä¿ååæ® |
| | | [Route("Gy_SOPBill/ModifyByID")] |
| | | [HttpPost] |
| | | public object Sub_SaveBill([FromBody] JObject oMain) |
| | | { |
| | | try |
| | | { |
| | | //æ¥çæé |
| | | //if (!DBUtility.ClsPub.Security_Log("Gy_SOPBillMain", 1, false, user)) |
| | | var _value = oMain["oMain"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string msg3 = sArray[1].ToString();//å½å人 |
| | | |
| | | //ååºåå |
| | | msg2 = "[" + msg2.ToString() + "]"; |
| | | |
| | | List<SOPBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SOPBill>>(msg2); |
| | | |
| | | string HBillNo = list[0].HBillNo; |
| | | DateTime HDate = list[0].HDate; |
| | | string HName = list[0].HName; |
| | | int HMaterID = list[0].HMaterID; |
| | | string HMaterNumber = list[0].HMaterNumber; |
| | | string HMaterName = list[0].HMaterName; |
| | | string HMaterModel = list[0].HMaterModel; |
| | | int HUnitID = list[0].HUnitID; |
| | | string HUnitNumber = list[0].HUnitNumber; |
| | | string HUnitName = list[0].HUnitName; |
| | | string HRemark = list[0].HRemark; |
| | | bool HStandard = list[0].HStandard; |
| | | bool HUse = list[0].HUse; |
| | | |
| | | //夿æé |
| | | //if (!ClsPub.Security_Log("Gy_Repair_Edit", 1, false, msg3)) |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | | // objJsonResult.count = 0; |
| | | // objJsonResult.Message = "æ æ¥çæéï¼"; |
| | | // objJsonResult.Message = "æ²¡ææ¾å°è¯¥åè½æ¨¡åï¼"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn("select * from h_v_Gy_SOPBillList order by hmainid ", "h_v_Gy_SOPBillList"); |
| | | } |
| | | else |
| | | { |
| | | string sql1 = "select * from h_v_Gy_SOPBillList where 1 = 1 "; |
| | | string sql = sql1 + sWhere + " order by hmainid "; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Gy_SOPBillList"); |
| | | } |
| | | //è¥MAINDIéå¤åéæ°è·å |
| | | oCN.BeginTran(); |
| | | //主表 |
| | | oCN.RunProc("Insert Into Gy_SOPBillMain " + |
| | | "(HBillType,HInterID,HBillNo,HDate" + |
| | | ",HYear,HPeriod,HRemark,HMaker,Hmakedate,HMaterID,HName,HMaterTypeID" + |
| | | ",HUnitID,HMaterNumber,HUnitNumber,HStandard" + |
| | | ") " + |
| | | " values('" + 3305 + "'," + HMaterID + ",'" + HMaterID + "','" + "2022-11-04" + "'" + |
| | | "," + 2022 + "," + 11 + ",'" + HRemark + "','" + "Test" + "'," + "2022-11-04" + "," + HMaterID.ToString() + ",'" + HName + "'," + 656 + |
| | | "," + HUnitID.ToString() + ",'" + HMaterNumber + "','" + HUnitNumber + "','" + HStandard.ToString() + |
| | | "') "); |
| | | //" values(" + 3305 + "','" + 12333 + "','" + "test" + "','" + HDate + "','" + |
| | | //2022 + "','" + 11 + "','" + HRemark + "','" + "Test" + "','" + "2022-11-04" + "','" + HMaterID.ToString() + "','" + HName + "','" + "656" + |
| | | //"','" + HUnitID.ToString() + "','" + HMaterNumber + "','" + HUnitNumber + "','" + HStandard.ToString() + |
| | | //") "); |
| | | //ä¿®æ¹ä¸çº§ä¸ºéæ«çº§ä»£ç |
| | | //oCN.RunProc("Update Gy_MouldType set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | //if (ds.Tables[0].Rows.Count != 0 || ds != null) |
| | | //{ |
| | | oCN.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucessï¼"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.Message = "æ°å¢æåï¼"; |
| | | return objJsonResult; |
| | | //} |
| | | //else |
| | | //{ |
| | | //objJsonResult.code = "0"; |
| | | //objJsonResult.count = 0; |
| | | //objJsonResult.Message = "æ æ°æ®"; |
| | | //objJsonResult.data = null; |
| | | //return objJsonResult; |
| | | //} |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.Message = "Exceptionï¼" + e.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #region å¼åº |
| | | [Route("Gy_SOPBill/SetExcel")] |
| | | [HttpGet] |
| | | public HttpResponseMessage Sc_StationInBillSetExcel(string sWhere) |
| | | { |
| | | HSSFWorkbook workbook = new HSSFWorkbook(); |
| | | ISheet sheet = workbook.CreateSheet("sheet1"); |
| | | IRow row = sheet.CreateRow(0); |
| | | |
| | | |
| | | row.CreateCell(0).SetCellValue("åæ®å·"); |
| | | row.CreateCell(1).SetCellValue("åæ®ç±»å"); |
| | | row.CreateCell(2).SetCellValue("å·¥èºåç§°"); |
| | | row.CreateCell(3).SetCellValue("ç©æä»£ç "); |
| | | row.CreateCell(4).SetCellValue("ç©æåç§°"); |
| | | row.CreateCell(5).SetCellValue("è§æ ¼åå·"); |
| | | row.CreateCell(6).SetCellValue("计éåä½ä»£ç "); |
| | | row.CreateCell(7).SetCellValue("计éåä½"); |
| | | row.CreateCell(8).SetCellValue("é»è®¤æå¯¼ä¹¦"); |
| | | row.CreateCell(9).SetCellValue("è¡¨å¤´å¤æ³¨"); |
| | | row.CreateCell(10).SetCellValue("å·¥åºå·"); |
| | | row.CreateCell(11).SetCellValue("å·¥åºä»£ç "); |
| | | row.CreateCell(12).SetCellValue("å·¥åº"); |
| | | row.CreateCell(13).SetCellValue("å·¥ä½ä¸å¿ä»£ç "); |
| | | row.CreateCell(14).SetCellValue("å·¥ä½ä¸å¿åç§°"); |
| | | row.CreateCell(15).SetCellValue("å·¥ä½ä»£ç "); |
| | | row.CreateCell(16).SetCellValue("å·¥ä½"); |
| | | row.CreateCell(17).SetCellValue("表ä½å¤æ³¨"); |
| | | row.CreateCell(18).SetCellValue("ä½¿ç¨æ è®°"); |
| | | row.CreateCell(19).SetCellValue("å¯ç¨äºº"); |
| | | row.CreateCell(20).SetCellValue("å¯ç¨æ¥æ"); |
| | | row.CreateCell(21).SetCellValue("å¶å人"); |
| | | row.CreateCell(22).SetCellValue("å¶åæ¥æ"); |
| | | row.CreateCell(23).SetCellValue("å®¡æ ¸äºº"); |
| | | row.CreateCell(24).SetCellValue("å®¡æ ¸æ¥æ"); |
| | | row.CreateCell(25).SetCellValue("ä¿®æ¹äºº"); |
| | | row.CreateCell(26).SetCellValue("ä¿®æ¹æ¥æ"); |
| | | row.CreateCell(27).SetCellValue("ä½åºäºº"); |
| | | row.CreateCell(28).SetCellValue("ä½åºæ¥æ"); |
| | | |
| | | |
| | | //精确æ§å¶å宽 |
| | | sheet.SetColumnWidth(1, 5000); |
| | | sheet.SetColumnWidth(2, 5000); |
| | | sheet.SetColumnWidth(3, 5000); |
| | | sheet.SetColumnWidth(4, 5000); |
| | | sheet.SetColumnWidth(5, 5000); |
| | | sheet.SetColumnWidth(6, 5000); |
| | | sheet.SetColumnWidth(7, 5000); |
| | | sheet.SetColumnWidth(8, 5000); |
| | | sheet.SetColumnWidth(9, 5000); |
| | | sheet.SetColumnWidth(10, 5000); |
| | | sheet.SetColumnWidth(11, 5000); |
| | | sheet.SetColumnWidth(12, 5000); |
| | | sheet.SetColumnWidth(13, 5000); |
| | | sheet.SetColumnWidth(14, 5000); |
| | | sheet.SetColumnWidth(15, 5000); |
| | | sheet.SetColumnWidth(16, 5000); |
| | | sheet.SetColumnWidth(17, 5000); |
| | | sheet.SetColumnWidth(18, 5000); |
| | | sheet.SetColumnWidth(19, 5000); |
| | | sheet.SetColumnWidth(20, 5000); |
| | | sheet.SetColumnWidth(21, 5000); |
| | | sheet.SetColumnWidth(22, 5000); |
| | | sheet.SetColumnWidth(23, 5000); |
| | | sheet.SetColumnWidth(24, 5000); |
| | | sheet.SetColumnWidth(25, 5000); |
| | | sheet.SetColumnWidth(26, 5000); |
| | | sheet.SetColumnWidth(27, 5000); |
| | | sheet.SetColumnWidth(28, 5000); |
| | | sheet.SetColumnWidth(29, 5000); |
| | | |
| | | |
| | | DataSet ds = oCN.RunProcReturn("select * from h_v_Gy_SOPBillList" + sWhere + " order by hmainid desc", "h_v_Gy_SOPBillList"); |
| | | for (var i = 0; i < ds.Tables[0].Rows.Count; i++) |
| | | { |
| | | IRow row1 = sheet.CreateRow(i + 1); |
| | | row1.CreateCell(0).SetCellValue(ds.Tables[0].Rows[i]["åæ®å·"].ToString()); |
| | | row1.CreateCell(1).SetCellValue(ds.Tables[0].Rows[i]["åæ®ç±»å"].ToString()); |
| | | row1.CreateCell(2).SetCellValue(ds.Tables[0].Rows[i]["å·¥èºåç§°"].ToString()); |
| | | row1.CreateCell(3).SetCellValue(ds.Tables[0].Rows[i]["ç©æä»£ç "].ToString()); |
| | | row1.CreateCell(4).SetCellValue(ds.Tables[0].Rows[i]["ç©æåç§°"].ToString()); |
| | | row1.CreateCell(5).SetCellValue(ds.Tables[0].Rows[i]["è§æ ¼åå·"].ToString()); |
| | | row1.CreateCell(6).SetCellValue(ds.Tables[0].Rows[i]["计éåä½ä»£ç "].ToString()); |
| | | row1.CreateCell(7).SetCellValue(ds.Tables[0].Rows[i]["计éåä½"].ToString()); |
| | | row1.CreateCell(8).SetCellValue(ds.Tables[0].Rows[i]["é»è®¤æå¯¼ä¹¦"].ToString()); |
| | | row1.CreateCell(9).SetCellValue(ds.Tables[0].Rows[i]["è¡¨å¤´å¤æ³¨"].ToString()); |
| | | row1.CreateCell(10).SetCellValue(ds.Tables[0].Rows[i]["å·¥åºå·"].ToString()); |
| | | row1.CreateCell(11).SetCellValue(ds.Tables[0].Rows[i]["å·¥åºä»£ç "].ToString()); |
| | | row1.CreateCell(12).SetCellValue(ds.Tables[0].Rows[i]["å·¥åº"].ToString()); |
| | | row1.CreateCell(13).SetCellValue(ds.Tables[0].Rows[i]["å·¥ä½ä¸å¿ä»£ç "].ToString()); |
| | | row1.CreateCell(14).SetCellValue(ds.Tables[0].Rows[i]["å·¥ä½ä¸å¿åç§°"].ToString()); |
| | | row1.CreateCell(15).SetCellValue(ds.Tables[0].Rows[i]["å·¥ä½ä»£ç "].ToString()); |
| | | row1.CreateCell(16).SetCellValue(ds.Tables[0].Rows[i]["å·¥ä½"].ToString()); |
| | | row1.CreateCell(17).SetCellValue(ds.Tables[0].Rows[i]["表ä½å¤æ³¨"].ToString()); |
| | | row1.CreateCell(18).SetCellValue(ds.Tables[0].Rows[i]["ä½¿ç¨æ è®°"].ToString()); |
| | | row1.CreateCell(19).SetCellValue(ds.Tables[0].Rows[i]["å¯ç¨äºº"].ToString()); |
| | | row1.CreateCell(20).SetCellValue(ds.Tables[0].Rows[i]["å¯ç¨æ¥æ"].ToString()); |
| | | row1.CreateCell(21).SetCellValue(ds.Tables[0].Rows[i]["å¶å人"].ToString()); |
| | | row1.CreateCell(22).SetCellValue(ds.Tables[0].Rows[i]["å¶åæ¥æ"].ToString()); |
| | | row1.CreateCell(23).SetCellValue(ds.Tables[0].Rows[i]["å®¡æ ¸äºº"].ToString()); |
| | | row1.CreateCell(24).SetCellValue(ds.Tables[0].Rows[i]["å®¡æ ¸æ¥æ"].ToString()); |
| | | row1.CreateCell(25).SetCellValue(ds.Tables[0].Rows[i]["ä¿®æ¹äºº"].ToString()); |
| | | row1.CreateCell(26).SetCellValue(ds.Tables[0].Rows[i]["ä¿®æ¹æ¥æ"].ToString()); |
| | | row1.CreateCell(27).SetCellValue(ds.Tables[0].Rows[i]["ä½åºäºº"].ToString()); |
| | | row1.CreateCell(28).SetCellValue(ds.Tables[0].Rows[i]["ä½åºæ¥æ"].ToString()); |
| | | |
| | | } |
| | | System.IO.MemoryStream ms = new System.IO.MemoryStream(); |
| | | workbook.Write(ms); |
| | | ms.Position = 0; |
| | | |
| | | var response = new HttpResponseMessage(HttpStatusCode.OK); |
| | | response.Content = new StreamContent(ms); |
| | | |
| | | response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); |
| | | var fileName = "ä½ä¸æå¯¼ä¹¦å表.xls"; |
| | | |
| | | response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") |
| | | { |
| | | FileName = System.Web.HttpUtility.UrlEncode(fileName) |
| | | }; |
| | | return response; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | // |
| | | private Int32 Fun_GetCol(string sCol) |
| | | { |
| | | return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain); |
| | | } |
| | | #region ä½¿ç¨ |
| | | [Route("Gy_SOPBill/BatchUse")] |
| | | [Route("Gy_SOPBill/Use")] |
| | | [HttpGet] |
| | | public object sy_Click() |
| | | { |
| | | long sOldInterID = 0; |
| | | for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++) |
| | | if (BillOld.omodel.HInterID == 0) |
| | | { |
| | | long HInterID = DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("HMainID")].Value); |
| | | if (HInterID == 0 || HInterID == sOldInterID) |
| | | objJsonResult.Message = "使ç¨å¤±è´¥!å½åä½ä¸æå¯¼ä¹¦ä¸æ¯æµè§ç¶æ!"; |
| | | return objJsonResult; |
| | | } |
| | | if (BillOld.Sub_RoutingCheckAndUsed(BillOld.omodel.HInterID)) |
| | | { |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "ä½¿ç¨æå!"; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.Message = "使ç¨å¤±è´¥!"; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | [Route("Gy_SOPBill/Cancel")] |
| | | [HttpGet] |
| | | public object fsy_Click() |
| | | { |
| | | if (BillOld.omodel.HInterID == 0) |
| | | { |
| | | objJsonResult.Message = "å使ç¨å¤±è´¥!å½åä½ä¸æå¯¼ä¹¦ä¸æ¯æµè§ç¶æ!"; |
| | | return objJsonResult; |
| | | } |
| | | if (BillOld.Sub_RoutingUsed_Back(BillOld.omodel.HInterID)) |
| | | { |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "åä½¿ç¨æå!"; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.Message = "å使ç¨å¤±è´¥!"; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | [Route("Gy_SOPBill/UploadFile1")] |
| | | [HttpPost] |
| | | public object UploadFile1() |
| | | { |
| | | |
| | | string HBillNo = HttpContext.Current.Request.Params["HBillNo"]; //åæ®å· |
| | | string HRemark = HttpContext.Current.Request.Params["HRemark"]; //夿³¨ |
| | | string HUserName = HttpContext.Current.Request.Params["HUserName"]; //å建人 |
| | | HttpPostedFile files = HttpContext.Current.Request.Files["file"]; |
| | | string path = HttpContext.Current.Server.MapPath("~/../Files/" + HBillNo); |
| | | //string path = @"D:\\Files\\"+ HBillNo; |
| | | dynamic dyResult = UpLoadFile(files, path, HBillNo, HRemark, HUserName); |
| | | if (dyResult != null && dyResult.result == 1) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "ä¸ä¼ æåï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = dyResult.returnval; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | } |
| | | |
| | | public dynamic UpLoadFile(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName) |
| | | { |
| | | dynamic Result_Ob = new { result = 1, returnval = "ä¸ä¼ æåï¼" }; |
| | | string filePath = Path.GetFullPath(files.FileName);//æä»¶ä¸ä¼ è·¯å¾ |
| | | string fileExtension = Path.GetExtension(files.FileName);// æä»¶æ©å±å |
| | | string filename = files.FileName;//æä»¶å |
| | | string fileSavePath = path;// ä¸ä¼ ä¿åè·¯å¾ |
| | | int filesize = files.ContentLength;//è·åä¸ä¼ æä»¶ç大å°åä½ä¸ºåèbyte |
| | | int Maxsize = 40000 * 1024;//å®ä¹ä¸ä¼ æä»¶çæå¤§ç©ºé´å¤§å°ä¸º40M |
| | | |
| | | try |
| | | { |
| | | if (files == null || files.ContentLength <= 0) |
| | | { |
| | | continue; |
| | | Result_Ob = new { result = 0, returnval = "æä»¶ä¸è½ä¸ºç©º!" }; |
| | | return Result_Ob; |
| | | } |
| | | if (filesize >= Maxsize) |
| | | { |
| | | Result_Ob = new { result = 0, returnval = "ä¸ä¼ æä»¶è¶
è¿40Mï¼ä¸è½ä¸ä¼ ï¼" }; |
| | | return Result_Ob; |
| | | } |
| | | |
| | | string fileurl = Path.Combine(fileSavePath, filename); |
| | | if (Directory.Exists(fileurl) == true) //妿åå¨éåæä»¶å°±æç¤º |
| | | { |
| | | Result_Ob = new { result = 0, returnval = "åå¨ååæä»¶ï¼" }; |
| | | return Result_Ob; |
| | | } |
| | | //å 餿°æ®è¡¨æ°æ® |
| | | ds = oCN.RunProcReturn("delete from Gy_SOPBillSub2 where HFileName='" + filename + "'", "Gy_SOPBillSub2"); |
| | | if (Directory.Exists(path)) |
| | | { |
| | | File.Delete(fileurl); //å 餿宿件 |
| | | files.SaveAs(fileurl); |
| | | string StrPath = "/files/" + HBillNo + "/" + filename; |
| | | if (File.Exists(fileurl)) |
| | | { |
| | | //è¿éå¯ä»¥æ§è¡ä¸äºå
¶å®çæä½ï¼æ¯å¦æ´æ°æ°æ®åº |
| | | //åå
¥æ°æ®è¡¨ |
| | | oCN.RunProc("Insert into Gy_SOPBillSub2 (HFileName,HPath,HFileType" + |
| | | ",HUpMan,HUpTime,HInterID,HEntryID,HSno,HFileID,HFileSize" + |
| | | ") values('" |
| | | + filename.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + |
| | | ",'" + HUserName + "',getdate()" + ",'" + 0 + "','" + 0 + "','" + 0 + "','" + 0 + "','" + 0 + |
| | | "') "); |
| | | } |
| | | else |
| | | { |
| | | Result_Ob = new { result = 0, returnval = "ä¸ä¼ å¤±è´¥ï¼æ¤æä»¶ä¸ºæ¶ææä»¶" }; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | sOldInterID = HInterID; |
| | | Directory.CreateDirectory(fileSavePath); //æ·»å æä»¶å¤¹ |
| | | files.SaveAs(fileurl); |
| | | string StrPath = "/files/" + HBillNo + "/" + filename; |
| | | if (File.Exists(fileurl)) |
| | | { |
| | | //è¿éå¯ä»¥æ§è¡ä¸äºå
¶å®çæä½ï¼æ¯å¦æ´æ°æ°æ®åº |
| | | //åå
¥æ°æ®è¡¨ |
| | | oCN.RunProc("Insert into Gy_SOPBillSub2 (HFileName,HPath,HFileType" + |
| | | ",HUpMan,HUpTime,HInterID,HEntryID,HSno,HFileID,HFileSize" + |
| | | ") values('" |
| | | + filename.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + |
| | | ",'" + HUserName + "',getdate()" + ",'" + 111 + "','" + 222 + "','" + 333 + "','" + 444 + "','" + 555 + |
| | | "') "); |
| | | } |
| | | else |
| | | { |
| | | Result_Ob = new { result = 0, returnval = "ä¸ä¼ å¤±è´¥ï¼æ¤æä»¶ä¸ºæ¶ææä»¶" }; |
| | | } |
| | | } |
| | | if (!oBill.Sub_RoutingCheckAndUsed(HInterID)) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | } |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "æ¹é使ç¨å®æ¯ï¼"; |
| | | return objJsonResult; |
| | | catch (Exception e) |
| | | { |
| | | Result_Ob = new { result = 0, returnval = e.Message }; |
| | | } |
| | | return Result_Ob; |
| | | } |
| | | #endregion |
| | | |
| | | } |
| | | } |