public ActionResult AddEmployee(AddEmployeeDetails model) { if (!ModelState.IsValid) { return(View(model)); } if (_employeeService.EmployeeExist(model.BankId, model.EmployeeCode ?? 0)) { ModelState.AddModelError("Employee", "The employee code is already in use."); return(View(model)); } if (_userManager.DoseUserExist(model.Username)) { ModelState.AddModelError("User", "The username is already taken."); return(View(model)); } MembershipCreateStatus status; Membership.CreateUser(model.Username, model.Password, model.Email, model.Question, model.Answer, true, out status); if (!ModelState.IsValid || status != MembershipCreateStatus.Success) { return(View(model)); } Roles.AddUserToRole(model.Username, "Banker"); _employeeService.AddEmployee(model.BankId, new EmployeeBO { Code = model.EmployeeCode ?? 0, GivenName = model.GivenName, FamilyName = model.FamilyName, Phone = model.Phone, Email = model.Email, Username = model.Username }); return(RedirectToAction("EmployeeManager")); }
public ActionResult AddEmployeeDetails(AddEmployeeDetails aed) { using (con) { con.Open(); SqlCommand com = new SqlCommand("Sp_empAdd", con); com.CommandType = CommandType.StoredProcedure; SqlDataAdapter sda = new SqlDataAdapter(com); com.Parameters.AddWithValue("@EmpName", aed.EmpName); com.Parameters.AddWithValue("@DeptId", aed.DeptId); //com.Parameters.AddWithValue("@DOB", aed.DOB); //com.Parameters.AddWithValue("@Designation", aed.Designation); //com.Parameters.AddWithValue("@GrossSalary", aed.GrossSalary); //com.Parameters.AddWithValue("@Acc_No", aed.BankAccount); //com.Parameters.AddWithValue("@Bank_Name", aed.BankName); //com.Parameters.AddWithValue("@Degree", aed.Degree); //com.Parameters.AddWithValue("@POY", aed.POY); //com.Parameters.AddWithValue("@DOJ", aed.DOJ); //List<ListItem> items = new List<ListItem>(); //items.Add(new ListItem("Item 2", "Value 2")); //items.Add(new ListItem("Item 1", "Value 1")); //items.Add(new ListItem("Item 3", "Value 3")); //items.Sort(delegate (ListItem item1, ListItem item2) { return item1.Text.CompareTo(item2.Text); }); //dropdown.Items.AddRange(items.ToArray()); com.ExecuteNonQuery(); } return(RedirectToAction("AddEmployeeDetails")); }
public ActionResult AddEmployee(int bankId) { var model = new AddEmployeeDetails { BankId = bankId }; return(View(model)); }