private void GenerateItemsConfigs() { for (var i = 0; i < NumberOfConfigs; i++) { var atype = new ItemType { Item_Type_Description = $"test {i}", Item_Type_Name = $"test {i}" }; ItemTypeMgmt.AddItemType(atype); var aCategory = new ItemCategory { Item_Category_Description = $"test {i}", Item_Category_Name = $"test {i}" }; ItemCategoryMgmt.AddItemCategory(aCategory); var aVendors = new Vendors { Vendor_Company = $"test {i}", Vendor_Email = $"test {i}", Vendor_Location = $"test {i}", Vendor_Name = $"test {i}", Vendor_Phone1 = "000", Vendor_Phone2 = "222", Vendor_Start_Date = "1/1/2009" }; VendorsMgmt.AddVendor(aVendors); } }
private void AddCategoryBtn_Click(object sender, EventArgs e) { try { if (Validators.TxtBoxNotEmpty(NameTxtBox.Text) && Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text)) { Nullable <int> Check = ItemCategoryMgmt.IsCategoryUsedByName(NameTxtBox.Text); if (Check == 10) { ItemCategory aItemCategory = new ItemCategory(); aItemCategory.Item_Category_Name = NameTxtBox.Text; aItemCategory.Item_Category_Description = DescriptionTxtBox.Text; if (!ItemCategoryMgmt.AddItemCategory(aItemCategory)) { MessageBox.Show(MsgTxt.UnexpectedError + "\nCannot Add Category\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } else { MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } else if (Check == 5) { MessageBox.Show(MsgTxt.ItemCategoryTxt + "\n" + NameTxtBox.Text + "\n" + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (Check == null) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error :Connection Problem In[AddCategoryBtn_Click] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } } else { MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Information); if (!Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text)) { DescriptionTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; DescriptionTxtBox.Focus(); } else { DescriptionTxtBox.BackColor = DescBGColor; } if (!Validators.TxtBoxNotEmpty(NameTxtBox.Text)) { NameTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; NameTxtBox.Focus(); } else { NameTxtBox.BackColor = NameBGColor; } } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [AddCategoryBtn_Click] - \nException:\n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }