/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">model</param> public int AddRecord(CPickOutBillData model) { StringBuilder strSql = new StringBuilder(); strSql.Append("set nocount on; "); strSql.Append("insert into CPickOutBill("); strSql.Append(@"stockUpDetailID,wareNo,wareLocatorNo,preWareNo,preWareLocatorNo,oldPalletNo,oldRegion,oldBoxNo,newBoxNo,num, isrtEmpId,isrtDt,instantState,isSapOutStock)"); strSql.Append(" values ("); strSql.Append(@"@stockUpDetailID,@wareNo,@wareLocatorNo,@preWareNo,@preWareLocatorNo,@oldPalletNo,@oldRegion,@oldBoxNo,@newBoxNo,@num, @isrtEmpId,@isrtDt,@instantState,@isSapOutStock)"); strSql.Append("; select @@identity; set nocount off; "); SqlParameter[] parameters = { new SqlParameter("@stockUpDetailID", SqlDbType.Int), new SqlParameter("@wareNo", SqlDbType.VarChar,20), new SqlParameter("@wareLocatorNo", SqlDbType.VarChar,20), new SqlParameter("@preWareNo", SqlDbType.VarChar,20), new SqlParameter("@preWareLocatorNo", SqlDbType.VarChar,20), new SqlParameter("@oldPalletNo", SqlDbType.VarChar,20), new SqlParameter("@oldRegion", SqlDbType.VarChar,10), new SqlParameter("@oldBoxNo", SqlDbType.VarChar,20), new SqlParameter("@newBoxNo", SqlDbType.VarChar,20), new SqlParameter("@num", SqlDbType.Float), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@instantState", SqlDbType.VarChar,20), new SqlParameter("@isSapOutStock", SqlDbType.Bit) }; parameters[0].Value = model.stockUpDetailID; parameters[1].Value = model.wareNo; parameters[2].Value = model.wareLocatorNo; parameters[3].Value = model.preWareNo; parameters[4].Value = model.preWareLocatorNo; parameters[5].Value = model.oldPalletNo; parameters[6].Value = model.oldRegion; parameters[7].Value = model.oldBoxNo; parameters[8].Value = model.newBoxNo; parameters[9].Value = model.num; parameters[10].Value = model.isrtEmpId; parameters[11].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[12].Value = model.instantState; parameters[13].Value = model.isSapOutStock; int id = 0; try { object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ret != null && ret != DBNull.Value) { id = Convert.ToInt32(ret); } } catch (Exception ex) { throw ex; } return id; }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(CPickOutBillData model) { return this.pickOutBillDB.ModifyRecord(model); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">model</param> public int AddRecord(CPickOutBillData model) { return this.pickOutBillDB.AddRecord(model); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(CPickOutBillData model) { bool ret = false; StringBuilder strSql = new StringBuilder(); strSql.Append("update CPickOutBill set "); strSql.Append("stockUpDetailID=@stockUpDetailID,"); strSql.Append("wareNo=@wareNo,"); strSql.Append("wareLocatorNo=@wareLocatorNo,"); strSql.Append("preWareNo=@preWareNo,"); strSql.Append("preWareLocatorNo=@preWareLocatorNo,"); strSql.Append("oldPalletNo=@oldPalletNo,"); strSql.Append("oldRegion=@oldRegion,"); strSql.Append("oldBoxNo=@oldBoxNo,"); strSql.Append("newBoxNo=@newBoxNo,"); strSql.Append("num=@num,"); strSql.Append("isrtEmpId=@isrtEmpId,"); strSql.Append("isrtDt=@isrtDt,"); strSql.Append("instantState=@instantState,"); strSql.Append("isSapOutStock=@isSapOutStock"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@stockUpDetailID", SqlDbType.Int), new SqlParameter("@wareNo", SqlDbType.VarChar,20), new SqlParameter("@wareLocatorNo", SqlDbType.VarChar,20), new SqlParameter("@preWareNo", SqlDbType.VarChar,20), new SqlParameter("@preWareLocatorNo", SqlDbType.VarChar,20), new SqlParameter("@oldPalletNo", SqlDbType.VarChar,20), new SqlParameter("@oldRegion", SqlDbType.VarChar,10), new SqlParameter("@oldBoxNo", SqlDbType.VarChar,20), new SqlParameter("@newBoxNo", SqlDbType.VarChar,20), new SqlParameter("@num", SqlDbType.Float), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@instantState", SqlDbType.VarChar,20), new SqlParameter("@isSapOutStock", SqlDbType.Bit) }; parameters[0].Value = model.id; parameters[1].Value = model.stockUpDetailID; parameters[2].Value = model.wareNo; parameters[3].Value = model.wareLocatorNo; parameters[4].Value = model.preWareNo; parameters[5].Value = model.preWareLocatorNo; parameters[6].Value = model.oldPalletNo; parameters[7].Value = model.oldRegion; parameters[8].Value = model.oldBoxNo; parameters[9].Value = model.newBoxNo; parameters[10].Value = model.num; parameters[11].Value = model.isrtEmpId; parameters[12].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[13].Value = model.instantState; parameters[14].Value = model.isSapOutStock; try { SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); ret = true; } catch (Exception ex) { throw ex; } return ret; }
/// <summary> /// 得到一个model /// </summary> /// <param name="id">主键值</param> /// <returns>model</returns> public CPickOutBillData GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append(@"select id,stockUpDetailID,wareNo,wareLocatorNo,preWareNo,preWareLocatorNo,oldPalletNo,oldRegion,oldBoxNo,newBoxNo,num, isrtEmpId,isrtDt,instantState,isSapOutStock from CPickOutBill"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int) }; parameters[0].Value = id; CPickOutBillData model = new CPickOutBillData(); DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables[0].Rows[0]; if (row["id"] != DBNull.Value) { model.id = Convert.ToInt32(row["id"]); } if (row["stockUpDetailID"] != DBNull.Value) { model.stockUpDetailID = Convert.ToInt32(row["stockUpDetailID"]); } if (row["wareNo"] != DBNull.Value) { model.wareNo = Convert.ToString(row["wareNo"]); } if (row["wareLocatorNo"] != DBNull.Value) { model.wareLocatorNo = Convert.ToString(row["wareLocatorNo"]); } if (row["preWareNo"] != DBNull.Value) { model.preWareNo = Convert.ToString(row["preWareNo"]); } if (row["preWareLocatorNo"] != DBNull.Value) { model.preWareLocatorNo = Convert.ToString(row["preWareLocatorNo"]); } if (row["oldPalletNo"] != DBNull.Value) { model.oldPalletNo = Convert.ToString(row["oldPalletNo"]); } if (row["oldRegion"] != DBNull.Value) { model.oldRegion = Convert.ToString(row["oldRegion"]); } if (row["oldBoxNo"] != DBNull.Value) { model.oldBoxNo = Convert.ToString(row["oldBoxNo"]); } if (row["newBoxNo"] != DBNull.Value) { model.newBoxNo = Convert.ToString(row["newBoxNo"]); } if (row["num"] != DBNull.Value) { model.num = Convert.ToDouble(row["num"]); } if (row["isrtEmpId"] != DBNull.Value) { model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]); } if (row["isrtDt"] != DBNull.Value) { model.isrtDt = Convert.ToString(row["isrtDt"]); } if (row["instantState"] != DBNull.Value) { model.instantState = Convert.ToString(row["instantState"]); } if (row["isSapOutStock"] != DBNull.Value) { model.isSapOutStock = Convert.ToBoolean(row["isSapOutStock"]); } return model; } else { return null; } }
//***************************************************************************** //do it later do it later do it later //***************************************************************************** /// <summary> /// 保存排托出库信息 /// </summary> /// <param name="stockUpDetailID">备货单明细ID</param> /// <param name="strNewPalletNo">新托盘号</param> /// <param name="strOldBoxNo">原箱号</param> /// <param name="strNewBoxNo">新箱号</param> /// <param name="num">数量</param> /// <returns></returns> public bool SaveOutStockInfo(int stockUpDetailID, string strNewPalletNo, string strOldBoxNo, string strNewBoxNo, double num) { bool ret = false; SqlTransaction trans = null; BArrangeBillBoxBB arraneBillBoxBB = new BArrangeBillBoxBB(this.connection); BForkliftTaskBC forkliftTaskBC = new BForkliftTaskBC(this.connection); CDEPickOutBoxBB DEPickOutBoxBB = new CDEPickOutBoxBB(this.connection); CStockUpDetailBB stockUpDetailBB = new CStockUpDetailBB(this.connection); CSaleDetailBB saleDetailBB = new CSaleDetailBB(this.connection); SCommBB commBB = new SCommBB(this.connection); UStockBB stockBB = new UStockBB(this.connection); UStockOutInDetailBB stockOutInDetailBB = new UStockOutInDetailBB(this.connection); LMaterialBB materialBB = new LMaterialBB(this.connection); try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransSaveOutStockInfo"); this.pickOutBillBB.Transaction = trans; arraneBillBoxBB.Transaction = trans; forkliftTaskBC.Transaction = trans; DEPickOutBoxBB.Transaction = trans; stockUpDetailBB.Transaction = trans; saleDetailBB.Transaction = trans; commBB.Transaction = trans; stockBB.Transaction = trans; stockOutInDetailBB.Transaction = trans; materialBB.Transaction = trans; } else { this.pickOutBillBB.Transaction = this.transaction; arraneBillBoxBB.Transaction = this.transaction; forkliftTaskBC.Transaction = this.transaction; DEPickOutBoxBB.Transaction = this.transaction; stockUpDetailBB.Transaction = this.transaction; saleDetailBB.Transaction = this.transaction; commBB.Transaction = this.transaction; stockBB.Transaction = this.transaction; stockOutInDetailBB.Transaction = this.transaction; materialBB.Transaction = this.transaction; } CStockUpDetailData stockUpDetailModel = new CStockUpDetailData(); vCStockUpDetailData vStockUpDetailModel = new vCStockUpDetailData(); DataTable dtArrangeBillBox = new DataTable(); DataTable dtDEPickOutBox = new DataTable(); DataTable dtWareLocator = new DataTable(); DataTable dtStockUpDetail = new DataTable(); string strSql = "", strPrePalletNo = "", strPreWareLocatorNo = ""; //获取备货单明细实例 stockUpDetailModel = stockUpDetailBB.GetModel(stockUpDetailID); //拆托拣货箱信息 dtDEPickOutBox = DEPickOutBoxBB.GetVList("boxNo='" + strOldBoxNo + "'").Tables[0]; //普通拣货箱信息 dtArrangeBillBox = arraneBillBoxBB.GetVList("boxNo='" + strOldBoxNo + "' and wareNo<>''").Tables[0]; //扫描箱以前所在库位 if (dtArrangeBillBox.Rows[0]["preWareLocatorNo"].ToString() != "") { strPrePalletNo = dtArrangeBillBox.Rows[0]["palletNo"].ToString();//原托盘条码号 strPreWareLocatorNo = dtArrangeBillBox.Rows[0]["preWareLocatorNo"].ToString();//物料箱以前所在库位 } //获取排托区下线库位信息 strSql = @"select wareLocator.wareNo,wareLocator.downWareLocatorNo as wareLocatorNo from dbo.BArrangeBillBox as arrangeBillBoxBox left join dbo.LWareLocator as wareLocator on wareLocator.wareLocatorNo=arrangeBillBoxBox.wareLocatorNo where arrangeBillBoxBox.boxNo='" + strOldBoxNo + "'"; dtWareLocator = commBB.Query(strSql).Tables[0]; #region 新增销售拣货单信息 CPickOutBillData pickOutBillModel = new CPickOutBillData(); //新增销售拣货单信息 pickOutBillModel.stockUpDetailID = stockUpDetailID;//备货单明细ID //从哪个拣货库区、库位赋值 if (dtDEPickOutBox.Rows.Count > 0) { pickOutBillModel.wareNo = dtDEPickOutBox.Rows[0]["preWareNo"].ToString();//以前的仓库编号 pickOutBillModel.wareLocatorNo = dtDEPickOutBox.Rows[0]["preWareLocatorNo"].ToString();//以前的库位编号 } else { pickOutBillModel.wareNo = dtArrangeBillBox.Rows[0]["preWareNo"].ToString();//以前的仓库编号 pickOutBillModel.wareLocatorNo = dtArrangeBillBox.Rows[0]["preWareLocatorNo"].ToString();//以前的库位编号 } pickOutBillModel.preWareNo = "";//以前的仓库编号 pickOutBillModel.preWareLocatorNo = "";//以前的库位编号 pickOutBillModel.oldPalletNo = dtArrangeBillBox.Rows[0]["palletNo"].ToString();//原托盘号 pickOutBillModel.oldRegion = dtArrangeBillBox.Rows[0]["region"].ToString();//原托内区域 pickOutBillModel.oldBoxNo = strOldBoxNo;//原箱号 pickOutBillModel.newBoxNo = strNewBoxNo;//新箱号 pickOutBillModel.num = num;//数量 pickOutBillModel.isrtEmpId = this.empId;//添加人 pickOutBillModel.isrtDt = System.DateTime.Now.ToString();//添加时间 pickOutBillModel.instantState = "01";//未发货 pickOutBillBB.AddRecord(pickOutBillModel); #endregion 新增销售拣货单信息 #region 新增新的排托箱 DataTable dtArrangeBillBoxNew = new DataTable(); dtArrangeBillBoxNew = arraneBillBoxBB.GetVList("boxNo='" + strNewBoxNo + "'").Tables[0]; //新增新的排托箱 if (dtArrangeBillBoxNew.Rows.Count == 0) { BArrangeBillBoxData newArrangeBillBoxModel = new BArrangeBillBoxData(); newArrangeBillBoxModel.arriveBillNo = "";//到货单号 newArrangeBillBoxModel.financeBillNo = dtArrangeBillBox.Rows[0]["financeBillNo"].ToString();//采购订单号 newArrangeBillBoxModel.arrangeBillNo = "";//排托单号 newArrangeBillBoxModel.stockUpBillNo = stockUpDetailModel.stockUpBillNo;//备货单编号 newArrangeBillBoxModel.boxNo = strNewBoxNo;//箱号 newArrangeBillBoxModel.oldBoxNo = strOldBoxNo;//原箱号 newArrangeBillBoxModel.materialNo = stockUpDetailModel.materialNo;//转换后物料编号 newArrangeBillBoxModel.oldMaterialNo = dtArrangeBillBox.Rows[0]["materialNo"].ToString();//转换前物料编号 newArrangeBillBoxModel.factNum = 0;//数量赋0,通过拣货箱明细计算数量 newArrangeBillBoxModel.palletNo = strNewPalletNo;//托盘号 newArrangeBillBoxModel.region = "";//区域 newArrangeBillBoxModel.oldPalletNo = dtArrangeBillBox.Rows[0]["palletNo"].ToString();//原托盘号 newArrangeBillBoxModel.oldRegion = dtArrangeBillBox.Rows[0]["region"].ToString();//原托内区域 //新箱库区、库位赋值,值为下线线体 if (dtWareLocator.Rows.Count > 0 && dtWareLocator.Rows[0]["wareLocatorNo"] != DBNull.Value && dtWareLocator.Rows[0]["wareLocatorNo"].ToString() != "") { newArrangeBillBoxModel.wareNo = dtWareLocator.Rows[0]["wareNo"].ToString();//库区 newArrangeBillBoxModel.wareLocatorNo = dtWareLocator.Rows[0]["wareLocatorNo"].ToString();//库位 } newArrangeBillBoxModel.preWareNo = "";//原库区 newArrangeBillBoxModel.preWareLocatorNo = "";//原库位 newArrangeBillBoxModel.isBoxArrange = true;//是否排托 newArrangeBillBoxModel.isPalletUsing = true;//托盘是否正在使用 newArrangeBillBoxModel.acceptEmpId = this.EmpID;//接收人 newArrangeBillBoxModel.acceptDt = System.DateTime.Now.ToString();//接收时间 newArrangeBillBoxModel.isOutStocking = false;//是否正在出库 arraneBillBoxBB.AddRecord(newArrangeBillBoxModel); } #endregion 新增新的排托箱 #region 库存所有操作 DataTable dtStock = new DataTable(); DataTable dtMaterial = new DataTable(); UStockOutInDetailData stockOutInDetailModel = new UStockOutInDetailData(); //更改正式库存信息 commBB.ExecuteSql("update dbo.UStock set num=num-" + num.ToString() + " where boxNo='" + strOldBoxNo + "'"); //增加出入库明细-拣货箱出库 dtStock = stockBB.GetList("boxNo='" + strOldBoxNo + "'").Tables[0]; if (dtStock.Rows.Count > 0)//原箱有库存 { dtMaterial = materialBB.GetList("materialNo='" + dtStock.Rows[0]["materialNo"].ToString() + "'").Tables[0]; //保存出入库明细数据 stockOutInDetailModel = new UStockOutInDetailData(); stockOutInDetailModel.billNo = stockUpDetailModel.stockUpBillNo;//单据编号 stockOutInDetailModel.outInType = "06";//销售出库 stockOutInDetailModel.isOut = true;//是否出库 stockOutInDetailModel.stockDt = System.DateTime.Today.ToString();//库存日期 stockOutInDetailModel.dt = System.DateTime.Today.ToString();//操作日期 stockOutInDetailModel.wareNo = dtStock.Rows[0]["wareNo"].ToString();//仓库 stockOutInDetailModel.wareLocatorNo = dtStock.Rows[0]["wareLocatorNo"].ToString();//库位 stockOutInDetailModel.salverNo = dtStock.Rows[0]["palletNo"].ToString();//托盘号 stockOutInDetailModel.boxNo = strOldBoxNo;//箱号 stockOutInDetailModel.materialNo = dtStock.Rows[0]["materialNo"].ToString();//物料编号 stockOutInDetailModel.factMonomerNum = Convert.ToDouble(dtMaterial.Rows[0]["U_UintQty"]);//单体数量 stockOutInDetailModel.factPackNum = Convert.ToDouble(dtMaterial.Rows[0]["U_BoxQty"]);//整箱数量 stockOutInDetailModel.num = num;//数量 stockOutInDetailModel.isrtEmpId = this.empId; stockOutInDetailModel.isrtDt = System.DateTime.Now.ToString(); stockOutInDetailBB.AddRecord(stockOutInDetailModel); } #endregion 库存所有操作 #region 更改备货单明细的新托盘号、状态 //更改备货单明细的新托盘号、状态 vStockUpDetailModel = stockUpDetailBB.GetVModel(stockUpDetailID); stockUpDetailModel.palletNo = strNewPalletNo;//新托盘号 if (vStockUpDetailModel.num > vStockUpDetailModel.factNum) { stockUpDetailModel.instantState = "02";//更改状态为“备货中” } else { stockUpDetailModel.instantState = "03";//更改状态为“备货完成” } stockUpDetailBB.ModifyRecord(stockUpDetailModel); #endregion 更改备货单明细的新托盘号、状态 #region 生成从拣货区到打托区叉车任务 bool isFinish = true; //如果某个托盘的备货单明细已经全部备货完成,生成托盘的叉车任务 strSql = @"select palletNo,instantState from dbo.CStockUpDetail where stockUpBillNo='" + stockUpDetailModel.stockUpBillNo + "' and palletIndex='" + stockUpDetailModel.palletIndex.ToString() + "'"; dtStockUpDetail = commBB.Query(strSql).Tables[0]; foreach (DataRow row in dtStockUpDetail.Rows) { if (row["instantState"].ToString() == "01" || row["instantState"].ToString() == "02") { isFinish = false; break; } } if (isFinish) { //保存从拣货区到打托区叉车任务 forkliftTaskBC.SaveForkliftTask(dtStockUpDetail.Rows[0]["palletNo"].ToString(), "", "", "14", this.empId); } #endregion 生成从拣货区到打托区叉车任务 #region 更改备货单状态 //如果备货单明细的状态全部为“03 备货完成”,更改备货单状态为“08 备货完成” strSql = @"update dbo.CStockUpBill set instantState='08' where not exists(select 1 from dbo.CStockUpDetail as t where t.stockUpBillNo=dbo.CStockUpBill.stockUpBillNo and instantState<>'03')"; commBB.ExecuteSql(strSql); #endregion 更改备货单状态 #region 更改箱锁定状态 int stockId = 0, boxId = 0; object obj = null; //查找库存 obj = commBB.ExecuteScalar("select top 1 id from dbo.UStock where boxNo='" + strOldBoxNo + "' and num>0 and isOutStocking=1"); if (obj == null) { obj = commBB.ExecuteScalar("select top 1 id from dbo.UStock where palletNo='" + strPrePalletNo + "' and num>0 and isOutStocking=1 order by id"); if (obj != null) { stockId = Convert.ToInt32(obj); } } else { stockId = Convert.ToInt32(obj); } //查找物料箱 obj = commBB.ExecuteScalar("select top 1 id from dbo.BArrangeBillBox where boxNo='" + strOldBoxNo + "' and wareNo<>'' and isOutStocking=1"); if (obj == null) { obj = commBB.ExecuteScalar("select top 1 id from dbo.BArrangeBillBox where palletNo='" + strPrePalletNo + "' and wareNo<>'' and isOutStocking=1 order by id"); if (obj != null) { boxId = Convert.ToInt32(obj); } } else { boxId = Convert.ToInt32(obj); } //更改库存中原箱的是否锁定状态 strSql = "update dbo.UStock set isOutStocking=0 where id='" + stockId.ToString() + "'"; commBB.ExecuteSql(strSql); //更改原箱的是否锁定状态 strSql = "update dbo.BArrangeBillBox set isOutStocking=0 where id='" + boxId.ToString() + "'"; commBB.ExecuteSql(strSql); #endregion 更改箱锁定状态 #region 如果原箱剩余数量为零,更改原箱的托盘号 if (strNewBoxNo == strOldBoxNo) { if (dtWareLocator.Rows.Count > 0 && dtWareLocator.Rows[0]["wareLocatorNo"] != DBNull.Value && dtWareLocator.Rows[0]["wareLocatorNo"].ToString() != "") { strSql = @"update dbo.BArrangeBillBox set oldMaterialNo=materialNo,materialNo='" + stockUpDetailModel.materialNo + "',oldPalletNo=palletNo,palletNo='" + strNewPalletNo + "',preWareNo=wareNo,preWareLocatorNo=wareLocatorNo,wareNo='" + dtWareLocator.Rows[0]["wareNo"].ToString() + "',wareLocatorNo='" + dtWareLocator.Rows[0]["wareLocatorNo"].ToString() + "',oldRegion=region,region='' where boxNo='" + strOldBoxNo + "'"; commBB.ExecuteSql(strSql); } } //如果箱内剩余数量为0,清空托盘号和库区、库位信息 dtArrangeBillBox = arraneBillBoxBB.GetVList("boxNo='" + strOldBoxNo + "'").Tables[0]; if (Convert.ToInt32(dtArrangeBillBox.Rows[0]["leavingNum"]) == 0) { commBB.ExecuteSql(@"update dbo.BArrangeBillBox set oldPalletNo=palletNo,palletNo='',preWareNo=wareNo,preWareLocatorNo=wareLocatorNo, wareNo='',wareLocatorNo='' where boxNo='" + strOldBoxNo + "'"); } #endregion 如果原箱剩余数量为零,更改原箱的托盘号 #region 原库位释放 //释放库位,首先判断原托盘上是否有物料 strSql = @"update dbo.LWareLocator set isUsing=0 where not exists(select 1 from dbo.BArrangeBillBox as t where t.palletNo='" + strPrePalletNo + "' and isnull(t.wareNo,'')<>'') and wareLocatorNo='" + strPreWareLocatorNo + "' and isUsing=1 and isDel=0"; commBB.ExecuteSql(strSql); #endregion 原库位释放 #region 出入库所有操作 //库存明细数量为0,删除信息 strSql = "delete from dbo.UStock where num=0"; commBB.ExecuteSql(strSql); #endregion 出入库所有操作 if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransSaveOutStockInfo"); throw ex; } finally { arraneBillBoxBB.Dispose(); forkliftTaskBC.Dispose(); stockUpDetailBB.Dispose(); commBB.Dispose(); saleDetailBB.Dispose(); DEPickOutBoxBB.Dispose(); stockBB.Dispose(); stockOutInDetailBB.Dispose(); materialBB.Dispose(); } return ret; }
/// <summary> /// 更新一条"销售拣货单"信息 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(CPickOutBillData model) { bool ret = false; SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransModify"); this.pickOutBillBB.Transaction = trans; this.errorDiaryBB.Transaction = trans; this.operatDiaryBB.Transaction = trans; } this.pickOutBillBB.ModifyRecord(model); SOperatDiaryData operatDiaryData = new SOperatDiaryData(); operatDiaryData.empId = this.empId; operatDiaryData.functionId = ""; operatDiaryData.recordId = model.id.ToString(); operatDiaryData.operateContent = "销售拣货单修改一条id为“" + model.id.ToString() + "”的记录"; this.operatDiaryBB.AddRecord(operatDiaryData); if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransModify"); SErrorDiaryData errorDiaryData = new SErrorDiaryData(); errorDiaryData.empId = this.empId; errorDiaryData.functionId = ""; errorDiaryData.errorText = "销售拣货单修改记录“" + model.id.ToString() + "”时报错:" + ex.Message; this.errorDiaryBB.AddRecord(errorDiaryData); throw ex; } finally { } return ret; }
/// <summary> /// 增加一条"销售拣货单"信息 /// </summary> /// <param name="model">model</param> public int AddRecord(CPickOutBillData model) { int id = 0; SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransAdd"); this.pickOutBillBB.Transaction = trans; this.errorDiaryBB.Transaction = trans; this.operatDiaryBB.Transaction = trans; } id = this.pickOutBillBB.AddRecord(model); SOperatDiaryData operatDiaryData = new SOperatDiaryData(); operatDiaryData.empId = this.empId; operatDiaryData.functionId = ""; operatDiaryData.recordId = id.ToString(); operatDiaryData.operateContent = "销售拣货单增加一条id为“" + id.ToString() + "”的记录"; this.operatDiaryBB.AddRecord(operatDiaryData); if (this.transaction == null) trans.Commit(); } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransAdd"); SErrorDiaryData errorDiaryData = new SErrorDiaryData(); errorDiaryData.empId = this.empId; errorDiaryData.functionId = ""; errorDiaryData.errorText = "销售拣货单增加记录时报错:" + ex.Message; this.errorDiaryBB.AddRecord(errorDiaryData); throw ex; } finally { } return id; }