/// <summary> /// 依据扫描条码,是否能够进行 /// </summary> /// <param name="id"></param> /// <returns></returns> public override BaseSearchModel GetModelByID(string id) { if (RecevieID == null || RecevieID.Length == 0) { throw new Exception("请扫描或输入领料单的条码标签"); } else { ModelAdo<RWBarcodeModel> adoRW = new ModelAdo<RWBarcodeModel>(); RWBarcodeModel RWModel = adoRW.GetModelByID(Barcode, "*"); if (RWModel == null) { throw new Exception("领料条码标签不存在"); } else { //依据扫描原材料条码,获取对应的数据 } } return base.GetModelByID(id); }
public override BarcodeModel.MODEL.BaseSearchModel Insert() { string sql = @" declare @bid varchar(30) declare @hid int declare @i int set @i=0 while @i<@printcount begin exec PROC_GETID 'RW01',@bid output insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011) values(@bid,getdate(),@userid,@username,@dj,N'创建条码标签') insert into RW01(RW01001,RW01002,RW01003,RW01004,RW01005,RW01006,RW01033,RW01018,RW01024,RW01025,RW01027,RW01032,RW01034,RW01035,RW01037,RW01038,RW01040,RW01041,RW01042,RW01043) values(@bid,@stock,@stockname,@stockspec,@unit,@qty,@wo,@remark,@userid,@username,@dj,1,@company,@Batch,@ProductionTime ,@ValidityTime,@tqty,@type,@pagecode,'WO') insert into RW04(RW04002,RW04003,RW04004,RW04005) values(getdate(),@dj,@bid,N'创建条码') set @i=@i+1 end "; ModelAdo<StockModel> adoStock = new ModelAdo<StockModel>(); StockModel sm = adoStock.GetModelByID(this.StockCode); BaseAdo ba = new BaseAdo(); ba.ExecuteSql(sql, new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName), new SqlParameter("@stock", this.StockCode), new SqlParameter("@stockname", this.StockName), new SqlParameter("@stockspec", this.StockSpec), new SqlParameter("@unit", this.Unit), new SqlParameter("@qty", this.UnitQty), new SqlParameter("@tqty", sm.StockType == "02" ? 1 : sm.UQTY), new SqlParameter("@type", sm.StockType), new SqlParameter("@wo", this.WorkOrder), new SqlParameter("@remark", this.Remark), new SqlParameter("@company", this.Company), new SqlParameter("@printcount", this.BarcodeQty), new SqlParameter("@Batch", this.Batch), new SqlParameter("@ProductionTime", this.ProductDate), new SqlParameter("@ValidityTime", this.LifeDate), new SqlParameter("@pagecode", this.PageCode), new SqlParameter("@dj", this.Danju)); return this; /* string sql = @" declare @dj varchar(30) exec PROC_GETID 'FG03',@dj output declare @bid varchar(30) declare @hid int declare @i int insert into FG03(FG03001,FG03002,FG03003,FG03004,FG03005,FG03006,FG03007,FG03008) values(@dj,getdate(),@userid,@username,'','','',N'创建条码') set @i=0 while @i<@printcount begin exec PROC_GETID 'FG01',@bid output insert into FG02(FG02002,FG02003,FG02004,FG02005,FG02010,FG02011) values(@bid,getdate(),@userid,@username,@dj,N'创建条码标签') insert into FG01(FG01001,FG01002,FG01003,FG01004,FG01005,FG01006,FG01012,FG01013,FG01014,FG01015,FG01018,FG01024,FG01025,FG01027,FG01032,FG01037,FG01033,FG01034,FG01035,FG01036,FG01038) values(@bid,@stock,@stockname,@stockspec,@unit,@qty,'','','','',@remark,@userid,@username,@dj,1,@company,@workorder,@productdate,@lifedate,@pagecode,@lifeday) insert into FG04(FG04002,FG04003,FG04004,FG04005) values(getdate(),@dj,@bid,N'创建条码') set @i=@i+1 end "; BaseAdo ba = new BaseAdo(); ba.ExecuteSql(sql, new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName), new SqlParameter("@workorder", this.WorkOrder), new SqlParameter("@stock", this.StockCode), new SqlParameter("@stockname", this.StockName), new SqlParameter("@stockspec", this.StockSpec), new SqlParameter("@unit", this.Unit), new SqlParameter("@qty", this.UnitQty), new SqlParameter("@remark", this.Remark), new SqlParameter("@company", this.Company), new SqlParameter("@printcount", this.BarcodeQty), new SqlParameter("@productdate", this.ProductDate.ToString("yyyy-MM-dd")), new SqlParameter("@lifedate", this.ProductDate.AddDays(this.LifeDate).ToString("yyyy-MM-dd")), new SqlParameter("@lifeday", this.LifeDate), new SqlParameter("@pagecode", this.PageCode)); return this; * */ }
public override BarcodeModel.MODEL.BaseSearchModel Insert() { using (TransactionScope ts = new TransactionScope()) { ModelAdo<RWBarcodeModel> adoRW = new ModelAdo<RWBarcodeModel>(); RWBarcodeModel barcode = adoRW.GetModelByID(this.RWID); ModelAdo<ReportModel> adoRM = new ModelAdo<ReportModel>(); ReportModel rm = adoRM.GetModelByID(this.ReportLineID + ""); if (barcode.Warehouse != rm.Warehouse) { throw new Exception("此工单需汇报" + rm.Warehouse + "仓库的料"); } string sql = @" declare @lineno varchar(30) declare @reportnumber varchar(30) declare @stock varchar(40) declare @stocktype varchar(40) declare @barcodeQTY numeric(15,3) select @wo=WK02002,@lineno=WK02012,@reportnumber=WK02013 from WK02 where WK02001=@rlid select @stock=RW01002,@stocktype=RW01041,@barcodeQTY=RW01006 from RW01 where RW01001=@bid if(@barcodeQTY=@deqty) update RW01 set RW01032=3 where RW01001=@bid else update RW01 set RW01006=RW01006-@deqty where RW01001=@bid insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02011) select RW01001,getdate(),@userid,@username,N'扣料 工单号'+@wo+' 数量'+convert(varchar(10),@deqty) from RW01 where RW01001=@bid update WK02 set WK02008=case when WK02008 is null then getdate() else WK02008 end,WK02009=WK02009+@deqty,WK02010=@wc where WK02001=@rlid update WK01 set WK01005=getdate() where WK01001=@wo and WK01005 is null and WK01006 is null if not exists(select * from WK04 where WK04001=@wo and WK04002=@wc and WK04004 is null) insert into WK04(WK04001,WK04002,WK04003) values(@wo,@wc,getdate()) if not exists(select * from WK02 where WK02002=@wo and WK02009<WK02005) update WK01 set WK01008=3 where WK01001=@wo else update WK01 set WK01008=2 where WK01001=@wo insert into WK05(WK05002,WK05003,WK05004,WK05005,WK05006,WK05007,WK05008,WK05009,WK05010) values(@wc,@wo,@bid,@stock,@deqty,@stocktype,getdate(),case @stocktype when '02' then 1 else 0 end,@rlid) select @wo WO,@reportnumber RN,@lineno LN,RW01017,RW01008,RW01009,RW01002,RW01006/RW01040 RW01006,RW01007,RW01034,RW01035,RW01041 from RW01 where RW01001=@bid "; BaseAdo ba = new BaseAdo(); DataSet ds = ba.GetDataSet(sql, new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName), new SqlParameter("@wo", this.WorkOrder), new SqlParameter("@bid", this.RWID), new SqlParameter("@deqty", this.DeQTY), new SqlParameter("@rlid", this.ReportLineID), new SqlParameter("@wc", this.WorkCenter)); if (ds.Tables[0].Rows[0]["RW01041"] + "" != "04" && ds.Tables[0].Rows[0]["RW01041"] + "" != "00") { List<Hashtable> list = new List<Hashtable>(); Hashtable h = new Hashtable(); //h["Qty"] = ds.Tables[0].Rows[0]["RW01006"]; h["Qty"] = this.DeQTY; h["StockCode"] = ds.Tables[0].Rows[0]["RW01002"]; h["ReportNumber"] = ds.Tables[0].Rows[0]["RN"]; h["LineNumber"] = ds.Tables[0].Rows[0]["LN"]; h["Bin"] = ds.Tables[0].Rows[0]["RW01009"]; h["Company"] = ds.Tables[0].Rows[0]["RW01034"]; h["SupplierBatch"] = ds.Tables[0].Rows[0]["RW01035"]; h["WorkOrder"] = ds.Tables[0].Rows[0]["WO"]; h["Warehouse"] = ds.Tables[0].Rows[0]["RW01008"]; list.Add(h); StockTransactionXml.ExportWOReportXML(list); } ts.Complete(); return this; } }
public override BarcodeModel.MODEL.BaseSearchModel Insert() { //①:解析获取的文件数据,依据每行来读取。 //②:替换对应公司,17-31,16-32[[不存在回滚]] //③:替换PART_CODE,通过SC01003,找到对应的StockName,StockCode[不存在回滚] //④:条码编号:[存在回滚] //⑤:是否存在装箱号条码。有:判断装箱条码中是否存在,如果存在:直接并入该装箱号条码。如果不存在:新建 //⑥:插入原材料: 1:插入,父单据号表; // 2:插入,子单据号明细表; // 3:插入,原材料条码表; // 4:插入,条码历史记录表; lock (objLock) { using (TransactionScope ts = new TransactionScope()) { try { BaseAdo ba = new BaseAdo(); string sql = @" declare @billid varchar(30) exec PROC_GETID 'RW03',@billid output --单据头 insert into RW03(RW03001,RW03002,RW03003,RW03004,RW03005,RW03006,RW03007,RW03008) values(@billid,getdate(),@userid,@username,'','','',N'创建条码') select @billid t"; DataSet dsBillId = ba.GetDataSet(sql, new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName)); string BillId = ""; //总单据号 if (dsBillId != null && dsBillId.Tables[0].Rows.Count > 0) { BillId = dsBillId.Tables[0].Rows[0][0] + ""; } string strImport = System.Text.Encoding.ASCII.GetString(this.Bytes); string[] strImportLine = strImport.Replace("\r", " ").Split('\n'); for (int i = 1; i < strImportLine.Length; i++) { string BarcodeId = "";//导入文件中获取 string PackageId = "";//导入文件中获取 string StockCode = ""; string StockName = ""; string StockSpec = "";//导入文件中获取 string StockUnit = "";//导入文件中获取 string PO = "";//导入文件中获取 decimal StockUnitQty = 0;//导入文件中获取 string Company = "";//导入文件中获取 string SupplierBatch = "";//导入文件中获取 DateTime ProductionTime = DateTime.Now;//导入文件中获取 DateTime ValidityTime = DateTime.Now;//导入文件中获取 string[] strImprotLineItem = strImportLine[i].Split(';'); if (strImprotLineItem[0].Contains("17")) { Company = "31"; } else if (strImprotLineItem[0].Contains("16")) { Company = "32"; } else { throw new Exception("未找到相对应的公司信息!"); } PO = strImprotLineItem[2]; StockSpec = strImprotLineItem[3]; PackageId = strImprotLineItem[5]; BarcodeId = strImprotLineItem[6]; SupplierBatch = strImprotLineItem[7]; StockUnitQty = decimal.Parse(strImprotLineItem[10]); DateTime.TryParse(strImprotLineItem[15], out ProductionTime); DateTime.TryParse(strImprotLineItem[16], out ValidityTime); ModelAdo<RWBarcodeModel> adoBarcode = new ModelAdo<RWBarcodeModel>(); RWBarcodeModel rwModel = adoBarcode.GetModelByID(BarcodeId); if (rwModel != null && rwModel.ID.Length >= 1) { throw new Exception(BarcodeId + "已存在于条码系统中!"); } if (!string.IsNullOrEmpty(PackageId)) { ModelAdo<PackingModel> adoPackage = new ModelAdo<PackingModel>(); PackingModel packageModel = adoPackage.GetModelByID(PackageId); if (packageModel != null) { } else { string sqlPackage = @" --装箱单 insert into RW07(RW07001,RW07002,RW07003,RW07004,RW07005,RW07006,RW07007,RW07008) values(@packageid,getdate(),@userid,@username,0,'',0,2)"; ba.ExecuteSql(sqlPackage, new SqlParameter("packageid", PackageId), new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName)); } } ModelAdo<StockModel> adoStock = new ModelAdo<StockModel>(); List<StockModel> Stocks = adoStock.GetList("SC01003=@stockspec", "", "", new SqlParameter("@stockspec", StockSpec)); if (Stocks != null && Stocks.Count >= 1) { StockCode = Stocks[0].StockCode; StockName = Stocks[0].StockName; StockUnit = Stocks[0].Unit; StockUnitQty = Stocks[0].UQTY; } else { //throw new Exception("未找到相对应的物料信息!"); continue; } string barcodeSql = @" --单据明细 insert into RW04(RW04002,RW04003,RW04004,RW04005) values(getdate(),@billid,@barcodeid,N'创建条码') --历史记录 insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011) values(@barcodeid,getdate(),@userid,@username,@billid,N'创建条码标签') --原材料 insert into RW01(RW01001,RW01002,RW01003,RW01004,RW01005,RW01006,RW01014,RW01024,RW01025,RW01027,RW01031,RW01032,RW01034,RW01035,RW01037,RW01038,RW01040,RW01041,RW01043) values(@barcodeid,@stock,@stockname,@stockspec,@unit,@qty,@po,@userid,@username,@billid,@packageid,1,@company,@supplierbatch,@productiontime ,@validitytime,@tqty,@stype,'PO') "; ba.ExecuteSql(barcodeSql, new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName), new SqlParameter("@stock", StockCode), new SqlParameter("@stockname", StockName), new SqlParameter("@barcodeid", BarcodeId), new SqlParameter("@stockspec", StockSpec), new SqlParameter("@packageid", PackageId), new SqlParameter("@unit", StockUnit), new SqlParameter("@qty", StockUnitQty), new SqlParameter("@tqty", Stocks[0].UQTY), new SqlParameter("@po", PO), new SqlParameter("@stype", Stocks[0].StockType), new SqlParameter("@company", Company), new SqlParameter("@supplierbatch", SupplierBatch), new SqlParameter("@productiontime", ProductionTime), new SqlParameter("@validitytime", ValidityTime), new SqlParameter("@billid", BillId)); } ts.Complete(); } catch (Exception ex) { throw ex; } } } return this; }
/* /// <summary> /// 创建条码信息 /// 1:插入,父单据号表; /// 2:插入,子单据号明细表; /// 3:插入,原材料条码表; /// 4:插入,条码历史记录表; /// </summary> /// <returns></returns> public override BaseSearchModel Insert() { ModelAdo<RWBarcodeModel> adoBarcode = new ModelAdo<RWBarcodeModel>(); ModelAdo<BillDetailModel> adoBillDetail = new ModelAdo<BillDetailModel>(); ModelAdo<RWHistoryModel> adoBarcodeHistroy = new ModelAdo<RWHistoryModel>(); List<RWBarcodeModel> listBarcode = new List<RWBarcodeModel>(); for (int i = 0; i < BarcodeQTY; i++) { RWBarcodeModel barcodeModel = new RWBarcodeModel() { Bill = billModel.ID, CompanyCode = this.Company, StockUnit = this.UNITPO, StockCode = this.StockCode, StockName = this.StockName, StockSpec = this.StockSpec, StockUnitQty = this.UNITQTY, SupplierCode = this.SupplierCode, SupplierName = this.SupplierName, Warehouse = this.Warehouse, SO = this.PO, Status = 1, POLine = this.LineNum, WarehouseInTime = DateTime.Now, WarehouseOutTime = DateTime.Now, Remark1 = Remark }; adoBarcode.Insert(barcodeModel); listBarcode.Add(barcodeModel); BillDetailModel billDetailModel = new BillDetailModel() { CreateTime = DateTime.Now, BillID = billModel.ID, BarcodeID = barcodeModel.ID, Remark = billModel.Remark }; adoBillDetail.Insert(billDetailModel); RWHistoryModel historyModel = new RWHistoryModel() { CreateTime = DateTime.Now, BillID = billModel.ID, BarcodeID = barcodeModel.ID, Remark = billModel.Remark }; adoBarcodeHistroy.Insert(historyModel); } this.RWBarcodeModels = listBarcode.ToArray(); return this; } * */ public override BarcodeModel.MODEL.BaseSearchModel Insert() { string sql = @" declare @bid varchar(30) declare @hid int declare @i int set @i=0 while @i<@printcount begin exec PROC_GETID 'RW01',@bid output insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011) values(@bid,getdate(),@userid,@username,@dj,N'创建条码标签') insert into RW01(RW01001,RW01002,RW01003,RW01004,RW01005,RW01006,RW01012,RW01013,RW01014,RW01015,RW01018,RW01024,RW01025,RW01027,RW01032,RW01034,RW01035,RW01037,RW01038,RW01040,RW01041,RW01043,RW01044,RW01045) values(@bid,@stock,@stockname,@stockspec,@unit,@qty,@sup,@supname,@po,@poline,@remark,@userid,@username,@dj,1,@company,@SupplierBatch,@ProductionTime ,@ValidityTime,@tqty,@type,'PO',@unitpur,@unitsale) insert into RW04(RW04002,RW04003,RW04004,RW04005) values(getdate(),@dj,@bid,N'创建条码') set @i=@i+1 end "; ModelAdo<StockModel> adoStock = new ModelAdo<StockModel>(); StockModel sm = adoStock.GetModelByID(this.StockCode); BaseAdo ba = new BaseAdo(); ba.ExecuteSql(sql, new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName), new SqlParameter("@stock", this.StockCode), new SqlParameter("@stockname", this.StockName), new SqlParameter("@stockspec", this.StockSpec), new SqlParameter("@unit", this.UNITWH), new SqlParameter("@qty", this.UNITQTY), new SqlParameter("@tqty", this.Type == "02" ? 1 : sm.UQTY), new SqlParameter("@type", sm.StockType), new SqlParameter("@po", this.PO), new SqlParameter("@poline", this.LineNum), new SqlParameter("@sup", this.SupplierCode), new SqlParameter("@supname", this.SupplierName), new SqlParameter("@remark", this.Remark), new SqlParameter("@company", this.Company), new SqlParameter("@SupplierBatch", this.SupplierBatch), new SqlParameter("@printcount", this.BarcodeQTY), new SqlParameter("@ProductionTime", this.ProductionTime), new SqlParameter("@ValidityTime", this.ValidityTime), new SqlParameter("@dj", this.Danju), new SqlParameter("@unitpur", this.PODivisor), new SqlParameter("@unitsale", this.SODivisor)); return this; }
public override BaseSearchModel Insert() { using (TransactionScope ts = new TransactionScope()) { if (PrintCount == 0) { throw new Exception("打印数量不能为空!"); } string sqlStr = @" declare @bid varchar(30) declare @hid int declare @i int declare @dj varchar(30) exec PROC_GETID 'RW03',@dj output insert into RW03(RW03001,RW03002,RW03003,RW03004,RW03005,RW03006,RW03007,RW03008) values(@dj,getdate(),@userid,@username,'','','',N'创建条码') set @i=0 while @i<@printcount begin exec PROC_GETID 'RW01',@bid output insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011) values(@bid,getdate(),@userid,@username,@dj,N'创建条码标签') insert into RW01(RW01001,RW01002,RW01003,RW01004,RW01005,RW01006,RW01012,RW01013,RW01014,RW01015,RW01018,RW01024,RW01025,RW01027,RW01032,RW01034,RW01035,RW01037,RW01038,RW01040,RW01041,RW01043) values(@bid,@stock,@stockname,@stockspec,@unit,@qty,@sup,@supname,@po,@poline,@remark,@userid,@username,@dj,1,@company,@SupplierBatch,@ProductionTime ,@ValidityTime,@tqty,@type,'REC') insert into RW04(RW04002,RW04003,RW04004,RW04005) values(getdate(),@dj,@bid,N'创建条码') set @i=@i+1 end select top [COUNT] RW01001 from RW01 order by RW01001 desc "; sqlStr = sqlStr.Replace("[COUNT]", this.PrintCount + ""); ModelAdo<StockModel> adoStock = new ModelAdo<StockModel>(); StockModel sm = adoStock.GetModelByID(this.StockCode); BaseAdo ba = new BaseAdo(); DataSet ds = ba.GetDataSet(sqlStr, new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName), new SqlParameter("@stock", this.StockCode), new SqlParameter("@stockname", sm.StockName), new SqlParameter("@stockspec", sm.StockSpec), new SqlParameter("@unit", this.StockUnit), new SqlParameter("@qty", this.StockUnitQty), new SqlParameter("@tqty", sm.StockType == "02" ? 1 : sm.UQTY), new SqlParameter("@po", this.PO), new SqlParameter("@poline", this.POLine), new SqlParameter("@sup", this.SupplierCode), new SqlParameter("@supname", this.SupplierName), new SqlParameter("@remark", this.Remark1), new SqlParameter("@company", this.CompanyCode), new SqlParameter("@SupplierBatch", this.SupplierBatch), new SqlParameter("@printcount", this.PrintCount), new SqlParameter("@type", sm.StockType), new SqlParameter("@ProductionTime", this.ProductDate), new SqlParameter("@ValidityTime", this.ExpirationDate) ); //StringBuilder sb = new StringBuilder(); //foreach (DataRow item in ds.Tables[0].Rows) //{ // sb.Append(",'" + item[0] + "'"); //} //sb.Remove(0, 1); //ExportXML(sb.ToString()); ts.Complete(); } return this; }
public override int Delete(string id) { ModelAdo<LoginHistoryModel> adoLHM = new ModelAdo<LoginHistoryModel>(); LoginHistoryModel lhm = adoLHM.GetModelByID(id); if (lhm != null) { lhm.LoginStatus = 0; lhm.LogoutTime = DateTime.Now; return adoLHM.Update(lhm); } else return 0; }