From 981e65a58c087f16fcff1777ea82f23759e84e5d Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期一, 28 十月 2024 17:57:24 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/Sc_MouldRepairInBillListController.cs |  568 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 504 insertions(+), 64 deletions(-)

diff --git a/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs b/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
index d59bf75..081f353 100644
--- a/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
+++ b/WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
@@ -4,6 +4,8 @@
 using System;
 using System.Collections.Generic;
 using System.Data;
+using System.IO;
+using System.Web;
 using System.Web.Http;
 using ViewAPI;
 using WebAPI.Models;
@@ -26,6 +28,7 @@
 
         public DAL.ClsSc_MouldScrapInBill BillNew0 = new DAL.ClsSc_MouldScrapInBill();   //妯″叿鎶ュ簾鍏ュ簱瀵瑰簲鍗曟嵁绫�
         public DAL.ClsSc_MouldScrapInBill BillOld0 = new DAL.ClsSc_MouldScrapInBill();   //妯″叿鎶ュ簾鍏ュ簱瀵瑰簲鍗曟嵁绫�
+        string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"];
 
 
         /// <summary>
@@ -603,6 +606,49 @@
         }
         #endregion
 
+        #region 鍣ㄥ叿瀵垮懡鑰楃敤鍒嗘瀽鎶ヨ〃 
+        [Route("Sc_MouldRepairInBillList/Get_Sc_MouldLifeUsePicReport")]
+        [HttpGet]
+        public object Get_Sc_MouldLifeUsePicReport(string sWhere)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("select * from h_v_Sc_MouldLifeUsePicReport order by 鏈堜唤 desc", "h_v_Sc_MouldLifeUsePicReport");
+                }
+                else
+                {
+                    string sql1 = "select * from h_v_Sc_MouldLifeUsePicReport where 1 = 1 ";
+                    string sql = sql1 + sWhere + " order by 鏃ユ湡 ";
+                    ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldLifeUsePicReport");
+                }
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
 
 
         /// <summary>
@@ -1245,8 +1291,6 @@
                     }
                     //================================================================================== 
 
-                    //鏇存柊鍙婃椂搴撳瓨琛�   鍑忓皯璋冨叆搴撳瓨,澧炲姞璋冨嚭搴撳瓨
-                    ds = oCN.RunProcReturn("exec h_KF_UPDateICinventory_Move  '"+ oBill.omodel.HInterID + "','"+ oBill.omodel.HBillType+ "','1'", "h_KF_UPDateICinventory_Move");
 
                     //瀹℃牳鍗曟嵁
                     if (!oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_MoveStockBill_AfterCheckCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true)
@@ -1298,9 +1342,6 @@
                         return objJsonResult;
                     }
                     //===========================================================          
-
-                    //鏇存柊鍙婃椂搴撳瓨琛�   澧炲姞璋冨叆搴撳瓨,鍑忓皯璋冨嚭搴撳瓨
-                    ds = oCN.RunProcReturn("exec h_KF_UPDateICinventory_Move  '" + oBill.omodel.HInterID + "','" + oBill.omodel.HBillType + "','2'", "h_KF_UPDateICinventory_Move");
 
                     //鍙嶅鏍稿崟鎹�
                     if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_MoveStockBill_AfterUnCheckCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true)
@@ -1830,6 +1871,66 @@
                 return objJsonResult;
             }
         }
+
+        #region 閿�鍞嚭搴撳崟鍒楄〃-鍒嗛〉
+        /// <summary>
+        /// 閿�鍞嚭搴撳崟鍒楄〃
+        /// </summary>
+        /// <returns></returns>
+        [Route("Kf_SellOutBill/GetSellOutBillList_byPage")]
+        [HttpGet]
+        public object GetSellOutBillList_byPage(string sWhere, string user, string Organization, int page, int size)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();  //瀹氫箟澹版槑鍙橀噺 锛屾妸閫氳繃 new List<object>()鍒涘缓鐨� 瀹炰緥锛岃祴鍊肩粰鍙橀噺
+                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Kf_SellOutBillQuery", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏌ヨ鏉冮檺!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                sWhere = sWhere.Replace("'", "''");
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_IF_SellOutBillList " + page + "," + size + ",'" + Organization + "'," + "''", "h_p_IF_SellOutBillList");
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn("exec h_p_IF_SellOutBillList " + page + "," + size + ",'" + Organization + "','" + sWhere + "'", "h_p_IF_SellOutBillList");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.list = columnNameList;
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+            }
+            catch (Exception ex)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         /// <summary>
         ///閿�鍞嚭搴撳崟鍒犻櫎鍔熻兘
         /// </summary>
