Esempio n. 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (cmbFinishProduct.Items.Count <= 0 || txtQuantity.Text.Equals(""))
                {
                    MessageBox.Show(this, "Please Select a Product and enter the Quantity", "Empty Fields", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    if (ItemSelect)
                    {
                        objDispatchProductCollec.Delete(objDispatchProduct);
                    }
                    bool ItemInList = true;
                    objFinishProduct = objFinishProductDL.Get(cmbFinishProduct.SelectedValue.ToString());
                    foreach (DispatchProducts obj in objDispatchProductCollec)
                    {
                        if (obj.DispatchFinishProduct.FinishProductCode == objFinishProduct.FinishProductCode)
                        {
                            MessageBox.Show(this, "This Product Already added to List, Please select the item from list and update", "Item Already Added", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            ItemInList = false;
                            break;
                        }
                    }
                    if (ItemInList)
                    {
                        DispatchProducts objTemp = new DispatchProducts();
                        objTemp.DispatchFinishProduct = objFinishProduct;
                        objTemp.DispatchQty           = Convert.ToDecimal(txtQuantity.Text);

                        objDispatchProductCollec.Add(objTemp);

                        ItemInList = true;
                        ClearItem();
                    }
                    else
                    {
                        if (ItemSelect)
                        {
                            objDispatchProductCollec.Add(objDispatchProduct);
                        }
                    }
                    bindProductList.DataSource = objDispatchProductCollec;
                    bindProductList.ResetBindings(false);
                }
            }
            catch (FormatException fex)
            {
                MessageBox.Show(this, "Quantity should be a Numaric value", "Invalid Type", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
 private void gvProductList_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         objDispatchProduct             = (DispatchProducts)gvProductList.Rows[e.RowIndex].DataBoundItem;
         cmbFinishProduct.SelectedValue = objDispatchProduct.DispatchFinishProduct.FinishProductCode;
         txtQuantity.Text = objDispatchProduct.DispatchQty.ToString();
         ItemSelect       = true;
         btnSave.Text     = "Save";
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }