private void btnRelieve_Click(object sender, EventArgs e) { if (RelieveCheck()) { BllProductBuildTable PBModel = new BllProductBuildTable(); BllProductBuildLineTable PBLModel = null; int i = 1; PBModel.SLIP_NUMBER = CConvert.ToString(CConvert.ToInt32(bProductBuild.GetBuildMaxSlipNumber()) + 1).PadLeft(4, '0'); BaseProductTable product = bProduct.GetModel(txtProduct.Text.Trim()); PBModel.PRODUCT_CODE = txtProduct.Text.Trim(); PBModel.WAREHOUSE_CODE = txtWarehouse.Text.Trim(); PBModel.QUANTITY = CConvert.ToDecimal(txtRelieveQuantity.Text.Trim()); PBModel.COMPANY_CODE = _userInfo.COMPANY_CODE; PBModel.BUILD_DATE = txtSlipDate.Value; BaseStockTable stock = new BaseStockTable(); stock = bPurchaseOrder.GetStockModel(txtWarehouse.Text.Trim(), txtProduct.Text.Trim()); PBModel.UNIT_CODE = stock.UNIT_CODE; PBModel.STATUS_FLAG = CConstant.RELIEVE_STATUS; PBModel.CREATE_USER = _userInfo.CODE; PBModel.LAST_UPDATE_USER = _userInfo.CODE; DataSet ds = bProductBuild.getParts(txtProduct.Text.Trim()); foreach (DataRow row in ds.Tables[0].Rows) { PBLModel = new BllProductBuildLineTable(); PBLModel.SLIP_NUMBER = PBModel.SLIP_NUMBER; PBLModel.LINE_NUMBER = i; PBLModel.PRODUCT_PARTS_CODE = CConvert.ToString(row["PRODUCT_PART_CODE"]); PBLModel.PARTS_QUANTITY = CConvert.ToDecimal(row["QUANTITY"]) * PBModel.QUANTITY; BaseStockTable stock1 = new BaseStockTable(); stock1 = bPurchaseOrder.GetStockModel(txtWarehouse.Text.Trim(), PBLModel.PRODUCT_PARTS_CODE); PBLModel.UNIT_CODE = stock1.UNIT_CODE; PBLModel.STATUS_FLAG = CConstant.INIT_STATUS; if (PBLModel.SLIP_NUMBER != null) { PBModel.AddItem(PBLModel); } i++; } int result = 0; try { result = bProductBuild.AddRelieve(PBModel); if (result <= 0) { string errorLog = "解除失败,请重试或与管理员联系."; MessageBox.Show(errorLog, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { txtWarehouse.Text = ""; txtWarehouseName.Text = ""; txtProduct.Text = ""; txtProductName.Text = ""; txtNoAlloation.Text = ""; txtRelieveQuantity.Text = ""; txtSlipDate.Value = DateTime.Now; MessageBox.Show("保存成功", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("保存失败,系统错误,请与管理员联系.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); Logger.Error("组成失败!", ex); } } }
public BllProductBuildTable GetModel(string SLIP_NUMBER) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 SLIP_NUMBER,WAREHOUSE_CODE,PRODUCT_CODE,QUANTITY,BUILD_DATE,COMPANY_CODE,UNIT_CODE,STATUS_FLAG,CREATE_USER,CREATE_DATE_TIME,LAST_UPDATE_TIME,LAST_UPDATE_USER from BLL_PRODUCT_BUILD "); strSql.Append(" where SLIP_NUMBER=@SLIP_NUMBER "); SqlParameter[] parameters = { new SqlParameter("@SLIP_NUMBER", SqlDbType.VarChar, 50) }; parameters[0].Value = SLIP_NUMBER; BllProductBuildTable PBModel = new BllProductBuildTable(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { PBModel.SLIP_NUMBER = ds.Tables[0].Rows[0]["SLIP_NUMBER"].ToString(); PBModel.WAREHOUSE_CODE = ds.Tables[0].Rows[0]["WAREHOUSE_CODE"].ToString(); PBModel.PRODUCT_CODE = ds.Tables[0].Rows[0]["PRODUCT_CODE"].ToString(); if (ds.Tables[0].Rows[0]["QUANTITY"].ToString() != "") { PBModel.QUANTITY = decimal.Parse(ds.Tables[0].Rows[0]["QUANTITY"].ToString()); } if (ds.Tables[0].Rows[0]["BUILD_DATE"].ToString() != "") { PBModel.BUILD_DATE = DateTime.Parse(ds.Tables[0].Rows[0]["BUILD_DATE"].ToString()); } PBModel.COMPANY_CODE = ds.Tables[0].Rows[0]["COMPANY_CODE"].ToString(); PBModel.UNIT_CODE = ds.Tables[0].Rows[0]["UNIT_CODE"].ToString(); if (ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString() != "") { PBModel.STATUS_FLAG = int.Parse(ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString()); } PBModel.CREATE_USER = ds.Tables[0].Rows[0]["CREATE_USER"].ToString(); if (ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString() != "") { PBModel.CREATE_DATE_TIME = DateTime.Parse(ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString()); } if (ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString() != "") { PBModel.LAST_UPDATE_TIME = DateTime.Parse(ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString()); } PBModel.LAST_UPDATE_USER = ds.Tables[0].Rows[0]["LAST_UPDATE_USER"].ToString(); strSql = new StringBuilder(); strSql.Append("select SLIP_NUMBER,LINE_NUMBER,PRODUCT_PARTS_CODE,PARTS_QUANTITY,UNIT_CODE,STATUS_FLAG from BLL_PRODUCT_BUILD_LINE "); strSql.Append(" where SLIP_NUMBER=@SLIP_NUMBER "); SqlParameter[] lineParam = { new SqlParameter("@SLIP_NUMBER", SqlDbType.VarChar, 50) }; lineParam[0].Value = SLIP_NUMBER; ds = DbHelperSQL.Query(strSql.ToString(), lineParam); BllProductBuildLineTable LModel = null; foreach (DataRow row in ds.Tables[0].Rows) { LModel = new BllProductBuildLineTable(); LModel.SLIP_NUMBER = row["SLIP_NUMBER"].ToString(); LModel.LINE_NUMBER = CConvert.ToInt32(row["LINE_NUMBER"]); LModel.PRODUCT_PARTS_CODE = row["PRODUCT_PARTS_CODE"].ToString(); LModel.PARTS_QUANTITY = CConvert.ToDecimal(row["PARTS_QUANTITY"].ToString()); LModel.UNIT_CODE = row["UNIT_CODE"].ToString(); LModel.STATUS_FLAG = CConvert.ToInt32(row["STATUS_FLAG"].ToString()); if (LModel.SLIP_NUMBER != null) { PBModel.AddItem(LModel); } } return(PBModel); } else { return(null); } }
private void btnSave_Click(object sender, EventArgs e) { if (isSearch) { if (saveCheck()) { BllProductBuildTable PBModel = new BllProductBuildTable(); BllProductBuildLineTable PBLModel = null; //组成编号 PBModel.SLIP_NUMBER = CConvert.ToString(CConvert.ToInt32(bProductBuild.GetBuildMaxSlipNumber()) + 1).PadLeft(4, '0'); //仓库 PBModel.WAREHOUSE_CODE = txtWarehouse.Text.Trim(); PBModel.PRODUCT_CODE = txtProduct.Text.Trim(); PBModel.QUANTITY = CConvert.ToDecimal(txtQuantity.Text.Trim()); PBModel.BUILD_DATE = txtFormDate.Value; PBModel.COMPANY_CODE = _userInfo.COMPANY_CODE; BaseStockTable stock = new BaseStockTable(); stock = bPurchaseOrder.GetStockModel(txtWarehouse.Text.Trim(), txtProduct.Text.Trim()); PBModel.UNIT_CODE = stock.UNIT_CODE; PBModel.STATUS_FLAG = CConstant.BUILD_STATUS; PBModel.CREATE_USER = _userInfo.CODE; PBModel.LAST_UPDATE_USER = _userInfo.CODE; foreach (DataGridViewRow row in dgvData.Rows) { if (row.Cells["PARTS_CODE"].Value != null) { PBLModel = new BllProductBuildLineTable(); PBLModel.SLIP_NUMBER = PBModel.SLIP_NUMBER; PBLModel.LINE_NUMBER = row.Index + 1; PBLModel.PRODUCT_PARTS_CODE = CConvert.ToString(row.Cells["PARTS_CODE"].Value); PBLModel.PARTS_QUANTITY = CConvert.ToDecimal(row.Cells["MIN_QUANTITY"].Value) * PBModel.QUANTITY; PBLModel.UNIT_CODE = CConvert.ToString(row.Cells["UNIT_CODE"].Value); PBLModel.STATUS_FLAG = CConstant.INIT; if (PBLModel.SLIP_NUMBER != null) { PBModel.AddItem(PBLModel); } } } int result = 0; try { result = bProductBuild.AddBuild(PBModel); if (result <= 0) { string errorLog = "保存失败,请重试或与管理员联系."; MessageBox.Show(errorLog, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { dgvData.Rows.Clear(); init(); txtWarehouse.Text = ""; txtWarehouseName.Text = ""; txtProduct.Text = ""; txtProductName.Text = ""; txtQuantity.Text = ""; txtPossibleQuantity.Text = ""; txtFormDate.Value = DateTime.Now; MessageBox.Show("保存成功", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("保存失败,系统错误,请与管理员联系.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); Logger.Error("组成失败!", ex); } } } }