@@ -3991,7 +4092,7 @@
                 lsmain = oListModels.getObjectByJson_Gy_MouldRepairWorkBillMain(msg2);
                 foreach (Model.ClsSb_MouldRepairWorkBillMain oItem in lsmain)
                 {
-                    //oItem.HMaker = "";
+                    oItem.HMaker = msg4;
                     UserName = msg4;  //鍒跺崟浜�
                     oItem.HBillType = "3807";
                     oItem.HBillSubType = "3807";
@@ -5061,7 +5162,7 @@
             string msg3 = sArray[1].ToString();
             string msg4 = sArray[2].ToString();
             string msg5 = sArray[3].ToString();
-
+            string msg6 = sArray[4].ToString();
 
             string UserName = "";
             ListModels oListModels = new ListModels();
@@ -5095,6 +5196,7 @@
                     //oItem.HBillNo = "";
                     oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));//  --鏃ユ湡
                     oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                    oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
                     //oItem.HMakeDate = "";
                     //oItem.HYear = "";
                     //oItem.HPeriod = "";
@@ -5181,6 +5283,32 @@
                     oBill.DetailColl.Add(oItemSub);
 
                 }
+
+                //琛ㄤ綋鏁版嵁
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                //濡傛灉鏄紪杈戝氨鍏佽淇濆瓨,鍚﹀垯涓嶅厑璁�
+                if (oBill.omodel.HInterID != 0)
+                {
+                    msg6 = msg6.Substring(1, msg6.Length - 2);
+                    msg6 = msg6.Replace("\\", "");
+                    msg6 = msg6.Replace("\n", "");  
+                    List<Model.ClsSc_MouldMaintainPlanBillSub_Plan> lss = new List<Model.ClsSc_MouldMaintainPlanBillSub_Plan>();
+                    lss = oListModels.getObjectByJson_Sc_MouldMaintainPlanBillSub_Plan(msg6);
+                    int l = 0;
+                    foreach (Model.ClsSc_MouldMaintainPlanBillSub_Plan oItem in lss)
+                    {
+
+                        l++;
+                        oItem.HEntryID = l;
+                        oItem.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                        oItem.HCloseType = false;   //鍏抽棴绫诲瀷
+                        oItem.HSourceInterID = 0;     // 婧愬崟涓诲唴鐮�
+                        oItem.HSourceEntryID = 0;   //婧愬崟瀛愬唴鐮�
+                        oItem.HRelationQty = 0;     //鍏宠仈鏁伴噺                  
+                        oBill.DetailCol2.Add(oItem);
+                    }
+                }
+                
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�
                 bool bResult;
