/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">model</param> public int AddRecord(BArrangeBillFactData model) { StringBuilder strSql = new StringBuilder(); strSql.Append("set nocount on; "); strSql.Append("insert into BArrangeBillFact("); strSql.Append(@"arrangeBillNo,arriveBillNo,financeBillNo,palletIndex,palletNo,isTally,isrtEmpId,isrtDt,updtEmpId,updtDt, instantState)"); strSql.Append(" values ("); strSql.Append(@"@arrangeBillNo,@arriveBillNo,@financeBillNo,@palletIndex,@palletNo,@isTally,@isrtEmpId,@isrtDt,@updtEmpId,@updtDt, @instantState)"); strSql.Append("; select @@identity; set nocount off; "); SqlParameter[] parameters = { new SqlParameter("@arrangeBillNo", SqlDbType.VarChar,20), new SqlParameter("@arriveBillNo", SqlDbType.VarChar,20), new SqlParameter("@financeBillNo", SqlDbType.VarChar,20), new SqlParameter("@palletIndex", SqlDbType.VarChar,10), new SqlParameter("@palletNo", SqlDbType.VarChar,20), new SqlParameter("@isTally", SqlDbType.Bit), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@updtEmpId", SqlDbType.Int), new SqlParameter("@updtDt", SqlDbType.DateTime), new SqlParameter("@instantState", SqlDbType.NVarChar,20) }; parameters[0].Value = model.arrangeBillNo; parameters[1].Value = model.arriveBillNo; parameters[2].Value = model.financeBillNo; parameters[3].Value = model.palletIndex; parameters[4].Value = model.palletNo; parameters[5].Value = model.isTally; parameters[6].Value = model.isrtEmpId; parameters[7].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[8].Value = model.updtEmpId; parameters[9].Value = model.updtDt == string.Empty ? null : model.updtDt; parameters[10].Value = model.instantState; 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(BArrangeBillFactData model) { return this.arrangeBillFactDB.ModifyRecord(model); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">model</param> public int AddRecord(BArrangeBillFactData model) { return this.arrangeBillFactDB.AddRecord(model); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(BArrangeBillFactData model) { bool ret = false; StringBuilder strSql = new StringBuilder(); strSql.Append("update BArrangeBillFact set "); strSql.Append("arrangeBillNo=@arrangeBillNo,"); strSql.Append("arriveBillNo=@arriveBillNo,"); strSql.Append("financeBillNo=@financeBillNo,"); strSql.Append("palletIndex=@palletIndex,"); strSql.Append("palletNo=@palletNo,"); strSql.Append("isTally=@isTally,"); strSql.Append("isrtEmpId=@isrtEmpId,"); strSql.Append("isrtDt=@isrtDt,"); strSql.Append("updtEmpId=@updtEmpId,"); strSql.Append("updtDt=@updtDt,"); strSql.Append("instantState=@instantState"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@arrangeBillNo", SqlDbType.VarChar,20), new SqlParameter("@arriveBillNo", SqlDbType.VarChar,20), new SqlParameter("@financeBillNo", SqlDbType.VarChar,20), new SqlParameter("@palletIndex", SqlDbType.VarChar,10), new SqlParameter("@palletNo", SqlDbType.VarChar,20), new SqlParameter("@isTally", SqlDbType.Bit), new SqlParameter("@isrtEmpId", SqlDbType.Int), new SqlParameter("@isrtDt", SqlDbType.DateTime), new SqlParameter("@updtEmpId", SqlDbType.Int), new SqlParameter("@updtDt", SqlDbType.DateTime), new SqlParameter("@instantState", SqlDbType.NVarChar,20) }; parameters[0].Value = model.id; parameters[1].Value = model.arrangeBillNo; parameters[2].Value = model.arriveBillNo; parameters[3].Value = model.financeBillNo; parameters[4].Value = model.palletIndex; parameters[5].Value = model.palletNo; parameters[6].Value = model.isTally; parameters[7].Value = model.isrtEmpId; parameters[8].Value = model.isrtDt == string.Empty ? null : model.isrtDt; parameters[9].Value = model.updtEmpId; parameters[10].Value = model.updtDt == string.Empty ? null : model.updtDt; parameters[11].Value = model.instantState; 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 BArrangeBillFactData GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append(@"select id,arrangeBillNo,arriveBillNo,financeBillNo,palletIndex,palletNo,isTally,isrtEmpId,isrtDt,updtEmpId,updtDt, instantState from BArrangeBillFact"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int) }; parameters[0].Value = id; BArrangeBillFactData model = new BArrangeBillFactData(); 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["arrangeBillNo"] != DBNull.Value) { model.arrangeBillNo = Convert.ToString(row["arrangeBillNo"]); } if (row["arriveBillNo"] != DBNull.Value) { model.arriveBillNo = Convert.ToString(row["arriveBillNo"]); } if (row["financeBillNo"] != DBNull.Value) { model.financeBillNo = Convert.ToString(row["financeBillNo"]); } if (row["palletIndex"] != DBNull.Value) { model.palletIndex = Convert.ToString(row["palletIndex"]); } if (row["palletNo"] != DBNull.Value) { model.palletNo = Convert.ToString(row["palletNo"]); } if (row["isTally"] != DBNull.Value) { model.isTally = Convert.ToBoolean(row["isTally"]); } if (row["isrtEmpId"] != DBNull.Value) { model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]); } if (row["isrtDt"] != DBNull.Value) { model.isrtDt = Convert.ToString(row["isrtDt"]); } if (row["updtEmpId"] != DBNull.Value) { model.updtEmpId = Convert.ToInt32(row["updtEmpId"]); } if (row["updtDt"] != DBNull.Value) { model.updtDt = Convert.ToString(row["updtDt"]); } if (row["instantState"] != DBNull.Value) { model.instantState = Convert.ToString(row["instantState"]); } return model; } else { return null; } }
//***************************************************************************** //do it later do it later do it later //***************************************************************************** /// <summary> /// 保存排托收货单信息 /// </summary> /// <param name="strArrangeBillNo">排托单号</param> /// <param name="strArriveBillNo">到货单号</param> /// <param name="strFinanceBillNos">采购订单编号组合</param> /// <param name="strPalletIndex">托盘序号</param> /// <param name="strPalletNo">托盘号</param> /// <param name="isrtEmpId">添加人</param> /// <param name="updtEmpId">修改人</param> /// <param name="strInstantState">状态:01 收货单,02 收货已完成</param> /// <returns></returns> public bool SaveRecord(string strArrangeBillNo, string strArriveBillNo,string strFinanceBillNos, string strPalletIndex, string strPalletNo, int isrtEmpId, int updtEmpId, string strInstantState) { bool ret = false; SqlTransaction trans = null; SCommBB commBB = new SCommBB(this.connection); BForkliftTaskBB forkliftTaskBB = new BForkliftTaskBB(this.connection); BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection); try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransSave"); this.arrangeBillFactBB.Transaction = trans; commBB.Transaction = trans; forkliftTaskBB.Transaction = trans; arrangeBillBoxBB.Transaction = trans; } else { this.arrangeBillFactBB.Transaction = this.transaction; commBB.Transaction = this.transaction; forkliftTaskBB.Transaction = this.transaction; arrangeBillBoxBB.Transaction = this.transaction; } DataSet ds = new DataSet(); BArrangeBillFactData arrangeBillFactModel = new BArrangeBillFactData(); #region 维护排托收货单信息 foreach (string strFinanceBillNo in strFinanceBillNos.Split(',')) { //维护排托收货单信息 ds = arrangeBillFactBB.GetList("arrangeBillNo='" + strArrangeBillNo + "' and palletIndex='" + strPalletIndex + "' and financeBillNo='" + strFinanceBillNo + "'");//添加物料编号 if (ds.Tables[0].Rows.Count == 0) { arrangeBillFactModel = new BArrangeBillFactData(); arrangeBillFactModel.arrangeBillNo = strArrangeBillNo;//排托单号 arrangeBillFactModel.arriveBillNo = strArriveBillNo;//到货单号 arrangeBillFactModel.financeBillNo = strFinanceBillNo;//采购订单号 arrangeBillFactModel.palletIndex = strPalletIndex;//托盘序号 arrangeBillFactModel.palletNo = strPalletNo;//托盘条码号 arrangeBillFactModel.isTally = false;//是否已理货 arrangeBillFactModel.isrtEmpId = isrtEmpId;//添加人 arrangeBillFactModel.isrtDt = System.DateTime.Now.ToString();//添加时间 arrangeBillFactModel.instantState = strInstantState;//状态 arrangeBillFactBB.AddRecord(arrangeBillFactModel); } else { arrangeBillFactModel = arrangeBillFactBB.GetModel(Convert.ToInt32(ds.Tables[0].Rows[0]["id"])); if (strPalletNo != "")//如果托盘号不为空,更改托盘号 { arrangeBillFactModel.palletNo = strPalletNo;//托盘条码号 } else { strPalletNo = ds.Tables[0].Rows[0]["palletNo"].ToString();//获取托盘条码 } arrangeBillFactModel.updtDt = System.DateTime.Now.ToString();//修改时间 arrangeBillFactModel.updtEmpId = updtEmpId;//修改人 arrangeBillFactModel.instantState = strInstantState;//状态 arrangeBillFactBB.ModifyRecord(arrangeBillFactModel); } } #endregion 维护排托收货单信息 #region 更改状态 //更改状态 if (strInstantState == "01")//排托中 { //更改排托单明细状态为“02 排托中” commBB.ExecuteSql("update dbo.BArrangeBillDetail set instantState='02' where arriveBillNo='" + strArriveBillNo + "' and palletIndex='" + strPalletIndex + "'"); //更改排托单状态为“03 排托中” commBB.ExecuteSql("update dbo.BArrangeBill set instantState='03' where arriveBillNo='" + strArriveBillNo + "'"); //更改到货单状态为“04 排托中” commBB.ExecuteSql("update dbo.BArriveBill set instantState='04' where billNo='" + strArriveBillNo + "'"); } else if (strInstantState == "02")//排托已完成 { #region 更改单据状态 //更改排托单明细状态为“03 排托已完成” commBB.ExecuteSql("update dbo.BArrangeBillDetail set instantState='03' where arriveBillNo='" + strArriveBillNo + "' and palletIndex='" + strPalletIndex + "'"); //如果排托单明细全部排托已完成,更改排托单状态为“排托已完成” commBB.ExecuteSql("update dbo.BArrangeBill set instantState='04' where arriveBillNo='" + strArriveBillNo + "' and not exists (select 1 from dbo.BArrangeBillDetail where dbo.BArrangeBill.arriveBillNo=dbo.BArrangeBillDetail.arriveBillNo and isnull(dbo.BArrangeBillDetail.instantState,'')<>'03')"); //如果排托单明细全部排托已完成,更改到货单状态为“排托已完成” commBB.ExecuteSql(@"update dbo.BArriveBill set instantState='05' where billNo='" + strArriveBillNo + "' and not exists (select 1 from dbo.BArrangeBillDetail where dbo.BArriveBill.billNo=dbo.BArrangeBillDetail.arriveBillNo and isnull(dbo.BArrangeBillDetail.instantState,'')<>'03')"); #endregion 更改单据状态 #region 生成叉车任务 //首先判断当前托盘存在未执行的叉车任务 DataTable dtForkliftTask = new DataTable(); dtForkliftTask = forkliftTaskBB.GetList("palletNo='" + strPalletNo + "' and isDeal=0").Tables[0]; if (dtForkliftTask.Rows.Count == 0) { BForkliftTaskData forkliftTaskModel = new BForkliftTaskData(); DataSet dsArrangeBillBox = new DataSet(); dsArrangeBillBox = arrangeBillBoxBB.GetVList("arriveBillNo='" + strArriveBillNo + "' and palletNo='" + strPalletNo + "' and isnull(wareNo,'')<>''"); if (dsArrangeBillBox.Tables[0].Rows.Count > 0) { forkliftTaskModel = new BForkliftTaskData(); forkliftTaskModel.taskType = "01";//任务类型为:从排托区到质检区 forkliftTaskModel.palletNo = strPalletNo;//托盘号 forkliftTaskModel.preWareNo = dsArrangeBillBox.Tables[0].Rows[0]["wareNo"].ToString();//源库区 forkliftTaskModel.preLocatorNo = dsArrangeBillBox.Tables[0].Rows[0]["wareLocatorNo"].ToString();//源库位 forkliftTaskModel.effectDt = System.DateTime.Now.ToString();//生效时间 forkliftTaskModel.isDeal = false;//是否处理 forkliftTaskModel.isrtDt = System.DateTime.Now.ToString();//添加时间 forkliftTaskModel.isrtEmpId = isrtEmpId;//添加人 forkliftTaskBB.AddRecord(forkliftTaskModel); } } #endregion 生成叉车任务 } #endregion 更改状态 if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransSave"); throw ex; } finally { commBB.Dispose(); forkliftTaskBB.Dispose(); arrangeBillBoxBB.Dispose(); } return ret; }
/// <summary> /// 保存非标准箱入质检区信息 /// </summary> /// <param name="strPalletNo">托盘号</param> /// <returns></returns> public bool SaveNoStandBoxInCheckInfo(string strPalletNo) { bool ret = false; SqlTransaction trans = null; SCommBB commBB = new SCommBB(this.connection); BForkliftTaskBB forkliftTaskBB = new BForkliftTaskBB(this.connection); BArrangeBillBoxBB arrangeBillBoxBB = new BArrangeBillBoxBB(this.connection); BArrangeBillFactDetailBB arrangeBillFactDetailBB = new BArrangeBillFactDetailBB(this.connection); try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransSave"); this.arrangeBillFactBB.Transaction = trans; commBB.Transaction = trans; forkliftTaskBB.Transaction = trans; arrangeBillBoxBB.Transaction = trans; arrangeBillFactDetailBB.Transaction = trans; } else { this.arrangeBillFactBB.Transaction = this.transaction; commBB.Transaction = this.transaction; forkliftTaskBB.Transaction = this.transaction; arrangeBillBoxBB.Transaction = this.transaction; arrangeBillFactDetailBB.Transaction = this.transaction; } DataTable dtArrangeBillBox = new DataTable(); string strArriveBillNo = "", strFinanceBillNo = ""; BArrangeBillFactData arrangeBillFactModel = new BArrangeBillFactData(); BArrangeBillFactDetailData arrangeBillFactDetailModel = new BArrangeBillFactDetailData(); BArrangeBillBoxData arrangeBillBoxModel = new BArrangeBillBoxData(); int mainId = 0; //获取到货箱信息 dtArrangeBillBox = arrangeBillBoxBB.GetList("palletNo='" + strPalletNo + "' and isnull(wareNo,'')<>''").Tables[0]; if (dtArrangeBillBox.Rows.Count > 0) { strArriveBillNo = dtArrangeBillBox.Rows[0]["arriveBillNo"].ToString();//到货单号 strFinanceBillNo = dtArrangeBillBox.Rows[0]["financeBillNo"].ToString();//采购单号 } #region 维护排托收货单信息 //维护排托收货单信息 arrangeBillFactModel.arrangeBillNo = "PT" + strArriveBillNo;//排托单号 arrangeBillFactModel.arriveBillNo = strArriveBillNo;//到货单号 arrangeBillFactModel.financeBillNo = strFinanceBillNo;//采购订单号 arrangeBillFactModel.palletIndex = "0";//托盘序号 arrangeBillFactModel.palletNo = strPalletNo;//托盘条码号 arrangeBillFactModel.isTally = false;//是否已理货 arrangeBillFactModel.isrtEmpId = this.empId;//添加人 arrangeBillFactModel.isrtDt = System.DateTime.Now.ToString();//添加时间 arrangeBillFactModel.instantState = "02";//状态 mainId = arrangeBillFactBB.AddRecord(arrangeBillFactModel); #endregion 维护排托收货单信息 #region 维护排托箱信息 foreach (DataRow row in dtArrangeBillBox.Rows) { //保存排托收货单明细信息 arrangeBillFactDetailModel = new BArrangeBillFactDetailData(); arrangeBillFactDetailModel.mainId = mainId.ToString();//排托收货单ID arrangeBillFactDetailModel.boxNo = row["boxNo"].ToString();//箱号 arrangeBillFactDetailModel.region = "0";//区域 arrangeBillFactDetailModel.isrtEmpId = this.empId; arrangeBillFactDetailModel.isrtDt = System.DateTime.Now.ToString(); arrangeBillFactDetailBB.AddRecord(arrangeBillFactDetailModel); //更改到货箱排托标志 commBB.ExecuteSql("update dbo.BArrangeBillBox set isBoxArrange=1 where boxNo='" + row["boxNo"].ToString() + "'"); } #endregion 维护排托箱信息 #region 生成叉车任务 BForkliftTaskData forkliftTaskModel = new BForkliftTaskData(); if (dtArrangeBillBox.Rows.Count > 0) { forkliftTaskModel = new BForkliftTaskData(); forkliftTaskModel.taskType = "10";//任务类型为:从收货区到质检区 forkliftTaskModel.palletNo = strPalletNo;//托盘号 forkliftTaskModel.preWareNo = dtArrangeBillBox.Rows[0]["wareNo"].ToString();//源库区 forkliftTaskModel.preLocatorNo = dtArrangeBillBox.Rows[0]["wareLocatorNo"].ToString();//源库位 forkliftTaskModel.effectDt = System.DateTime.Now.ToString();//生效时间 forkliftTaskModel.isDeal = false;//是否处理 forkliftTaskBB.AddRecord(forkliftTaskModel); } #endregion 生成叉车任务 if (this.transaction == null) trans.Commit(); ret = true; } catch (Exception ex) { if (this.transaction == null) trans.Rollback("TransSave"); throw ex; } finally { commBB.Dispose(); forkliftTaskBB.Dispose(); arrangeBillBoxBB.Dispose(); arrangeBillFactDetailBB.Dispose(); } return ret; }
/// <summary> /// 更新一条"排托收货单"信息 /// </summary> /// <param name="model">model</param> public bool ModifyRecord(BArrangeBillFactData model) { bool ret = false; SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransModify"); this.arrangeBillFactBB.Transaction = trans; this.errorDiaryBB.Transaction = trans; this.operatDiaryBB.Transaction = trans; } this.arrangeBillFactBB.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(BArrangeBillFactData model) { int id = 0; SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TransAdd"); this.arrangeBillFactBB.Transaction = trans; this.errorDiaryBB.Transaction = trans; this.operatDiaryBB.Transaction = trans; } id = this.arrangeBillFactBB.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; }