| | |
| | | |
| | | oCN.RunProc(@"Insert Into Sc_MouldUpperBillSub |
| | | (HInterID, HBillNo_bak, HEntryID, HMouldID, HQty |
| | | , HSourceID, HICMOInterID, HICMOEntryID, HICMOBillNo) |
| | | , HSourceID, HICMOInterID, HICMOEntryID, HICMOBillNo,HScanDate,HBarCode) |
| | | values(" |
| | | + HInterID + ",'"+ HBillNo + "'," + i + "," + oSub.HMouldID.ToString() + ",'" + oSub.HQty |
| | | + "'," + oSub.HSourceID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString()+",'"+ oSub.HICMOBillNo.ToString() + |
| | | + "'," + oSub.HSourceID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString()+",'"+ oSub.HICMOBillNo.ToString() + "','getdate()','" + oSub.HBarCode.ToString() + |
| | | "') "); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 上模单 APP新增 |
| | | /// <summary> |
| | | /// 新增单据-保存按钮 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | [Route("Sc_MouldUpperBill/AddSc_MouldUpperBill_APP")] |
| | | [HttpPost] |
| | | public object AddSc_MouldUpperBill_APP([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | oCN.BeginTran(); |
| | | //保存主表 |
| | | objJsonResult = AddBillMain_APP(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_APP(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_APP(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_APP(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,HScanDate,HBarCode) |
| | | values(" |
| | | + HInterID + ",'" + HBillNo + "'," + i + "," + oSub.HMouldID.ToString() + ",'" + oSub.HQty |
| | | + "'," + oSub.HSourceID.ToString() + "," + oSub.HICMOInterID.ToString() + "," + oSub.HICMOEntryID.ToString() + ",'" + oSub.HICMOBillNo.ToString() + "',getdate(),'" + oSub.HBarCode.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/GetBarCode_FC")] |
| | | [HttpGet] |
| | | public object GetBarCode_FC(string HBarCode, int HMaterID) |
| | | { |
| | | try |
| | | { |
| | | |
| | | ds = oCN.RunProcReturn("exec h_p_Sc_MouldFill_Verification '" + HBarCode + "','" + HMaterID + "'", "h_p_Sc_MouldFill_Verification"); |
| | | |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "查无数据!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) == 1) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; //失败! |
| | | objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; //成功! |
| | | objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]); |
| | | 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 |
| | | } |
| | | } |