| | |
| | | { |
| | | private jsonScanline objJsonResult = new jsonScanline(); |
| | | public DataSet ds = new DataSet(); |
| | | public DataSet ds0 = new DataSet(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | |
| | | #region çæç®±ç æ¥å£ |
| | |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region æ¥å·¥å¹³å°å¼å·¥åä¿å/ç¼è¾ |
| | | /// <summary> |
| | | /// å¼å·¥å |
| | | /// </summary> |
| | | /// <param name="msg"></param> |
| | | /// <returns></returns> |
| | | #region ç®±æ¡ç ç»å®å
³ç³»æäº¤æ¥å£ |
| | | [Route("packagebarcode/pack")] |
| | | [HttpPost] |
| | | public object pack([FromBody] JObject msg) |
| | |
| | | { |
| | | JavaScriptSerializer js = new JavaScriptSerializer(); //å®ä¾åä¸ä¸ªè½å¤åºååæ°æ®çç±» |
| | | ScanLineCode list = js.Deserialize<ScanLineCode>(msg.ToString()); //å°jsonæ°æ®è½¬å为对象类åå¹¶èµå¼ç»list |
| | | if (list.billno != "" && list.billno != null) //ä»»å¡åå·ï¼éå¿
é¡»ï¼éç©ºåæ ¡éªbarcodesébarcodeæ¯å¦ç±æ¤ä»»å¡åå¶ä½çæç |
| | | { |
| | | ds = oCN.RunProcReturn("Select HBarCode barcode from Gy_BarCodeBill where HSourceBillNo='" + list.billno.ToString().Trim()+"' Order by HItemID ", "Gy_BarCodeBill"); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.status = -1; |
| | | objJsonResult.msg = "å½åè®¢åæ ç»å®æ¡ç !"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | List<string> NameList = (from r in ds.Tables[0].AsEnumerable() select r.Field<string>("barcode")).ToList(); |
| | | List<string> NameList1= list.barcodes.Select(t => t.barcode).ToList(); |
| | | var strList = NameList1.Except(NameList).ToList(); //夿æäº¤æ°æ®ä¸æ¡ç æ¯å¦åå¨äºè®¢åä¸ |
| | | if (strList.Count > 0) |
| | | { |
| | | string Str=String.Join(",", strList.ToArray()); |
| | | objJsonResult.status = -1; |
| | | objJsonResult.msg = "æ¡ç :"+ Str.ToString()+" ä¸å
å«å¨è®¢å:"+list.billno+"ä¸!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | DLL.ClsSc_PackUnionBill oBill = new DLL.ClsSc_PackUnionBill(); |
| | | //å¤æç®±ç æ¯å¦åå¨ |
| | | bool IsBarCodePack = oBill.IsBarCodePack(list.packagebarcode); |
| | | if (IsBarCodePack == false) |
| | | { |
| | | objJsonResult.status = -1; |
| | | objJsonResult.msg = "ç®±ç å·²åå¨,ä¸è½éå¤ç»å®ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | Models.ClsSc_PackUnionBillMain oItem = new ClsSc_PackUnionBillMain(); |
| | | oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); |
| | | oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); |
| | | oItem.HBillType = "3783"; |
| | | oItem.HBillSubType = "3783"; |
| | | oItem.HDate= DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); |
| | | oItem.HBillNo = DBUtility.ClsPub.CreateBillCode(oItem.HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true); |
| | | oItem.HBillStatus = 1; |
| | | oItem.HCheckItemNowID = 0; |
| | | oItem.HCheckItemNextID = 0; |
| | | oItem.HCheckFlowID = 0; |
| | | oItem.HRemark = "èªå¨å
è£
线çè¾°ç®±æ¡ç "; |
| | | oItem.HBacker = ""; |
| | | oItem.HBackDate = ""; |
| | | oItem.HMaker = ""; |
| | | oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); |
| | | oItem.HChecker = ""; |
| | | oItem.HCheckDate = ""; |
| | | oItem.HUpDater = ""; |
| | | oItem.HUpDateDate = ""; |
| | | oItem.HCloseMan = ""; |
| | | oItem.HCloseDate = ""; |
| | | oItem.HCloseType = false; |
| | | oItem.HDeleteMan = ""; |
| | | oItem.HDeleteDate = ""; |
| | | oItem.HICMOInterID = 0; |
| | | oItem.HICMOBillNo = ""; |
| | | oItem.HBarCode_Pack= list.packagebarcode; |
| | | oItem.HMaterID = 0; |
| | | oItem.HUnitID = 0; |
| | | oItem.HUseFlag =false; //ææç¶æ |
| | | oBill.omodel = oItem; |
| | | for (int i = 0; i < list.barcodes.Count; i++) |
| | | { |
| | | //夿æ¡ç æ¯å¦åå¨ |
| | | bool IsBarCode = oBill.IsBarCodePack(list.barcodes[i].barcode); |
| | | if (IsBarCodePack == false) |
| | | { |
| | | objJsonResult.status = -1; |
| | | objJsonResult.msg = "æ¡ç å·²åå¨,ä¸è½éå¤ç»å®ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | Models.ClsSc_PackUnionBillSub oItemSub = new ClsSc_PackUnionBillSub(); |
| | | ds0 = oCN.RunProcReturn("Select HBarCode,HMaterID,HUnitID,HQty,HSourceID,HGroupID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType from Gy_BarCodeBill where HSourceBillNo='" + list.billno.ToString().Trim() + "' and HBarCode='" + list.barcodes[i].barcode + "' Order by HItemID ", "Gy_BarCodeBill"); |
| | | oItemSub.HEntryID = i+1; |
| | | oItemSub.HMaterID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HMaterID"].ToString()); |
| | | oItemSub.HUnitID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HUnitID"].ToString()); |
| | | oItemSub.HQty = DBUtility.ClsPub.isDoule(ds0.Tables[0].Rows[0]["HQty"].ToString()); |
| | | oItemSub.HSourceID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HSourceID"].ToString()); |
| | | oItemSub.HEquipID = 0; |
| | | oItemSub.HGroupID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HGroupID"].ToString()); |
| | | oItemSub.HWorkerID = 0; |
| | | oItemSub.HBarCode = list.barcodes[i].barcode; |
| | | oItemSub.HBarCode_Pack = list.packagebarcode; |
| | | oItemSub.HCloseMan = ""; |
| | | oItemSub.HCloseType = false; |
| | | oItemSub.HRemark = ""; |
| | | oItemSub.HSourceInterID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HSourceInterID"].ToString()); |
| | | oItemSub.HSourceEntryID = DBUtility.ClsPub.isLong(ds0.Tables[0].Rows[0]["HSourceEntryID"].ToString()); |
| | | oItemSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds0.Tables[0].Rows[0]["HSourceBillNo"].ToString()); |
| | | oItemSub.HSourceBillType = DBUtility.ClsPub.isStrNull(ds0.Tables[0].Rows[0]["HSourceBillType"].ToString()); |
| | | oItemSub.HRelationQty = 0; |
| | | oItemSub.HRelationMoney = 0; |
| | | oBill.DetailColl.Add(oItemSub); |
| | | } |
| | | //ä¿å |
| | | //ä¿å宿¯åå¤ç |
| | | bool bResult; |
| | | if (oBill.omodel.HInterID == 0) |
| | | { |
| | | // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); |
| | | bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | else |
| | | { |
| | | bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | if (bResult) |
| | | { |
| | | objJsonResult.status = 0; |
| | | objJsonResult.msg = "success"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.status = -1; |
| | | objJsonResult.msg = "ä¿å失败ï¼" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.status =-1; |
| | | objJsonResult.msg = e.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region ç®±æ¡ç åæ¶ç»å®å
³ç³» |
| | | [Route("packagebarcode/cancel")] |
| | | [HttpPost] |
| | | public object cancel(string packagebarcode) |
| | | { |
| | | try |
| | | { |
| | | // |
| | | oCN.BeginTran(); |
| | | //å é¤å表 |
| | | oCN.RunProc("Delete From Sc_PackUnionBillSub where HBarCode_Pack=" + packagebarcode.ToString()); |
| | | //å é¤ä¸»è¡¨ |
| | | oCN.RunProc("Delete From Sc_PackUnionBillMain where HBarCode_Pack=" + packagebarcode.ToString()); |
| | | //å 餿¡ç æ¡£æ¡è¡¨ |
| | | oCN.RunProc("Delete From Gy_BarCodeBill where HBarCode=" + packagebarcode.ToString()); |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.status = 0; |
| | | objJsonResult.msg = "success"; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.status =-1; |
| | | objJsonResult.msg = "success"; |
| | | objJsonResult.status = -1; |
| | | objJsonResult.msg = e.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |