| using Newtonsoft.Json.Linq; | 
| using System; | 
| using System.Collections.Generic; | 
| using System.Data; | 
| using System.Linq; | 
| using System.Web; | 
| using System.Web.Http; | 
| using WebAPI.Models; | 
| using Newtonsoft.Json; | 
| using Model; | 
| using DBUtility; | 
| using SyntacticSugar.constant; | 
|   | 
| namespace WebAPI.Controllers.MJGL | 
| { | 
|     public class Sc_MouldUpperBillController : ApiController | 
|     { | 
|         private json objJsonResult = new json(); | 
|         public DataSet ds = new DataSet(); | 
|         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|         Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); | 
|         public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill(); | 
|   | 
|         #region 上模单 列表查询 | 
|         [Route("Sc_MouldUpperBill/Sc_MouldUpperBillList")] | 
|         [HttpGet] | 
|         public object Sc_MouldUpperBillList(string sWhere, string user) | 
|         { | 
|             try | 
|             { | 
|                 List<object> columnNameList = new List<object>(); | 
|   | 
|                 //查看权限 | 
|                 if (!DBUtility.ClsPub.Security_Log("Sc_MouldUpperBill_Query", 1, false, user)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "无查看权限!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 ds = oCN.RunProcReturn("select * from  h_v_Qj_Sc_MouldUpperBillList where 1=1" + sWhere + "order by hmainid desc ", "h_v_Qj_Sc_MouldUpperBillList"); | 
|   | 
|                 //添加列名 | 
|                 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));//获取到DataColumn列对象的列名 | 
|                 } | 
|   | 
|                 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 | 
|   | 
|         #region 上模单 列表分页查询 | 
|         [Route("Sc_MouldUpperBill/Sc_MouldUpperBillListPage")] | 
|         [HttpGet] | 
|         public object Sc_MouldUpperBillListPage(string sWhere, string user, int page, int size) | 
|         { | 
|             try | 
|             { | 
|                 List<object> columnNameList = new List<object>(); | 
|   | 
|                 //查看权限 | 
|                 if (!DBUtility.ClsPub.Security_Log("Sc_MouldUpperBill_Query", 1, false, user)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "无查看权限!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 sWhere = sWhere.Replace("'", "''"); | 
|                 ds = oCN.RunProcReturn("exec h_p_Sc_MouldUpperBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldUpperBillList"); | 
|   | 
|                 //添加列名 | 
|                 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));//获取到DataColumn列对象的列名 | 
|                 } | 
|   | 
|   | 
|                 objJsonResult.code = CodeConstant.SUCCEED; | 
|                 objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); | 
|                 objJsonResult.Message = "Sucess!"; | 
|                 objJsonResult.data = ds.Tables[0]; | 
|                 objJsonResult.list = columnNameList; | 
|                 return objJsonResult; | 
|             } | 
|             catch (Exception ex) | 
|             { | 
|                 objJsonResult.code = CodeConstant.FAIL; | 
|                 objJsonResult.count = CountConstant.FAIL; | 
|                 objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|         } | 
|         #endregion | 
|   | 
|         #region 上模单 保存前、保存后控制 | 
|   | 
|         //保存前控制 | 
|         public json BeforeSave_MouldUpperBill(Int64 HInterID, string HBillNo, Int64 OperationType) | 
|         { | 
|             DataSet BeforeSave = oCN.RunProcReturn("Exec h_p_Sc_MouldUpperBill_BeforeSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_Sc_MouldUpperBill_BeforeSaveCtrl"); | 
|             if (BeforeSave == null || BeforeSave.Tables[0].Rows.Count == 0) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "保存前判断失败!"; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             else if (DBUtility.ClsPub.isLong(BeforeSave.Tables[0].Rows[0]["HBack"]) == 1) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0;  //失败! | 
|                 objJsonResult.Message = DBUtility.ClsPub.isStrNull(BeforeSave.Tables[0].Rows[0]["HRemark"]); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             else | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 1;  //成功! | 
|                 objJsonResult.Message = DBUtility.ClsPub.isStrNull(BeforeSave.Tables[0].Rows[0]["HRemark"]); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|         } | 
|   | 
|         //保存后控制 | 
|         public json AfterSave_MouldUpperBill(Int64 HInterID, string HBillNo, Int64 OperationType) | 
|         { | 
|             DataSet AfterSave = oCN.RunProcReturn("Exec h_p_Sc_MouldUpperBill_AfterSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_Sc_MouldUpperBill_AfterSaveCtrl"); | 
|             if (AfterSave == null || AfterSave.Tables[0].Rows.Count == 0) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "保存后判断失败!"; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             else if (DBUtility.ClsPub.isLong(AfterSave.Tables[0].Rows[0]["HBack"]) == 1) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0;  //失败! | 
|                 objJsonResult.Message = DBUtility.ClsPub.isStrNull(AfterSave.Tables[0].Rows[0]["HRemark"]); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             else | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 1;  //成功! | 
|                 objJsonResult.Message = DBUtility.ClsPub.isStrNull(AfterSave.Tables[0].Rows[0]["HRemark"]); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|         } | 
|   | 
|         #endregion | 
|   | 
|         #region 上模单 新增 | 
|         /// <summary> | 
|         /// 新增单据-保存按钮 | 
|         ///参数:string sql。 | 
|         ///返回值:object。 | 
|         /// </summary> | 
|         [Route("Sc_MouldUpperBill/AddSc_MouldUpperBill")] | 
|         [HttpPost] | 
|         public object AddSc_MouldUpperBill([FromBody] JObject sMainSub) | 
|         { | 
|             var _value = sMainSub["sMainSub"].ToString(); | 
|             string msg1 = _value.ToString(); | 
|             oCN.BeginTran(); | 
|             //保存主表 | 
|             objJsonResult = AddBillMain(msg1); | 
|             if (objJsonResult.code == "0") | 
|             { | 
|                 oCN.RollBack(); | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = objJsonResult.Message; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             oCN.Commit(); | 
|             objJsonResult.code = "1"; | 
|             objJsonResult.count = 1; | 
|             objJsonResult.Message = "新增单据成功!"; | 
|             objJsonResult.data = ds.Tables[0]; | 
|             return objJsonResult; | 
|         } | 
|   | 
|         public json AddBillMain(string msg1) | 
|         { | 
|             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
|             string msg2 = sArray[0].ToString(); | 
|             string msg3 = sArray[1].ToString(); | 
|             int OperationType = int.Parse(sArray[2].ToString());//数据类型 1添加 3修改 2 复制  | 
|             string user = sArray[3].ToString();//用户名 | 
|             try | 
|             { | 
|                 if (!DBUtility.ClsPub.Security_Log("Sc_MouldUpperBill_Edit", 1, false, user)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "无权限编辑!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 msg2 = "[" + msg2.ToString() + "]"; | 
|                 List<ClsSc_MouldUpperBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldUpperBillMain>>(msg2); | 
|                 string HBillType = "3846"; | 
|                 long HInterID = mainList[0].HInterID;//递入type得到的单据ID | 
|                 string HBillNo = mainList[0].HBillNo;//递入type得到的单据号 | 
|                 DateTime HDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));//日期 | 
|                 int HYear = DateTime.Now.Year; | 
|                 double HPeriod = DateTime.Now.Month; | 
|                 string HRemark = mainList[0].HRemark;//备注 | 
|                 string HMaker = mainList[0].HMaker;//制单人 | 
|                 int HOrgID = mainList[0].HOrgID;  //组织 | 
|                 Int64 HDeptID = mainList[0].HDeptID; | 
|                 Int64 HEmpID = mainList[0].HEmpID; | 
|                 Int64 HMangerID = mainList[0].HMangerID; | 
|   | 
|                 ds = oCN.RunProcReturn("select * from h_v_Qj_Sc_MouldUpperBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_Qj_Sc_MouldUpperBillList"); | 
|   | 
|                 if ((OperationType == 1) && ds.Tables[0].Rows.Count == 0)//新增 | 
|                 { | 
|                     //保存前控制 | 
|                     objJsonResult = BeforeSave_MouldUpperBill(HInterID, HBillNo, 1); | 
|                     if (objJsonResult.count == 0) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = objJsonResult.Message; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     //主表 | 
|                     oCN.RunProc(@"Insert Into Sc_MouldUpperBillMain    | 
|                    (HBillType,HBillStatus, HBillSubType, HInterID, HBillNo, HDate | 
|                    , HYear, HPeriod, HRemark, HMaker, HMakeDate, HOrgID | 
|                    , HDeptID, HEmpID, HMangerID)" + | 
|                     " values('" + HBillType + "','1','" + HBillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" + | 
|                     "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()," +  HOrgID +  | 
|                     ","+ HDeptID + ","+ HEmpID + ","+ HMangerID + ") "); | 
|   | 
|                 } | 
|                 else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0) | 
|                 { | 
|                     //保存前控制 | 
|                     objJsonResult = BeforeSave_MouldUpperBill(HInterID, HBillNo, 2); | 
|                     if (objJsonResult.count == 0) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = objJsonResult.Message; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     //修改 | 
|                     oCN.RunProc("update Sc_MouldUpperBillMain  set " + | 
|                        "HDate='" + HDate + | 
|                        "',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker + | 
|                        "',hupdatedate=getdate(),HDeptID=" + HDeptID + ",HEmpID=" + HEmpID + ",HMangerID=" + HMangerID + " where HInterID='" + HInterID + "'"); | 
|   | 
|                     //删除子表 | 
|                     oCN.RunProc("delete from Sc_MouldUpperBillSub where HInterID='" + HInterID + "'"); | 
|                 } | 
|                 //保存子表 | 
|                 objJsonResult = AddBillSub(msg3, HInterID, HBillNo, OperationType); | 
|                 if (objJsonResult.code == "0") | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = objJsonResult.Message; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|               | 
|                 objJsonResult.code = "1"; | 
|                 objJsonResult.count = 1; | 
|                 objJsonResult.Message = null; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "Exception!" + e.ToString(); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|         } | 
|   | 
|         public json AddBillSub(string msg3, long HInterID,string HBillNo, Int64 OperationType) | 
|         { | 
|             List<ClsSc_MouldUpperBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldUpperBillSub>>(msg3); | 
|             int i = 0; | 
|             foreach (ClsSc_MouldUpperBillSub oSub in DetailColl) | 
|             { | 
|                 i++; | 
|   | 
|                 oCN.RunProc(@"Insert Into Sc_MouldUpperBillSub    | 
|                    (HInterID, HBillNo_bak, HEntryID, HMouldID, HQty | 
|                    , HSourceID, HICMOInterID, HICMOEntryID, HICMOBillNo) | 
|                     values(" | 
|                      + HInterID + ",'"+ HBillNo + "'," + i + "," + oSub.HMouldID.ToString() + ",'" + oSub.HQty  | 
|                      + "'," + oSub.HSourceID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString()+",'"+ oSub.HICMOBillNo.ToString() + | 
|                      "') "); | 
|             } | 
|   | 
|             if (OperationType == 1)//新增 | 
|             { | 
|                 //保存后控制 | 
|                 objJsonResult = AfterSave_MouldUpperBill(HInterID, HBillNo, 1); | 
|                 if (objJsonResult.count == 0) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = objJsonResult.Message; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|             } | 
|             else | 
|             { | 
|                 //保存后控制 | 
|                 objJsonResult = AfterSave_MouldUpperBill(HInterID, HBillNo, 2); | 
|                 if (objJsonResult.count == 0) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = objJsonResult.Message; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|             } | 
|             objJsonResult.code = "1"; | 
|             objJsonResult.count = 1; | 
|             objJsonResult.Message = null; | 
|             objJsonResult.data = null; | 
|             return objJsonResult; | 
|         } | 
|   | 
|         #endregion | 
|   | 
|         #region 上模单删除功能 | 
|         [Route("Sc_MouldUpperBill/DeltetSc_MouldUpperBill")] | 
|         [HttpGet] | 
|         public object DeltetSc_MouldUpperBill(string HInterID, int HPRDORGID, string user) | 
|         { | 
|   | 
|             //编辑权限 | 
|             if (!DBUtility.ClsPub.Security_Log("Sc_MouldUpperBill_Delete", 1, false, user)) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "无删除权限!"; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|   | 
|             string[] HInterIDs = HInterID.Split(','); | 
|             string[] HBillNos = new string[HInterIDs.Length]; | 
|   | 
|             for (int i = 0; i < HInterIDs.Length; i++) | 
|             { | 
|                 oCN.BeginTran(); | 
|                 string hmainid = HInterIDs[i].Split('_')[0]; | 
|                 string hsubid = HInterIDs[i].Split('_')[1]; | 
|   | 
|                 ds = oCN.RunProcReturn(@"select HMaker,HBillNo,HBillStatus,HChecker from Sc_MouldUpperBillMain a | 
|                                     inner join Sc_MouldUpperBillSub b on a.HInterID = b.HInterID | 
|                                     where a.HInterID = " + hmainid , "Sc_MouldUpperBillMain"); | 
|   | 
|                 if (ds.Tables[0].Rows.Count != 0) | 
|                 { | 
|                     HBillNos[i] = ds.Tables[0].Rows[0]["HBillNo"].ToString(); | 
|                     string sReturn = ""; | 
|                     if (oSystemParameter.ShowBill(ref sReturn)) | 
|                     { | 
|                         if (oSystemParameter.omodel.Sc_ProcessExchangeBill_DeleterAndMakerMustSame == "Y") | 
|                         { | 
|                             if (ds.Tables[0].Rows[0]["HMaker"].ToString() != user && (user != "admin" && user != "Admin")) | 
|                             { | 
|                                 objJsonResult.code = "0"; | 
|                                 objJsonResult.count = 0; | 
|                                 objJsonResult.Message = "单据号:" + HBillNos[i] + "只能删除本人的单据!"; | 
|                                 objJsonResult.data = null; | 
|                                 oCN.RollBack(); | 
|                                 return objJsonResult; | 
|                             } | 
|                         } | 
|                     } | 
|   | 
|                     if (int.Parse(ds.Tables[0].Rows[0]["HBillStatus"].ToString()) > 1) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "单据号:" + HBillNos[i] + "单据当前处于不能删除状态,不能删除!"; | 
|                         objJsonResult.data = null; | 
|                         oCN.RollBack(); | 
|                         return objJsonResult; | 
|                     } | 
|   | 
|                     if (ds.Tables[0].Rows[0]["HChecker"].ToString()  != "") | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "单据号:" + HBillNos[i] + "单据已经审核,不能删除!"; | 
|                         objJsonResult.data = null; | 
|                         oCN.RollBack(); | 
|                         return objJsonResult; | 
|                     } | 
|   | 
|                     if (ds.Tables[0].Rows.Count == 1) { | 
|                         oCN.RunProc("delete from Sc_MouldUpperBillMain where HInterID=" + hmainid); | 
|                     } | 
|   | 
|                     oCN.RunProc("delete from Sc_MouldUpperBillSub where HInterID=" + hmainid + " and HEntryID=" + hsubid); | 
|   | 
|                     oCN.Commit(); | 
|                 } | 
|                 else | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "单据未找到"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|             } | 
|   | 
|             objJsonResult.code = "1"; | 
|             objJsonResult.count = 1; | 
|             objJsonResult.Message = "删除成功!"; | 
|             objJsonResult.data = null; | 
|             return objJsonResult; | 
|         } | 
|         #endregion | 
|   | 
|         #region 上模单审核/反审核功能 | 
|         [Route("Sc_MouldUpperBill/CheckSc_MouldUpperBill")] | 
|         [HttpGet] | 
|         public object CheckSc_MouldUpperBill(string HInterID, int Type, string user) | 
|         { | 
|             try | 
|             { | 
|                 //判断是否有删除权限 | 
|                 if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBill_Sub_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; | 
|                 BillOld.MvarItemKey = "Sc_MouldUpperBillMain"; | 
|                 oCN.BeginTran();//开始事务 | 
|   | 
|                 //Type 1 审核  2  反审核 | 
|                 if (Type == 1) | 
|                 { | 
|                     //判断单据是否已经审核 | 
|                     DataSet ds; | 
|                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; | 
|                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); | 
|                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) | 
|                     { | 
|                         if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已审核!不需要再审核!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|   | 
|                         //审核单据 | 
|                         if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 1; | 
|                             objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                     } | 
|                     else | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "单据不存在!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|   | 
|   | 
|                 } | 
|                 else | 
|                 { | 
|                     //判断单据是否已经反审核 | 
|                     DataSet ds; | 
|                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; | 
|                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); | 
|                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) | 
|                     { | 
|                         if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已反审核!不需要再反审核!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|   | 
|                         //反审核单据 | 
|                         if (BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) | 
|                         { | 
|   | 
|                         } | 
|                         else | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 1; | 
|                             objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                     } | 
|   | 
|                     else | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "单据不存在!"; | 
|                         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_MouldUpperBill/CloseSc_MouldUpperBill")] | 
|         [HttpGet] | 
|         public object CloseSc_MouldUpperBill(string HInterID, int Type, string user) | 
|         { | 
|             try | 
|             { | 
|                 //判断是否有删除权限 | 
|                 if (!DBUtility.ClsPub.Security_Log("Sc_MouldUpperBill_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; | 
|                 BillOld.MvarItemKey = "Sc_MouldUpperBillMain"; | 
|                 oCN.BeginTran();//开始事务 | 
|   | 
|                 //Type 1 关闭  2  反关闭 | 
|                 if (Type == 1) | 
|                 { | 
|                     //判断单据是否已经关闭 | 
|                     DataSet ds; | 
|                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; | 
|                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); | 
|                     if (ds == null || ds.Tables[0].Rows.Count == 0) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "单据不存在!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) | 
|                     { | 
|                         if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已作废!不能进行关闭!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|   | 
|   | 
|                         if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已关闭!不能再次关闭!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         //关闭单据 | 
|                         if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 1; | 
|                             objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                     } | 
|                 } | 
|                 else | 
|                 { | 
|                     //判断单据是否已经反关闭 | 
|                     DataSet ds; | 
|                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; | 
|                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); | 
|                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) | 
|                     { | 
|                         if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已作废!不能进行关闭!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|   | 
|                         if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据未关闭!不需要再反关闭!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         //反关闭单据 | 
|                         if (!BillOld.CancelClose(Int64.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_MouldUpperBill/DropSc_MouldUpperBill")] | 
|         [HttpGet] | 
|         public object DropSc_MouldUpperBill(string HInterID, int Type, string user) | 
|         { | 
|             try | 
|             { | 
|                 //判断是否有作废权限 | 
|                 if (!DBUtility.ClsPub.Security_Log("Sc_MouldUpperBill_Drop", 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; | 
|                 BillOld.MvarItemKey = "Sc_MouldUpperBillMain"; | 
|                 oCN.BeginTran();//开始事务 | 
|   | 
|                 //Type 1 作废  2  反作废 | 
|                 if (Type == 1) | 
|                 { | 
|                     //判断单据是否已经作废 | 
|                     DataSet ds; | 
|                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; | 
|                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); | 
|                     if (ds == null || ds.Tables[0].Rows.Count == 0) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "单据不存在!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) | 
|                     { | 
|                         if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已审核!不能进行作废!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已作废!不需要再作废!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         //作废单据 | 
|                         if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 1; | 
|                             objJsonResult.Message = "作废失败!原因:" + ClsPub.sExeReturnInfo; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                     } | 
|                 } | 
|                 else | 
|                 { | 
|                     //判断单据是否已经反作废 | 
|                     DataSet ds; | 
|                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; | 
|                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); | 
|                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) | 
|                     { | 
|                         if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已审核!不能进行作废!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         if (ds.Tables[0].Rows[0]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据未作废!不需要再反作废!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         //反作废单据 | 
|                         if (!BillOld.AbandonCancelltion(Int64.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_MouldUpperBill/Sc_MouldLowerBillList")] | 
|         [HttpGet] | 
|         public object Sc_MouldLowerBillList(string sWhere, string user) | 
|         { | 
|             try | 
|             { | 
|                 List<object> columnNameList = new List<object>(); | 
|   | 
|                 //查看权限 | 
|                 if (!DBUtility.ClsPub.Security_Log("Sc_MouldLowerBill_Query", 1, false, user)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "无查看权限!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 ds = oCN.RunProcReturn("select * from  h_v_Qj_Sc_MouldLowerBillList where 1=1" + sWhere + "order by hmainid desc ", "h_v_Qj_Sc_MouldLowerBillList"); | 
|   | 
|                 //添加列名 | 
|                 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));//获取到DataColumn列对象的列名 | 
|                 } | 
|   | 
|                 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 | 
|   | 
|         #region 下模单 列表分页查询 | 
|         [Route("Sc_MouldUpperBill/Sc_MouldLowerBillListPage")] | 
|         [HttpGet] | 
|         public object Sc_MouldLowerBillListPage(string sWhere, string user, int page, int size) | 
|         { | 
|             try | 
|             { | 
|                 List<object> columnNameList = new List<object>(); | 
|   | 
|                 //查看权限 | 
|                 if (!DBUtility.ClsPub.Security_Log("Sc_MouldLowerBill_Query", 1, false, user)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "无查看权限!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 sWhere = sWhere.Replace("'", "''"); | 
|                 ds = oCN.RunProcReturn("exec h_p_Sc_MouldLowerBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldLowerBillList"); | 
|   | 
|                 //添加列名 | 
|                 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));//获取到DataColumn列对象的列名 | 
|                 } | 
|   | 
|   | 
|                 objJsonResult.code = CodeConstant.SUCCEED; | 
|                 objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); | 
|                 objJsonResult.Message = "Sucess!"; | 
|                 objJsonResult.data = ds.Tables[0]; | 
|                 objJsonResult.list = columnNameList; | 
|                 return objJsonResult; | 
|             } | 
|             catch (Exception ex) | 
|             { | 
|                 objJsonResult.code = CodeConstant.FAIL; | 
|                 objJsonResult.count = CountConstant.FAIL; | 
|                 objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|         } | 
|         #endregion | 
|   | 
|         #region 下模单 保存前、保存后控制 | 
|   | 
|         //保存前控制 | 
|         public json BeforeSave_MouldLowerBill(Int64 HInterID, string HBillNo, Int64 OperationType) | 
|         { | 
|             DataSet BeforeSave = oCN.RunProcReturn("Exec h_p_Sc_MouldLowerBill_BeforeSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_Sc_MouldLowerBill_BeforeSaveCtrl"); | 
|             if (BeforeSave == null || BeforeSave.Tables[0].Rows.Count == 0) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "保存前判断失败!"; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             else if (DBUtility.ClsPub.isLong(BeforeSave.Tables[0].Rows[0]["HBack"]) == 1) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0;  //失败! | 
|                 objJsonResult.Message = DBUtility.ClsPub.isStrNull(BeforeSave.Tables[0].Rows[0]["HRemark"]); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             else | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 1;  //成功! | 
|                 objJsonResult.Message = DBUtility.ClsPub.isStrNull(BeforeSave.Tables[0].Rows[0]["HRemark"]); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|         } | 
|   | 
|         //保存后控制 | 
|         public json AfterSave_MouldLowerBill(Int64 HInterID, string HBillNo, Int64 OperationType) | 
|         { | 
|             DataSet AfterSave = oCN.RunProcReturn("Exec h_p_Sc_MouldLowerBill_AfterSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_Sc_MouldLowerBill_AfterSaveCtrl"); | 
|             if (AfterSave == null || AfterSave.Tables[0].Rows.Count == 0) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "保存后判断失败!"; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             else if (DBUtility.ClsPub.isLong(AfterSave.Tables[0].Rows[0]["HBack"]) == 1) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0;  //失败! | 
|                 objJsonResult.Message = DBUtility.ClsPub.isStrNull(AfterSave.Tables[0].Rows[0]["HRemark"]); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             else | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 1;  //成功! | 
|                 objJsonResult.Message = DBUtility.ClsPub.isStrNull(AfterSave.Tables[0].Rows[0]["HRemark"]); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|         } | 
|   | 
|         #endregion | 
|   | 
|         #region 下模单 新增 | 
|         /// <summary> | 
|         /// 新增单据-保存按钮 | 
|         ///参数:string sql。 | 
|         ///返回值:object。 | 
|         /// </summary> | 
|         [Route("Sc_MouldUpperBill/AddSc_MouldLowerBill")] | 
|         [HttpPost] | 
|         public object AddSc_MouldLowerBill([FromBody] JObject sMainSub) | 
|         { | 
|             var _value = sMainSub["sMainSub"].ToString(); | 
|             string msg1 = _value.ToString(); | 
|             oCN.BeginTran(); | 
|             //保存主表 | 
|             objJsonResult = AddMouldLowerBill(msg1); | 
|             if (objJsonResult.code == "0") | 
|             { | 
|                 oCN.RollBack(); | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = objJsonResult.Message; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             oCN.Commit(); | 
|             objJsonResult.code = "1"; | 
|             objJsonResult.count = 1; | 
|             objJsonResult.Message = "新增单据成功!"; | 
|             objJsonResult.data = ds.Tables[0]; | 
|             return objJsonResult; | 
|         } | 
|   | 
|         public json AddMouldLowerBill(string msg1) | 
|         { | 
|             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
|             string msg2 = sArray[0].ToString(); | 
|             string msg3 = sArray[1].ToString(); | 
|             int OperationType = int.Parse(sArray[2].ToString());//数据类型 1添加 3修改 2 复制  | 
|             string user = sArray[3].ToString();//用户名 | 
|             try | 
|             { | 
|                 if (!DBUtility.ClsPub.Security_Log("Sc_MouldLowerBill_Edit", 1, false, user)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "无权限编辑!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 msg2 = "[" + msg2.ToString() + "]"; | 
|                 List<ClsSc_MouldLowerBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldLowerBillMain>>(msg2); | 
|                 string HBillType = "3847"; | 
|                 long HInterID = mainList[0].HInterID;//递入type得到的单据ID | 
|                 string HBillNo = mainList[0].HBillNo;//递入type得到的单据号 | 
|                 DateTime HDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));//日期 | 
|                 int HYear = DateTime.Now.Year; | 
|                 double HPeriod = DateTime.Now.Month; | 
|                 string HRemark = mainList[0].HRemark;//备注 | 
|                 string HMaker = mainList[0].HMaker;//制单人 | 
|                 int HOrgID = mainList[0].HOrgID;  //组织 | 
|                 Int64 HDeptID = mainList[0].HDeptID; | 
|                 Int64 HEmpID = mainList[0].HEmpID; | 
|                 Int64 HMangerID = mainList[0].HMangerID; | 
|   | 
|                 ds = oCN.RunProcReturn("select * from h_v_Qj_Sc_MouldLowerBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_Qj_Sc_MouldLowerBillList"); | 
|   | 
|                 if ((OperationType == 1) && ds.Tables[0].Rows.Count == 0)//新增 | 
|                 { | 
|                     //保存前控制 | 
|                     objJsonResult = BeforeSave_MouldLowerBill(HInterID, HBillNo, 1); | 
|                     if (objJsonResult.count == 0) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = objJsonResult.Message; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     //主表 | 
|                     oCN.RunProc(@"Insert Into Sc_MouldLowerBillMain    | 
|                    (HBillType,HBillStatus, HBillSubType, HInterID, HBillNo, HDate | 
|                    , HYear, HPeriod, HRemark, HMaker, HMakeDate, HOrgID | 
|                    , HDeptID, HEmpID, HMangerID)" + | 
|                     " values('" + HBillType + "','1','" + HBillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" + | 
|                     "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()," + HOrgID + | 
|                     "," + HDeptID + "," + HEmpID + "," + HMangerID + ") "); | 
|   | 
|                 } | 
|                 else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0) | 
|                 { | 
|                     //保存前控制 | 
|                     objJsonResult = BeforeSave_MouldLowerBill(HInterID, HBillNo, 2); | 
|                     if (objJsonResult.count == 0) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = objJsonResult.Message; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     //修改 | 
|                     oCN.RunProc("update Sc_MouldLowerBillMain  set " + | 
|                        "HDate='" + HDate + | 
|                        "',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker + | 
|                        "',hupdatedate=getdate(),HDeptID=" + HDeptID + ",HEmpID=" + HEmpID + ",HMangerID=" + HMangerID + " where HInterID='" + HInterID + "'"); | 
|   | 
|                     //删除子表 | 
|                     oCN.RunProc("delete from Sc_MouldLowerBillSub where HInterID='" + HInterID + "'"); | 
|                 } | 
|                 //保存子表 | 
|                 objJsonResult = AddMouldLowerBill(msg3, HInterID, HBillNo, OperationType); | 
|                 if (objJsonResult.code == "0") | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = objJsonResult.Message; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 objJsonResult.code = "1"; | 
|                 objJsonResult.count = 1; | 
|                 objJsonResult.Message = null; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "Exception!" + e.ToString(); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|         } | 
|   | 
|         public json AddMouldLowerBill(string msg3, long HInterID, string HBillNo, Int64 OperationType) | 
|         { | 
|             List<ClsSc_MouldLowerBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldLowerBillSub>>(msg3); | 
|             int i = 0; | 
|             foreach (ClsSc_MouldLowerBillSub oSub in DetailColl) | 
|             { | 
|                 i++; | 
|   | 
|                 oCN.RunProc(@"Insert Into Sc_MouldLowerBillSub    | 
|                    (HInterID, HBillNo_bak, HEntryID, HMouldID, HQty | 
|                    , HSourceID, HICMOInterID, HICMOEntryID, HICMOBillNo) | 
|                     values(" | 
|                      + HInterID + ",'" + HBillNo + "'," + i + "," + oSub.HMouldID.ToString() + ",'" + oSub.HQty | 
|                      + "'," + oSub.HSourceID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString() + ",'" + oSub.HICMOBillNo.ToString() + | 
|                      "') "); | 
|             } | 
|   | 
|             if (OperationType == 1)//新增 | 
|             { | 
|                 //保存后控制 | 
|                 objJsonResult = AfterSave_MouldLowerBill(HInterID, HBillNo, 1); | 
|                 if (objJsonResult.count == 0) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = objJsonResult.Message; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|             } | 
|             else | 
|             { | 
|                 //保存后控制 | 
|                 objJsonResult = AfterSave_MouldLowerBill(HInterID, HBillNo, 2); | 
|                 if (objJsonResult.count == 0) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = objJsonResult.Message; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|             } | 
|             objJsonResult.code = "1"; | 
|             objJsonResult.count = 1; | 
|             objJsonResult.Message = null; | 
|             objJsonResult.data = null; | 
|             return objJsonResult; | 
|         } | 
|   | 
|         #endregion | 
|   | 
|         #region 下模单删除功能 | 
|         [Route("Sc_MouldUpperBill/DeltetSc_MouldLowerBill")] | 
|         [HttpGet] | 
|         public object DeltetSc_MouldLowerBill(string HInterID, int HPRDORGID, string user) | 
|         { | 
|   | 
|             //编辑权限 | 
|             if (!DBUtility.ClsPub.Security_Log("Sc_MouldLowerBill_Delete", 1, false, user)) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "无删除权限!"; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|   | 
|             string[] HInterIDs = HInterID.Split(','); | 
|             string[] HBillNos = new string[HInterIDs.Length]; | 
|   | 
|             for (int i = 0; i < HInterIDs.Length; i++) | 
|             { | 
|                 oCN.BeginTran(); | 
|                 string hmainid = HInterIDs[i].Split('_')[0]; | 
|                 string hsubid = HInterIDs[i].Split('_')[1]; | 
|   | 
|                 ds = oCN.RunProcReturn(@"select HMaker,HBillNo,HBillStatus,HChecker from Sc_MouldLowerBillMain a | 
|                                     inner join Sc_MouldLowerBillSub b on a.HInterID = b.HInterID | 
|                                     where a.HInterID = " + hmainid, "Sc_MouldLowerBillMain"); | 
|   | 
|                 if (ds.Tables[0].Rows.Count != 0) | 
|                 { | 
|                     HBillNos[i] = ds.Tables[0].Rows[0]["HBillNo"].ToString(); | 
|                     string sReturn = ""; | 
|                     if (oSystemParameter.ShowBill(ref sReturn)) | 
|                     { | 
|                         if (oSystemParameter.omodel.Sc_ProcessExchangeBill_DeleterAndMakerMustSame == "Y") | 
|                         { | 
|                             if (ds.Tables[0].Rows[0]["HMaker"].ToString() != user && (user != "admin" && user != "Admin")) | 
|                             { | 
|                                 objJsonResult.code = "0"; | 
|                                 objJsonResult.count = 0; | 
|                                 objJsonResult.Message = "单据号:" + HBillNos[i] + "只能删除本人的单据!"; | 
|                                 objJsonResult.data = null; | 
|                                 oCN.RollBack(); | 
|                                 return objJsonResult; | 
|                             } | 
|                         } | 
|                     } | 
|   | 
|                     if (int.Parse(ds.Tables[0].Rows[0]["HBillStatus"].ToString()) > 1) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "单据号:" + HBillNos[i] + "单据当前处于不能删除状态,不能删除!"; | 
|                         objJsonResult.data = null; | 
|                         oCN.RollBack(); | 
|                         return objJsonResult; | 
|                     } | 
|   | 
|                     if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "") | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "单据号:" + HBillNos[i] + "单据已经审核,不能删除!"; | 
|                         objJsonResult.data = null; | 
|                         oCN.RollBack(); | 
|                         return objJsonResult; | 
|                     } | 
|   | 
|                     if (ds.Tables[0].Rows.Count == 1) | 
|                     { | 
|                         oCN.RunProc("delete from Sc_MouldLowerBillMain where HInterID=" + hmainid); | 
|                     } | 
|   | 
|                     oCN.RunProc("delete from Sc_MouldLowerBillSub where HInterID=" + hmainid + " and HEntryID=" + hsubid); | 
|   | 
|                     oCN.Commit(); | 
|                 } | 
|                 else | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "单据未找到"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|             } | 
|   | 
|             objJsonResult.code = "1"; | 
|             objJsonResult.count = 1; | 
|             objJsonResult.Message = "删除成功!"; | 
|             objJsonResult.data = null; | 
|             return objJsonResult; | 
|         } | 
|         #endregion | 
|   | 
|         #region 下模单审核/反审核功能 | 
|         [Route("Sc_MouldUpperBill/CheckSc_MouldLowerBill")] | 
|         [HttpGet] | 
|         public object CheckSc_MouldLowerBill(string HInterID, int Type, string user) | 
|         { | 
|             try | 
|             { | 
|                 //判断是否有删除权限 | 
|                 if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBill_Sub_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; | 
|                 BillOld.MvarItemKey = "Sc_MouldLowerBillMain"; | 
|                 oCN.BeginTran();//开始事务 | 
|   | 
|                 //Type 1 审核  2  反审核 | 
|                 if (Type == 1) | 
|                 { | 
|                     //判断单据是否已经审核 | 
|                     DataSet ds; | 
|                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; | 
|                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); | 
|                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) | 
|                     { | 
|                         if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已审核!不需要再审核!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|   | 
|                         //审核单据 | 
|                         if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 1; | 
|                             objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                     } | 
|                     else { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "单据不存在!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                 } | 
|                 else | 
|                 { | 
|                     //判断单据是否已经反审核 | 
|                     DataSet ds; | 
|                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; | 
|                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); | 
|                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) | 
|                     { | 
|                         if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已反审核!不需要再反审核!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|   | 
|                         //反审核单据 | 
|                         if (BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) | 
|                         { | 
|   | 
|                         } | 
|                         else | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 1; | 
|                             objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                     } | 
|                     else | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "单据不存在!"; | 
|                         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_MouldUpperBill/CloseSc_MouldLowerBill")] | 
|         [HttpGet] | 
|         public object CloseSc_MouldLowerBill(string HInterID, int Type, string user) | 
|         { | 
|             try | 
|             { | 
|                 //判断是否有删除权限 | 
|                 if (!DBUtility.ClsPub.Security_Log("Sc_MouldLowerBill_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; | 
|                 BillOld.MvarItemKey = "Sc_MouldLowerBillMain"; | 
|                 oCN.BeginTran();//开始事务 | 
|   | 
|                 //Type 1 关闭  2  反关闭 | 
|                 if (Type == 1) | 
|                 { | 
|                     //判断单据是否已经关闭 | 
|                     DataSet ds; | 
|                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; | 
|                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); | 
|                     if (ds == null || ds.Tables[0].Rows.Count == 0) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "单据不存在!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) | 
|                     { | 
|                         if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已作废!不能进行关闭!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|   | 
|   | 
|                         if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已关闭!不能再次关闭!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         //关闭单据 | 
|                         if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 1; | 
|                             objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                     } | 
|                 } | 
|                 else | 
|                 { | 
|                     //判断单据是否已经反关闭 | 
|                     DataSet ds; | 
|                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; | 
|                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); | 
|                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) | 
|                     { | 
|                         if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已作废!不能进行关闭!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|   | 
|                         if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据未关闭!不需要再反关闭!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         //反关闭单据 | 
|                         if (!BillOld.CancelClose(Int64.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_MouldUpperBill/DropSc_MouldLowerBill")] | 
|         [HttpGet] | 
|         public object DropSc_MouldLowerBill(string HInterID, int Type, string user) | 
|         { | 
|             try | 
|             { | 
|                 //判断是否有作废权限 | 
|                 if (!DBUtility.ClsPub.Security_Log("Sc_MouldLowerBill_Drop", 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; | 
|                 BillOld.MvarItemKey = "Sc_MouldLowerBillMain"; | 
|                 oCN.BeginTran();//开始事务 | 
|   | 
|                 //Type 1 作废  2  反作废 | 
|                 if (Type == 1) | 
|                 { | 
|                     //判断单据是否已经作废 | 
|                     DataSet ds; | 
|                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; | 
|                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); | 
|                     if (ds == null || ds.Tables[0].Rows.Count == 0) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "单据不存在!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) | 
|                     { | 
|                         if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已审核!不能进行作废!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已作废!不需要再作废!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         //作废单据 | 
|                         if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 1; | 
|                             objJsonResult.Message = "作废失败!原因:" + ClsPub.sExeReturnInfo; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                     } | 
|                 } | 
|                 else | 
|                 { | 
|                     //判断单据是否已经反作废 | 
|                     DataSet ds; | 
|                     string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; | 
|                     ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); | 
|                     if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) | 
|                     { | 
|                         if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已审核!不能进行作废!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         if (ds.Tables[0].Rows[0]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据未作废!不需要再反作废!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         //反作废单据 | 
|                         if (!BillOld.AbandonCancelltion(Int64.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_MouldLowerBill/Sc_MouldUpperBillList")] | 
|         [HttpGet] | 
|         public object Sc_MouldUpperBillList(string sWhere) | 
|         { | 
|             try | 
|             { | 
|   | 
|                 ds = oCN.RunProcReturn("select * from  h_v_Qj_Sc_MouldUpperBillList where 1=1" + sWhere, "h_v_Qj_Sc_MouldUpperBillList"); | 
|   | 
|                 if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "查无数据!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 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; | 
|             } | 
|         } | 
|         #endregion | 
|   | 
|         #region 上/下模单获取条码信息 | 
|         [Route("Sc_MouldUpperBill/txtHBarCode_KeyDown")] | 
|         [HttpGet] | 
|         public object txtHBarCode_KeyDown(string HBarCode,int HSourceID, string UserID, string HBillType) | 
|         { | 
|             try | 
|             { | 
|                 if (HBarCode == null || HBarCode.Equals("")) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "空白码,条形码不能为空!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 ds = oCN.RunProcReturn("exec h_p_Sc_AllowLoadData '" + HBarCode + "','"+ HSourceID + "','"+ HBillType + "'", "h_p_Sc_AllowLoadData"); | 
|   | 
|                 if (ds == null || ds .Tables.Count== 0 || ds.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "查无数据!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 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; | 
|             } | 
|         } | 
|         #endregion | 
|   | 
|         #region 上模单 PDA新增 | 
|         /// <summary> | 
|         /// 新增单据-保存按钮 | 
|         ///参数:string sql。 | 
|         ///返回值:object。 | 
|         /// </summary> | 
|         [Route("Sc_MouldUpperBill/AddSc_MouldUpperBill_PDA")] | 
|         [HttpPost] | 
|         public object AddSc_MouldUpperBill_PDA([FromBody] JObject oMain) | 
|         { | 
|             var _value = oMain["oMain"].ToString(); | 
|             string msg1 = _value.ToString(); | 
|             oCN.BeginTran(); | 
|             //保存主表 | 
|             objJsonResult = AddBillMain_PDA(msg1); | 
|             if (objJsonResult.code == "0") | 
|             { | 
|                 oCN.RollBack(); | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = objJsonResult.Message; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             oCN.Commit(); | 
|             objJsonResult.code = "1"; | 
|             objJsonResult.count = 1; | 
|             objJsonResult.Message = "新增单据成功!"; | 
|             objJsonResult.data = ds.Tables[0]; | 
|             return objJsonResult; | 
|         } | 
|   | 
|         public json AddBillMain_PDA(string msg1) | 
|         { | 
|             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
|             string msg2 = sArray[0].ToString(); | 
|             string user = sArray[1].ToString();//用户名 | 
|             int OperationType = int.Parse(sArray[2].ToString());//数据类型 1添加 3修改 2 复制  | 
|             try | 
|             { | 
|                 if (!DBUtility.ClsPub.Security_Log("Sc_MouldUpperBill_Edit", 1, false, user)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "无权限编辑!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 msg2 = "[" + msg2.ToString() + "]"; | 
|                 List<ClsSc_MouldUpperBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldUpperBillMain>>(msg2); | 
|                 string HBillType = "3846"; | 
|                 long HInterID = mainList[0].HInterID;//递入type得到的单据ID | 
|                 string HBillNo = mainList[0].HBillNo;//递入type得到的单据号 | 
|                 DateTime HDate = mainList[0].HDate;//日期 | 
|                 int HYear = DateTime.Now.Year; | 
|                 double HPeriod = DateTime.Now.Month; | 
|                 string HRemark = mainList[0].HRemark;//备注 | 
|                 string HMaker = mainList[0].HMaker;//制单人 | 
|                 int HOrgID = mainList[0].HOrgID;  //组织 | 
|                 Int64 HDeptID = mainList[0].HDeptID; | 
|                 Int64 HEmpID = mainList[0].HEmpID; | 
|                 Int64 HMangerID = mainList[0].HMangerID; | 
|   | 
|                 ds = oCN.RunProcReturn("select * from h_v_Qj_Sc_MouldUpperBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_Qj_Sc_MouldUpperBillList"); | 
|   | 
|                 if ((OperationType == 1) && ds.Tables[0].Rows.Count == 0)//新增 | 
|                 { | 
|                     //保存前控制 | 
|                     objJsonResult = BeforeSave_MouldUpperBill(HInterID, HBillNo, 1); | 
|                     if (objJsonResult.count == 0) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = objJsonResult.Message; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     //主表 | 
|                     oCN.RunProc(@"Insert Into Sc_MouldUpperBillMain    | 
|                    (HBillType,HBillStatus, HBillSubType, HInterID, HBillNo, HDate | 
|                    , HYear, HPeriod, HRemark, HMaker, HMakeDate, HOrgID | 
|                    , HDeptID, HEmpID, HMangerID)" + | 
|                     " values('" + HBillType + "','1','" + HBillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" + | 
|                     "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()," + HOrgID + | 
|                     "," + HDeptID + "," + HEmpID + "," + HMangerID + ") "); | 
|   | 
|                 } | 
|                 else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0) | 
|                 { | 
|                     //保存前控制 | 
|                     objJsonResult = BeforeSave_MouldUpperBill(HInterID, HBillNo, 2); | 
|                     if (objJsonResult.count == 0) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = objJsonResult.Message; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     //修改 | 
|                     oCN.RunProc("update Sc_MouldUpperBillMain  set " + | 
|                        "HDate='" + HDate + | 
|                        "',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker + | 
|                        "',hupdatedate=getdate(),HDeptID=" + HDeptID + ",HEmpID=" + HEmpID + ",HMangerID=" + HMangerID + " where HInterID='" + HInterID + "'"); | 
|   | 
|                     //删除子表 | 
|                     oCN.RunProc("delete from Sc_MouldUpperBillSub where HInterID='" + HInterID + "'"); | 
|                 } | 
|                 //保存子表 | 
|                 objJsonResult = AddBillSub_PDA(msg2, HInterID, HBillNo, OperationType); | 
|                 if (objJsonResult.code == "0") | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = objJsonResult.Message; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 objJsonResult.code = "1"; | 
|                 objJsonResult.count = 1; | 
|                 objJsonResult.Message = null; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "Exception!" + e.ToString(); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|         } | 
|   | 
|         public json AddBillSub_PDA(string msg2, long HInterID, string HBillNo, Int64 OperationType) | 
|         { | 
|             List<ClsSc_MouldUpperBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldUpperBillSub>>(msg2); | 
|             int i = 0; | 
|             foreach (ClsSc_MouldUpperBillSub oSub in DetailColl) | 
|             { | 
|                 i++; | 
|   | 
|                 oCN.RunProc(@"Insert Into Sc_MouldUpperBillSub    | 
|                    (HInterID, HBillNo_bak, HEntryID, HMouldID, HQty | 
|                    , HSourceID, HICMOInterID, HICMOEntryID, HICMOBillNo | 
|                     ,HProcExchBillNo,HProcExchInterID,HProcExchEntryID | 
|                     ,HScanDate,HBarCode) | 
|                     values(" | 
|                      + HInterID + ",'" + HBillNo + "'," + i + "," + oSub.HMouldID.ToString() + ",'" + oSub.HQty | 
|                      + "'," + oSub.HSourceID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString() + ",'" + oSub.HICMOBillNo.ToString() | 
|                      + "','" + oSub.HProcExchBillNo.ToString() + "'," + oSub.HProcExchInterID.ToString() + "," + oSub.HProcExchEntryID.ToString() | 
|                      + ",'" + oSub.HScanDate.ToString() + "','" + oSub.HMouldNumber.ToString() + "') "); | 
|             } | 
|   | 
|             if (OperationType == 1)//新增 | 
|             { | 
|                 //保存后控制 | 
|                 objJsonResult = AfterSave_MouldUpperBill(HInterID, HBillNo, 1); | 
|                 if (objJsonResult.count == 0) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = objJsonResult.Message; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|             } | 
|             else | 
|             { | 
|                 //保存后控制 | 
|                 objJsonResult = AfterSave_MouldUpperBill(HInterID, HBillNo, 2); | 
|                 if (objJsonResult.count == 0) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = objJsonResult.Message; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|             } | 
|             objJsonResult.code = "1"; | 
|             objJsonResult.count = 1; | 
|             objJsonResult.Message = null; | 
|             objJsonResult.data = null; | 
|             return objJsonResult; | 
|         } | 
|   | 
|         #endregion | 
|   | 
|         #region 下模单 PDA新增 | 
|         /// <summary> | 
|         /// 新增单据-保存按钮 | 
|         ///参数:string sql。 | 
|         ///返回值:object。 | 
|         /// </summary> | 
|         [Route("Sc_MouldUpperBill/AddSc_MouldLowerBill_PDA")] | 
|         [HttpPost] | 
|         public object AddSc_MouldLowerBill_PDA([FromBody] JObject oMain) | 
|         { | 
|             var _value = oMain["oMain"].ToString(); | 
|             string msg1 = _value.ToString(); | 
|             oCN.BeginTran(); | 
|             //保存主表 | 
|             objJsonResult = AddSc_MouldLowerBillMain_PDA(msg1); | 
|             if (objJsonResult.code == "0") | 
|             { | 
|                 oCN.RollBack(); | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = objJsonResult.Message; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             oCN.Commit(); | 
|             objJsonResult.code = "1"; | 
|             objJsonResult.count = 1; | 
|             objJsonResult.Message = "新增单据成功!"; | 
|             objJsonResult.data = ds.Tables[0]; | 
|             return objJsonResult; | 
|         } | 
|   | 
|         public json AddSc_MouldLowerBillMain_PDA(string msg1) | 
|         { | 
|             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
|             string msg2 = sArray[0].ToString(); | 
|             string user = sArray[1].ToString();//用户名 | 
|             int OperationType = int.Parse(sArray[2].ToString());//数据类型 1添加 3修改 2 复制  | 
|             try | 
|             { | 
|                 if (!DBUtility.ClsPub.Security_Log("Sc_MouldLowerBill_Edit", 1, false, user)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "无权限编辑!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 msg2 = "[" + msg2.ToString() + "]"; | 
|                 List<ClsSc_MouldLowerBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldLowerBillMain>>(msg2); | 
|                 string HBillType = "3847"; | 
|                 long HInterID = mainList[0].HInterID;//递入type得到的单据ID | 
|                 string HBillNo = mainList[0].HBillNo;//递入type得到的单据号 | 
|                 DateTime HDate = mainList[0].HDate;//日期 | 
|                 int HYear = DateTime.Now.Year; | 
|                 double HPeriod = DateTime.Now.Month; | 
|                 string HRemark = mainList[0].HRemark;//备注 | 
|                 string HMaker = mainList[0].HMaker;//制单人 | 
|                 int HOrgID = mainList[0].HOrgID;  //组织 | 
|                 Int64 HDeptID = mainList[0].HDeptID; | 
|                 Int64 HEmpID = mainList[0].HEmpID; | 
|                 Int64 HMangerID = mainList[0].HMangerID; | 
|   | 
|                 ds = oCN.RunProcReturn("select * from h_v_Qj_Sc_MouldLowerBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_Qj_Sc_MouldLowerBillList"); | 
|   | 
|                 if ((OperationType == 1) && ds.Tables[0].Rows.Count == 0)//新增 | 
|                 { | 
|                     //保存前控制 | 
|                     objJsonResult = BeforeSave_MouldLowerBill(HInterID, HBillNo, 1); | 
|                     if (objJsonResult.count == 0) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = objJsonResult.Message; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     //主表 | 
|                     oCN.RunProc(@"Insert Into Sc_MouldLowerBillMain    | 
|                    (HBillType,HBillStatus, HBillSubType, HInterID, HBillNo, HDate | 
|                    , HYear, HPeriod, HRemark, HMaker, HMakeDate, HOrgID | 
|                    , HDeptID, HEmpID, HMangerID)" + | 
|                     " values('" + HBillType + "','1','" + HBillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" + | 
|                     "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()," + HOrgID + | 
|                     "," + HDeptID + "," + HEmpID + "," + HMangerID + ") "); | 
|   | 
|                 } | 
|                 else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0) | 
|                 { | 
|                     //保存前控制 | 
|                     objJsonResult = BeforeSave_MouldLowerBill(HInterID, HBillNo, 2); | 
|                     if (objJsonResult.count == 0) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = objJsonResult.Message; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     //修改 | 
|                     oCN.RunProc("update Sc_MouldLowerBillMain  set " + | 
|                        "HDate='" + HDate + | 
|                        "',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker + | 
|                        "',hupdatedate=getdate(),HDeptID=" + HDeptID + ",HEmpID=" + HEmpID + ",HMangerID=" + HMangerID + " where HInterID='" + HInterID + "'"); | 
|   | 
|                     //删除子表 | 
|                     oCN.RunProc("delete from Sc_MouldLowerBillSub where HInterID='" + HInterID + "'"); | 
|                 } | 
|                 //保存子表 | 
|                 objJsonResult = AddSc_MouldLowerBillSub_PDA(msg2, HInterID, HBillNo, OperationType); | 
|                 if (objJsonResult.code == "0") | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = objJsonResult.Message; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 objJsonResult.code = "1"; | 
|                 objJsonResult.count = 1; | 
|                 objJsonResult.Message = null; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "Exception!" + e.ToString(); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|         } | 
|   | 
|         public json AddSc_MouldLowerBillSub_PDA(string msg2, long HInterID, string HBillNo, Int64 OperationType) | 
|         { | 
|             List<ClsSc_MouldLowerBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldLowerBillSub>>(msg2); | 
|             int i = 0; | 
|             foreach (ClsSc_MouldLowerBillSub oSub in DetailColl) | 
|             { | 
|                 i++; | 
|   | 
|                 oCN.RunProc(@"Insert Into Sc_MouldLowerBillSub    | 
|                    (HInterID, HBillNo_bak, HEntryID, HMouldID, HQty | 
|                    , HSourceID, HICMOInterID, HICMOEntryID, HICMOBillNo | 
|                     ,HProcExchBillNo,HProcExchInterID,HProcExchEntryID | 
|                     ,HScanDate,HBarCode) | 
|                     values(" | 
|                      + HInterID + ",'" + HBillNo + "'," + i + "," + oSub.HMouldID.ToString() + ",'" + oSub.HQty | 
|                      + "'," + oSub.HSourceID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString() + ",'" + oSub.HICMOBillNo.ToString() | 
|                      + "','" + oSub.HProcExchBillNo.ToString() + "'," + oSub.HProcExchInterID.ToString() + "," + oSub.HProcExchEntryID.ToString() | 
|                      + ",'" + oSub.HScanDate.ToString() + "','" + oSub.HMouldNumber.ToString() + "') "); | 
|             } | 
|   | 
|             if (OperationType == 1)//新增 | 
|             { | 
|                 //保存后控制 | 
|                 objJsonResult = AfterSave_MouldLowerBill(HInterID, HBillNo, 1); | 
|                 if (objJsonResult.count == 0) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = objJsonResult.Message; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|             } | 
|             else | 
|             { | 
|                 //保存后控制 | 
|                 objJsonResult = AfterSave_MouldLowerBill(HInterID, HBillNo, 2); | 
|                 if (objJsonResult.count == 0) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = objJsonResult.Message; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|             } | 
|             objJsonResult.code = "1"; | 
|             objJsonResult.count = 1; | 
|             objJsonResult.Message = null; | 
|             objJsonResult.data = null; | 
|             return objJsonResult; | 
|         } | 
|   | 
|         #endregion | 
|     } | 
| } |