Example #1
0
 private void btnAddProduct_Click(object sender, EventArgs e)
 {
     try
     {
         List <Product> lstProduct = gridProduct.DataSource as List <Product>;
         bool           temp       = lstProduct.Exists(p => p.ProductName.ToLower().Replace(" ", "") == txtProduct.Text.ToLower().Replace(" ", ""));
         if (!temp && !string.IsNullOrEmpty(txtProduct.Text))
         {
             Product tempProduct = new Product();
             tempProduct.ID          = string.IsNullOrEmpty(lblPidInfo.Text) ? 0 : Convert.ToInt32(lblPidInfo.Text);
             tempProduct.ProductName = txtProduct.Text;
             mngStock.CreateOrUpdateProduct(tempProduct);
             GetProductAndCompany();
             HideProductLabels();
             MessageBox.Show("This item successfully added/updated.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         Logger.WriteErrorMessage(ex);
     }
 }