public JsonResult SaveBarcode(string erpvoucherno, string materialno, string materialdesc, string ean, string batch, string edate, string num, string everynum, string receivetime, string RowNO, string RowNODel, string MaterialNoID, string StrongHoldCode, string CompanyCode, string Createname, string WarehouseName, string TracNo, string ProjectNo, string flag = "")//flag=1 是预留释放打印 { //查物料 T_Material_Func funM = new T_Material_Func(); string strErrMsg = ""; List <T_MaterialInfo> modelList = funM.GetMaterialModelBySql(materialno, ref strErrMsg); if (modelList == null || modelList.Count == 0) { //失败 return(Json(new { state = false, obj = "没有该物料号" + materialno }, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(Userno)) { return(Json(new { state = false, obj = "Cookie失效,重新登陆!" }, JsonRequestBehavior.AllowGet)); } try { DateTime time1 = DateTime.Now; DateTime time2 = DateTime.Now.AddSeconds(1); string err = ""; //计算外箱数量,和尾箱数量,和尾箱里面的个数 int outboxnum = 0; int inboxnum = 0; decimal tailnum = 0; GetBoxInfo(ref outboxnum, ref tailnum, ref inboxnum, num, everynum); if (outboxnum == 0) { return(Json(new { state = false, obj = "打印数量为0" }, JsonRequestBehavior.AllowGet)); } Print_DB print_DB = new Print_DB(); List <string> squence = GetSerialnos(outboxnum + inboxnum, "外", ref err); //外箱码序列号 List <string> squenceforin = GetSerialnos(Int16.Parse(num), "内", ref err); //本体序列号 //int matenoid = selectItem.MaterialNoID; sq = ""; //存放打印条码内容 List <Barcode_Model> listbarcode = new List <Barcode_Model>(); int k = 0; int kIn = 0; //执行打印外箱命令 for (int i = 0; i < outboxnum; i++) { Barcode_Model model = new Barcode_Model(); model.CompanyCode = CompanyCode; model.StrongHoldCode = StrongHoldCode; model.MaterialNoID = Convert.ToInt32(MaterialNoID); model.MaterialNo = materialno; model.MaterialDesc = materialdesc; model.BatchNo = DateTime.Now.ToString("yyyyMMdd"); model.ErpVoucherNo = erpvoucherno; //model.EDate = Convert.ToDateTime(edate); model.Qty = Convert.ToDecimal(everynum); model.SerialNo = squence[k++]; model.Creater = Userno; //model.EAN = ean; //model.ReceiveTime = string.IsNullOrEmpty(receivetime) ? DateTime.Now : Convert.ToDateTime(receivetime); model.ReceiveTime = time1; model.BarCode = "1@" + model.StrongHoldCode + "@" + model.MaterialNo + "@" + model.BatchNo + "@" + model.Qty + "@" + model.SerialNo; model.RowNo = RowNO; model.RowNoDel = RowNODel; model.BarcodeType = 1; model.ProductClass = Createname; model.WorkNo = WarehouseName; model.TracNo = TracNo; model.ProjectNo = ProjectNo; model.originalCode = flag; listbarcode.Add(model); if (modelList[0].sku == "是") { //本体打印 for (int ii = 0; ii < Convert.ToDecimal(everynum); ii++) { Barcode_Model modelIn1 = new Barcode_Model(); modelIn1.CompanyCode = CompanyCode; modelIn1.StrongHoldCode = StrongHoldCode; modelIn1.MaterialNoID = Convert.ToInt32(MaterialNoID); modelIn1.MaterialNo = materialno; modelIn1.MaterialDesc = materialdesc; modelIn1.BatchNo = DateTime.Now.ToString("yyyyMMdd"); modelIn1.ErpVoucherNo = erpvoucherno; modelIn1.Qty = 1; modelIn1.SerialNo = squenceforin[kIn++]; modelIn1.Creater = Userno; modelIn1.ReceiveTime = time2; //modelIn1.ReceiveTime = string.IsNullOrEmpty(receivetime) ? DateTime.Now : Convert.ToDateTime(receivetime); modelIn1.BarCode = "2@" + modelIn1.StrongHoldCode + "@" + modelIn1.MaterialNo + "@" + modelIn1.BatchNo + "@" + modelIn1.Qty + "@" + modelIn1.SerialNo; modelIn1.RowNo = RowNO; modelIn1.RowNoDel = RowNODel; modelIn1.BarcodeType = 2; modelIn1.ProductClass = Createname; modelIn1.WorkNo = WarehouseName; modelIn1.TracNo = TracNo; modelIn1.ProjectNo = ProjectNo; modelIn1.fserialno = model.SerialNo; modelIn1.originalCode = flag; listbarcode.Add(modelIn1); } } } if (inboxnum == 1) { Barcode_Model model = new Barcode_Model(); model.CompanyCode = CompanyCode; model.StrongHoldCode = StrongHoldCode; model.MaterialNoID = Convert.ToInt32(MaterialNoID); model.MaterialNo = materialno; model.MaterialDesc = materialdesc; model.BatchNo = DateTime.Now.ToString("yyyyMMdd"); model.ErpVoucherNo = erpvoucherno; //model.EDate = Convert.ToDateTime(edate); model.Qty = Convert.ToDecimal(tailnum); model.SerialNo = squence[k++]; model.Creater = Userno; //model.EAN = ean; //model.ReceiveTime = string.IsNullOrEmpty(receivetime) ? DateTime.Now : Convert.ToDateTime(receivetime); model.ReceiveTime = time1; model.BarCode = "1@" + model.StrongHoldCode + "@" + model.MaterialNo + "@" + model.BatchNo + "@" + model.Qty + "@" + model.SerialNo; model.RowNo = RowNO; model.RowNoDel = RowNODel; model.BarcodeType = 1; model.ProductClass = Createname; model.WorkNo = WarehouseName; model.TracNo = TracNo; model.ProjectNo = ProjectNo; model.originalCode = flag; listbarcode.Add(model); if (modelList[0].sku == "是") { //本体打印 for (int ii = 0; ii < Convert.ToDecimal(tailnum); ii++) { Barcode_Model modelIn2 = new Barcode_Model(); modelIn2.CompanyCode = CompanyCode; modelIn2.StrongHoldCode = StrongHoldCode; modelIn2.MaterialNoID = Convert.ToInt32(MaterialNoID); modelIn2.MaterialNo = materialno; modelIn2.MaterialDesc = materialdesc; modelIn2.BatchNo = DateTime.Now.ToString("yyyyMMdd"); modelIn2.ErpVoucherNo = erpvoucherno; modelIn2.Qty = 1; modelIn2.SerialNo = squenceforin[kIn++]; modelIn2.Creater = Userno; modelIn2.ReceiveTime = time2; //modelIn2.ReceiveTime = string.IsNullOrEmpty(receivetime) ? DateTime.Now : Convert.ToDateTime(receivetime); modelIn2.BarCode = "2@" + modelIn2.StrongHoldCode + "@" + modelIn2.MaterialNo + "@" + modelIn2.BatchNo + "@" + modelIn2.Qty + "@" + modelIn2.SerialNo; modelIn2.RowNo = RowNO; modelIn2.RowNoDel = RowNODel; modelIn2.BarcodeType = 2; modelIn2.ProductClass = Createname; modelIn2.WorkNo = WarehouseName; modelIn2.TracNo = TracNo; modelIn2.ProjectNo = ProjectNo; modelIn2.fserialno = model.SerialNo; modelIn2.originalCode = flag; listbarcode.Add(modelIn2); } } } if (print_DB.SubBarcodes(listbarcode, "sup", 1, ref err)) { string serialnosB = ""; string serialnosS = ""; for (int i = 0; i < listbarcode.Count; i++) { if (listbarcode[i].BarcodeType == 1) { serialnosB += listbarcode[i].SerialNo + ","; } else { serialnosS += listbarcode[i].SerialNo + ","; } } if (serialnosS == "") { return(Json(new { state = true, obj = time1.ToString("yyyy/MM/dd HH:mm:ss") }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { state = true, obj = time1.ToString("yyyy/MM/dd HH:mm:ss"), objS = time2.ToString("yyyy/MM/dd HH:mm:ss") }, JsonRequestBehavior.AllowGet)); } //return Json(new { state = true, obj = serialnosB, objS = serialnosS }, JsonRequestBehavior.AllowGet); } else { return(Json(new { state = false, obj = err }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { state = false, obj = ex.ToString() }, JsonRequestBehavior.AllowGet)); } }
public JsonResult Print(string IDs, string Path) { try { List <Barcode_Model> barcodelist = new List <Barcode_Model>(); var Isxls = System.IO.Path.GetExtension(Path).ToString().ToLower(); DataTable dt = new DataTable(); if (Isxls == ".xls") { dt = ImportExcelFile(Path); } if (Isxls == ".xlsx") { dt = ImportExcelFilexlsx(Path); } barcodelist = Print_DB.ConvertToModel <Barcode_Model>(dt); List <Barcode_Model> barcodelistnew = new List <Barcode_Model>(); List <Barcode_Model> barcodelistnewsub = new List <Barcode_Model>(); List <Barcode_Model> barcodelistnewAll = new List <Barcode_Model>(); string[] ids = IDs.Split(','); for (int i = 0; i < ids.Length; i++) { if (ids[i] != "") { List <Barcode_Model> barcodes = new List <Barcode_Model>(); barcodes.AddRange(barcodelist.Where(P => P.RowNo == ids[i])); //单张条码 //Barcode_Model model = (Barcode_Model)DeepCopy(barcodes[0]); //barcodelistnew.Add(model); //多张条码 if (barcodes.Count == 1 && barcodes[0].BoxCount >= 1) { for (int j = 0; j < barcodes[0].BoxCount; j++) { Barcode_Model model = (Barcode_Model)DeepCopy(barcodes[0]); barcodelistnew.Add(model); } } } } if (barcodelistnew != null && barcodelistnew.Count > 0) { string strMsg = ""; PrintInController printIn = new PrintInController(); List <string> squence = printIn.GetSerialnos(barcodelistnew.Count, "外", ref strMsg); int k = 0; DateTime time = DateTime.Now; for (int i = 0; i < barcodelistnew.Count; i++) { barcodelistnew[i].CompanyCode = "SHJC"; barcodelistnew[i].BarcodeType = 1; barcodelistnew[i].SerialNo = squence[k++]; barcodelistnew[i].Creater = currentUser.UserNo; barcodelistnew[i].ReceiveTime = time; barcodelistnew[i].BarCode = "1@" + barcodelistnew[i].StrongHoldCode + "@" + barcodelistnew[i].MaterialNo + "@" + barcodelistnew[i].BatchNo + "@" + barcodelistnew[i].Qty + "@" + barcodelistnew[i].SerialNo; //查物料 T_Material_Func funM = new T_Material_Func(); string strErrMsg = ""; List <T_MaterialInfo> modelList = funM.GetMaterialModelBySql(barcodelistnew[i].MaterialNo, ref strErrMsg); if (modelList == null || modelList.Count == 0) { //失败 return(Json(new { state = false, obj = "没有该物料号" + barcodelistnew[i].MaterialNo }, JsonRequestBehavior.AllowGet)); } if (modelList[0].sku == "是") { for (int kk = 0; kk < barcodelistnew[i].Qty; kk++) { Barcode_Model modelsub = (Barcode_Model)DeepCopy(barcodelistnew[i]); modelsub.fserialno = barcodelistnew[i].SerialNo; barcodelistnewsub.Add(modelsub); } } } //本体打印 DateTime timesub = DateTime.Now.AddSeconds(5); if (barcodelistnewsub != null && barcodelistnewsub.Count > 0) { List <string> squencesub = printIn.GetSerialnos(barcodelistnewsub.Count, "内", ref strMsg); int ksub = 0; for (int isub = 0; isub < barcodelistnewsub.Count; isub++) { barcodelistnewsub[isub].CompanyCode = "SHJC"; barcodelistnewsub[isub].BarcodeType = 2; barcodelistnewsub[isub].SerialNo = squencesub[ksub++]; barcodelistnewsub[isub].Creater = currentUser.UserNo; barcodelistnewsub[isub].ReceiveTime = timesub; barcodelistnewsub[isub].Qty = 1; barcodelistnewsub[isub].BarCode = "2@" + barcodelistnewsub[isub].StrongHoldCode + "@" + barcodelistnewsub[isub].MaterialNo + "@" + barcodelistnewsub[isub].BatchNo + "@1@" + barcodelistnewsub[isub].SerialNo; } } barcodelistnewAll.AddRange(barcodelistnew); barcodelistnewAll.AddRange(barcodelistnewsub); Print_DB func = new Print_DB(); if (func.SubBarcodesNoPrint(barcodelistnewAll, ref strMsg)) { if (barcodelistnewsub != null && barcodelistnewsub.Count > 0) { return(Json(new { state = true, obj = time.ToString("yyyy/MM/dd HH:mm:ss"), obj1 = timesub.ToString("yyyy/MM/dd HH:mm:ss") }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { state = true, obj = time.ToString("yyyy/MM/dd HH:mm:ss"), obj1 = "" }, JsonRequestBehavior.AllowGet)); } } else { //失败 return(Json(new { state = false, obj = strMsg }, JsonRequestBehavior.AllowGet)); } } else { //失败 return(Json(new { state = false, obj = "数据为空" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { state = false, obj = ex.ToString() }, JsonRequestBehavior.AllowGet)); } }
public ActionResult SaveBarcode(string data) { var objT_InStockDetailInfo = JsonConvert.DeserializeObject <T_InStockDetailInfo>(data); string EveryQty = objT_InStockDetailInfo.EveryQty, num = objT_InStockDetailInfo.num, Userno = objT_InStockDetailInfo.Userno, erpvoucherno = objT_InStockDetailInfo.ErpVoucherNo, materialno = objT_InStockDetailInfo.MaterialNo, materialdesc = objT_InStockDetailInfo.MaterialDesc, RowNO = objT_InStockDetailInfo.RowNo, RowNODel = objT_InStockDetailInfo.RowNoDel, MaterialNoID = objT_InStockDetailInfo.MaterialNoID.ToString(), StrongHoldCode = objT_InStockDetailInfo.StrongHoldCode, CompanyCode = objT_InStockDetailInfo.CompanyCode, Createname = objT_InStockDetailInfo.Creater, WarehouseName = objT_InStockDetailInfo.WareHouseNo, TracNo = objT_InStockDetailInfo.TracNo, ProjectNo = objT_InStockDetailInfo.ProjectNo, BatchNo = objT_InStockDetailInfo.FromBatchNo; T_InStock_Func InFunc = new T_InStock_Func(); string strMsg = ""; T_InStockInfo InStockInfo = new T_InStockInfo() { ID = objT_InStockDetailInfo.HeaderID }; InFunc.GetModelByID(ref InStockInfo, ref strMsg); //查物料 T_Material_Func funM = new T_Material_Func(); string strErrMsg = ""; List <T_MaterialInfo> modelList = funM.GetMaterialModelBySql(materialno, ref strErrMsg); if (modelList == null || modelList.Count == 0)//失败 { return(Json(new { state = false, obj = "没有该物料号" + materialno }, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(Userno)) { return(Json(new { state = false, obj = "Cookie失效,重新登陆!" }, JsonRequestBehavior.AllowGet)); } try { DateTime time1 = DateTime.Now; DateTime time2 = DateTime.Now.AddSeconds(1); string err = ""; //计算外箱数量,和尾箱数量,和尾箱里面的个数 int outboxnum = 0; int inboxnum = 0; decimal tailnum = 0; GetBoxInfo(ref outboxnum, ref tailnum, ref inboxnum, num, EveryQty); if (outboxnum == 0) { return(Json(new { state = false, obj = "打印数量为0" }, JsonRequestBehavior.AllowGet)); } Print_DB print_DB = new Print_DB(); List <string> squence = GetSerialnos((outboxnum + inboxnum).ToString(), "外", ref err); //外箱码序列号 List <string> squenceforin = GetSerialnos(num, "内", ref err); //本体序列号 List <Barcode_Model> listbarcode = new List <Barcode_Model>(); //存放打印条码内容 T_Product_DB proDB = new T_Product_DB(); int k = 0; for (int i = 0; i < outboxnum; i++)//执行打印外箱命令 { Barcode_Model model = new Barcode_Model(); model.CompanyCode = CompanyCode; model.StrongHoldCode = StrongHoldCode; model.MaterialNoID = Convert.ToInt32(MaterialNoID); model.MaterialNo = materialno; model.MaterialDesc = materialdesc; //model.BatchNo = DateTime.Now.ToString("yyyyMMdd"); model.BatchNo = BatchNo; model.ProductBatch = objT_InStockDetailInfo.ProductBatch;//给批号加密成8位 model.ErpVoucherNo = erpvoucherno; model.Qty = Convert.ToDecimal(EveryQty); model.SerialNo = squence[k++]; model.Creater = Userno; model.ReceiveTime = time1; model.BarCode = "2@" + model.MaterialNo + "@" + model.Qty + "@" + model.SerialNo; model.RowNo = RowNO; model.RowNoDel = RowNODel; model.BarcodeType = 1; model.ProductClass = Createname; model.WorkNo = WarehouseName; model.TracNo = TracNo; model.ProjectNo = ProjectNo; model.SupCode = InStockInfo.SupplierNo; model.SupName = InStockInfo.SupplierName; model.StoreCondition = InStockInfo.StrVoucherType; model.department = InStockInfo.DepartmentCode; model.departmentname = InStockInfo.DepartmentName; model.ProtectWay = objT_InStockDetailInfo.sale_vouchertypename; model.LABELMARK = objT_InStockDetailInfo.Customer_voucherno; model.CusCode = objT_InStockDetailInfo.SupplierNo; model.CusName = objT_InStockDetailInfo.SUPPLIERSHORTNAME; model.erpwarehousename = objT_InStockDetailInfo.ErpWarehouseName; model.StoreCondition = objT_InStockDetailInfo.CustomerItemCode; model.spec = objT_InStockDetailInfo.spec; if (erpvoucherno.Substring(0, 2) == "DC") { model.dimension = erpvoucherno; model.VoucherType = "30"; } listbarcode.Add(model); } if (inboxnum == 1) { Barcode_Model model = new Barcode_Model(); model.CompanyCode = CompanyCode; model.StrongHoldCode = StrongHoldCode; model.MaterialNoID = Convert.ToInt32(MaterialNoID); model.MaterialNo = materialno; model.MaterialDesc = materialdesc; //model.BatchNo = DateTime.Now.ToString("yyyyMMdd"); model.BatchNo = BatchNo; model.ProductBatch = objT_InStockDetailInfo.ProductBatch;//给批号加密成8位 model.ErpVoucherNo = erpvoucherno; model.Qty = Convert.ToDecimal(tailnum); model.SerialNo = squence[k++]; model.Creater = Userno; model.ReceiveTime = time1; model.BarCode = "2@" + model.MaterialNo + "@" + model.Qty + "@" + model.SerialNo; model.RowNo = RowNO; model.RowNoDel = RowNODel; model.BarcodeType = 1; model.ProductClass = Createname; model.WorkNo = WarehouseName; model.TracNo = TracNo; model.ProjectNo = ProjectNo; model.SupCode = InStockInfo.SupplierNo; model.SupName = InStockInfo.SupplierName; model.StoreCondition = InStockInfo.StrVoucherType; model.department = InStockInfo.DepartmentCode; model.departmentname = InStockInfo.DepartmentName; model.ProtectWay = objT_InStockDetailInfo.sale_vouchertypename; model.LABELMARK = objT_InStockDetailInfo.Customer_voucherno; model.CusCode = objT_InStockDetailInfo.SupplierNo; model.CusName = objT_InStockDetailInfo.SUPPLIERSHORTNAME; model.erpwarehousename = objT_InStockDetailInfo.ErpWarehouseName; model.StoreCondition = objT_InStockDetailInfo.CustomerItemCode; model.spec = objT_InStockDetailInfo.spec; if (erpvoucherno.Substring(0, 2) == "DC") { model.dimension = erpvoucherno; model.VoucherType = "30"; } listbarcode.Add(model); } if (print_DB.SubBarcodes(listbarcode, "sup", 1, ref err)) { string serialnosS = ""; for (int i = 0; i < listbarcode.Count; i++) { if (listbarcode[i].BarcodeType != 1) { serialnosS += listbarcode[i].SerialNo + ","; } } if (serialnosS == "") { return(Json(new { state = true, obj = time1.ToString("yyyy/MM/dd HH:mm:ss") }, JsonRequestBehavior.AllowGet)); } return(Json(new { state = true, obj = time1.ToString("yyyy/MM/dd HH:mm:ss"), objS = time2.ToString("yyyy/MM/dd HH:mm:ss") }, JsonRequestBehavior.AllowGet)); } return(Json(new { state = false, obj = err }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { state = false, obj = ex.ToString() }, JsonRequestBehavior.AllowGet)); } }