Exemple #1
0
        public GRNMaterialsCollec Get()
        {
            try
            {
                DataTable dt = Execute.RunSP_DataTable(Connection, "SPGET_GRNMaterials");

                GRNMaterialsCollec objGRNMatCollec = new GRNMaterialsCollec();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    GRNMaterials objGRNMaterial = new GRNMaterials();
                    objGRNMaterial.GRN       = objGRN_DL.Get(Convert.ToInt64(dt.Rows[i]["GRNNO"]));
                    objGRNMaterial.GrossQty  = Convert.ToDecimal(dt.Rows[i]["GrossQty"]);
                    objGRNMaterial.Material  = objMaterial_DL.Get(Convert.ToString(dt.Rows[i]["MaterialCode"]));
                    objGRNMaterial.NetQty    = Convert.ToDecimal(dt.Rows[i]["NetQty"]);
                    objGRNMaterial.Remarks   = Convert.ToString(dt.Rows[i]["Remarks"]);
                    objGRNMaterial.UnitPrice = Convert.ToDecimal(dt.Rows[i]["UnitPrice"]);


                    objGRNMatCollec.Add(objGRNMaterial);
                }

                return(objGRNMatCollec);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Exemple #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Material     objMaterial         = new Material();
            GRNMaterials objGRNMaterialsTemp = new GRNMaterials();

            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
                {
                    if (txtNetQty.Text != "0")
                    {
                        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   = "N/A";
                        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);


                        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;
            }
        }