private void LoginBtn_Click(object sender, EventArgs e) { try { string Name = NameTxtBox.Text; string ID1 = IDTxtBox.Text; ID = ID1; //SELECT [TYPE] FROM [dbo].[PASSENGER] WHERE [PASSENGER_ID] = 'AA110' AND [NAME] like 'Aymen' sql = "SELECT [TYPE] FROM [dbo].[PASSENGER] WHERE [PASSENGER_ID] = '" + ID1 + "' AND [NAME] like '" + Name + "'"; cmd = new SqlCommand(sql, con); DataReader = cmd.ExecuteReader(); output = ""; while (DataReader.Read()) { output += DataReader.GetValue(0); if (output == "Admen") { // Here i should open a form that contain the operation that admin can perform. /* * AdmenForm form = new AdmenForm(); * this.Hide(); * form.Show(); */ MessageBox.Show("Admin Form :D"); DataReader.Close(); cmd.Dispose(); return; } } // Console.WriteLine() if (output == "User") { // Here i should open a form that contain the operation that USER can perform. user form = new user(); this.Hide(); form.Show(); } else { MessageBox.Show("inValid user name and password", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); NameTxtBox.Focus(); } DataReader.Close(); cmd.Dispose(); } catch (Exception E) { MessageBox.Show(E.Message); } }
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 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(); } }
public Login() { InitializeComponent(); this.ActiveControl = NameTxtBox; NameTxtBox.Focus(); }
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(); } }