Exemple #1
0
        private void cmbGRNNO_SelectedIndexChanged(object sender, EventArgs e)
        {
            GRNMaterials      objGRNMat    = new GRNMaterials();
            GRNBasicProducts  objGRNBasic  = new GRNBasicProducts();
            GRNFinishProducts objGRNFinish = new GRNFinishProducts();

            GRNMaterials_DL      objGRNMatDL    = new GRNMaterials_DL(ConnectionStringClass.GetConnection());
            GRNBasicProducts_DL  objGRNBasicDL  = new GRNBasicProducts_DL(ConnectionStringClass.GetConnection());
            GRNFinishProducts_DL objGRNFinishDL = new GRNFinishProducts_DL(ConnectionStringClass.GetConnection());

            GRN_DL objGRNDL = new GRN_DL(ConnectionStringClass.GetConnection());

            try
            {
                long GRNNO = 0;
                if (cmbGRNNO.Items.Count > 0 && cmbGRNNO.SelectedValue != null)
                {
                    GRNNO = Convert.ToInt64(cmbGRNNO.SelectedValue);
                }

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



                if (!ItemCode.Equals("") && !GRNNO.Equals(""))
                {
                    if (cmbMTNType.SelectedItem.Equals("Material"))
                    {
                        objGRNMat = objGRNMatDL.Get(GRNNO, ItemCode);
                        if (objGRNMat != null)
                        {
                            txtGRNUnitCost.Text  = objGRNMat.UnitPrice.ToString();
                            txtAvailableQty.Text = objGRNMatDL.Get_AvailableQty(GRNNO, ItemCode).ToString();
                            txtGRNQty.Text       = objGRNMat.NetQty.ToString();
                            //txtStockHoldingCost.Text = objGRNDL.Get_StockHoldingCost(GRNNO, objGRNMat.UnitPrice).ToString();
                        }
                    }
                    else if (cmbMTNType.SelectedItem.Equals("Basic Product"))
                    {
                        objGRNBasic = objGRNBasicDL.Get(GRNNO, ItemCode);
                        if (objGRNBasic != null)
                        {
                            txtGRNUnitCost.Text  = objGRNBasic.UnitPrice.ToString();
                            txtAvailableQty.Text = objGRNBasicDL.Get_AvailableQty(GRNNO, ItemCode).ToString();
                            txtGRNQty.Text       = objGRNBasic.NetQty.ToString();
                            //txtStockHoldingCost.Text = objGRNDL.Get_StockHoldingCost(GRNNO, objGRNBasic.UnitPrice).ToString();
                        }
                    }
                    else if (cmbMTNType.SelectedItem.Equals("Finish Product"))
                    {
                        objGRNFinish = objGRNFinishDL.Get(GRNNO, ItemCode);
                        if (objGRNFinish != null)
                        {
                            txtGRNUnitCost.Text  = objGRNFinish.UnitPrice.ToString();
                            txtAvailableQty.Text = objGRNFinishDL.Get_AvailableQty(GRNNO, ItemCode).ToString();
                            txtGRNQty.Text       = objGRNFinish.NetQty.ToString();
                            // txtStockHoldingCost.Text = objGRNDL.Get_StockHoldingCost(GRNNO, objGRNFinish.UnitPrice).ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                objGRNMat      = null;
                objGRNBasic    = null;
                objGRNFinish   = null;
                objGRNMatDL    = null;
                objGRNBasicDL  = null;
                objGRNFinishDL = null;
            }
        }