| | |
| | | using WebAPI.Models; |
| | | using WebAPI.DLL; |
| | | using DBUtility; |
| | | using SyntacticSugar.constant; |
| | | using Newtonsoft.Json; |
| | | |
| | | namespace WebAPI.Controllers |
| | | { |
| | |
| | | private json objJsonResult = new json(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | DataSet ds; |
| | | DLL.ClsSb_MouldRepairWorkBill oBill = new DLL.ClsSb_MouldRepairWorkBill(); |
| | | |
| | | #region 器具维修派工单查询 |
| | | [Route("Sc_MouldRepairSendWorkBill/GetMouldRepairSendWorkBillList")] |
| | | [HttpGet] |
| | | public object GetMouldRepairSendWorkBillList(string sWhere) |
| | | public object GetMouldRepairSendWorkBillList(string sWhere,string user) |
| | | { |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Sc_MouldRepairSendWorkBillList", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无查看权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn("select * from h_v_Sc_MouldRepairSendWorkBill ", "h_v_Sc_MouldRepairSendWorkBill"); |
| | | ds = oCN.RunProcReturn("select * from h_v_Sc_MouldRepairSendWorkBill order by hmainid desc ", "h_v_Sc_MouldRepairSendWorkBill"); |
| | | } |
| | | else |
| | | { |
| | | string sql1 = "select * from h_v_Sc_MouldRepairSendWorkBill where 1 = 1 "; |
| | | string sql = sql1 + sWhere; |
| | | string sql = sql1 + sWhere+ " order by hmainid desc "; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldRepairSendWorkBill"); |
| | | } |
| | | |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "没有返回任何记录!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | //if (ds.Tables[0].Rows.Count != 0 || ds != null) |
| | | //{ |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | //} |
| | | //else |
| | | //{ |
| | | //objJsonResult.code = "0"; |
| | | //objJsonResult.count = 0; |
| | | //objJsonResult.Message = "无数据"; |
| | | //objJsonResult.data = null; |
| | | //return objJsonResult; |
| | | //} |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 器具维修派工单 编辑查询 |
| | | [Route("Sc_MouldRepairSendWorkBill/Sc_MouldRepairSendWorkBill_Edit")] |
| | | [HttpGet] |
| | | public object Sc_MouldRepairSendWorkBill_Edit(string linterid, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_Sc_MouldRepairSendWorkBill_Edit where 1=1 and hmainid=" + linterid + "order by hmainid desc ", "h_v_Sc_MouldRepairSendWorkBill_Edit"); |
| | | |
| | | //添加列名 |
| | | 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_MouldRepairSendWorkBill/GetMouldRepairSendWorkBillListPage")] |
| | | [HttpGet] |
| | | public object GetMouldRepairSendWorkBillListPage(string sWhere, string user, int page, int size) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | if (!DBUtility.ClsPub.Security_Log("Sc_MouldRepairSendWorkBillList", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无查看权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn("exec h_p_Sc_MouldRepairSendWorkBill " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldRepairSendWorkBill"); |
| | | } |
| | | else |
| | | { |
| | | sWhere = sWhere.Replace("'", "''"); |
| | | ds = oCN.RunProcReturn("exec h_p_Sc_MouldRepairSendWorkBill " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldRepairSendWorkBill"); |
| | | } |
| | | |
| | | |
| | | //添加列名 |
| | | 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; |
| | | } |
| | |
| | | string msg2 = sArray[0].ToString(); |
| | | string msg3 = sArray[1].ToString(); |
| | | |
| | | int hentryid = int.Parse(sArray[2].ToString());//子表的顺序id |
| | | int OperationType = int.Parse(sArray[3].ToString());//数据类型 1添加 3修改 |
| | | int OperationType = int.Parse(sArray[2].ToString());//数据类型 1添加 3修改 |
| | | string msg4 = sArray[3].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Sc_MouldRepairSendWorkBill_Edit", 1, false, msg4)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | omodel = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsSb_MouldRepairWorkBillMain>(msg2); |
| | | string BillType = "3843"; |
| | | |
| | | |
| | | if (OperationType == 1)//新增 |
| | | { |
| | | //保存前控制 |
| | | objJsonResult = BeforeSave_MouldRepairSendWorkBill(omodel.HInterID, omodel.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_MouldRepairSendWorkBill " + |
| | | "(HBillType,HBillSubType,HInterID,HBillNo,HDate" + |
| | |
| | | ",HEquipID,HRepairID,HRepairBeginDate,HRepairEndDate,HRepairContent" + |
| | | ",HCycleUnit,HPlanTimes,HTimes,HEmpID,HManagerID" + |
| | | ",HDeptID,HExplanation,HInnerBillNo,HMouldID" + |
| | | ",HSupID,HRepairType,HNewModel,HNewDesignLife,HMainSourceBillType,HMainSourceInterID,HMainSourceEntryID" + |
| | | ",HSupID,HRepairType,HNewModel,HNewDesignLife,HMainSourceBillType,HMainSourceInterID,HMainSourceEntryID,HBillStatus" + |
| | | ") " + |
| | | " values('" + BillType + "','" + BillType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" + |
| | | "," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + omodel.HMaker + "',getdate()" + |
| | |
| | | ",'" + omodel.HCycleUnit + "'," + omodel.HPlanTimes.ToString() + "," + omodel.HTimes.ToString() + "," + omodel.HEmpID.ToString() + "," + omodel.HManagerID.ToString() + |
| | | "," + omodel.HDeptID.ToString() + ",'" + omodel.HExplanation + "','" + omodel.HInnerBillNo + "'," + omodel.HMouldID.ToString() + |
| | | ", " + omodel.HSupID.ToString() + ",'" + omodel.HRepairType + "','" + omodel.HNewModel + "'," + omodel.HNewDesignLife.ToString() + ",'" + omodel.HMainSourceBillType + "'," + omodel.HMainSourceInterID.ToString() + "," + omodel.HMainSourceEntryID.ToString() + |
| | | ") "); |
| | | |
| | | ",1) "); |
| | | } |
| | | else if (OperationType == 3) |
| | | { |
| | | //保存前控制 |
| | | objJsonResult = BeforeSave_MouldRepairSendWorkBill(omodel.HInterID, omodel.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_MouldRepairSendWorkBill set " + |
| | | " HBillNo='" + omodel.HBillNo + "'" + //固定赋值=============== |
| | |
| | | ",HYear='" + omodel.HYear.ToString() + "'" + |
| | | ",HPeriod='" + omodel.HPeriod.ToString() + "'" + |
| | | ",HRemark='" + omodel.HRemark + "'" + |
| | | ",HUpDater='" + omodel.HUpDater + "'" + |
| | | ",HUpDater='" + omodel.HMaker + "'" + |
| | | ",HUpDateDate=getdate()" + |
| | | //======================================== |
| | | ",HMouldID=" + omodel.HMouldID.ToString() + |
| | |
| | | " where HInterID=" + omodel.HInterID.ToString()); |
| | | |
| | | //删除子表 |
| | | oCN.RunProc("delete from Sc_MouldRepairSendWorkBillSub where HInterID='" + omodel.HInterID.ToString() + "' and HEntryID='" + hentryid + "'"); |
| | | oCN.RunProc("delete from Sc_MouldRepairSendWorkBillSub where HInterID='" + omodel.HInterID.ToString() + "'"); |
| | | } |
| | | //保存子表 |
| | | objJsonResult = AddBillSub(msg3, hentryid); |
| | | objJsonResult = AddBillSub(msg3, OperationType); |
| | | if (objJsonResult.code == "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | |
| | | } |
| | | } |
| | | |
| | | public json AddBillSub(string msg3, int hentryid) |
| | | public json AddBillSub(string msg3,Int64 OperationType) |
| | | { |
| | | DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSb_MouldRepairWorkBillSub>>(msg3); |
| | | int i = 1; |
| | |
| | | ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + |
| | | ",HRepairID,HRepairExplanation,HManagerID,HMoney" + |
| | | ") values(" |
| | | + omodel.HInterID.ToString() + "," + (hentryid == -1 ? i : hentryid) + ",'" + oSub.HCloseMan + "','" + DateTime.Now + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" + |
| | | + omodel.HInterID.ToString() + "," + (i) + ",'" + oSub.HCloseMan + "','" + DateTime.Now + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" + |
| | | "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() + |
| | | "," + oSub.HRepairID.ToString() + ",'" + oSub.HRepairExplanation + "'," + oSub.HManagerID.ToString() + "," + oSub.HMoney.ToString() + |
| | | ") "); |
| | | i++; |
| | | } |
| | | if (OperationType == 1)//新增 |
| | | { |
| | | //保存后控制 |
| | | objJsonResult = AfterSave_MouldRepairSendWorkBill(omodel.HInterID, omodel.HBillNo, 1); |
| | | if (objJsonResult.count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //保存后控制 |
| | | objJsonResult = AfterSave_MouldRepairSendWorkBill(omodel.HInterID, omodel.HBillNo, 2); |
| | | if (objJsonResult.count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | #region 器具维修派工单 保存前、保存后控制 |
| | | |
| | | //保存前控制 |
| | | public json BeforeSave_MouldRepairSendWorkBill(Int64 HInterID, string HBillNo, Int64 OperationType) |
| | | { |
| | | DataSet BeforeSave = oCN.RunProcReturn("Exec h_p_Sc_MouldRepairSendWorkBill_BeforeSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "',''," + OperationType.ToString(), "h_p_Sc_MouldRepairSendWorkBill_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_MouldRepairSendWorkBill(Int64 HInterID, string HBillNo, Int64 OperationType) |
| | | { |
| | | DataSet AfterSave = oCN.RunProcReturn("Exec h_p_Sc_MouldRepairSendWorkBill_AfterSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_Sc_MouldRepairSendWorkBill_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 |
| | | |
| | | #endregion |
| | | |
| | | #region 器具维修派工单 删除 |
| | | [Route("Sc_MouldRepairSendWorkBill/MouldDeleteBill")] |
| | | [HttpGet] |
| | | public object MouldDeleteBill(long HInterID, string user) |
| | | { |
| | | try |
| | | { |
| | | //判断权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Sc_MouldRepairSendWorkBill_Delete", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "没有删除权限"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | if (oBill.omodel.HChecker != "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "单据已经审核,不能删除!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //删除前控制========================================= |
| | | string sql1 = "exec h_p_Sc_MouldRepairSendWorkBill_BeforeDelCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'"; |
| | | ds = oCN.RunProcReturn(sql1, "h_p_Sc_MouldRepairSendWorkBill_BeforeDelCtrl"); |
| | | if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "删除失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //================================================================================== |
| | | |
| | | bool IsDete = oBill.DeleteBill(HInterID, oBill.omodel.HBillNo, "h_p_Sc_MouldRepairSendWorkBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | if (IsDete) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "删除成功"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "删除失败"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无权限删除"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 器具维修派工单 审核/反审核 |
| | | [Route("Sc_MouldRepairSendWorkBill/CheckDeOAuditBill")] |
| | | [HttpGet] |
| | | public object CheckDeOAuditBill(int HInterID, int IsAudit, string CurUserName) |
| | | { |
| | | |
| | | DBUtility.ClsPub.CurUserName = CurUserName; //存储用户名 |
| | | try |
| | | { |
| | | //判断是否有审核权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Sc_MouldRepairSendWorkBill_Check", 1, false, CurUserName)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核失败!无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //判断id 是否大于0 |
| | | if (HInterID <= 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ID小于0"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | //转换id |
| | | Int64 lngBillKey = 0; |
| | | lngBillKey = DBUtility.ClsPub.isLong(HInterID); |
| | | |
| | | //查询审核的这条数据 |
| | | ds = oCN.RunProcReturn("select * from Sc_MouldRepairSendWorkBill where HInterID='" + lngBillKey.ToString() + "'", "Sc_MouldRepairSendWorkBill"); |
| | | |
| | | if (ds.Tables[0].Rows.Count != 0) |
| | | { |
| | | string HCloseMan = ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim();//关闭人 |
| | | string HDeleteMan = ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim();//做废人 |
| | | string HChecker = ds.Tables[0].Rows[0]["HChecker"].ToString().Trim();//审核人 |
| | | |
| | | if (HCloseMan != "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据已关闭,不能审核"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (HDeleteMan != "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据已作废,不能审核"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //IsAudit 0 审核 |
| | | if (IsAudit == 0) |
| | | { |
| | | if (HChecker != "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据已审核!不能再次审核"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | //IsAudit 1 反审核 |
| | | if (IsAudit == 1) |
| | | { |
| | | if (HChecker == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据未审核!不需要反审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据不存在;原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | DataSet ds2; |
| | | //审核提交 |
| | | if (IsAudit == 0) |
| | | { |
| | | //审核前控制========================================= |
| | | string sql1 = "exec h_p_Sc_MouldRepairSendWorkBill_BeforeCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + CurUserName + "'"; |
| | | ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldRepairSendWorkBill_BeforeCheckCtrl"); |
| | | if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系"; |
| | | objJsonResult.data = null; |
| | | oCN.RollBack(); |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "审核失败!原因:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ; |
| | | objJsonResult.data = null; |
| | | oCN.RollBack(); |
| | | return objJsonResult; |
| | | } |
| | | //================================================================================== |
| | | |
| | | if (CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "审核成功"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核失败,原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | //反审核提交 |
| | | if (IsAudit == 1) |
| | | { |
| | | //反审核前控制========================================= |
| | | string sql1 = "exec h_p_Sc_MouldRepairSendWorkBill_BeforeUnCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + CurUserName + "'"; |
| | | ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldRepairSendWorkBill_BeforeUnCheckCtrl"); |
| | | if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "反审核失败!原因:反审核前判断失败,请与网络管理人员联系"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | |
| | | } |
| | | if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "反审核失败!原因:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //=========================================================== |
| | | |
| | | if (AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "反审核成功"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "反审核失败,原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核失败或反审核失败" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | //审核 |
| | | public bool CheckBill(Int64 lngBillKey, ref string sReturn) |
| | | { |
| | | try |
| | | { |
| | | string HChecker = DBUtility.ClsPub.CurUserName;//用户名 |
| | | oCN.BeginTran();//打开事务 |
| | | oCN.RunProc("update Sc_MouldRepairSendWorkBill set HChecker='" + HChecker + "',HCheckDate='" + DateTime.Now + "',HBillStatus=2 where HInterID='" + lngBillKey + "'"); |
| | | |
| | | //审核后控制========================================= |
| | | DataSet ds2; |
| | | string sql1 = "exec h_p_Sc_MouldRepairSendWorkBill_AfterCheckCtrl " + lngBillKey + ",'','" + HChecker + "'"; |
| | | ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldRepairSendWorkBill_AfterCheckCtrl"); |
| | | if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "审核失败!原因:审核后判断失败,请与网络管理人员联系"; |
| | | objJsonResult.data = null; |
| | | oCN.RollBack(); |
| | | sReturn = "审核失败!原因:审核后判断失败,请与网络管理人员联系"; |
| | | return false; |
| | | } |
| | | |
| | | if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "审核失败!原因:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); |
| | | objJsonResult.data = null; |
| | | oCN.RollBack(); |
| | | sReturn = "审核失败!原因:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); |
| | | return false; |
| | | } |
| | | //================================================================================== |
| | | |
| | | oCN.Commit();//关闭事务 |
| | | sReturn = "审核单据成功!"; |
| | | return true; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | sReturn = e.Message; |
| | | throw (e); |
| | | } |
| | | } |
| | | //反审核 |
| | | public bool AbandonCheck(Int64 lngBillKey, ref string sReturn) |
| | | { |
| | | try |
| | | { |
| | | string HChecker = DBUtility.ClsPub.CurUserName;//用户名 |
| | | oCN.BeginTran();//打开事务 |
| | | oCN.RunProc("update Sc_MouldRepairSendWorkBill set HChecker='',HCheckDate=null,HBillStatus=1 where HInterID='" + lngBillKey + "'"); |
| | | |
| | | //反审核后控制========================================= |
| | | DataSet ds2; |
| | | string sql1 = "exec h_p_Sc_MouldRepairSendWorkBill_AfterUnCheckCtrl " + lngBillKey + ",'','" + HChecker + "'"; |
| | | ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldRepairSendWorkBill_AfterUnCheckCtrl"); |
| | | if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "审核失败!原因:反审核后判断失败,请与网络管理人员联系"; |
| | | objJsonResult.data = null; |
| | | oCN.RollBack(); |
| | | sReturn = "审核失败!原因:反审核后判断失败,请与网络管理人员联系"; |
| | | return false; |
| | | } |
| | | |
| | | if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "审核失败!原因:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); |
| | | objJsonResult.data = null; |
| | | oCN.RollBack(); |
| | | sReturn = "审核失败!原因:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); |
| | | return false; |
| | | } |
| | | //================================================================================== |
| | | oCN.Commit();//关闭事务 |
| | | sReturn = "反审核单据成功!"; |
| | | return true; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | sReturn = e.Message; |
| | | throw (e); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 器具维修派工单 关闭/反关闭 |
| | | /// <summary> |
| | | /// </summary> |
| | | /// <param name="HInterID">单据ID</param> |
| | | /// <param name="IsAudit">关闭(0),反关闭(1)</param> |
| | | /// <param name="CurUserName">关闭人</param> |
| | | /// <returns></returns> |
| | | [Route("Sc_MouldRepairSendWorkBill/CloseSc_MouldRepairSendWorkBill")] |
| | | [HttpGet] |
| | | public object CloseSc_MouldRepairSendWorkBill(int HInterID, int IsAudit, string CurUserName) |
| | | { |
| | | string ModRightNameCheck = "Sc_MouldRepairSendWorkBill_Close"; |
| | | DBUtility.ClsPub.CurUserName = CurUserName; |
| | | try |
| | | { |
| | | //检查权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "关闭失败!无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //HInterID数据判断 |
| | | if (HInterID <= 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HInterID小于0!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | Int64 lngBillKey = 0; |
| | | lngBillKey = DBUtility.ClsPub.isLong(HInterID); //对HInterID进行类型的转换 |
| | | DAL.ClsSc_ICMOBill oBill = new DAL.ClsSc_ICMOBill(); //实例化单据操作类,用于进行相关操作 |
| | | oBill.MvarItemKey = "Sc_MouldRepairSendWorkBill"; |
| | | |
| | | |
| | | //进行需要进行的关闭/反关闭操作 |
| | | if (IsAudit == 0) //关闭提交 |
| | | { |
| | | string sql = ""; |
| | | //关闭前控制===============================================Begin=================================================================== |
| | | sql = "exec h_p_Sc_MouldRepairSendWorkBill_BeforeCloseCtrl " + HInterID + ",' ','" + CurUserName + "'"; |
| | | ds = oCN.RunProcReturn(sql, "h_p_Sc_MouldRepairSendWorkBill_BeforeCloseCtrl"); |
| | | 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 (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "关闭失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //关闭前控制===============================================End=================================================================== |
| | | |
| | | //关闭提交 |
| | | if (oBill.CloseBill(lngBillKey, "", "h_p_Sc_MouldRepairSendWorkBill_AfterCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "关闭成功"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | if (IsAudit == 1) //反关闭提交 |
| | | { |
| | | string sql = ""; |
| | | //反关闭前控制===============================================Begin=================================================================== |
| | | sql = "exec h_p_Sc_MouldRepairSendWorkBill_BeforeUnCloseCtrl " + HInterID + ",'','" + CurUserName + "'"; |
| | | ds = oCN.RunProcReturn(sql, "h_p_Sc_MouldRepairSendWorkBill_BeforeUnCloseCtrl"); |
| | | 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 (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "反关闭失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //反关闭前控制===============================================End=================================================================== |
| | | |
| | | //反关闭提交 |
| | | if (oBill.CancelClose(lngBillKey,"", "h_p_Sc_MouldRepairSendWorkBill_AfterUnCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "反关闭成功"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "反关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "关闭失败或者反关闭失败!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |