|  |  | 
 |  |  |                     { | 
 |  |  |                         objJsonResult.code = "0"; | 
 |  |  |                         objJsonResult.count = 0; | 
 |  |  |                         objJsonResult.Message = "保存失败!物料属性不能为空!"; | 
 |  |  |                         objJsonResult.Message = "保存失败!物料分类不能为空!"; | 
 |  |  |                         objJsonResult.data = 1; | 
 |  |  |                         return objJsonResult; | 
 |  |  |                     } | 
 |  |  | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
 |  |  |  | 
 |  |  |                 if (user == "10000")//api同步方式 | 
 |  |  |                 { | 
 |  |  |                     oCN.RunProc("delete from Gy_Material where HERPItemID=" + HItemID); | 
 |  |  | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; ; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //删除权限 | 
 |  |  |                 if (!DBUtility.ClsPub.Security_Log("Gy_Material_Delete", 1, false, user)) | 
 |  |  |                 { | 
 |  |  | 
 |  |  |                 ds = oCN.RunProcReturn("select * from Gy_Material where HItemID=" + HItemID, "Gy_Material"); | 
 |  |  |                 if (ds == null || ds.Tables[0].Rows.Count == 0) | 
 |  |  |                 { | 
 |  |  |                     oCN.RollBack();//回滚事务 | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "没有数据,无法删除!"; | 
 |  |  | 
 |  |  |             } | 
 |  |  |             catch (Exception e) | 
 |  |  |             { | 
 |  |  |                 oCN.RollBack();//回滚事务 | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  |                 objJsonResult.Message = "删除失败!" + e.ToString(); | 
 |  |  | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         #region 物料审核、反审核 | 
 |  |  |         /// <summary> | 
 |  |  |         ///  | 
 |  |  |         /// </summary> | 
 |  |  |         /// <param name="HInterID">单据ID</param> | 
 |  |  |         /// <param name="IsAudit">审核(0),反审核(1)</param> | 
 |  |  |         /// <param name="CurUserName">审核人</param> | 
 |  |  |         /// <returns></returns> | 
 |  |  |         [Route("Gy_Material/AuditGy_Material")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object AuditGy_Material(int HInterID, int IsAudit, string CurUserName) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 //审核权限 | 
 |  |  |                 if (!DBUtility.ClsPub.Security_Log_second("Gy_Material_Check", 1, false, CurUserName)) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "审核失败!无权限!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 var ds = oCN.RunProcReturn("select * from Gy_Material where HItemID=" + HInterID, "Gy_Material"); | 
 |  |  |                 if (ds.Tables[0].Rows.Count > 0) | 
 |  |  |                 { | 
 |  |  |                     if (IsAudit == 0)  //审核判断 | 
 |  |  |                     { | 
 |  |  |                         if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "") | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = "单据已审核!不能再次审核!"; | 
 |  |  |                             objJsonResult.data = null; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     if (IsAudit == 1) //反审核判断 | 
 |  |  |                     { | 
 |  |  |                         if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() == "") | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = "单据未审核!不需要反审核!"; | 
 |  |  |                             objJsonResult.data = null; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "单据不存在!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 oCN.BeginTran(); | 
 |  |  |  | 
 |  |  |                 if (IsAudit == 0)  //审核判断 | 
 |  |  |                 { | 
 |  |  |                     oCN.RunProc("update Gy_Material set HCheckEmp='" + CurUserName + "',HCheckTime=getdate() where HItemID=" + HInterID); | 
 |  |  |  | 
 |  |  |                     objJsonResult.code = "1"; | 
 |  |  |                     objJsonResult.count = 1; | 
 |  |  |                     objJsonResult.Message = "审核成功"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                 } | 
 |  |  |                 if (IsAudit == 1) //反审核判断 | 
 |  |  |                 { | 
 |  |  |                     oCN.RunProc("update Gy_Material set HCheckEmp='',HCheckTime=null where HItemID=" + HInterID); | 
 |  |  |  | 
 |  |  |                     objJsonResult.code = "1"; | 
 |  |  |                     objJsonResult.count = 1; | 
 |  |  |                     objJsonResult.Message = "反审核成功"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                 } | 
 |  |  |                 oCN.Commit(); | 
 |  |  |  | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |             catch (Exception e) | 
 |  |  |             { | 
 |  |  |                 oCN.RollBack(); | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  |                 objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString(); | 
 |  |  |                 objJsonResult.data = null; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  |         #region 物料禁用、反禁用 | 
 |  |  |         /// <summary> | 
 |  |  |         ///  | 
 |  |  |         /// </summary> | 
 |  |  |         /// <param name="HInterID">单据ID</param> | 
 |  |  |         /// <param name="IsStop">禁用(0),反禁用(1)</param> | 
 |  |  |         /// <param name="CurUserName">审核人</param> | 
 |  |  |         /// <returns></returns> | 
 |  |  |         [Route("Gy_Material/StopGy_Material")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object StopGy_Material(int HInterID, int IsStop, string CurUserName) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 //审核权限 | 
 |  |  |                 if (!DBUtility.ClsPub.Security_Log_second("Gy_Material_Stop", 1, false, CurUserName)) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "禁用失败!无权限!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 var ds = oCN.RunProcReturn("select * from Gy_Material where HItemID=" + HInterID, "Gy_Material"); | 
 |  |  |                 if (ds.Tables[0].Rows.Count > 0) | 
 |  |  |                 { | 
 |  |  |                     if (IsStop == 0)  //禁用判断 | 
 |  |  |                     { | 
 |  |  |                         if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "") | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = "单据已禁用!不能再次禁用!"; | 
 |  |  |                             objJsonResult.data = null; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     if (IsStop == 1) //反禁用判断 | 
 |  |  |                     { | 
 |  |  |                         if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() == "") | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = "单据未禁用!不需要反禁用!"; | 
 |  |  |                             objJsonResult.data = null; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "单据不存在!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 oCN.BeginTran(); | 
 |  |  |  | 
 |  |  |                 if (IsStop == 0)  //禁用判断 | 
 |  |  |                 { | 
 |  |  |                     oCN.RunProc("update Gy_Material set HStopEmp='" + CurUserName + "',HStopTime=getdate(),HStopflag=1 where HItemID=" + HInterID); | 
 |  |  |  | 
 |  |  |                     objJsonResult.code = "1"; | 
 |  |  |                     objJsonResult.count = 1; | 
 |  |  |                     objJsonResult.Message = "禁用成功"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                 } | 
 |  |  |                 if (IsStop == 1) //反禁用判断 | 
 |  |  |                 { | 
 |  |  |                     oCN.RunProc("update Gy_Material set HStopEmp='',HStopTime=null,HStopflag=0 where HItemID=" + HInterID); | 
 |  |  |  | 
 |  |  |                     objJsonResult.code = "1"; | 
 |  |  |                     objJsonResult.count = 1; | 
 |  |  |                     objJsonResult.Message = "反禁用成功"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                 } | 
 |  |  |                 oCN.Commit(); | 
 |  |  |  | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |             catch (Exception e) | 
 |  |  |             { | 
 |  |  |                 oCN.RollBack(); | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  |                 objJsonResult.Message = "禁用失败或者反禁用失败!" + e.ToString(); | 
 |  |  |                 objJsonResult.data = null; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  | 
 |  |  |                 int HMouldMaintainRuleInterID = mainList[0].HMouldMaintainRuleInterID; | 
 |  |  |                 int HNowSupID = mainList[0].HNowSupID; | 
 |  |  |                 int HNowSupTypeID = mainList[0].HNowSupTypeID; | 
 |  |  |  | 
 |  |  |                 int HMadeSupID = mainList[0].HMadeSupID; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                 //主表 | 
 |  |  | 
 |  |  |                 ",HOutComDate,HOutComNo,HDeptID,HSupID,HSupNumber" + | 
 |  |  |                 ",HPrintQty,HMouldStatus,HWhID,HRoutingID,HCaveQty" + | 
 |  |  |                 ",HBomID,HVersion,HSPGroupID,HSPID,HDesignLife,HNowSupID,HNowSupTypeID" + | 
 |  |  |                 ",HUseLife,HLeaveLife,HProdQty,HProdWeight,HMouldOWNER,HSaveLife,HMouldDotCheckRuleInterID,HMouldMaintainRuleInterID,HBarCode" + | 
 |  |  |                 ",HUseLife,HLeaveLife,HProdQty,HProdWeight,HMouldOWNER,HSaveLife,HMouldDotCheckRuleInterID,HMouldMaintainRuleInterID,HBarCode,HMadeSupID" + | 
 |  |  |                 ") " + | 
 |  |  |                 " values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" + | 
 |  |  |                 "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()" + | 
 |  |  | 
 |  |  |                 ",'" + HOutComDate + "','" + HOutComNo + "'," + HDeptID + "," + HSupID + ",'" + HSupNumber + "'" + | 
 |  |  |                 "," + HPrintQty + ",'" + HMouldStatus + "'," + HWHID + "," + HRoutingID + "," + HCaveQty + | 
 |  |  |                 "," + HBOMID + ",'" + HVersion + "'," + HSPGroupID + "," + HSPID + ",'" + HDesignLife + "','" + HNowSupID + "','" + HNowSupTypeID + "'" + | 
 |  |  |                 ",'" + HUseLife + "','" + HLeaveLife + "','" + HProdQty + "','" + HProdWeight + "','" + HMouldOWNER + "','" + HSaveLife + "','" + HMouldDotCheckRuleInterID + "','" + HMouldMaintainRuleInterID + "','" + HBarCode + "'" + | 
 |  |  |                 ",'" + HUseLife + "','" + HLeaveLife + "','" + HProdQty + "','" + HProdWeight + "','" + HMouldOWNER + "','" + HSaveLife + "','" + HMouldDotCheckRuleInterID + "','" + HMouldMaintainRuleInterID + "','" + HBarCode + "'," + HMadeSupID + | 
 |  |  |                 ") "); | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 
 |  |  |                 int HMouldMaintainRuleInterID = mainList[0].HMouldMaintainRuleInterID; | 
 |  |  |                 int HNowSupID = mainList[0].HNowSupID; | 
 |  |  |                 int HNowSupTypeID = mainList[0].HNowSupTypeID; | 
 |  |  |                 int HMadeSupID = mainList[0].HMadeSupID; | 
 |  |  |  | 
 |  |  |                 //若MAINDI重复则重新获取 | 
 |  |  |                 oCN.BeginTran(); | 
 |  |  | 
 |  |  |                 ",HNowSupTypeID=" + HNowSupTypeID.ToString() + | 
 |  |  |                 ",HProdWeight=" + HProdWeight.ToString() + | 
 |  |  |                 ",HBarCode='" + HBarCode.ToString() + "'" + | 
 |  |  |                 ",HMadeSupID=" + HMadeSupID + | 
 |  |  |                 " where HInterID=" + HInterID.ToString()); | 
 |  |  |  | 
 |  |  |                 //修改子项目代码 | 
 |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  |         /// 磨具档案修改按钮方法-计算下次保养/校正日期-获取档案最近一次的保养记录 | 
 |  |  |         ///参数:string sql。 | 
 |  |  |         ///返回值:object。 | 
 |  |  |         /// </summary> | 
 |  |  |         [Route("Gy_Mould_Edit/calculateHNextMainDate")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object calculateHNextMainDate(long HInterID) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 string sql = @"select top(1) a.HInterID, b.HEndDate 保养记录结束日期 | 
 |  |  |                             from Gy_MouldFileMain AS a LEFT OUTER JOIN | 
 |  |  |                             Sc_MouldMaintainBillMain AS b on a.HInterID = b.HMouldID | 
 |  |  |                             where a.HInterID = " + HInterID + | 
 |  |  |                             " order by b.HEndDate desc"; | 
 |  |  |  | 
 |  |  |                 ds = oCN.RunProcReturn(sql, "Sc_MouldMaintainBillMain"); | 
 |  |  |  | 
 |  |  |                 objJsonResult.code = "1"; | 
 |  |  |                 objJsonResult.count = 1; | 
 |  |  |                 objJsonResult.Message = ""; | 
 |  |  |                 objJsonResult.data = ds.Tables[0]; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |             catch (Exception e) | 
 |  |  |             { | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  |                 objJsonResult.Message = "Exception!" + e.ToString(); | 
 |  |  |                 objJsonResult.data = null; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  |         /// 磨具档案修改按钮方法 |