public void AddNewItem() { if (!string.IsNullOrEmpty(TxtSKUNum.Text.Trim())) { cloth.SKUNumber = TxtSKUNum.Text.Trim(); if (!string.IsNullOrEmpty(TxtColor.Text.Trim())) { cloth.Color = TxtColor.Text.Trim(); if (!string.IsNullOrEmpty(TxtSize.Text.Trim())) { cloth.Size = TxtSize.Text.Trim(); if (!string.IsNullOrEmpty(TxtName.Text.Trim())) { cloth.Name = TxtName.Text.Trim(); int Result = dal.AddNewCloth(cloth); if (Result > 0) { MessageBox.Show("New Item Added Successfully"); LoadDGV(); HideTextBoxes(); } else { MessageBox.Show("Something went Wrong"); } } else { MessageBox.Show("Product Name cannot be empty"); TxtName.Focus(); } } else { MessageBox.Show("Size cannot be empty"); TxtSize.Focus(); } } else { MessageBox.Show("Color cannot be empty"); TxtColor.Focus(); } } else { MessageBox.Show("SKU Number cannot be empty"); TxtSKUNum.Focus(); } }
public void InsertProduct() { if (string.IsNullOrEmpty(TxtSKUNum.Text)) { MessageBox.Show("SKU Number Cannot be Empty"); TxtSKUNum.Focus(); } else { int Result = dal.InsertCloth(cloth); try { if (Result > 0) { MessageBox.Show("Product Added Successfully"); LoadDGV(); } else { DialogResult dialogResult = MessageBox.Show("This item does not exist, would you like add it?", "Item Not Exist!", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { cloth.SKUNumber = TxtSKUNum.Text.Trim(); TxtColor.Text = cloth.ProductColor(); TxtSize.Text = cloth.ProductSize(); DisplayTextBoxes(); } else if (dialogResult == DialogResult.No) { return; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }