| | |
| | | public class Sc_QualityReportBillController : ApiController |
| | | { |
| | | public DBUtility.ClsPub.Enum_BillStatus BillStatus; |
| | | private json objJsonResult = new json(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | private json objJsonResult = new json(); |
| | | private json objJsonResultReturn = new json(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); |
| | | DataSet ds; |
| | | |
| | | #region è¿åçäº§è´¨éæ±æ¥åå表 |
| | |
| | | { |
| | | ds = oCN.RunProcReturn |
| | | ("select a.HInterID,a.HBillType,a.HICMOBillNo,a.HICMOInterID,a.HMaterID" + |
| | | ",m.HNumber HMaterNumber,m.HName HMaterName,m.HModel HMaterModel " + |
| | | ",m.HNumber HMaterNumber,m.HName HMaterName,m.HModel HMaterModel,a.HICMOEntryID " + |
| | | " from Sc_ICMOBillStatus_Tmp a " + |
| | | " left join Gy_Material m on a.HMaterID=m.HItemID " + |
| | | " Where a.HInterID=" + HInterID + " and a.HBillType="+ HBillType, "Sc_ICMOBillStatus_Tmp"); |
| | |
| | | string msg = sArray[0].ToString(); |
| | | string OperationType = sArray[1].ToString().Trim(); |
| | | bool bResult = false; |
| | | bool bResult2 = false; |
| | | try |
| | | { |
| | | msg = "[" + msg.ToString() + "]"; |
| | |
| | | { |
| | | //æ¯å¦ä¿å |
| | | bResult = AddBillTmpSQL(mainList, ref ClsPub.sExeReturnInfo); |
| | | //æ¯å¦å®¡æ ¸ |
| | | bResult2 = set_CheckBill(mainList[0].HInterID, ref ClsPub.sExeReturnInfo); |
| | | } |
| | | else if (OperationType.Equals("3")) |
| | | { |
| | |
| | | //æ¯å¦ä¿å |
| | | if (bResult == true) |
| | | { |
| | | //æ¯å¦å®¡æ ¸ |
| | | if (bResult2 == true) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "åæ®åç宿¯!åæ®å·:" + mainList[0].HBillNo.Trim(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ®åç宿¯ï¼èªå¨å®¡æ ¸å¤±è´¥ï¼åå :" + ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "æ«ç ä¿åæåï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | |
| | | //åºå®èµå¼================================= |
| | | BillNew.HInterID = mainList[0].HInterID;//éå
¥typeå¾å°çåæ®ID |
| | | BillNew.HBillNo = mainList[0].HBillNo; |
| | | BillNew.HBillType = mainList[0].HBillType; |
| | | BillNew.HDate = mainList[0].HDate; |
| | | BillNew.HICMOBillNo = mainList[0].HICMOBillNo; |
| | | BillNew.HICMOInterID = mainList[0].HICMOInterID; |
| | | BillNew.HICMOEntryID = mainList[0].HICMOEntryID; |
| | | BillNew.HProcExchBillNo = mainList[0].HProcExchBillNo; |
| | | BillNew.HProcExchInterID = mainList[0].HProcExchInterID; |
| | | BillNew.HProcExchEntryID = mainList[0].HProcExchEntryID; |
| | |
| | | BillNew.HBarCode = mainList[0].HBarCode; |
| | | BillNew.HMaker = mainList[0].HMaker; |
| | | BillNew.HMakeDate = mainList[0].HMakeDate; |
| | | BillNew.HReportType = mainList[0].HReportType; |
| | | BillNew.HSourceBillNo = mainList[0].HICMOBillNo; |
| | | BillNew.HSourceInterID = mainList[0].HICMOInterID; |
| | | BillNew.HSourceBillType = mainList[0].HSourceBillType; |
| | | oCN.BeginTran(); |
| | | //主表 |
| | | //临æ¶è¡¨ |
| | | oCN.RunProc("Insert Into Sc_ICMOBillQualityStatus_Tmp " + |
| | | " (HInterID,HBillNo,HDate,HICMOBillNo,HICMOInterID" + |
| | | ",HProcExchBillNo,HProcExchInterID,HProcExchEntryID,HProcID,HMaterID" + |
| | | ",HSourceID,HGroupID,HCheckManID,HBadReasonID,HBarCode" + |
| | | ",HMaker,HMakeDate" + |
| | | ",HMaker,HMakeDate,HBillType,HReportType,HSourceBillNo" + |
| | | ",HSourceInterID,HSourceBillType,HICMOEntryID,HSourceEntryID" + |
| | | ") " + |
| | | " values(" + BillNew.HInterID + ",'" + BillNew.HBillNo + "','" + BillNew.HDate + "','" + BillNew.HICMOBillNo + "'," + BillNew.HICMOInterID + |
| | | ",'" + BillNew.HProcExchBillNo + "'," + BillNew.HProcExchInterID + "," + BillNew.HProcExchEntryID + "," + BillNew.HProcID + "," + BillNew.HMaterID + |
| | | "," + BillNew.HSourceID + "," + BillNew.HGroupID + "," + BillNew.HCheckManID + "," + BillNew.HBadReasonID + ",'" + BillNew.HBarCode + "'" + |
| | | ",'" + BillNew.HMaker + "','" + BillNew.HMakeDate + "'" + |
| | | ",'" + BillNew.HMaker + "','" + BillNew.HMakeDate + "','" + BillNew.HBillType + "','" + +BillNew.HReportType + "','" +BillNew.HSourceBillNo + "'" + |
| | | "," + BillNew.HSourceInterID + ",'" + BillNew.HSourceBillType + "'," + BillNew.HICMOEntryID + "," + BillNew.HICMOEntryID + |
| | | ") "); |
| | | //夿æ¯å¦å
许ä¿å |
| | | ds = oCN.RunProcReturn("exec h_p_JIT_ICMOBillQualityStatus_SaveCtrl", "h_p_JIT_ICMOBillQualityStatus_SaveCtrl"); |
| | | if (ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2") |
| | | { |
| | | sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); |
| | | oCN.RollBack(); |
| | | return false; |
| | | } |
| | | sReturn = "æ°å¢åæ®æåï¼"; |
| | | sReturn = "æ«ç æåï¼"; |
| | | oCN.Commit(); |
| | | return true; |
| | | } |
| | |
| | | sReturn = e.Message; |
| | | oCN.RollBack(); |
| | | throw (e); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region è´¨éæ±æ¥åå表å é¤æé® |
| | | [Route("DeltetSc_QualityReportBill")] |
| | | [HttpGet] |
| | | public object DeltetSc_QualityReportBill(long HItemID) |
| | | { |
| | | DataSet ds; |
| | | DataSet ds1; |
| | | try |
| | | { |
| | | //å 餿é |
| | | //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName)) |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | | // objJsonResult.count = 0; |
| | | // objJsonResult.Message = "å®¡æ ¸å¤±è´¥ï¼æ æéï¼"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | if (HItemID == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HItemID为空ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | oCN.BeginTran();//å¼å§äºå¡ |
| | | ds = oCN.RunProcReturn("select * from Sc_QualityReportBillMain where hmainid=" + HItemID, "Sc_QualityReportBillMain"); |
| | | ds1 = oCN.RunProcReturn("select * from Sc_QualityReportBillSub where hmainid=" + HItemID, "Sc_QualityReportBillSub"); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ²¡ææ°æ®ï¼æ æ³å é¤ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | } |
| | | //var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]); |
| | | //if (HStopflag) |
| | | //{ |
| | | // oCN.RollBack();//åæ»äºå¡ |
| | | // objJsonResult.code = "0"; |
| | | // objJsonResult.count = 0; |
| | | // objJsonResult.Message = "æ°æ®å·²å 餿 æ³å次å é¤ï¼"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | //ds1 = oCN.RunProcReturn("Select HItemID from Sc_QualityReportBill Where HParentID='" + HItemID + "'", "Sc_QualityReportBill"); |
| | | //if (ds1.Tables[0].Rows.Count != 0) |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | | // objJsonResult.count = 0; |
| | | // objJsonResult.Message = "æ¤é¡¹ç®åå¨å项ç®ï¼ä¸è½å é¤ï¼"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | string HUseFlag = Convert.ToString(ds.Tables[0].Rows[0]["HUseFlag"]); |
| | | if (HUseFlag == "已使ç¨") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ¤é¡¹ç®å·²ä½¿ç¨ï¼ä¸è½å é¤ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCN.RunProc("delete from Sc_QualityReportBillMain where hmainid=" + HItemID); |
| | | oCN.RunProc("delete from Sc_QualityReportBillSub where hmainid=" + HItemID); |
| | | 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 |
| | |
| | | #endregion |
| | | |
| | | #region å®¡æ ¸ |
| | | public bool set_CheckBill(long HInterID, ref string sReturn) |
| | | public object set_CheckBill(long HInterID,string HChecker, ref string sReturn) |
| | | { |
| | | SQLHelper.ClsCN oCN1 = new SQLHelper.ClsCN(); |
| | | try |
| | | { |
| | | oCN.BeginTran(); |
| | | ds = oCN.RunProcReturn("exec Sc_ICMOBillQualityStatus_AutoCheck", "Sc_ICMOBillQualityStatus_AutoCheck"); |
| | | if (ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2") |
| | | oCN1.BeginTran(); |
| | | //å®¡æ ¸æé |
| | | if (!DBUtility.ClsPub.Security_Log("Sc_QualityReportBill_Check", 1, true, HChecker)) |
| | | { |
| | | sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); |
| | | oCN.RollBack(); |
| | | return false; |
| | | oCN1.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ¨æ²¡ææé,请ä¸ç®¡çåèç³»ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | sReturn = "å®¡æ ¸æåï¼"; |
| | | oCN.Commit(); |
| | | // |
| | | if (HInterID == 0) |
| | | { |
| | | oCN1.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ®ID为0ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | DAL.ClsSc_QualityReportBill oBill = new DAL.ClsSc_QualityReportBill(); |
| | | //æ¥çæ¯å¦å·²å®¡æ ¸,å
³é,ä½åº |
| | | if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | { |
| | | if (oBill.omodel.HChecker.Trim() != "") |
| | | { |
| | | oCN1.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ®å·²å®¡æ ¸ï¼ä¸è½åæ¬¡å®¡æ ¸ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (oBill.omodel.HCloseMan.Trim() != "") |
| | | { |
| | | oCN1.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "忮已å
³éï¼ä¸è½åæ¬¡å®¡æ ¸ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (oBill.omodel.HDeleteMan.Trim() != "") |
| | | { |
| | | oCN1.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "忮已ä½åºï¼ä¸è½åæ¬¡å®¡æ ¸ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | oCN1.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ®ä¸åå¨ï¼åå :" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //å®¡æ ¸ |
| | | if (CheckBill(HInterID, HChecker, ref DBUtility.ClsPub.sExeReturnInfo) == true) |
| | | { |
| | | oCN1.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "å®¡æ ¸æåï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | oCN1.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "å®¡æ ¸å¤±è´¥ï¼åå :" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN1.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "å®¡æ ¸å¤±è´¥ï¼åå :" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | //å®¡æ ¸SQL |
| | | public bool CheckBill(Int64 HInterID,string HChecker, ref string sReturn) |
| | | { |
| | | |
| | | try |
| | | { |
| | | oCN.RunProc(" Update Sc_QualityReportBillMain set HChecker='" + HChecker + "',HCheckDate=GETDATE() Where HInterID=" + HInterID.ToString()); |
| | | sReturn = ""; |
| | | return true; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | sReturn = e.Message; |
| | | oCN.RollBack(); |
| | | throw (e); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region å 餿«æè®°å½è¡ |
| | | [Route("Sc_QualityReportBill/del_BarCodeDetail")] |
| | | [HttpGet] |
| | | public object del_BarCodeDetail(long HItemID) |
| | | { |
| | | try |
| | | { |
| | | oCN.RunProc("delete from Sc_ICMOBillQualityStatus_Tmp where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "å 餿åï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region æäº¤ä¿åï¼å主å表åæç»è¡¨ |
| | | [Route("Sc_QualityReportBill/set_SaveBill")] |
| | | [HttpGet] |
| | | public object set_SaveBill(long HInterID,string HChecker) |
| | | { |
| | | try |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | bool bResult2 = false; |
| | | oCN.BeginTran(); |
| | | //ä¿å |
| | | oCN.RunProc("exec h_p_save_Sc_QualityReportBill " + HInterID); |
| | | //夿æ¯å¦å
许ä¿åï¼ä¸å
许ååæ» |
| | | ds = oCN.RunProcReturn("exec h_p_JIT_ICMOBillQualityStatus_SaveCtrl", "h_p_JIT_ICMOBillQualityStatus_SaveCtrl"); |
| | | if (ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2") |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | oCN.Commit(); |
| | | //è·åèªå¨å®¡æ ¸åæ° |
| | | string sReturn = ""; |
| | | if (oSystemParameter.ShowBill(ref sReturn) == true) |
| | | { |
| | | if (oSystemParameter.omodel.Sc_ICMOBillQualityStatus_AutoCheck == "Y") //ç³»ç»åæ° èªå¨å®¡æ ¸ |
| | | { |
| | | //å®¡æ ¸ |
| | | objJsonResultReturn = (json)set_CheckBill(HInterID, HChecker, ref ClsPub.sExeReturnInfo); |
| | | if (objJsonResultReturn.code == "1") |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "åæ®åç宿¯ï¼å®¡æ ¸æåï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "åæ®åç宿¯ï¼èªå¨å®¡æ ¸å¤±è´¥ï¼åå ï¼" + objJsonResultReturn.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "åæ®åç宿¯ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "åæ®åç宿¯ï¼è·åèªå¨å®¡æ ¸åæ°å¤±è´¥ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |