private bool CheckRequiredFields() { bool RequiredFieldsFilled = true; int Cnt = 1; string MsgToDisplay = MsgTxt.PleaseSelectTxt; if (!Validators.TxtBoxNotEmpty(NameTxtBox.Text)) { RequiredFieldsFilled = false; MsgToDisplay += "\n" + Cnt++ + ")" + MsgTxt.VendorTxt; NameTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; } else { NameTxtBox.BackColor = NameBGColor; } if (!Validators.TxtBoxNotEmpty(Phone1TxtBox.Text)) { RequiredFieldsFilled = false; MsgToDisplay += "\n" + Cnt++ + ")" + MsgTxt.PhoneTxt; Phone1TxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; } else { Phone1TxtBox.BackColor = PhoneBGColor; } if (!Validators.TxtBoxNotEmpty(CompanyTxtBox.Text)) { RequiredFieldsFilled = false; MsgToDisplay += "\n" + Cnt++ + ")" + MsgTxt.CompanyTxt; CompanyTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; } else { CompanyTxtBox.BackColor = CompanyBGColor; } double TestParserBal = 0.00; if (!double.TryParse(OpenBalTxtBox.Text, out TestParserBal)) { RequiredFieldsFilled = false; MsgToDisplay += "\n" + Cnt++ + ")" + MsgTxt.OpeningBalTxt; OpenBalTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; } else { OpenBalTxtBox.BackColor = CompanyBGColor; } if (!RequiredFieldsFilled) { MessageBox.Show(MsgToDisplay, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(RequiredFieldsFilled); }
private void AddDisposalReasonBtn_Click(object sender, EventArgs e) { if (Validators.TxtBoxNotEmpty(NameTxtBox.Text)) { if (Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text)) { DisposalReason aDisposalReason = new DisposalReason(); aDisposalReason.Disposal_Detailed_Name = NameTxtBox.Text; aDisposalReason.Disposal_Detailed_Comment = DescriptionTxtBox.Text; Nullable <int> IsAddDisposalReasonOK = DisposalReasonMgmt.AddDisposalReason(aDisposalReason); if (IsAddDisposalReasonOK == 1) { MessageBox.Show(MsgTxt.DisposalReasonTxt + NameTxtBox.Text + "\n" + MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error: AddDisposalReasonBtn_Click] \n Exception: \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } } else { MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields + "\n" + "1)" + MsgTxt.DescriptionTxt, MsgTxt.PleaseAddAllRequiredFields, MessageBoxButtons.OK, MessageBoxIcon.Warning); DescriptionTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; DescriptionTxtBox.Focus(); NameTxtBox.BackColor = NameBGColor; } } else { MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields + "\n" + "1)" + MsgTxt.NameTxt + "\n 2)" + MsgTxt.DescriptionTxt, MsgTxt.PleaseAddAllRequiredFields, MessageBoxButtons.OK, MessageBoxIcon.Warning); 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; } } }
private void BarcodeAddBtn_Click(object sender, EventArgs e) { try { if (Validators.TxtBoxNotEmpty(BarcodeTxtBox.Text)) { AddItemUsingBarcode(BarcodeTxtBox.Text); } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [BarcodeAddBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } }
private void UpdateInfoBtn_Click(object sender, EventArgs e) { try { if (UserNameComboBox.SelectedValue != null && UserNameComboBox.Text != "") { UserNameComboBox.BackColor = UserBGColor; if (Validators.TxtBoxNotEmpty(PasswordTxtBox.Text)) { PasswordTxtBox.BackColor = PasswordBGColor; Users aUser = new Users(); aUser.User_Name = NameTxtBox.Text; aUser.User_Address = AddressTxtBox.Text; aUser.User_Phone1 = Phone1TxtBox.Text; aUser.User_Phone2 = Phone2TxtBox.Text; aUser.User_Password = PasswordTxtBox.Text; aUser.User_Description = DescriptionTxtBox.Text; aUser.User_ID = int.Parse(UserNameComboBox.SelectedValue.ToString()); UsersMgmt.UpdateUser(aUser); foreach (TextBox aTextBox in this.UserInfoGB.Controls.OfType <TextBox>()) { aTextBox.Text = ""; } MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); UserNameComboBox.Text = ""; } else { MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); PasswordTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; PasswordTxtBox.Focus(); } } else { MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); UserNameComboBox.BackColor = SharedVariables.TxtBoxRequiredColor; UserNameComboBox.Focus(); } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UpdateInfoBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
private void UpdatePrivBtn_Click(object sender, EventArgs e) { try { if (Validators.TxtBoxNotEmpty(UserNameComboBox.Text)) { int UserID = int.Parse(UserNameComboBox.SelectedValue.ToString()); if (UsersMgmt.SelectUserInfoByID(UserID)["IsAdmin"].ToString() == "1") { MessageBox.Show(UiText.CannotEditAdminsTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { foreach (CheckBox aCheckBox in PriviligesGB.Controls.OfType <CheckBox>()) { if (aCheckBox.Checked == true) { if (!PriviligesMgmt.IsPriviligeExist(UserID, EventsMgmt.SelectEventIDbyName(aCheckBox.Tag.ToString()))) { PriviligesMgmt.AddPrivilige(UserID, EventsMgmt.SelectEventIDbyName(aCheckBox.Tag.ToString())); } } else { if (PriviligesMgmt.IsPriviligeExist(UserID, EventsMgmt.SelectEventIDbyName(aCheckBox.Tag.ToString()))) { PriviligesMgmt.RemovePrivilige(UserID, EventsMgmt.SelectEventIDbyName(aCheckBox.Tag.ToString())); } } } MessageBox.Show(MsgTxt.UpdateSuccessfully, MsgTxt.UpdateSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + " " + MsgTxt.UserTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UpdatePrivBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } }
private void Phone1ComboBox_TextChanged(object sender, EventArgs e) { if (!IsLoading && !OnExit) { if (Validators.TxtBoxNotEmpty(Phone1ComboBox.Text)) { Phone1ComboBox.BackColor = Color.White; DataRow DR = CustomerMgmt.SelectCustomerByPhone1(Phone1ComboBox.Text); if (DR != null) { UpdateCustomerBtn.Show(); CustomerID = int.Parse(DR["ID"].ToString()); NameTxtBox.Text = DR["Name"].ToString(); AddressTxtBox.Text = DR["Address"].ToString(); EmailTxtBox.Text = DR["Email"].ToString(); Phone1TxtBox.Text = DR["Phone1"].ToString(); DataRow CusAccount = CustomersAccountsMgmt.SelectCustomerAccountRowByCusID(CustomerID); if (CusAccount != null) { MakeUserAccountChkBox.Checked = true; } else { MakeUserAccountChkBox.Checked = false; } } else { UpdateCustomerBtn.Hide(); // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [Phone1ComboBox_TextChanged:SelectCustomerByPhone1 ==null] \n Exception: " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { UpdateCustomerBtn.Hide(); MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); Phone1ComboBox.BackColor = SharedVariables.TxtBoxRequiredColor; Phone1ComboBox.Focus(); } } }
private void BarcodeTxtBox_KeyPress(object sender, KeyPressEventArgs e) { try { if (e.KeyChar == (int)Keys.Return) { if (Validators.TxtBoxNotEmpty(BarcodeTxtBox.Text)) { AddItemUsingBarcode(BarcodeTxtBox.Text); } //DataTable aItemTable = ItemsMgmt.SelectItemByBarCode(BarcodeTxtBox.Text); //if (aItemTable.Rows.Count == 1) //{ // TeldgView.ClearSelection(); // int RowNum = TeldgView.Rows.Add(); // TeldgView.Rows[RowNum].Cells["Barcode"].Value = aItemTable.Rows[0]["Barcode"].ToString(); // TeldgView.Rows[RowNum].Cells["Description"].Value = aItemTable.Rows[0]["Description"].ToString(); // TeldgView.Rows[RowNum].Cells["PricePerUnit"].Value = aItemTable.Rows[0]["SellPrice"].ToString(); // TeldgView.Rows[RowNum].Cells["AvalQty"].Value = aItemTable.Rows[0]["Qty"].ToString(); // TeldgView.Rows[RowNum].Selected = true; // BarcodeTxtBox.Text = string.Empty; // ItemDescriptionComboBox.Text = string.Empty; //} //else //{ // MessageBox.Show(MsgTxt.ItemNotFoundTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); // BarcodeTxtBox.Text = string.Empty; // ItemDescriptionComboBox.Text = string.Empty; //} } else { return; } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [BarcodeTxtBox_KeyPress] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); throw; } }
private void UpdateItemBtn_Click(object sender, EventArgs e) { try { if (Validators.TxtBoxNotEmpty(BarcodeTxtBox.Text) || WithoutBarcodeChkBox.Checked) { BarcodeTxtBox.BackColor = BarcodeTxtBoxBGColor; double ParsingOutTester = 0; if (Validators.TxtBoxNotEmpty(QtyTxtBox.Text) && double.TryParse(QtyTxtBox.Text, out ParsingOutTester)) { QtyTxtBox.BackColor = QtyTxtBoxBGColor; if (Validators.TxtBoxNotEmpty(RenderPointTxtBox.Text) && double.TryParse(RenderPointTxtBox.Text, out ParsingOutTester)) { RenderPointTxtBox.BackColor = RenderTxtBoxBGColor; if (Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text)) { DescriptionTxtBox.BackColor = DescriptionBGColor; if (Validators.TxtBoxNotEmpty(SellPriceTxtBox.Text) && double.TryParse(SellPriceTxtBox.Text, out ParsingOutTester)) { SellPriceTxtBox.BackColor = SellPriceBGColor; if (Validators.TxtBoxNotEmpty(AvgCostTxtBox.Text) && double.TryParse(AvgCostTxtBox.Text, out ParsingOutTester)) { AvgCostTxtBox.BackColor = AvgUnitCostBGColor; bool IsPriceLevelsEmpty = false; foreach (var tb in Pricing.Controls.OfType <TextBox>()) { if (!Validators.TxtBoxNotEmpty(tb.Text) || !double.TryParse(tb.Text, out ParsingOutTester)) { IsPriceLevelsEmpty = true; tb.BackColor = SharedVariables.TxtBoxRequiredColor; } else { // tb.BackColor = Color.Black; } } if (IsPriceLevelsEmpty) { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.PriceLevelsTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { bool IsBarcodeUsed = false; //CHECK IF NEW BARCODE IS NOT CHECKED string OldBarcode; if (!WithoutBarcodeChkBox.Checked) { IsBarcodeUsed = ItemsMgmt.IsItemExist(BarcodeTxtBox.Text); if (ByBarcDescChkBox.Checked) { OldBarcode = BarcodeToEditTxtBox.Text; } else { OldBarcode = ItemDescriptionComboBox.SelectedValue.ToString(); } } else { OldBarcode = WithoutBarcodeComboBox.SelectedValue.ToString(); } Items aItem = new Items(); aItem.Item_Type = (int)TypeComboBox.SelectedValue; aItem.Item_Category = (int)CategoryComboBox.SelectedValue; aItem.Vendor = (int)VendorComboBox.SelectedValue; aItem.Item_Tax_Level = (int)TaxLevelComboBox.SelectedValue; if (WithoutBarcodeChkBox.Checked) { aItem.Item_Barcode = WithoutBarcodeComboBox.SelectedValue.ToString(); } else { //aItem.IsWithoutBarcode = 0; aItem.Item_Barcode = BarcodeTxtBox.Text; } aItem.Item_ID = ItemsMgmt.SelectItemIDByBarcode(OldBarcode); if (!IsBarcodeUsed || WithoutBarcodeChkBox.Checked || OldBarcode == aItem.Item_Barcode) { aItem.Item_Description = DescriptionTxtBox.Text; aItem.Avalable_Qty = double.Parse(QtyTxtBox.Text); aItem.Render_Point = double.Parse(RenderPointTxtBox.Text); // aItem.Entry_Date = DateTime.Now.ToShortDateString(); double aSellPrice = double.Parse(SellPriceTxtBox.Text); double aUnitCost = double.Parse(AvgCostTxtBox.Text); double aTax = double.Parse(ItemTaxLevelMgmt.SelectItemTaxByID(aItem.Item_Tax_Level)); if (TaxEnclodedChkBox.Checked) { aItem.Sell_Price = Math.Round(aSellPrice / ((aTax / 100) + 1), 4); aItem.Avg_Unit_Cost = Math.Round(aUnitCost / ((aTax / 100) + 1), 4); } else { aItem.Sell_Price = aSellPrice; aItem.Avg_Unit_Cost = aUnitCost; } ItemsMgmt.UpdateItemByID(aItem); int ItemID = aItem.Item_ID; foreach (var tb in Pricing.Controls.OfType <TextBox>()) { Nullable <int> PriceLevelID = PriceLevelsMgmt.SelectPriceLevelIDByName(tb.Name); if (PriceLevelID != null) { double atbSellPrice = double.Parse(tb.Text); if (TaxEnclodedChkBox.Checked) { atbSellPrice = Math.Round(atbSellPrice / ((aTax / 100) + 1), 4); } Nullable <int> IsAddSpecialPriceOK; if (SpecialPricesMgmt.IsSpecialPriceExist(ItemID, (int)PriceLevelID) == true)//exist update { IsAddSpecialPriceOK = SpecialPricesMgmt.UpdatePriceLevel(ItemID, (int)PriceLevelID, atbSellPrice); } else if (SpecialPricesMgmt.IsSpecialPriceExist(ItemID, (int)PriceLevelID) == false)//not exist create new { IsAddSpecialPriceOK = SpecialPricesMgmt.AddSpecialPrice(ItemID, (int)PriceLevelID, atbSellPrice); } //null database error else { MessageBox.Show(MsgTxt.UnexpectedError + "DataBase: SpecialPricesMgmt.AddSpecialPrice", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { MessageBox.Show("UNEXPECTED ERROR !!ITEM ADDED SUCCESSFULY, NOT PRICE LEVELS ADDED " + "\n" + "PLEASE ADD PRICE LEVELS MANUALLY FROM EDIT ITEM PAGE", "PRICE LEVEL ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); throw new System.ArgumentException("Parameter cannot be null", "original"); } } MessageBox.Show(MsgTxt.UpdateSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(MsgTxt.BarcodeTxt + " " + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); BarcodeTxtBox.Text = ""; } } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.UnitCostTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); AvgCostTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; AvgCostTxtBox.Focus(); } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.SellingPriceTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); SellPriceTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; SellPriceTxtBox.Focus(); } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.DescriptionTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); DescriptionTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; DescriptionTxtBox.Focus(); } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.RenderPointTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); RenderPointTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; RenderPointTxtBox.Focus(); } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.ValidQtyTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); QtyTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; QtyTxtBox.Focus(); } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.BarcodeTxt + "\n2)" + MsgTxt.IfNotBarChkWithoutBarcodeTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); BarcodeTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; BarcodeTxtBox.Focus(); } } catch (Exception ex) { IsUpdating = false; MessageBox.Show(MsgTxt.UnexpectedError + "\nException: IN[UpdateItemBtn_Click] \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); throw; } }
private void BarcodeToEditTxtBox_KeyPress(object sender, KeyPressEventArgs e) { try { if (e.KeyChar == (int)Keys.Return) { IsUpdating = true; if (Validators.TxtBoxNotEmpty(BarcodeToEditTxtBox.Text)) { aItemData = ItemsMgmt.SelectItemByBarCode(BarcodeToEditTxtBox.Text); if (aItemData != null) { if (aItemData.Rows.Count > 0) { UpdateItemBtn.Show(); TypeComboBox.Text = ItemTypeMgmt.SelectItemTypeByID(int.Parse(aItemData.Rows[0]["Type"].ToString())); CategoryComboBox.Text = ItemCategoryMgmt.SelectItemCategoryByID(int.Parse(aItemData.Rows[0]["Category"].ToString())); VendorComboBox.Text = VendorsMgmt.SelectVendorByID(int.Parse(aItemData.Rows[0]["Vendor"].ToString())); TaxLevelComboBox.Text = ItemTaxLevelMgmt.SelectItemTaxByID(int.Parse(aItemData.Rows[0]["TaxLevel"].ToString())); BarcodeTxtBox.Text = BarcodeToEditTxtBox.Text; DescriptionTxtBox.Text = aItemData.Rows[0]["Description"].ToString(); ItemDescriptionComboBox.Text = aItemData.Rows[0]["Description"].ToString(); QtyTxtBox.Text = aItemData.Rows[0]["Qty"].ToString(); RenderPointTxtBox.Text = aItemData.Rows[0]["RenderPoint"].ToString(); DateAddedTxtBox.Text = aItemData.Rows[0]["EntryDate"].ToString(); SellPriceTxtBox.Text = aItemData.Rows[0]["SellPrice"].ToString(); AvgCostTxtBox.Text = aItemData.Rows[0]["AvgUnitCost"].ToString(); AvailableQtyTxtBox.Text = aItemData.Rows[0]["OnHandQty"].ToString(); /*@SMS V01O changed*/ Pricing.Controls.Clear(); //ADDING PRICE LEVELS int ItemID = int.Parse(aItemData.Rows[0]["ID"].ToString()); aPriceLevelsTable = PriceLevelsMgmt.SelectAll(); if (aPriceLevelsTable.Rows.Count > 0) { foreach (DataRow r in aPriceLevelsTable.Rows) { if (r["Name"].ToString() != "Standard") { Label aLabel = new Label(); aLabel.Text = r["Name"].ToString(); TextBox aTextBox = new TextBox(); DataTable aSpecialPriceTable = SpecialPricesMgmt.SelectSpecialPricebyItemIDandPriceLevelID(ItemID, int.Parse(r["ID"].ToString())); if (aSpecialPriceTable.Rows.Count > 0) { aTextBox.Text = aSpecialPriceTable.Rows[0]["Price"].ToString(); } else { aTextBox.Text = SellPriceTxtBox.Text; } aTextBox.Name = r["Name"].ToString(); aTextBox.TextChanged += new EventHandler(Calcium_RMS.Validators.TextBoxDoubleInputChange); Pricing.Controls.Add(aLabel); Pricing.Controls.Add(aTextBox); } } } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.BarcodeTxt + "\n2)" + MsgTxt.IfNotBarChkWithoutBarcodeTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show(MsgTxt.NotUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } else { UpdateItemBtn.Hide(); } TaxEnclodedChkBox.Checked = false; UpdateMargin(); IsUpdating = false; } catch (Exception ex) { IsUpdating = false; MessageBox.Show(MsgTxt.UnexpectedError + "\nException: IN[BarcodeToEditTxtBox_KeyPress] \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); throw; } }
private void UpdateCustomerBtn_Click(object sender, EventArgs e) { try { if (NameTxtBox.Text.ToUpper() == "CASH") { return; } if (Validators.TxtBoxNotEmpty(NameTxtBox.Text) && Validators.TxtBoxNotEmpty(Phone1TxtBox.Text)) { Phone1TxtBox.BackColor = PhoneColor; NameTxtBox.BackColor = NameColor; if (!CustomerMgmt.IsPhoneUsed(Phone1TxtBox.Text) || Phone1TxtBox.Text == Phone1ComboBox.Text) { Customer aCustomer = new Customer(); aCustomer.Customer_Name = NameTxtBox.Text; aCustomer.Customer_Address = AddressTxtBox.Text; aCustomer.Customer_Email = EmailTxtBox.Text; aCustomer.Customer_Phone1 = Phone1TxtBox.Text; aCustomer.Customer_ID = CustomerID; DataRow CusAccount = CustomersAccountsMgmt.SelectCustomerAccountRowByCusID(CustomerID); if (MakeUserAccountChkBox.Checked == false) { if (CusAccount != null) { Err1.Show(); } else { CustomerMgmt.UpdateInfomationByID(aCustomer); MessageBox.Show(MsgTxt.UpdateSuccessfully, MsgTxt.UpdateSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } else { if (CusAccount == null) { if (!CustomersAccountsMgmt.InsertCustomerAccount(CustomerID)) { MessageBox.Show(MsgTxt.UnexpectedError, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (!CustomerMgmt.UpdateInfomationByID(aCustomer)) { MessageBox.Show(MsgTxt.UnexpectedError, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); throw new Exception("Database Error in [Update Information By ID]"); } else { MessageBox.Show(MsgTxt.UpdateSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } } else { MessageBox.Show(MsgTxt.PhoneInUse, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); if (!Validators.TxtBoxNotEmpty(Phone1TxtBox.Text)) { Phone1TxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; Phone1TxtBox.Focus(); } else { Phone1TxtBox.BackColor = PhoneColor; } if (!Validators.TxtBoxNotEmpty(NameTxtBox.Text)) { NameTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; NameTxtBox.Focus(); } else { NameTxtBox.BackColor = NameColor; } } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UpdateCustomerBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
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(); } }
private void AddCustomerBtn_Click(object sender, EventArgs e) { try { double TestParserBal = 0.00; if (Validators.TxtBoxNotEmpty(NameTxtBox.Text) && Validators.TxtBoxNotEmpty(Phone1TxtBox.Text)) { if (MakeUserAccountChkBox.Checked) { if (!double.TryParse(OpenBalTxtBox.Text, out TestParserBal)) { MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } if (!CustomerMgmt.IsPhoneUsed(Phone1TxtBox.Text)) { Customer aCustomer = new Customer(); aCustomer.Customer_Name = NameTxtBox.Text; aCustomer.Customer_Address = AddressTxtBox.Text; aCustomer.Customer_Email = EmailTxtBox.Text; aCustomer.Customer_Phone1 = Phone1TxtBox.Text; if (CustomerMgmt.InsertCustomer(aCustomer)) { if (MakeUserAccountChkBox.Checked) { int CustomerID = CustomerMgmt.SelectCustomerIDByPhone1(Phone1TxtBox.Text); if (!CustomersAccountsMgmt.InsertCustomerAccount(CustomerID)) { MessageBox.Show(MsgTxt.UnexpectedError, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } int AccountID = int.Parse(CustomersAccountsMgmt.SelectCustomerAccountRowByCusID(CustomerID)["ID"].ToString()); CustomersAccountsMgmt.UpdateAccountAmountByAccountID(AccountID, TestParserBal); } MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult ret; ret = MessageBox.Show(MsgTxt.AddAnotherItemTxt, MsgTxt.InformationCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); if (ret == DialogResult.Yes) { foreach (TextBox aTextBox in this.CustomerInfoGB.Controls.OfType <TextBox>()) { aTextBox.Text = ""; } } else { this.Close(); } } else { MessageBox.Show(MsgTxt.UnexpectedError, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show(MsgTxt.PhoneInUse, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); if (!Validators.TxtBoxNotEmpty(Phone1TxtBox.Text)) { Phone1TxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; Phone1TxtBox.Focus(); } else { Phone1TxtBox.BackColor = PhoneColor; } if (!Validators.TxtBoxNotEmpty(NameTxtBox.Text)) { NameTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; NameTxtBox.Focus(); } else { NameTxtBox.BackColor = NameColor; } } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [AddCustomerBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
private void AddItemBtn_Click(object sender, EventArgs e) { try { if (Validators.TxtBoxNotEmpty(BarcodeTxtBox.Text) || WithoutBarcodeChkBox.Checked) { BarcodeTxtBox.BackColor = BarcodeTxtBoxBGColor; double ParsingOutTester = 0; if (Validators.TxtBoxNotEmpty(QtyTxtBox.Text) && double.TryParse(QtyTxtBox.Text, out ParsingOutTester)) { QtyTxtBox.BackColor = QtyTxtBoxBGColor; if (Validators.TxtBoxNotEmpty(RenderPointTxtBox.Text) && double.TryParse(RenderPointTxtBox.Text, out ParsingOutTester)) { RenderPointTxtBox.BackColor = RenderTxtBoxBGColor; if (Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text)) { DescriptionTxtBox.BackColor = DescriptionBGColor; if (Validators.TxtBoxNotEmpty(SellPriceTxtBox.Text) && double.TryParse(SellPriceTxtBox.Text, out ParsingOutTester)) { SellPriceTxtBox.BackColor = SellPriceBGColor; if (Validators.TxtBoxNotEmpty(AvgCostTxtBox.Text) && double.TryParse(AvgCostTxtBox.Text, out ParsingOutTester)) { AvgCostTxtBox.BackColor = AvgUnitCostBGColor; bool IsPriceLevelsEmpty = false; foreach (var tb in Pricing.Controls.OfType <TextBox>()) { if (!Validators.TxtBoxNotEmpty(tb.Text) || !double.TryParse(tb.Text, out ParsingOutTester)) { IsPriceLevelsEmpty = true; tb.BackColor = SharedVariables.TxtBoxRequiredColor; } else { tb.BackColor = Color.White; } } if (IsPriceLevelsEmpty) { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.PriceLevelsTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { Items aItem = new Items(); if (TypeComboBox.SelectedValue == null || CategoryComboBox.SelectedValue == null || VendorComboBox.SelectedValue == null || TaxLevelComboBox.SelectedValue == null) { MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } aItem.Item_Type = (int)TypeComboBox.SelectedValue; aItem.Item_Category = (int)CategoryComboBox.SelectedValue; aItem.Vendor = (int)VendorComboBox.SelectedValue; aItem.Item_Tax_Level = (int)TaxLevelComboBox.SelectedValue; if (WithoutBarcodeChkBox.Checked) { aItem.IsWithoutBarcode = 1; int aWithoutBarcode_Barcode = ItemsMgmt.SelectWithoutBarcode_Barcode();; if (aWithoutBarcode_Barcode == 0) { MessageBox.Show(MsgTxt.UnexpectedError + "\nException: IN[AddItemBtn_Click:Cannot Select Without Barcode _ Barcode] \n" + MsgTxt.PleaseTryAgainLaterTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } while (ItemsMgmt.IsItemExist(aWithoutBarcode_Barcode.ToString())) { aWithoutBarcode_Barcode++; } aItem.Item_Barcode = "NOBC" + aWithoutBarcode_Barcode.ToString(); } else { if (aThereIsWeigth && WeightChkBox.Checked && BarcodeTxtBox.Text.Length >= BarcodeLength) { aItem.IsWeight = 1; aItem.IsWithoutBarcode = 0; aItem.Item_Barcode = BarcodeTxtBox.Text.Substring(0, BarcodeLength); } else { aItem.IsWeight = 0; aItem.IsWithoutBarcode = 0; aItem.Item_Barcode = BarcodeTxtBox.Text; } } if (!ItemsMgmt.IsItemExist(aItem.Item_Barcode)) { aItem.Item_Description = DescriptionTxtBox.Text; aItem.Avalable_Qty = double.Parse(QtyTxtBox.Text); aItem.Render_Point = double.Parse(RenderPointTxtBox.Text); aItem.Entry_Date = DateTime.Now.ToShortDateString(); double aSellPrice = double.Parse(SellPriceTxtBox.Text); double aUnitCost = double.Parse(AvgCostTxtBox.Text); double aTax = double.Parse(ItemTaxLevelMgmt.SelectItemTaxByID(aItem.Item_Tax_Level)); if (TaxEnclodedChkBox.Checked) { aItem.Sell_Price = Math.Round(aSellPrice / ((aTax / 100) + 1), 5); aItem.Avg_Unit_Cost = Math.Round(aUnitCost / ((aTax / 100) + 1), 5); } else { aItem.Sell_Price = aSellPrice; aItem.Avg_Unit_Cost = aUnitCost; } if (!ItemsMgmt.AddItem(aItem)) { MessageBox.Show(MsgTxt.UnexpectedError + "DataBase: ItemsMgmt.AddItem" + MsgTxt.DidnotAdded + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } int ItemID = ItemsMgmt.SelectItemIDByBarcode(aItem.Item_Barcode); foreach (var tb in Pricing.Controls.OfType <TextBox>()) { double atbSellPrice = double.Parse(tb.Text); if (TaxEnclodedChkBox.Checked) { atbSellPrice = Math.Round(atbSellPrice / ((aTax / 100) + 1), 5); } Nullable <int> PriceLevelID = PriceLevelsMgmt.SelectPriceLevelIDByName(tb.Name); if (PriceLevelID != null) { Nullable <int> IsAddSpecialPriceOK = SpecialPricesMgmt.AddSpecialPrice(ItemID, (int)PriceLevelID, atbSellPrice); if (IsAddSpecialPriceOK == null) { MessageBox.Show(MsgTxt.PriceLevelsTxt + " " + tb.Name + " " + MsgTxt.DidnotAdded + "\n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show(MsgTxt.UnexpectedError + "DataBase: " + MsgTxt.PriceLevelsTxt + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } } MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult ret; ret = MessageBox.Show(MsgTxt.AddAnotherItemTxt, MsgTxt.InformationCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); if (ret == DialogResult.Yes) { ReloadForm(); } else { this.Close(); } } else { MessageBox.Show(MsgTxt.BarcodeTxt + " " + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); BarcodeTxtBox.Text = ""; } } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.UnitCostTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); AvgCostTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; AvgCostTxtBox.Focus(); } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.SellingPriceTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); SellPriceTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; SellPriceTxtBox.Focus(); } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.DescriptionTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); DescriptionTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; DescriptionTxtBox.Focus(); } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.RenderPointTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); RenderPointTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; RenderPointTxtBox.Focus(); } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.ValidQtyTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); QtyTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; QtyTxtBox.Focus(); } } else { MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.BarcodeTxt + "\n2)" + MsgTxt.IfNotBarChkWithoutBarcodeTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); BarcodeTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; BarcodeTxtBox.Focus(); } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\nException: IN[AddItemBtn_Click] \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); throw; } }
private void AddUserBtn_Click(object sender, EventArgs e) { try { if (Validators.TxtBoxNotEmpty(UserNameTxtBox.Text) && Validators.TxtBoxNotEmpty(PasswordTxtBox.Text)) { if (!UsersMgmt.IsUserExist(UserNameTxtBox.Text)) { Users aUser = new Users(); aUser.User_Name = NameTxtBox.Text; aUser.User_Address = AddressTxtBox.Text; aUser.User_Phone1 = Phone1TxtBox.Text; aUser.User_Phone2 = Phone2TxtBox.Text; aUser.User_Password = PasswordTxtBox.Text; aUser.User_Description = DescriptionTxtBox.Text; aUser.User_UserName = UserNameTxtBox.Text; if (UsersMgmt.AddUser(aUser)) { MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult ret; ret = MessageBox.Show(MsgTxt.AddAnotherItemTxt, MsgTxt.InformationCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); if (ret == DialogResult.Yes) { foreach (TextBox aTextBox in this.UserInfoGB.Controls.OfType <TextBox>()) { aTextBox.Text = ""; } } else { this.Close(); } } else { MessageBox.Show(MsgTxt.UnexpectedError + " \n[DataBase Error]:IN [AddUserBtn_Click]" + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } } else { MessageBox.Show(MsgTxt.UserTxt + " [ " + UserNameTxtBox.Text + " ] " + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); if (!Validators.TxtBoxNotEmpty(PasswordTxtBox.Text)) { PasswordTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; PasswordTxtBox.Focus(); } else { PasswordTxtBox.BackColor = PasswordBGColor; } if (!Validators.TxtBoxNotEmpty(UserNameTxtBox.Text)) { UserNameTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; UserNameTxtBox.Focus(); } else { UserNameTxtBox.BackColor = NameBGColor; } } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + " \n[Exception]:IN [AddUserBtn_Click]" + "\n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
private void AddTaxBtn_Click(object sender, EventArgs e) { try { double TestParser; if (Validators.TxtBoxNotEmpty(PercentageTxtBox.Text) && Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text)) { if (!double.TryParse(PercentageTxtBox.Text, out TestParser)) { MessageBox.Show(MsgTxt.PleaseSelectCorrectAmountTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); PercentageTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; return; } else { PercentageTxtBox.BackColor = PercentageBGColor; } Nullable <int> Check = ItemTaxLevelMgmt.IsTaxLevelUsed(PercentageTxtBox.Text); if (Check == 10) { ItemTaxLevel aItemTaxLevel = new ItemTaxLevel(); aItemTaxLevel.Item_Tax_Percentage = PercentageTxtBox.Text; aItemTaxLevel.Item_Tax_Description = DescriptionTxtBox.Text; if (ItemTaxLevelMgmt.AddTaxLevel(aItemTaxLevel)) { MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show(MsgTxt.UnexpectedError + " \n[DataBase Error]:IN [AddTaxBtn_Click]" + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } } else if (Check == 5) { MessageBox.Show(MsgTxt.PercentageTxt + " [ " + PercentageTxtBox.Text + " ] " + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (Check == null) { MessageBox.Show(MsgTxt.UnexpectedError + " \n[DataBase Error2]:IN [AddTaxBtn_Click]" + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } } else { MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); if (!Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text)) { DescriptionTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; DescriptionTxtBox.Focus(); } else { DescriptionTxtBox.BackColor = DescriptionBGColor; } if (!Validators.TxtBoxNotEmpty(PercentageTxtBox.Text)) { PercentageTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; PercentageTxtBox.Focus(); } else { PercentageTxtBox.BackColor = PercentageBGColor; } } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + " \n[Exception]:IN [AddUserBtn_Click]" + "\n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
private void AddNewPriceLevelBtn_Click(object sender, EventArgs e) { try { if (Validators.TxtBoxNotEmpty(NameTxtBox.Text) && Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text)) { Nullable <int> Check = PriceLevelsMgmt.IsPriceLevelUsed(NameTxtBox.Text); if (Check == 10) { PriceLevels aPriceLevel = new PriceLevels(); aPriceLevel.Price_Level_Name = NameTxtBox.Text; aPriceLevel.Price_Level_Description = DescriptionTxtBox.Text; try { PriceLevelsMgmt.AddPriceLevel(aPriceLevel); MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception) { } } else if (Check == 5) { MessageBox.Show(MsgTxt.PriceLevelsTxt + "[" + NameTxtBox.Text + "]" + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (Check == null) { MessageBox.Show(MsgTxt.UnexpectedError + " \n[DataBase Error]:IN [AddNewPriceLevelBtn_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 = DescriptionBGColor; } if (!Validators.TxtBoxNotEmpty(NameTxtBox.Text)) { NameTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor; NameTxtBox.Focus(); } else { NameTxtBox.BackColor = NameBGColor; } } } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + " \n[Exception]:IN [AddNewPriceLevelBtn_Click]" + "\n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }