private void btnSave_Click(object sender, EventArgs e) { bool checkvalidate = validation(); if (checkvalidate == false) return; int selectedRoleTypeId = 0; var selectedRoleType = cmbRoleType.SelectedItem as Roles; if (selectedRoleType == null) selectedRoleTypeId = 0; else selectedRoleTypeId = selectedRoleType.Id; Employees empDetials = new Employees { Id = maxId, LoginId = txtLoginName.Text.Trim(), Name = txtName.Text.Trim(), Role = selectedRoleTypeId, Password = txtPassword.Text, Status = 1, CreatedOn = DateTime.Today.Date, CreatedBy = ApplicationElements.loggedInEmployee.Id }; string insertStatus = empRepo.InsertEmployee(empDetials); if (insertStatus == "Success") { MessageBox.Show("Data inserted successfully."); loadGridviewData(); CleareAllcontrolsRecursive(); } else { MessageBox.Show("Add Failed..."); loadGridviewData(); CleareAllcontrolsRecursive(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click(object sender, EventArgs e) { try { int selectedRoleTypeId = 0; var selectedRoleType = cmbRoleType.SelectedItem as Roles; if (selectedRoleType == null) selectedRoleTypeId = 0; else selectedRoleTypeId = selectedRoleType.Id; Employees empDetials = new Employees { Id = Convert.ToInt32(dtDetails.Rows[rowId]["Id"]), LoginId = txtLoginName.Text.Trim(), Name = txtName.Text.Trim(), Role = selectedRoleTypeId, Status=1, Password = txtPassword.Text, ModifiedOn = DateTime.Today.Date, ModifiedBy = ApplicationElements.loggedInEmployee.Id }; string updateStatus = empRepo.updateEmployeeInformation(empDetials); if (updateStatus == "Success") { MessageBox.Show("Details updated successfully."); loadGridviewData(); CleareAllcontrolsRecursive(); } else { MessageBox.Show("Update Failed..."); loadGridviewData(); CleareAllcontrolsRecursive(); } // txtRole.Visible = true; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, EventArgs e) { try { Employees empDetials = new Employees { Id = Convert.ToInt32(dtDetails.Rows[rowId]["Id"]), LoginId = txtLoginName.Text.Trim(), Name = txtName.Text.Trim(), Password = txtPassword.Text, Status = 0, ModifiedOn = DateTime.Today.Date, ModifiedBy = ApplicationElements.loggedInEmployee.Id }; var confirmResult = MessageBox.Show("Are you sure to disable this employee ??", "Confirm Disable!!", MessageBoxButtons.YesNo); if (confirmResult == DialogResult.Yes) { string updateStatus = empRepo.updateEmployeeInformation(empDetials); if (updateStatus == "Success") { MessageBox.Show("Employee disabled successfully."); loadGridviewData(); CleareAllcontrolsRecursive(); } else { MessageBox.Show("Disable Failed..."); loadGridviewData(); CleareAllcontrolsRecursive(); } HideControls(false); loadGridviewData(); } else { //HideControls(false); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }