Example #1
0
 private void AddBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (cbCategory.Text == "" || tbCode.Text == "" || tbName.Text == "" || tbVolume.Text == "" || cbUnit.Text == "" || stockNumber.Text == "" || price.Text == "" || ProductPhoto.Text == "" || cbStatu.Text == "")
         {
             lblUyarı.Text = "All fields mark with (*) are mandatory !";
         }
         else
         {
             lblUyarı.Text = "";
             if (Convert.ToInt16(tbVolume.Text) < 0 || (isValid(tbVolume.Text)))
             {
                 lblUyarı.Text = "Please, enter a valid volume !";
             }
             else
             {
                 lblUyarı.Text = "";
                 if (Convert.ToInt16(stockNumber.Text) < 0 || isValid(stockNumber.Text))
                 {
                     lblUyarı.Text = "Please, enter a valid stock number !";
                 }
                 else
                 {
                     lblUyarı.Text = "";
                     if (Convert.ToDecimal(price.Text) < 0 || isValid(price.Text))
                     {
                         lblUyarı.Text = "Please, enter a valid price !";
                     }
                     else
                     {
                         lblUyarı.Text = "";
                         if (ProductPhoto.Text == "openFileDialog")
                         {
                             lblUyarı.Text = "Please, upload a valid photo !";
                         }
                         else
                         {
                             lblUyarı.Text = "";
                             if (sellerService.CheckProductExist(new Contracts.Request.Product.CheckProductExistRequest(tbCode.Text, tbName.Text, Convert.ToInt16(tbVolume.Text), cbUnit.Text, seller.SellerID)) == false)
                             {
                                 sellerService.AddProduct(new Contracts.Request.Product.AddProductRequest(cbCategory.Text, tbCode.Text, tbName.Text, Convert.ToInt16(tbVolume.Text), cbUnit.Text, seller.SellerID, Convert.ToInt16(stockNumber.Text), Convert.ToDecimal(price.Text), ProductPhoto.Text));
                                 dataGridView.DataSource = sellerService.AllProductList(new Contracts.Request.Product.AllProductRequest(seller.SellerID));
                                 ShowAutoClosingMessageBoxInfo("Added successfull", "Successfull");
                             }
                             else
                             {
                                 lblUyarı.Text = "You have already added this product";
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }