/// <summary> /// 构造函数 /// </summary> /// <param name="connection">数据连接</param> public LBOMBC(SqlConnection connection) { this.connection = connection; this.bOMBB = new LBOMBB(this.connection); this.errorDiaryBB = new SErrorDiaryBB(this.connection); this.operatDiaryBB = new SOperatDiaryBB(this.connection); }
/// <summary> /// 构造函数 /// </summary> public LBOMBC() { this.selfConn = true; this.connection = new SqlConnection(HS.Config.SqlDataObject.GetSqlConnectionString); this.connection.Open(); this.bOMBB = new LBOMBB(this.connection); this.errorDiaryBB = new SErrorDiaryBB(this.connection); this.operatDiaryBB = new SOperatDiaryBB(this.connection); }
//***************************************************************************** //do it later do it later do it later //***************************************************************************** /// <summary> /// 保存BOM /// </summary> /// <param name="arrangeBillModel"></param> /// <param name="dtArrange"></param> /// <param name="isSubmit"></param> /// <returns></returns> public bool SaveBOMBill(LBOMData lBOMmodel, DataTable data) { bool ret = false; LBOMBB lbomBB = new LBOMBB(connection); LBOMDetailBB lbomDetailBB = new LBOMDetailBB(connection); SqlTransaction trans = null; try { if (this.transaction == null) { trans = this.connection.BeginTransaction("TranSave"); lbomDetailBB.Transaction = trans; lbomBB.Transaction = trans; } else { lbomDetailBB.Transaction = this.transaction; lbomBB.Transaction = this.transaction; } if (lBOMmodel.id == 0)//新增物料清单 { #region 新增物料清单 //新增物料清单信息 int bomid = lbomBB.AddRecord(lBOMmodel); foreach (DataRow dr in data.Rows) { if (dr["isdel"].ToString() == "0")//未删除 { LBOMDetailData model = new LBOMDetailData(); model.BOMId = bomid; model.isrtDt = lBOMmodel.isrtDt; model.isrtEmpId = lBOMmodel.isrtEmpId; model.materialNo = dr["materialNo"].ToString(); model.num = Convert.ToInt32(dr["num"]); lbomDetailBB.AddRecord(model); } } #endregion 新增物料清单 } else { #region 修改物料清单信息 //修改物料清单信息 lbomBB.ModifyRecord(lBOMmodel); foreach (DataRow dr in data.Rows) { if (Convert.ToInt32(dr["id"]) > 0 && dr["isdel"].ToString() == "1")//删除方法 { lbomDetailBB.DeleteRecord(Convert.ToInt32(dr["id"])); } else if (Convert.ToInt32(dr["id"]) > 0 && dr["isdel"].ToString() == "0")//修改 { LBOMDetailData model = lbomDetailBB.GetModel(Convert.ToInt32(dr["id"])); model.BOMId = lBOMmodel.id; model.isrtDt = lBOMmodel.isrtDt; model.isrtEmpId = lBOMmodel.isrtEmpId; model.materialNo = dr["materialNo"].ToString(); model.updtDt = lBOMmodel.updtDt; model.updtEmpId = lBOMmodel.updtEmpId; model.num = Convert.ToInt32(dr["num"]); lbomDetailBB.ModifyRecord(model); } else if (Convert.ToInt32(dr["id"]) == 0 && dr["isdel"].ToString() == "0")//添加 { LBOMDetailData model = new LBOMDetailData(); model.BOMId = lBOMmodel.id; model.isrtDt = lBOMmodel.isrtDt; model.isrtEmpId = lBOMmodel.isrtEmpId; model.materialNo = dr["materialNo"].ToString(); model.num = Convert.ToInt32(dr["num"]); lbomDetailBB.AddRecord(model); } } #endregion 修改物料清单信息 } if (this.transaction == null) trans.Commit(); ret = true; } catch { if (transaction == null) trans.Rollback("TranSave"); throw new Exception("保存物料清单信息出错了!"); } finally { lbomBB.Dispose(); lbomDetailBB.Dispose(); } return ret; }