@@ -5496,7 +5624,7 @@
                 foreach (Model.ClsSc_MouldMaintainBillMain oItem in lsmain)
                 {
                     UserName = oItem.HMaker;  //鍒跺崟浜�
-                    DBUtility.ClsPub.CurUserName = UserName;
+                    DBUtility.ClsPub.CurUserName = msg5;
                     oItem.HBillType = "3819";
                     oItem.HBillSubType = "3819";
 
@@ -6492,8 +6620,6 @@
             string msg2 = sArray[0].ToString();
             string msg3 = sArray[1].ToString();
             string msg4 = sArray[2].ToString();
-            //string msg5 = sArray[3].ToString();
-
 
             string UserName = "";
             ListModels oListModels = new ListModels();
@@ -6514,28 +6640,14 @@
                 msg2 = msg2.Replace("\n", "");  //\n
                 lsmain = oListModels.getObjectByJson_Sc_MouldDotCheckPlanBillMain(msg2);
                 foreach (Model.ClsSc_MouldDotCheckPlanBillMain oItem in lsmain)
-                {
-                    //oItem.HMaker = "";
+                {                  
                     UserName = oItem.HMaker;  //鍒跺崟浜�
                     oItem.HBillType = "3820";
                     oItem.HBillSubType = "3820";
-
-                    //oItem.HInterID =0;
-                    //oItem.HBillNo = "";
+                 
                     oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));//  --鏃ユ湡
-                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
-                    //oItem.HMakeDate = "";
-                    //oItem.HYear = "";
-                    //oItem.HPeriod = "";
-                    //oItem.HRemark = "";
-                    //oItem.HCycleUnit = "";
-                    //oItem.HCheckCycle = "";
-                    //oItem.HBeginDate = "";
-                    //oItem.HEndDate = "";
-                    //oItem.HInnerBillNo = "";
-                    //oItem.HExplanation = "";
-
-                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo);
+                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);                   
+                  
                     if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
                     {
                         objJsonResult.code = "0";
@@ -6560,7 +6672,7 @@
 
                     i++;
                     oItemSub.HEntryID = i;
-                    //oItemSub.HCloseMan = "";       //琛屽叧闂�
+
                     oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                     oItemSub.HCloseType = false;   //鍏抽棴绫诲瀷
                     //oItemSub.HRemark = "";         //澶囨敞
@@ -6568,43 +6680,10 @@
                     oItemSub.HSourceEntryID = 0;   //婧愬崟瀛愬唴鐮�
                     //oItemSub.HSourceBillNo = "";  //婧愬崟鍗曞彿
                     //oItemSub.HSourceBillType = ""; //婧愬崟绫诲瀷
-                    oItemSub.HRelationQty = 0;     //鍏宠仈鏁伴噺
-                                                   //oItemSub.HRelationMoney = 0;   //鍏宠仈閲戦
-                                                   //HMaterID = "";//閰嶄欢浠g爜
-                                                   //HUnitID = "";//鍗曚綅浠g爜
-                                                   //HQty = "";//瀹為檯鐢ㄩ噺
-                                                   //HQtyMust = "";//鍗曚綅鐢ㄩ噺
-                                                   //HRemark = "";//澶囨敞
+                    oItemSub.HRelationQty = 0;     //鍏宠仈鏁伴噺                                                
 
                     oBill.DetailColl.Add(oItemSub);
-
-                }
-
-                ////閰嶄欢椤硅〃浣撴暟鎹�
-                ////鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
-                //msg5 = msg5.Substring(1, msg5.Length - 2);
-                //msg5 = msg5.Replace("\\", "");
-                //msg5 = msg5.Replace("\n", "");  //\n
-                //                                //msg2 = msg2.Replace("'", "鈥�");
-                //List<Model.ClsSc_MouldDotCheckPlanBillSub_Item> ls1 = new List<Model.ClsSc_MouldDotCheckPlanBillSub_Item>();
-                //ls1 = oListModels.getObjectByJson_Sc_MouldDotCheckPlanBillSub_Item(msg5);
-                //int j = 0;
-                //foreach (Model.ClsSc_MouldDotCheckPlanBillSub_Item oItemSub in ls1)
-                //{
-
-                //    j++;
-                //    oItemSub.HEntryID = j;
-                //    //oItemSub.HCloseMan = "";       //琛屽叧闂�
-                //    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
-                //    oItemSub.HCloseType = false;   //鍏抽棴绫诲瀷
-
-                //    oItemSub.HSourceInterID = 0;     // 婧愬崟涓诲唴鐮�
-                //    oItemSub.HSourceEntryID = 0;   //婧愬崟瀛愬唴鐮�
-
-                //    oItemSub.HRelationQty = 0;     //鍏宠仈鏁伴噺
-                //    oBill.DetailCol.Add(oItemSub);
-                //}
-
+                }                
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�
                 bool bResult;
@@ -10233,5 +10312,366 @@
             return objJsonResult;
         }
         #endregion
