From b7ede349929b44bd664d059728919f6c8eede66a Mon Sep 17 00:00:00 2001
From: ch <37327@LLOOCCY>
Date: 星期四, 30 三月 2023 09:39:44 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/生产管理/生产任务单/Sc_ICMOBillController.cs |  331 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 303 insertions(+), 28 deletions(-)

diff --git "a/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs" "b/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs"
index 2339256..9a42063 100644
--- "a/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs"
+++ "b/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs"
@@ -25,6 +25,7 @@
 
         //鑾峰彇绯荤粺鍙傛暟
         Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
+        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
 
         #region 鐢熶骇浠诲姟鍗� 淇濆瓨/缂栬緫鍔熻兘
         [Route("Sc_ICMOBill/ICMOBillEdit")]
@@ -111,17 +112,27 @@
                 {
                     //涓昏〃
                     oCN.RunProc(@"Insert Into Sc_ICMOBillMain   
-                        (HBillType,HInterID,HBillNo,HDate,HPRDORGID
+                        (HBillType,HBillStatus,HInterID,HBillNo,HDate,HPRDORGID
                         ,HYear,HPeriod,HRemark,HMaker,HMakeDate
                         ,HSeOrderBillNo,HSeOrderInterID,HSeOrderEntryID,HEmpID,HCusID
                         ,HCenterID,HPlanQty,HDeptID,HMaterID,HUnitID,HBomID,HPlanBeginDate,HPlanEndDate,HISENTRUST,HISREWORK)
-                        values('3710'," + HInterID + ",'" + HBillNo + "','" + HDate + "'," + HPRDORGID +
+                        values('3710',1," + HInterID + ",'" + HBillNo + "','" + HDate + "'," + HPRDORGID +
                     "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + HRemark + "','" + HMaker + "',getdate()" +
                     ",'" + HSeOrderBillNo + "'," + HSeOrderInterID + "," + HSeOrderEntryID + "," + HEmpID + "," + HCusID +
                     "," + HCenterID + "," + HPlanQty + ",0,0,0,0,'',''" + "," + HISENTRUST + "," + HISREWORK + ") ");
                 }
                 else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
-                { //淇敼
+                {
+                    if (ds.Tables[0].Rows[0]["瀹℃牳浜�"].ToString() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插鏍�,涓嶅厑璁镐慨鏀�!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    //淇敼
                     oCN.RunProc("update Sc_ICMOBillMain  set " +
                                 "HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" +
                                 ", HSeOrderBillNo='" + HSeOrderBillNo + "', HSeOrderInterID=" + HSeOrderInterID + ", HSeOrderEntryID=" + HSeOrderEntryID + ", HEmpID=" + HEmpID + ", HCusID=" + HCusID + "" +
@@ -141,6 +152,9 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
+
+                //淇敼瀛楁 HSTOCKINORGID
+                oCN.RunProc("update Sc_ICMOBillSub set HSTOCKINORGID=" + HPRDORGID + " where HInterID=" + HInterID);
 
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
@@ -171,7 +185,7 @@
             long HSeOrderEntrySEQ = DetailColl[0].HSeOrderEntrySEQ == null ? 0 : DetailColl[0].HSeOrderEntrySEQ;		//閿�鍞鍗曡鍙�,
             string HPROJECTNO = DetailColl[0].HPROJECTNO == null ? "''" : DetailColl[0].HPROJECTNO;   //椤圭洰缂栧彿,
             long HPRODUCTTYPE = DetailColl[0].HPRODUCTTYPE == null ? 0 : DetailColl[0].HPRODUCTTYPE;			//浜у搧绫诲瀷,
-            long HCOSTRATE = DetailColl[0].HCOSTRATE == null ? 0 : DetailColl[0].HCOSTRATE;			// 鏉冮噸,
+            double HCOSTRATE = DetailColl[0].HCOSTRATE == null ? 0 : DetailColl[0].HCOSTRATE;			// 鏉冮噸,
             long HBASEUNITID = DetailColl[0].HBASEUNITID == null ? 0 : DetailColl[0].HBASEUNITID;       //鍩烘湰璁¢噺鍗曚綅,
 
             int i = 0;
@@ -229,12 +243,13 @@
 	            ,HBeginDate,HEndDate
                 ,HMaterID,HUnitID,HRemark,HSourceID,HDeptID,HSTATUS
 				,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney
-                ,HINSTOCKTYPE,HCHECKPRODUCT,HQAIP,HISBACKFLUSH,HREQSRC,HSTOCKINQUASELAUXQTY,HSeOrderEntrySEQ,HPROJECTNO,HPRODUCTTYPE,HCOSTRATE,HBASEUNITID) 
+                ,HINSTOCKTYPE,HCHECKPRODUCT,HQAIP,HISBACKFLUSH,HREQSRC,HSTOCKINQUASELAUXQTY,HSeOrderEntrySEQ,HPROJECTNO,HPRODUCTTYPE,HCOSTRATE,HBASEUNITID
+                ,HSTOCKINORGID) 
                  values({HInterID},{i},{(oSub.HQty == null ? 0 : oSub.HQty)}
                 ,'{(oSub.HPlanBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HPlanBeginDate.ToString())}','{(oSub.HPlanEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HPlanEndDate.ToString())}'
                 ,'{(oSub.HPlanBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HPlanBeginDate.ToString())}','{(oSub.HPlanEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HPlanEndDate.ToString())}'
                 ,{oSub.HMaterID},{oSub.HUnitID},'{oSub.HRemark}',{oSub.HSourceID},{oSub.HDeptID},{oSub.HSTATUS}
-	                    ,0,0,'','',0,0,{HINSTOCKTYPE},{HCHECKPRODUCT},{HQAIP},{HISBACKFLUSH},{HREQSRC},{HSTOCKINQUASELAUXQTY},{HSeOrderEntrySEQ},{HPROJECTNO},{HPRODUCTTYPE},{HCOSTRATE},{HBASEUNITID})");
+	                    ,0,0,'','',0,0,{HINSTOCKTYPE},{HCHECKPRODUCT},{HQAIP},{HISBACKFLUSH},{HREQSRC},{HSTOCKINQUASELAUXQTY},{HSeOrderEntrySEQ},{HPROJECTNO},{HPRODUCTTYPE},{HCOSTRATE},{HBASEUNITID},{oSub.HSTOCKINORGID})");
             }
 
             objJsonResult.code = "1";
@@ -285,12 +300,14 @@
                 ,HPlanBeginDate,HPlanEndDate
 	            ,HBeginDate,HEndDate
                 ,HMaterID,HUnitID,HRemark,HSourceID,HDeptID,HSTATUS
-				,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney) 
+				,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney
+                ,HCOSTRATE,HISBACKFLUSH,HBatchNo,HBomID,HCHECKPRODUCT,HSEQ) 
                  values({oSub.HInterID},{oSub.HEntryID},{(oSub.HQty == null ? 0 : oSub.HQty)}
                 ,'{(oSub.HPlanBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HPlanBeginDate.ToString())}','{(oSub.HPlanEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HPlanEndDate.ToString())}'
                 ,'{(oSub.HPlanBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HPlanBeginDate.ToString())}','{(oSub.HPlanEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HPlanEndDate.ToString())}'
                 ,{oSub.HMaterID},{oSub.HUnitID},'{oSub.HRemark}',{oSub.HSourceID},{oSub.HDeptID},4
-	                    ,0,0,'','',0,0)");
+	                    ,0,0,'','',0,0
+                ,{oSub.HCOSTRATE},{oSub.HISBACKFLUSH},'{oSub.HBatchNo}',{oSub.HBomID},{oSub.HCHECKPRODUCT},{oSub.HSEQ})");
                 }
 
                 foreach (var _item in _mainList)
