Exemplo n.º 1
0
 private void btnCalculate_Click(object sender, EventArgs e)
 {
     if (CalculateCheck())
     {
         BAlloation     bAlloation        = new BAlloation();
         decimal        alloationQuantity = bAlloation.GetAlloationQuantity(txtWarehouse.Text.Trim(), txtProduct.Text.Trim());
         BaseStockTable stock             = new BaseStockTable();
         stock = bPurchaseOrder.GetStockModel(txtWarehouse.Text.Trim(), txtProduct.Text.Trim());
         txtNoAlloation.Text = CConvert.ToString(stock.QUANTITY - alloationQuantity);
     }
 }
Exemplo n.º 2
0
 private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.ColumnIndex == dgvData.Columns["BtnProduct"].Index)
         {
             FrmMasterSearch frm = new FrmMasterSearch("PRODUCT", "");
             if (frm.ShowDialog(this) == DialogResult.OK)
             {
                 if (frm.BaseMasterTable != null)
                 {
                     DataGridViewRow  dr           = dgvData.Rows[e.RowIndex];
                     string           code         = frm.BaseMasterTable.Code;
                     BaseProductTable productTable = bProduct.GetModel(code);
                     BaseStockTable   stock        = bStock.GetModel(txtDepartualCode.Text.Trim(), productTable.CODE);
                     BAlloation       bAlloation   = new BAlloation();
                     if (productTable != null)
                     {
                         dr.Cells["PRODUCT_CODE"].Value = productTable.CODE;
                         dr.Cells["PRODUCT_NAME"].Value = productTable.NAME;
                         decimal alloationQuantity = bAlloation.GetAlloationQuantity(txtDepartualCode.Text.Trim(), productTable.CODE);
                         dr.Cells["QUANTITY"].Value          = stock.QUANTITY - alloationQuantity;
                         dr.Cells["UNIT_NAME"].Value         = bCommon.GetBaseMaster("UNIT", productTable.BASIC_UNIT_CODE).Name;
                         dr.Cells["UNIT_CODE"].Value         = productTable.BASIC_UNIT_CODE;
                         dr.Cells["TRANSFER_QUANTITY"].Value = "1";
                     }
                     else
                     {
                         MessageBox.Show("商品不存在.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                         dr.Cells["QUANTITY"].Value = "0";
                         dr.Cells["CODE"].Selected  = true;
                     }
                 }
             }
             frm.Dispose();
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 3
0
        public void OperateInit(int currentPage)
        {
            BllProductBuildTable PBModel = bProductBuild.GetModel(_slip_number);

            txtWarehouse.Text        = PBModel.WAREHOUSE_CODE;
            txtWarehouseName.Text    = bCommon.GetBaseMaster("WAREHOUSE", PBModel.WAREHOUSE_CODE).Name;
            txtProduct.Text          = PBModel.PRODUCT_CODE;
            txtProductName.Text      = bCommon.GetBaseMaster("PRODUCT", PBModel.PRODUCT_CODE).Name;
            txtQuantity.Text         = CConvert.ToString(PBModel.QUANTITY);
            txtPossibleQuantity.Text = CConvert.ToString(PBModel.QUANTITY);
            txtFormDate.Value        = PBModel.BUILD_DATE;

            dgvData.Rows.Clear();
            //foreach (BllProductBuildLineTable LModel in PBModel.Items)
            //{
            //    int currentRowIndex = dgvData.Rows.Add(1);
            //    DataGridViewRow row = dgvData.Rows[currentRowIndex];
            //    row.Cells[1].Selected = false;
            //    row.Cells["No"].Value = LModel.LINE_NUMBER;
            //    row.Cells["PARTS_CODE"].Value = LModel.PRODUCT_PARTS_CODE;

            //    BaseProductTable product = new BaseProductTable();
            //    BProduct bProduct = new BProduct();
            //    product = bProduct.GetModel(LModel.PRODUCT_PARTS_CODE);
            //    row.Cells["PARTS_NAME"].Value = product.NAME;
            //    row.Cells["SPEC"].Value = product.SPEC;

            //    BAlloation bAlloation = new BAlloation();
            //    decimal alloationQuantity = bAlloation.GetAlloationQuantity(PBModel.WAREHOUSE_CODE, LModel.PRODUCT_PARTS_CODE);
            //    BaseStockTable stock = new BaseStockTable();
            //    stock = bPurchaseOrder.GetStockModel(PBModel.WAREHOUSE_CODE, LModel.PRODUCT_PARTS_CODE);
            //    row.Cells["NO_ALLOATION"].Value = stock.QUANTITY - alloationQuantity;
            //    row.Cells["UNIT_CODE"].Value = PBModel.UNIT_CODE;
            //    row.Cells["UNIT_NAME"].Value = bCommon.GetBaseMaster("UNIT", PBModel.UNIT_CODE).Name;

            //    row.Cells["PURCHASE_QUANTITY"].Value = LModel.PARTS_QUANTITY;

            //    row.Cells["STATUE_FLAG"].Value = "OK";

            //}
            for (int i = (currentPage - 1) * PageSize + 1; i <= PBModel.Items.Count && (i - (currentPage - 1) * PageSize) < PageSize; i++)
            {
                int             currentRowIndex = dgvData.Rows.Add(1);
                DataGridViewRow row             = dgvData.Rows[currentRowIndex];
                row.Cells[1].Selected           = false;
                row.Cells["No"].Value           = PBModel.Items[i - 1].LINE_NUMBER;
                row.Cells["PARTS_CODE"].Value   = PBModel.Items[i - 1].PRODUCT_PARTS_CODE;
                row.Cells["MIN_QUANTITY"].Value = PBModel.Items[i - 1].PARTS_QUANTITY / PBModel.QUANTITY;
                BaseProductTable product  = new BaseProductTable();
                BProduct         bProduct = new BProduct();
                product = bProduct.GetModel(PBModel.Items[i - 1].PRODUCT_PARTS_CODE);
                row.Cells["PARTS_NAME"].Value = product.NAME;
                row.Cells["SPEC"].Value       = product.SPEC;

                BAlloation     bAlloation        = new BAlloation();
                decimal        alloationQuantity = bAlloation.GetAlloationQuantity(PBModel.WAREHOUSE_CODE, PBModel.Items[i - 1].PRODUCT_PARTS_CODE);
                BaseStockTable stock             = new BaseStockTable();
                stock = bPurchaseOrder.GetStockModel(PBModel.WAREHOUSE_CODE, PBModel.Items[i - 1].PRODUCT_PARTS_CODE);
                row.Cells["NO_ALLOATION"].Value = stock.QUANTITY - alloationQuantity;
                row.Cells["UNIT_CODE"].Value    = PBModel.UNIT_CODE;
                row.Cells["UNIT_NAME"].Value    = bCommon.GetBaseMaster("UNIT", PBModel.UNIT_CODE).Name;

                row.Cells["PURCHASE_QUANTITY"].Value = PBModel.Items[i - 1].PARTS_QUANTITY;

                row.Cells["STATUE_FLAG"].Value = "OK";
            }

            if (PBModel.Items.Count < PageSize * currentPage)
            {
                dgvData.Rows.Add(PageSize - PBModel.Items.Count);
            }
        }
Exemplo n.º 4
0
        private void dgvData_CellValidated(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                DataGridViewRow dr = dgvData.Rows[e.RowIndex];
                if (e.ColumnIndex == dgvData.Columns["PRODUCT_CODE"].Index)
                {
                    string           code         = dr.Cells["PRODUCT_CODE"].Value.ToString().Trim();
                    BaseProductTable productTable = bProduct.GetModel(code);

                    if (productTable != null)
                    {
                        dr.Cells["PRODUCT_CODE"].Value = productTable.CODE;
                        dr.Cells["PRODUCT_NAME"].Value = productTable.NAME;

                        BaseStockTable stock             = bStock.GetModel(txtDepartualCode.Text.Trim(), productTable.CODE);
                        BAlloation     bAlloation        = new BAlloation();
                        decimal        alloationQuantity = bAlloation.GetAlloationQuantity(txtDepartualCode.Text.Trim(), productTable.CODE);
                        dr.Cells["QUANTITY"].Value          = stock.QUANTITY - alloationQuantity;
                        dr.Cells["UNIT_NAME"].Value         = bCommon.GetBaseMaster("UNIT", productTable.BASIC_UNIT_CODE).Name;
                        dr.Cells["UNIT_CODE"].Value         = productTable.BASIC_UNIT_CODE;
                        dr.Cells["TRANSFER_QUANTITY"].Value = "1";
                    }
                    else
                    {
                        MessageBox.Show("商品不存在.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        dr.Cells["PRODUCT_CODE"].Value      = null;
                        dr.Cells["PRODUCT_NAME"].Value      = null;
                        dr.Cells["QUANTITY"].Value          = "0";
                        dr.Cells["UNIT_NAME"].Value         = null;
                        dr.Cells["UNIT_CODE"].Value         = null;
                        dr.Cells["TRANSFER_QUANTITY"].Value = "0";
                        dr.Cells["CODE"].Selected           = true;
                    }
                }
                else if (e.ColumnIndex == dgvData.Columns["TRANSFER_QUANTITY"].Index)
                {
                    if (dr.Cells["TRANSFER_QUANTITY"].Value == null)
                    {
                        dr.Cells["TRANSFER_QUANTITY"].Value = 0;
                        MessageBox.Show("调拨数量不能为空!");
                    }
                    else
                    {
                        Int32 price;
                        if (!Int32.TryParse(CConvert.ToString(dr.Cells["TRANSFER_QUANTITY"].Value),
                                            System.Globalization.NumberStyles.Integer,
                                            System.Globalization.NumberFormatInfo.CurrentInfo, out price))
                        {
                            MessageBox.Show("调拨数量只能为整数,请重新输入!");
                            dr.Cells["TRANSFER_QUANTITY"].Value    = "0";
                            dr.Cells["TRANSFER_QUANTITY"].Selected = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show("PRODUCT_CODE");
                Logger.Error(ex.Message, ex);
            }
        }