+
+        #region 鍣ㄥ叿鐐规璁板綍鎷嶇収涓婁紶
+        [Route("Sc_MouldDotCheckBill/UploadFile")]
+        [HttpPost]
+        public object UploadFile()
+        {
+
+            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/MouldFolder/" + 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)
+                {
+                    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 MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList");
+                if (Directory.Exists(path))
+                {
+                    File.Delete(fileurl);      //鍒犻櫎鎸囧畾鏂囦欢
+                    files.SaveAs(fileurl);
+                    string StrPath = "/files/MouldFolder/" + HBillNo + "/" + filename;
+                    if (File.Exists(fileurl))
+                    {
+                        //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱
+                        //鍐欏叆鏁版嵁琛�
+                        oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
+                                    ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
+                                    ",HFileClsID,HSourceBillNo" +
+                                   ") values('"
+                                    + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
+                                    ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
+                                    "','" + 0 + "','" + HBillNo +
+                                   "') ");
+                    }
+                    else
+                    {
+                        Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" };
+                    }
+                }
+                else
+                {
+                    Directory.CreateDirectory(fileSavePath); //娣诲姞鏂囦欢澶�
+                    files.SaveAs(fileurl);
+                    string StrPath = "/files/MouldFolder/" + HBillNo + "/" + filename;
+                    if (File.Exists(fileurl))
+                    {
+                        //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱
+                        //鍐欏叆鏁版嵁琛�
+                        oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
+                                    ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
+                                    ",HFileClsID,HSourceBillNo" +
+                                   ") values('"
+                                    + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
+                                    ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
+                                    "','" + 0 + "','" + HBillNo +
+                                   "') ");
+                    }
+                    else
+                    {
+                        Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" };
+                    }
+                }
+
+            }
+            catch (Exception e)
+            {
+                Result_Ob = new { result = 0, returnval = e.Message };
+            }
+            return Result_Ob;
+        }
+
+        /// <summary>
+        /// 鏍规嵁鍗曟嵁鍙锋煡鎵句笂浼犳枃浠跺垪琛�
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("Sc_MouldDotCheckBill/Filelist")]
+        [HttpGet]
+        public object Filelist(string HBillNo)
+        {
+            var url = fileip + "/files/MouldFolder/" + HBillNo + "/";
+            //@"C:\\files\\"
+            try
+            {
+                ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url  from MES_AccessoriesList where HSourceBillNo='" + HBillNo + "'", "MES_AccessoriesList");
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
+        /// 鏍规嵁ID,鍗曟嵁鍙�,鏂囦欢鍚� 鍒犻櫎鏂囦欢
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("Sc_MouldDotCheckBill/DeleteFilelist")]
+        [HttpGet]
+        public object DeleteFilelist(string HItemID, string HSourceBillNo, string HFileName)
+        {
+            try
+            {
+
+                oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID);
+                string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/MouldFolder/" + HSourceBillNo), HFileName);
+                File.Delete(fileurl);      //鍒犻櫎鎸囧畾鏂囦欢
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鍣ㄥ叿淇濆吇璁板綍鎷嶇収涓婁紶
+        [Route("Sc_MouldMaintainBill/UploadFile")]
+        [HttpPost]
+        public object UploadFile_Maintain()
+        {
+
+            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/MouldFolder/" + HBillNo);
+            //string path = @"D:\\Files\\"+ HBillNo;
+            dynamic dyResult = UpLoadFile_Maintain(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_Maintain(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)
+                {
+                    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 MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList");
+                if (Directory.Exists(path))
+                {
+                    File.Delete(fileurl);      //鍒犻櫎鎸囧畾鏂囦欢
+                    files.SaveAs(fileurl);
+                    string StrPath = "/files/MouldFolder/" + HBillNo + "/" + filename;
+                    if (File.Exists(fileurl))
+                    {
+                        //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱
+                        //鍐欏叆鏁版嵁琛�
+                        oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
+                                    ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
+                                    ",HFileClsID,HSourceBillNo" +
+                                   ") values('"
+                                    + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
+                                    ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
+                                    "','" + 0 + "','" + HBillNo +
+                                   "') ");
+                    }
+                    else
+                    {
+                        Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" };
+                    }
+                }
+                else
+                {
+                    Directory.CreateDirectory(fileSavePath); //娣诲姞鏂囦欢澶�
+                    files.SaveAs(fileurl);
+                    string StrPath = "/files/MouldFolder/" + HBillNo + "/" + filename;
+                    if (File.Exists(fileurl))
+                    {
+                        //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱
+                        //鍐欏叆鏁版嵁琛�
+                        oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
+                                    ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
+                                    ",HFileClsID,HSourceBillNo" +
+                                   ") values('"
+                                    + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
+                                    ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
+                                    "','" + 0 + "','" + HBillNo +
+                                   "') ");
+                    }
+                    else
+                    {
+                        Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" };
+                    }
+                }
+
+            }
+            catch (Exception e)
+            {
+                Result_Ob = new { result = 0, returnval = e.Message };
+            }
+            return Result_Ob;
+        }
+
+        /// <summary>
+        /// 鏍规嵁鍗曟嵁鍙锋煡鎵句笂浼犳枃浠跺垪琛�
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("Sc_MouldMaintainBill/Filelist")]
+        [HttpGet]
+        public object Filelist_Maintain(string HBillNo)
+        {
+            var url = fileip + "/files/MouldFolder/" + HBillNo + "/";
+            //@"C:\\files\\"
+            try
+            {
+                ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url  from MES_AccessoriesList where HSourceBillNo='" + HBillNo + "'", "MES_AccessoriesList");
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
+        /// 鏍规嵁ID,鍗曟嵁鍙�,鏂囦欢鍚� 鍒犻櫎鏂囦欢
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("Sc_MouldMaintainBill/DeleteFilelist")]
+        [HttpGet]
+        public object DeleteFilelist_Maintain(string HItemID, string HSourceBillNo, string HFileName)
+        {
+            try
+            {
+
+                oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID);
+                string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/MouldFolder/" + HSourceBillNo), HFileName);
+                File.Delete(fileurl);      //鍒犻櫎鎸囧畾鏂囦欢
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion    
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1