@@ -392,6 +409,7 @@
             string msg2 = sArray[0].ToString(); //涓昏〃鏁版嵁
             int OperationType = int.Parse(sArray[1].ToString()); // 鏁版嵁绫诲瀷 1娣诲姞 3淇敼
             string user = sArray[2].ToString();
+            int HEntryID = int.Parse(sArray[3].ToString());
 
             try
             {
@@ -429,27 +447,37 @@
                 {
                     //涓昏〃
                     oCN.RunProc(@"Insert Into Sc_ICMOBillMain   
-                        (HBillType,HInterID,HBillNo,HDate,HPRDORGID
+                        (HBillType,HBillStatus,HInterID,HBillNo,HDate,HPRDORGID
                         ,HYear,HPeriod,HRemark,HMaker,HMakeDate
                         ,HSeOrderBillNo,HSeOrderInterID,HSeOrderEntryID,HEmpID,HCusID
                         ,HCenterID,HPlanQty,HDeptID,HMaterID,HUnitID,HBomID,HPlanBeginDate,HPlanEndDate)
-                        values('3710'," + HInterID + ",'" + HBillNo + "','" + HDate + "'," + HPRDORGID +
+                        values('3710',1," + HInterID + ",'" + HBillNo + "','" + HDate + "'," + HPRDORGID +
                     "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + HRemark + "','" + HMaker + "',getdate()" +
                     ",'" + HSeOrderBillNo + "'," + HSeOrderInterID + "," + HSeOrderEntryID + "," + HEmpID + "," + HCusID +
                     "," + HCenterID + ",0,0,0,0," + HBomID + ",'','') ");
                 }
                 else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0)
-                { //淇敼
+                {
+                    if (ds.Tables[0].Rows[0]["瀹℃牳浜�"].ToString() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插鏍�,涓嶅厑璁镐慨鏀�!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    //淇敼
                     oCN.RunProc("update Sc_ICMOBillMain  set " +
-                                "HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" +
+                                "HRemark='" + HRemark + "', HUpDater='" + HMaker + "', HUpDateDate=getdate()" +
                                 ", HSeOrderBillNo='" + HSeOrderBillNo + "', HSeOrderInterID=" + HSeOrderInterID + ", HSeOrderEntryID=" + HSeOrderEntryID + ", HEmpID=" + HEmpID + ", HCusID=" + HCusID + "" +
                                 ", HCenterID=" + HCenterID + ",HBomID=" + HBomID + " where HInterID=" + HInterID);
 
                     //鍒犻櫎瀛愯〃
-                    oCN.RunProc("delete from Sc_ICMOBillSub where HInterID='" + HInterID + "'");
+                    oCN.RunProc("delete from Sc_ICMOBillSub where HInterID='" + HInterID + "' and HEntryID='" + HEntryID + "'");
                 }
                 //淇濆瓨瀛愯〃
-                objJsonResult = AddBillSub_NoTable(msg3, HInterID, OperationType);
+                objJsonResult = AddBillSub_NoTable(msg3, HInterID, OperationType, HEntryID);
 
                 if (objJsonResult.code == "0")
                 {
@@ -476,7 +504,7 @@
             }
         }
 
-        public json AddBillSub_NoTable(string msg3, long HInterID, int OperationType)
+        public json AddBillSub_NoTable(string msg3, long HInterID, int OperationType,int HEntryID)
         {
             ClsSc_ICMOBillSub oSub = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsSc_ICMOBillSub>(msg3);
             if (oSub.HQty <= 0 || oSub.HQty == null)
@@ -515,28 +543,30 @@
                 return objJsonResult;
             }
 
-            if (oSub.HBomID == 0)
-            {
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = "BOM涓嶈兘涓虹┖";
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
+            //if (oSub.HBomID == 0)
+            //{
+            //    objJsonResult.code = "0";
+            //    objJsonResult.count = 0;
+            //    objJsonResult.Message = "BOM涓嶈兘涓虹┖";
+            //    objJsonResult.data = null;
+            //    return objJsonResult;
+            //}
 
             oCN.RunProc($@"Insert into Sc_ICMOBillSub 
                 (HInterID,HENTRYID,HQty
                 ,HPlanBeginDate,HPlanEndDate
 	            ,HBeginDate,HEndDate
                 ,HMaterID,HUnitID,HRemark,HSourceID,HDeptID,HSTATUS
-                ,HBomID,HEntryCusID
-				,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney) 
-                 values({HInterID},1,{(oSub.HQty == null ? 0 : oSub.HQty)}
+                ,HBomID,HEntryCusID,HSTOCKINORGID
+				,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney
+                ,HAuxQty,HAuxUnit,HWidth,HWeight) 
+                 values({HInterID},{HEntryID},{(oSub.HQty == null ? 0 : oSub.HQty)}
                 ,'{(oSub.HPlanBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HPlanBeginDate.ToString())}','{(oSub.HPlanEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HPlanEndDate.ToString())}'
                 ,'{(oSub.HBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HBeginDate.ToString())}','{(oSub.HEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HEndDate.ToString())}'
                 ,{oSub.HMaterID},{oSub.HUnitID},'{oSub.HRemark}',{oSub.HSourceID},{oSub.HDeptID},{oSub.HSTATUS}
-                 ,{oSub.HBomID}  ,{oSub.HCusID} 
-	                    ,0,0,'','',0,0)");
+                 ,{oSub.HBomID}  ,{oSub.HCusID} ,{oSub.HSTOCKINORGID}
+	                    ,0,0,'','',0,0
+                ,{oSub.HAuxQty},{oSub.HAuxUnit},{oSub.HWidth},{oSub.HWeight})");
 
 
             objJsonResult.code = "1";
@@ -546,6 +576,241 @@
             return objJsonResult;
         }
         #endregion
+
+        #region 鐢熶骇浠诲姟鍗曞鏍�/鍙嶅鏍稿姛鑳�
+        [Route("Sc_ICMOBill/CheckSc_ICMOReportBill")]
+        [HttpGet]
+        public object CheckSc_ICMOReportBill(string HInterID,int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Sc_ICMOBill_Check", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬鏍�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (string.IsNullOrWhiteSpace(HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ClsPub.CurUserName = user;
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 瀹℃牳  2  鍙嶅鏍�
+                if (Type == 1)
+                {
+                    if (!BillOld.CheckBill(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    if (BillOld.AbandonCheck(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    {
+                        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                        DataSet DSet = oCn.RunProcReturn("exec h_p_Sc_ICMOBill_AbandonCheckCtrl " + int.Parse(HInterID), "h_p_Sc_ICMOBill_AbandonCheckCtrl");
+                        //if (DBUtility.ClsPub.isInt(DSet.Tables[0].Rows[0]["Hback"]) != 0)
+                        //{
+                        //    objJsonResult.code = "0";
+                        //    objJsonResult.count = 1;
+                        //    objJsonResult.Message = "璇ヤ换鍔″崟宸蹭笅鎺ㄦ祦杞崱锛屼笉鍏佽鍙嶅鏍�" + DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[0]["HBackRemark"]);
+                        //    objJsonResult.data = null;
+                        //    return objJsonResult;
+                        //}
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢熶骇浠诲姟鍗曞叧闂�/鍙嶅叧闂姛鑳�
+        [Route("Sc_ICMOBill/CloseSc_ICMOReportBill")]
+        [HttpGet]
+        public object CloseSc_ICMOReportBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Sc_ICMOBill_Close", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愬叧闂�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (string.IsNullOrWhiteSpace(HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ClsPub.CurUserName = user;
+
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 鍏抽棴  2  鍙嶅叧闂�
+                if (Type == 1)
+                {
+                    if (!BillOld.CloseBill(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    if (!BillOld.CancelClose(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢熶骇浠诲姟鍗曚綔搴�/鍙嶄綔搴熷姛鑳�
+        [Route("Sc_ICMOBill/CancellSc_ICMOReportBill")]
+        [HttpGet]
+        public object CancellSc_ICMOReportBill(string HInterID, int Type, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Sc_ICMOBill_Delete", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愪綔搴�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (string.IsNullOrWhiteSpace(HInterID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                ClsPub.CurUserName = user;
+
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+
+                //Type 1 浣滃簾  2  鍙嶄綔搴�
+                if (Type == 1)
+                {
+                    if (!BillOld.Cancelltion(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    if (!BillOld.AbandonCancelltion(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鎵ц鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
 
         #region 鐢熶骇浠诲姟鍗曞垹闄ゅ姛鑳�
         [Route("Sc_ICMOBill/DeltetSc_ICMOReportBill")]
@@ -582,6 +847,16 @@
                     objJsonResult.data = null;
                     return objJsonResult; ;
                 }
+
+                if (int.Parse(ds.Tables[0].Rows[0]["HBillStatus"].ToString()) > 1)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶆槸鏈鏍哥姸鎬�,涓嶅厑璁稿垹闄わ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult; ;
+                }
+
                 oCN.RunProc("delete from Sc_ICMOBillMain  where HInterID=" + HInterID);
                 oCN.RunProc("delete from Sc_ICMOBillSub  where HInterID=" + HInterID);
                 oCN.Commit();//鎻愪氦浜嬪姟

--
Gitblit v1.9.1