コード例 #1
0
        private void cmbMRType_SelectedIndexChanged(object sender, EventArgs e)
        {
            Material      objMat    = new Material();
            BasicProduct  objBasic  = new BasicProduct();
            FinishProduct objFinish = new FinishProduct();

            bindItemList.DataSource = null;
            objMRFinishhProductCollec.Clear();
            objMRMaterialCollec.Clear();
            objMRBasicProductCollec.Clear();

            try
            {
                if (cmbMRType.SelectedItem.Equals("Material"))
                {
                    cmbItem.DataSource    = objMaterialDL.GetDataView();
                    cmbItem.DisplayMember = "Material";
                    cmbItem.ValueMember   = "MaterialCode";



                    objMat = objMaterialDL.Get(cmbItem.SelectedValue.ToString());
                    if (objMat != null)
                    {
                        lblUnit.Text = objMat.MatUnit.UnitCode;
                    }
                }
                else if (cmbMRType.SelectedItem.Equals("Basic Products"))
                {
                    cmbItem.DataSource    = objBasicProductDL.GetDataView(true);
                    cmbItem.DisplayMember = "Code";
                    cmbItem.ValueMember   = "BasicProductCode";



                    objBasic = objBasicProductDL.Get(cmbItem.SelectedValue.ToString());
                    if (objBasic != null)
                    {
                        lblUnit.Text = objBasic.BasicProductUnit.UnitCode;
                    }
                }
                else if (cmbMRType.SelectedItem.Equals("Finish Products"))
                {
                    cmbItem.DataSource    = objFinishProductDL.GetDataView(1);
                    cmbItem.DisplayMember = "Code";
                    cmbItem.ValueMember   = "FinishProductCode";


                    objFinish = objFinishProductDL.Get(cmbItem.SelectedValue.ToString());
                    if (objFinish != null)
                    {
                        lblUnit.Text = objFinish.FinishProductPackingType.PackingTitle;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        private void cmbItem_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtGRNUnitCost.Text      = "0.00";
            cmbGRNNO.Text            = "";
            txtAvailableQty.Text     = "0.00";
            txtStockHoldingCost.Text = "0.00";
            txtGRNQty.Text           = "0.00";

            Material      objMat    = new Material();
            BasicProduct  objBasic  = new BasicProduct();
            FinishProduct objFinish = new FinishProduct();
            Store         objStore  = new Store();

            try
            {
                String ItemCode = "";
                txtUnit.Text = "";
                if (cmbItem.Items.Count > 0 && cmbItem.SelectedValue != null)
                {
                    ItemCode = cmbItem.SelectedValue.ToString();
                }


                if (cmbStoreFrom.Items.Count > 0)
                {
                    objStore = (Store)cmbStoreFrom.SelectedItem;
                }

                if (!ItemCode.Equals(""))
                {
                    if (cmbMTNType.SelectedItem.Equals("Material"))
                    {
                        cmbGRNNO.DataSource = objGRNDL.Get_GEN_BY_Material(ItemCode, objStore.StoreID);
                        objMat       = objMaterialDL.Get(ItemCode);
                        txtUnit.Text = objMat.MatUnit.UnitName;
                    }
                    else if (cmbMTNType.SelectedItem.Equals("Basic Product"))
                    {
                        cmbGRNNO.DataSource = objGRNDL.Get_GEN_BY_BasicProduct(ItemCode, objStore.StoreID);
                        objBasic            = objBasicProductDL.Get(ItemCode);
                        txtUnit.Text        = objBasic.BasicProductUnit.UnitName;
                    }
                    else if (cmbMTNType.SelectedItem.Equals("Finish Product"))
                    {
                        cmbGRNNO.DataSource = objGRNDL.Get_GEN_BY_FinishProduct(ItemCode, objStore.StoreID);
                        objFinish           = objFinishProductDL.Get(ItemCode);
                        txtUnit.Text        = objFinish.FinishProductPackingType.PackingTitle;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
 private void cmbFinishProduct_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         objFinishProduct = objFinishProductDL.Get(cmbFinishProduct.SelectedValue.ToString());
         lblUnit.Text     = objFinishProduct.FinishProductPackingType.PackingTitle;
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #4
0
        private void cmbItem_SelectedIndexChanged(object sender, EventArgs e)
        {
            //txtGRNUnitCost.Text = "0.0";
            //  cmbGRNNO.Text = "";

            Material      objMat     = new Material();
            BasicProduct  objBasic   = new BasicProduct();
            FinishProduct objFinish  = new FinishProduct();
            Store         objStore   = new Store();
            Stock_DL      objStockDL = new Stock_DL(ConnectionStringClass.GetConnection());


            try
            {
                String ItemCode = "";
                txtUnit.Text         = "";
                txtAvailableQty.Text = "";
                if (cmbItem.Items.Count > 0 && cmbItem.SelectedValue != null)
                {
                    ItemCode = cmbItem.SelectedValue.ToString();

                    objStore = (Store)cmbStoreFrom.SelectedItem;
                    if (cmbMTNType.SelectedItem.Equals("Material"))
                    {
                        objMat       = objMaterialDL.Get(ItemCode);
                        txtUnit.Text = objMat.MatUnit.UnitName;
                        //txtGRNUnitCost.Text = objStockDL.GetAVGUnitPrice_Material(objStore.StoreID, ItemCode).ToString();
                        txtAvailableQty.Text = objStockDL.GetAvailableQty(objStore.StoreID, ItemCode, Stock.Type.Material).ToString();
                    }
                    else if (cmbMTNType.SelectedItem.Equals("Basic Product"))
                    {
                        objBasic     = objBasicProductDL.Get(ItemCode);
                        txtUnit.Text = objBasic.BasicProductUnit.UnitName;
                        //txtGRNUnitCost.Text = objStockDL.GetAVGUnitPrice_BasicProduct(objStore.StoreID, ItemCode).ToString();
                        txtAvailableQty.Text = objStockDL.GetAvailableQty(objStore.StoreID, ItemCode, Stock.Type.BasicProduct).ToString();
                    }
                    else if (cmbMTNType.SelectedItem.Equals("Finish Product"))
                    {
                        objFinish    = objFinishProductDL.Get(ItemCode);
                        txtUnit.Text = objFinish.FinishProductPackingType.PackingTitle;
                        //txtGRNUnitCost.Text = objStockDL.GetAVGUnitPrice_FinishProduct(objStore.StoreID, ItemCode).ToString();
                        txtAvailableQty.Text = objStockDL.GetAvailableQty(objStore.StoreID, ItemCode, Stock.Type.FinishProduct).ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #5
0
        private void dgvProductListSecondary_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                objFinishProductSec = objFinishProductDL.Get(dgvProductListSecondary.CurrentRow.Cells["ProductCode"].Value.ToString());

                txtSecondaryProduct.Text = objFinishProductSec.FinishProductCode;
                txtDescriptionSec.Text   = objFinishProductSec.FinishProductDescription;
                txtPrimaryQty.Text       = objFinishProductSec.PrimaryFinishProductQty.ToString();
                txtPeiceRateSec.Text     = objFinishProductSec.FinishProductAvgCost.ToString();

                txtSecondaryProductCode.Text = dgvProductListSecondary.CurrentRow.Cells["ProductCode"].Value.ToString();

                Load_TertiaryProductList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #6
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Store objStore = new Store();

            objStore.StoreID = CurrStore;
            objDepTo         = objDepartmentDL.Get(25);
            objDepFrom       = objDepartmentDL.Get(25);

            //objMTN.MTNDate = DateTime.Now;
            //objMTN.MTNApprovedBy = null;
            objMTN.MTNDepartmentFrom = objDepFrom;
            objMTN.MTNDepartmentTo   = objDepTo;
            objMTN.MTNEnterdBy       = CurrentUser.UserEmp;
            objMTN.MTNStatus         = MTN.Status.Initial;
            objMTN.MTNType           = MTN.Type.Dispose;
            objMTN.MTNStore          = objStore;
            objMTN.MTNItemType       = MTN.ItemType.Finish_Product;

            objMTN.MTNItemType = MTN.ItemType.Finish_Product;

            objMTN.MTNNo = objMTNDL.Add_FinishedGoodsReturns(objMTN);


            //objMTN.MTNNo =
            //objMTNDL.Add(objMTN);

            if (objMTN.MTNNo > 0)
            {
                foreach (DataGridViewRow dr in dgvProduct.Rows)
                {
                    String tempproductCode = dr.Cells[0].Value.ToString();
                    String tempproduct     = dr.Cells[1].Value.ToString();
                    long   tempqty         = Convert.ToInt64(dr.Cells[2].Value.ToString());
                    string tempstore       = dr.Cells[3].Value.ToString();


                    objFinishProduct = objFinishProductDL.Get(tempproductCode);
                    //objMTNFinish.Batch = "No";
                    //objMTNFinish.Description = "No";
                    objMTNFinish.FinishProduct   = objFinishProduct;
                    objMTNFinish.MTN             = objMTN;
                    objMTNFinish.ReceivedQty     = 0;
                    objMTNFinish.UnitRate        = 0;
                    objMTNFinish.UnitRate_Budget = 0;
                    objMTNFinish.TransferQty     = tempqty;
                    objMTNFinisProductDL.Add(objMTNFinish);
                }
                MessageBox.Show(this, "Successfully Saved, MTN No is " + objMTN.MTNNo, "Successfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
        }
コード例 #7
0
        private void dgvActivity_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                FinishProduct objFinishProduct = new FinishProduct();

                objFinishProduct = objFinishProduct_DL.Get(dgvActivityz.CurrentRow.Cells["PrimaryFinishProduct"].Value.ToString());


                objBatchActivity = objBatchActivity_DL.GetByID(Convert.ToInt32(dgvActivityz.CurrentRow.Cells["BatchActID"].Value));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
コード例 #8
0
        public string Save_STDBatch()
        {
            try
            {
                objStdBatch.STDBatchDescription  = txtRemarks.Text;
                objStdBatch.STDBatchInstructedBy = CurrentUser.UserEmp;
                objStdBatch.STDBatchSize         = Convert.ToDecimal(txtBatchSize.Text);
                objStdBatch.STDInstructedDate    = DateTime.Now;
                objStdBatch.STDDuration          = Convert.ToDecimal(txtBatchDuration.Text);

                if (cmbProductType.SelectedIndex == 0 || cmbProductType.SelectedIndex == 1)
                {
                    BasicProduct objBasic = objBasicProductDL.Get(cmbProductCode.SelectedValue.ToString());

                    objStdBatch.STDBatchBasicProduct  = objBasic;
                    objStdBatch.STDBatchFinishProduct = new FinishProduct();
                    objStdBatch.STDBatchType          = "Basic";

                    objStdBatch.STDBatchID = objSTDBatchDL.Add_Basic(objStdBatch);
                }
                else if (cmbProductType.SelectedIndex == 2)
                {
                    FinishProduct objFinish = objFinishProductDL.Get(cmbProductCode.SelectedValue.ToString());
                    objStdBatch.STDBatchBasicProduct  = new BasicProduct();
                    objStdBatch.STDBatchFinishProduct = objFinish;
                    objStdBatch.STDBatchType          = "Finish";
                }



                return(objStdBatch.STDBatchID);
            }
            catch (FormatException fex)
            {
                MessageBox.Show(this, "Invalid Data, Please check Standard Batch Size and Duration", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return("No");
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return("No");
            }
        }
コード例 #9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            DispatchNoteList objRemove = new DispatchNoteList();

            DispatchNoteList obj = new DispatchNoteList();


            if ((txtDiaptchNote.Text != "") && (cmbProductCode.SelectedValue != null) && (txtIssuedQty.Text != ""))
            {
                if (DataValidation.IsNumericNumber(txtIssuedQty.Text))
                {
                    if (txtBatchID.Text != "")
                    {
                        obj.BatchNo = txtBatchID.Text;
                    }
                    else
                    {
                        obj.BatchNo = "No";
                    }

                    obj.DispatchID    = txtDiaptchNote.Text;
                    obj.FinishProduct = Convert.ToString(cmbProductCode.SelectedValue);
                    obj.Qty           = Convert.ToUInt32(txtIssuedQty.Text);
                    obj.ProductName   = objFinishProduct_DL.Get(obj.FinishProduct).FinishProductDescription;

                    objCollec.Add(obj);
                }
                else
                {
                    MessageBox.Show(this, "please enter valid quantity", "MRP System", MessageBoxButtons.OK);
                }
            }
            else
            {
                MessageBox.Show("Please Fill All Fields");
            }

            gvProductList.AutoGenerateColumns = false;
            objSource.DataSource     = objCollec;
            gvProductList.DataSource = objSource;
            objSource.ResetBindings(true);
        }
コード例 #10
0
        private void dgvActivity_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                FinishProduct objFinishProduct = new FinishProduct();

                objFinishProduct = objFinishProduct_DL.Get(dgvActivity.CurrentRow.Cells["SecondaryFinishProduct"].Value.ToString());



                objBatchActivity = objBatchActivity_DL.GetByID(Convert.ToInt32(dgvActivity.CurrentRow.Cells["BatchActID"].Value));

                btnSendToStore.Enabled = true;

                txtProductCode.Text = objFinishProduct.FinishProductCode;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
コード例 #11
0
        private void dgvActivity_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                FinishProduct objFinishProduct = new FinishProduct();

                objFinishProduct = objFinishProduct_DL.Get(dgvActivity.CurrentRow.Cells["SecondaryFinishProduct"].Value.ToString());



                objBatchActivity = objBatchActivity_DL.GetByID(Convert.ToInt32(dgvActivity.CurrentRow.Cells["BatchActID"].Value));

                Load_BatchLabourDetails();
                Load_BatchMachineDetails();

                txtProductCode.Text = objFinishProduct.FinishProductCode;
                txtTransferQty.Text = objBatchActivity.StopQty.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
コード例 #12
0
        private void btnItemAdd_Click(object sender, EventArgs e)
        {
            if (txtQty.Text.Equals(""))
            {
                MessageBox.Show(this, "Please fill the quantity field", "Empty Field", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                bool            ItemList = false;
                MRFinishProduct objMRMat = new MRFinishProduct();

                try
                {
                    if (ItemSelect)
                    {
                        objMRMat.Description   = txtDescription.Text;
                        objMRMat.FinishProduct = objFinishProduct_DL.Get(cmbItem.SelectedValue.ToString());
                        objMRMat.ReqdQty       = Convert.ToDecimal(txtQty.Text);
                        objMRMat.MRBINNo       = "N/A";


                        if (objMRFinishProduct.FinishProduct.FinishProductCode != objMRMat.FinishProduct.FinishProductCode)
                        {
                            foreach (MRFinishProduct obj in objMRFinishProductCollec)
                            {
                                if (obj.FinishProduct.FinishProductCode == objMRMat.FinishProduct.FinishProductCode)
                                {
                                    MessageBox.Show(this,
                                                    "This item already in the list,Please Select the item from List and Update",
                                                    "Item in the List",
                                                    MessageBoxButtons.OK,
                                                    MessageBoxIcon.Information);

                                    ItemList = true;
                                    break;
                                }
                            }
                            if (!ItemList)
                            {
                                objMRFinishProductCollec.Delete(objMRFinishProduct);
                                objMRFinishProductCollec.Add(objMRMat);
                                ClearItem();
                            }
                        }
                        else
                        {
                            objMRFinishProductCollec.Delete(objMRFinishProduct);
                            objMRFinishProductCollec.Add(objMRMat);
                            ClearItem();
                        }


                        bindItemList.DataSource = objMRFinishProductCollec;
                        bindItemList.ResetBindings(false);
                    }
                    else
                    {
                        objMRMat.Description   = txtDescription.Text;
                        objMRMat.FinishProduct = objFinishProduct_DL.Get(cmbItem.SelectedValue.ToString());
                        objMRMat.ReqdQty       = Convert.ToDecimal(txtQty.Text);

                        objMRMat.MRBINNo = "N/A";

                        if (objMRFinishProductCollec.Count > 0)
                        {
                            foreach (MRFinishProduct obj in objMRFinishProductCollec)
                            {
                                if (obj.FinishProduct.FinishProductCode == objMRMat.FinishProduct.FinishProductCode)
                                {
                                    MessageBox.Show(this, "This item already in the list,Please Select the item from List and Update", "Item in the List", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    ItemList = true;
                                    break;
                                }
                            }
                            if (!ItemList)
                            {
                                objMRFinishProductCollec.Add(objMRMat);
                                ClearItem();
                            }
                        }
                        else
                        {
                            objMRFinishProductCollec.Add(objMRMat);
                            ClearItem();
                        }
                        bindItemList.DataSource = objMRFinishProductCollec;
                        bindItemList.ResetBindings(false);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    objMRMat = null;
                }
            }
        }
コード例 #13
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            BasicProduct  objBasic         = new BasicProduct();
            FinishProduct objFinishProduct = new FinishProduct();
            Material      objMaterial      = new Material();

            GRNMaterials      objGRNMaterialsTemp     = new GRNMaterials();
            GRNBasicProducts  objGRNBasicProductTemp  = new GRNBasicProducts();
            GRNFinishProducts objGRNFinishProductTemp = new GRNFinishProducts();

            bool ItemInList = false;

            try
            {
                if (txtNetQty.Text.Equals("") || txtUnitCost.Text.Equals(""))
                {
                    MessageBox.Show(this, "Please Fill all fields", "Empty Fields", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    bool Quantity = true;

                    if (Quantity)
                    {
                        if (objGRN.GRNType == GRN.Type.Material)
                        {
                            if (ItemSelect)
                            {
                                objGRNMaterialsCollec.Delete(objGRNMaterials);
                            }
                            objMaterial = objMaterialDL.Get(cmbItem.SelectedValue.ToString());

                            objGRNMaterialsTemp.Material = objMaterial;

                            objGRNMaterialsTemp.GrossQty = Convert.ToDecimal(txtNetQty.Text);
                            objGRNMaterialsTemp.NetQty   = Convert.ToDecimal(txtNetQty.Text);


                            objGRNMaterialsTemp.Remarks   = txtRemarks.Text;
                            objGRNMaterialsTemp.UnitPrice = Convert.ToDecimal(txtUnitCost.Text);
                            foreach (GRNMaterials obj in objGRNMaterialsCollec)
                            {
                                if (obj.Material.MaterialCode == objMaterial.MaterialCode)
                                {
                                    MessageBox.Show(this, "This item already added to the list, You can't add same item repeatedly to a GRN. If you want GRN same item again Please create a another GRN", "Item already Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    ItemInList = true;
                                    break;
                                }
                            }
                            if (!ItemInList)
                            {
                                objGRNMaterialsCollec.Add(objGRNMaterialsTemp);
                                bindItemList.DataSource = objGRNMaterialsCollec;
                                ClearItem();
                            }
                            ItemInList = false;
                            bindItemList.ResetBindings(false);
                        }
                        else if (objGRN.GRNType == GRN.Type.BasicProduct)
                        {
                            if (ItemSelect)
                            {
                                objGRNBasicProductCollec.Delete(objGRNBasicProduct);
                            }
                            objBasic = objBasicProductDL.Get(cmbItem.SelectedValue.ToString());
                            objGRNBasicProductTemp.GrossQty     = Convert.ToDecimal(txtNetQty.Text);
                            objGRNBasicProductTemp.BasicProduct = objBasic;
                            objGRNBasicProductTemp.NetQty       = Convert.ToDecimal(txtNetQty.Text);
                            objGRNBasicProductTemp.Remarks      = txtRemarks.Text;
                            objGRNBasicProductTemp.UnitPrice    = Convert.ToDecimal(txtUnitCost.Text);
                            foreach (GRNBasicProducts obj in objGRNBasicProductCollec)
                            {
                                if (obj.BasicProduct.BasicProductCode == objBasic.BasicProductCode)
                                {
                                    MessageBox.Show(this, "This item already added to the list, You can't add same item repeatedly to a GRN. If you want GRN same item again Please create a another GRN", "Item already Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    ItemInList = true;
                                    break;
                                }
                            }
                            if (!ItemInList)
                            {
                                objGRNBasicProductCollec.Add(objGRNBasicProductTemp);
                                bindItemList.DataSource = objGRNBasicProductCollec;
                                ClearItem();
                            }
                            ItemInList = false;
                            bindItemList.ResetBindings(false);
                        }
                        else if (objGRN.GRNType == GRN.Type.FinishProduct)
                        {
                            if (ItemSelect)
                            {
                                objGRNFinishProductCollec.Delete(objGRNFinishProduct);
                            }
                            objFinishProduct = objFinishProductDL.Get(cmbItem.SelectedValue.ToString());
                            objGRNFinishProductTemp.GrossQty       = Convert.ToDecimal(txtNetQty.Text);
                            objGRNFinishProductTemp.FinishProducts = objFinishProduct;
                            objGRNFinishProductTemp.NetQty         = Convert.ToDecimal(txtNetQty.Text);
                            objGRNFinishProductTemp.Remarks        = txtRemarks.Text;
                            objGRNFinishProductTemp.UnitPrice      = Convert.ToDecimal(txtUnitCost.Text);
                            foreach (GRNFinishProducts obj in objGRNFinishProductCollec)
                            {
                                if (obj.FinishProducts.FinishProductCode == objFinishProduct.FinishProductCode)
                                {
                                    MessageBox.Show(this, "This item already added to the list, You can't add same item repeatedly to a GRN. If you want GRN same item again Please create a another GRN", "Item already Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    ItemInList = true;
                                    break;
                                }
                            }
                            if (!ItemInList)
                            {
                                objGRNFinishProductCollec.Add(objGRNFinishProductTemp);
                                bindItemList.DataSource = objGRNFinishProductCollec;
                                ClearItem();
                            }
                            ItemInList = false;
                            bindItemList.ResetBindings(false);
                        }
                    }
                }
            }
            catch (FormatException fex)
            {
                MessageBox.Show(this, fex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objMaterial      = null;
                objBasic         = null;
                objFinishProduct = null;
            }
        }
コード例 #14
0
        private void cmbBasicProductCode_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtPackType.Visible     = false;
            lblPackType.Visible     = false;
            txtBasicProduct.Visible = false;
            txtBasicQty.Visible     = false;
            lblBasic.Visible        = false;
            lblBasicQty.Visible     = false;

            txtBasicProduct.Text = "";
            txtBasicQty.Text     = "";
            txtCatergory.Text    = "";
            txtPackType.Text     = "";
            txtProductCode.Text  = "";
            txtProductName.Text  = "";
            txtProductType.Text  = "";
            txtProductUnit.Text  = "";
            txtSubCatergory.Text = "";


            txtFinishProductQty.Text = "0.00";
            txtBasicProductQty.Text  = "0.00";
            txtMaterialQty.Text      = "0.00";

            cmbFinishPart.SelectedIndex   = -1;
            cmbBasicPart.SelectedIndex    = -1;
            cmbMaterialPart.SelectedIndex = -1;

            try
            {
                if (cmbProductCode.Items.Count > 0 && cmbProductCode.SelectedItem != null)
                {
                    if (cmbProductType.SelectedIndex == 0)
                    {
                        objBasicProduct      = objBasicProductDL.Get(cmbProductCode.SelectedValue.ToString());
                        txtCatergory.Text    = objBasicProduct.BasicProductCategory.Category;
                        txtProductCode.Text  = objBasicProduct.BasicProductCode;
                        txtProductName.Text  = objBasicProduct.BasicProductDescription;
                        txtProductType.Text  = objBasicProduct.BasicProductType;
                        txtProductUnit.Text  = objBasicProduct.BasicProductUnit.UnitCode;
                        txtSubCatergory.Text = objBasicProduct.BasicProductSubCategory.Category;
                        objFormula           = objBasicProduct.BasicProductFormula;
                        if (objBasicProduct.BasicProductFormula.FormulaID == 0)
                        {
                            objFormula.FormulaInstructedBy   = CurrentUser.UserEmp;
                            objFormula.FormulaInstructedDate = DateTime.Now;
                            objFormula.FormulaQty            = 1000;
                            objFormula.FormulaUnit           = objBasicProduct.BasicProductUnit;
                            long formulaID = objFormulaDL.Add(objFormula);
                            if (formulaID > 0)
                            {
                                objFormula.FormulaID = formulaID;
                                objBasicProduct.BasicProductFormula = objFormula;
                                objBasicProductDL.Update(objBasicProduct, objBasicProduct.BasicProductCode);
                            }
                            else
                            {
                                MessageBox.Show(this, "There are was an error occured while initializing the Formula, Please Try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }

                        bindItemList.DataSource = objFormulaDL.GetDataView_Items(objBasicProduct.BasicProductFormula.FormulaID);
                    }
                    else if (cmbProductType.SelectedIndex == 1)
                    {
                        objBasicProduct      = objBasicProductDL.Get(cmbProductCode.SelectedValue.ToString());
                        txtCatergory.Text    = objBasicProduct.BasicProductCategory.Category;
                        txtProductCode.Text  = objBasicProduct.BasicProductCode;
                        txtProductName.Text  = objBasicProduct.BasicProductDescription;
                        txtProductType.Text  = objBasicProduct.BasicProductType;
                        txtProductUnit.Text  = objBasicProduct.BasicProductUnit.UnitCode;
                        txtSubCatergory.Text = objBasicProduct.BasicProductSubCategory.Category;
                        objFormula           = objBasicProduct.BasicProductFormula;
                        if (objBasicProduct.BasicProductFormula.FormulaID == 0)
                        {
                            objFormula.FormulaInstructedBy   = CurrentUser.UserEmp;
                            objFormula.FormulaInstructedDate = DateTime.Now;
                            objFormula.FormulaQty            = 1000;
                            objFormula.FormulaUnit           = objBasicProduct.BasicProductUnit;
                            long formulaID = objFormulaDL.Add(objFormula);
                            if (formulaID > 0)
                            {
                                objFormula.FormulaID = formulaID;
                                objBasicProduct.BasicProductFormula = objFormula;
                                objBasicProductDL.Update(objBasicProduct, objBasicProduct.BasicProductCode);
                            }
                            else
                            {
                                MessageBox.Show(this, "There are was an error occured while initializing the Formula, Please Try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        bindItemList.DataSource = objFormulaDL.GetDataView_Items(objBasicProduct.BasicProductFormula.FormulaID);
                    }
                    else if (cmbProductType.SelectedIndex == 2)
                    {
                        objFinishProduct        = objFinishProductDL.Get(cmbProductCode.SelectedValue.ToString());
                        txtPackType.Visible     = true;
                        lblPackType.Visible     = true;
                        txtBasicProduct.Visible = true;
                        txtBasicQty.Visible     = true;
                        lblBasic.Visible        = true;
                        lblBasicQty.Visible     = true;

                        txtCatergory.Text    = objFinishProduct.BasicProduct.BasicProductCategory.Category;
                        txtPackType.Text     = objFinishProduct.FinishProductPackingType.PackingTitle;
                        txtProductCode.Text  = objFinishProduct.FinishProductCode;
                        txtProductName.Text  = objFinishProduct.FinishProductDescription;
                        txtProductType.Text  = "Finish";
                        txtProductUnit.Text  = "N/A";
                        txtBasicProduct.Text = objFinishProduct.BasicProduct.Code;
                        txtBasicQty.Text     = objFinishProduct.BasicProductQty.ToString();
                        txtSubCatergory.Text = objFinishProduct.BasicProduct.BasicProductSubCategory.Category;
                        objFormula           = objFinishProduct.FinishProductFormula;
                        if (objFormula.FormulaID == 0)
                        {
                            objFormula.FormulaInstructedBy   = CurrentUser.UserEmp;
                            objFormula.FormulaInstructedDate = DateTime.Now;
                            objFormula.FormulaQty            = 1000;
                            long formulaID = objFormulaDL.Add_FG(objFormula);
                            if (formulaID > 0)
                            {
                                objFormula.FormulaID = formulaID;
                                objFinishProduct.FinishProductFormula = objFormula;
                                objFinishProductDL.Update(objFinishProduct, objFinishProduct.FinishProductCode);
                            }
                            else
                            {
                                MessageBox.Show(this, "There are was an error occured while initializing the Formula, Please Try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }

                        bindItemList.DataSource = objFormulaDL.GetDataView_Items(objFinishProduct.FinishProductFormula.FormulaID);
                    }

                    bindBasicProduct.DataSource  = objFormulaBasicProductDL.GetDataView_FormulaID(objFormula.FormulaID);
                    bindFinishProduct.DataSource = objFormulaFinishProductDL.GetDataView_FormulaID(objFormula.FormulaID);
                    bindMaterialList.DataSource  = objFormulaMaterialDL.GetDataView_FormulaID(objFormula.FormulaID);
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }