private void createBtn_Click(object sender, EventArgs e) { if (Software.Resources.ApplicationHelper.IsValidEmail(emailBox.Text) == true) { if (Software.Resources.ApplicationHelper.IsValidPassword(passBox.Text) == true) { Software.Model.Employee employee = new Software.Model.Employee(); employee.Name = nameBox.Text; employee.Contact_No = contactBox.Text; employee.Email = emailBox.Text; employee.Address = addressBox.Text; employee.Hire_Date = hireDateTime.Value; employee.Commission = Convert.ToInt32(commissionBox.Text); employee.Job_Id = ((Software.Model.Job)jobComboBox.SelectedItem).Id; employee.Picture = pictureBox.ImageLocation; employee.Password = passBox.Text; employee.Authority = authorityBox.Text; Software.Database.SQL.EmployeeDB.InsertEmployee(employee); MetroFramework.MetroMessageBox.Show(this, "Data has been inserted!", "Successfully Completed", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } else { MetroFramework.MetroMessageBox.Show(this, "You must provide a valid password which has minimum 5 length and has upper case letter, lower case letter, decimal digit and special character", "Invalid Password"); } } else { MetroFramework.MetroMessageBox.Show(this, "You must provide a valid email !", "Invalid Email"); } }
private void updateBtn_Click(object sender, EventArgs e) { int selectedRowIndex = 0; if (table.SelectedCells.Count > 0) { if (Software.Resources.ApplicationHelper.IsValidEmail(emailBox.Text) == true) { if (Software.Resources.ApplicationHelper.IsValidPassword(passBox.Text) == true) { Software.Model.Employee employee = new Software.Model.Employee(); selectedRowIndex = table.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = table.Rows[selectedRowIndex]; employee.Id = Convert.ToInt32(Convert.ToString(selectedRow.Cells["Id"].Value)); employee.Name = nameBox.Text; employee.Contact_No = contactBox.Text; employee.Email = emailBox.Text; employee.Address = addressBox.Text; employee.Hire_Date = hireDateTime.Value; employee.Commission = Convert.ToInt32(commissionBox.Text); employee.Job_Id = ((Software.Model.Job)jobComboBox.SelectedItem).Id; employee.Picture = pictureBox.ImageLocation; employee.Password = passBox.Text; employee.Authority = authorityBox.Text; Software.Database.SQL.EmployeeDB.UpdateEmployee(employee);
private void LoginBtn_Click(object sender, EventArgs e) { try { Software.Model.Employee employee = employees.SingleOrDefault(i => i.Email.Equals(emailBox.Text) && i.Password.Equals(passBox.Text)); if (emailBox.Text == "" || passBox.Text == "") { MessageBox.Show(" Enter UserName and Password ."); return; } //Write Login Method else if (!(employee is null)) { access = employee.Authority; if (Login_Form.access.Equals("CUSTOMER")) { new Customer_HomePage().ShowDialog(); } new HomePage().ShowDialog(); } else { MessageBox.Show("Not Registered User or Invalid Name/Password"); } }
private void updateBtn_Click(object sender, EventArgs e) { int selectedRowIndex = 0; if (table.SelectedCells.Count > 0) { if (Software.Resources.ApplicationHelper.IsValidEmail(emailBox.Text) == true) { if (Software.Resources.ApplicationHelper.IsValidPassword(passBox.Text) == true) { Software.Model.Employee employee = new Software.Model.Employee(); selectedRowIndex = table.SelectedCells[0].RowIndex; DataGridViewRow selectedRow = table.Rows[selectedRowIndex]; employee.Id = Convert.ToInt32(Convert.ToString(selectedRow.Cells["Id"].Value)); employee.Name = nameBox.Text; employee.Contact_No = contactBox.Text; employee.Email = emailBox.Text; employee.Address = addressBox.Text; employee.Hire_Date = hireDateTime.Value; employee.Commission = Convert.ToInt32(commissionBox.Text); employee.Job_Id = ((Software.Model.Job)jobComboBox.SelectedItem).Id; employee.Picture = pictureBox.ImageLocation; employee.Password = passBox.Text; employee.Authority = authorityBox.Text; Software.Database.SQL.EmployeeDB.UpdateEmployee(employee); MetroFramework.MetroMessageBox.Show(this, "Your data has been updated successfully.", "Successfully Completed", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MetroFramework.MetroMessageBox.Show(this, "You must provide a valid password!", "Invalid Password"); } } else { MetroFramework.MetroMessageBox.Show(this, "You must provide a valid email!", "Invalid Email"); } } else { MetroFramework.MetroMessageBox.Show(this, "You must select a row to update its value!", "Invalid Selection"); } DoRefresh(); table.CurrentCell = table.Rows[selectedRowIndex].Cells[0]; table.Rows[selectedRowIndex].Selected = true; }