public ActionResult StaffEdit(KIDStaff std) { int StaffID = std.StaffID; string Position = std.Position; string FirstName = std.FirstName; string LastName = std.LastName; string Password = std.Password; string Email = std.Email; string PhoneNumber = std.PhoneNumber; Boolean StaffStatus = std.StaffStatus; DateTime StartDate = std.StartDate; DateTime EndDate = std.EndDate; //DateTime ModifiedDateTime = std.ModifiedDateTime; DateTime ModifiedDateTime = DateTime.Now; //string ModifiedUser = std.ModifiedUser; string ModifiedUser = User.Identity.Name; //asp //UserManager.RemoveFromRole(Email, Position); //keep _stafRepo.EditStaff(std); return(RedirectToAction("Index")); }
public List <KIDStaff> ViewPositions() { List <KIDStaff> StaffList = new List <KIDStaff>(); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["KID"].ConnectionString)) { using (SqlCommand command = new SqlCommand()) { command.Connection = connection; command.CommandText = "SELECT * FROM AspNetRoles"; command.CommandType = CommandType.Text; connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { KIDStaff Staff = new KIDStaff(); Staff.RoleName = reader["Name"].ToString(); StaffList.Add(Staff); } } } } return(StaffList); }
public virtual void Save(KIDStaff kidstaff) { using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["KID"].ConnectionString)) { using (SqlCommand command = new SqlCommand()) { command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "sp_Staff_InsertUpdate"; if (kidstaff.StaffID != 0) { command.Parameters.AddWithValue("@StaffID", kidstaff.StaffID); } command.Parameters.AddWithValue("@Position", kidstaff.Position); command.Parameters.AddWithValue("@FirstName", kidstaff.FirstName); command.Parameters.AddWithValue("@LastName", kidstaff.LastName); command.Parameters.AddWithValue("@Password", kidstaff.Password); command.Parameters.AddWithValue("@Email", kidstaff.Email); command.Parameters.AddWithValue("@PhoneNumber", kidstaff.PhoneNumber); command.Parameters.AddWithValue("@StaffStatus", kidstaff.StaffStatus); command.Parameters.AddWithValue("@StartDate", kidstaff.StartDate); command.Parameters.AddWithValue("@EndDate", kidstaff.EndDate); command.Parameters.AddWithValue("@ModifiedDateTime", kidstaff.ModifiedDateTime); command.Parameters.AddWithValue("@ModifiedUser", kidstaff.ModifiedUser); connection.Open(); command.ExecuteNonQuery(); } } }
//From Allen //public KIDStaff StaffMember() //{ // KIDStaff staffmember = new KIDStaff(); // using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["KlamathIrrigation_Test"].ConnectionString)) // { // using (SqlCommand command = new SqlCommand()) // { // command.Connection = connection; // command.CommandType = CommandType.Text; // command.CommandText = "SELECT FirstName, LastName, Positions.Position FROM KIDStaff, Positions WHERE Positions.PositionID = KIDStaff.Position"; // connection.Open(); // using (SqlDataReader reader = command.ExecuteReader()) // { // while (reader.Read()) // { // staffmember.FirstName = reader["FirstName"].ToString(); // staffmember.LastName = reader["LastName"].ToString(); // staffmember.Position = reader["Position"].ToString(); // } // } // } // } // return (staffmember); //} //public static ListModel GetPositionList() //{ // ListModel model = new ListModel(); // using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["KID"].ConnectionString)) // { // using (SqlCommand command = new SqlCommand()) // { // command.Connection = connection; // command.CommandText = "SELECT * FROM Positions ORDER BY PositionID"; // command.CommandType = CommandType.Text; // connection.Open(); // using (SqlDataReader reader = command.ExecuteReader()) // { // model.PositionList = new List<SelectListItem>(); // while (reader.Read()) // { // model.PositionList.Add(new SelectListItem { Text = reader.GetString(1), Value = reader.GetInt32(0).ToString() }); // } // } // } // return model; // } //} public List <SelectListItem> GetPositionList(KIDStaff p) { List <SelectListItem> PositionList = new List <SelectListItem>(); //List<Positions> PositionList = new List<Positions>(); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["KID"].ConnectionString)) { using (SqlCommand command = new SqlCommand()) { command.Connection = connection; command.CommandText = "SELECT Position FROM KIDStaff ORDER BY PositionID"; command.CommandType = CommandType.Text; connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { var t = new SelectListItem() { Text = p.Position, Value = p.Position }; PositionList.Add(t); } } } } return(PositionList); }
public ActionResult Index(int?page) { //display current user log in create partial for all views // User.Identity.GetUserName(); int pageSize = 5; int pageIndex = 1; pageIndex = page.HasValue ? Convert.ToInt32(page) : 1; IPagedList <KIDStaff> staff = null; OfficeStaffRepository staffrepository = new OfficeStaffRepository(); KIDStaff KidStaff = new KIDStaff(); List <KIDStaff> obStaffList = new List <KIDStaff>(); obStaffList = staffrepository.ViewStaff(); KidStaff.kidstaff = obStaffList; staff = obStaffList.ToPagedList(pageIndex, pageSize); return(View(staff)); }
public ActionResult ViewStaff(int StaffID) { KIDStaff kidstaff = _stafRepo.Get(StaffID); KIDStaff StaffModel = new KIDStaff() { StaffID = kidstaff.StaffID, Position = kidstaff.Position, FirstName = kidstaff.FirstName, LastName = kidstaff.LastName, Password = kidstaff.Password, Email = kidstaff.Email, PhoneNumber = kidstaff.PhoneNumber, StaffStatus = kidstaff.StaffStatus, StartDate = kidstaff.StartDate, EndDate = kidstaff.EndDate, ModifiedDateTime = kidstaff.ModifiedDateTime, ModifiedUser = kidstaff.ModifiedUser, }; return(ViewStaff(StaffID)); }
public ActionResult Add(KIDStaff kidstaff) { //Adding to KIDStaff if (!ModelState.IsValid) { return(View(kidstaff)); } //Adds user to ASP side of things...ASP = SQL, ASP = SQL var user = new ApplicationUser { UserName = kidstaff.Email, Email = kidstaff.Email }; var result = this.UserManager.Create(user, kidstaff.Password); if (result.Succeeded) { UserManager.AddToRole(user.Id, kidstaff.Position.ToString()); var role = this.RoleManager.FindByName(""); } //SQL Statement to add to KIDStaff _stafRepo.AddStaff(kidstaff); return(RedirectToAction("Index")); }
public List <KIDStaff> ViewStaff() { List <KIDStaff> StaffList = new List <KIDStaff>(); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["KID"].ConnectionString)) { using (SqlCommand command = new SqlCommand()) { command.Connection = connection; command.CommandText = "SELECT * FROM KIDStaff ORDER BY StaffID ASC"; //command.CommandText = "SELECT Positions.Position, StaffID, FirstName, LastName, Password, Email, PhoneNumber,StaffStatus, StartDate, EndDate, ModifiedDateTime, ModifiedUser FROM KIDStaff, Positions WHERE Positions.PositionID = KIDStaff.Position ORDER BY KIDStaff.StaffStatus DESC,KIDStaff.StaffID ASC "; command.CommandType = CommandType.Text; connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { //guid KIDStaff Staff = new KIDStaff(); Staff.StaffID = int.Parse(reader["StaffID"].ToString()); Staff.Position = reader["Position"].ToString(); Staff.FirstName = reader["FirstName"].ToString(); Staff.LastName = reader["LastName"].ToString(); Staff.Password = reader["Password"].ToString(); Staff.Email = reader["Email"].ToString(); Staff.PhoneNumber = reader["PhoneNumber"].ToString(); Staff.StaffStatus = Boolean.Parse(reader["StaffStatus"].ToString()); Staff.StartDate = DateTime.Parse(reader["StartDate"].ToString()); Staff.EndDate = DateTime.Parse(reader["EndDate"].ToString()); Staff.ModifiedDateTime = DateTime.Parse(reader["ModifiedDateTime"].ToString()); Staff.ModifiedUser = reader["ModifiedUser"].ToString(); StaffList.Add(Staff); } } } } return(StaffList); }
public KIDStaff Get(int id) { KIDStaff p = null; using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["KID"].ConnectionString)) { using (SqlCommand command = new SqlCommand()) { command.Connection = connection; command.CommandText = "SELECT * FROM KIDStaff"; command.CommandType = CommandType.Text; connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { p = new KIDStaff(); p.StaffID = int.Parse(reader["StaffID"].ToString()); p.Position = reader["Position"].ToString(); p.FirstName = reader["FirstName"].ToString(); p.LastName = reader["LastName"].ToString(); p.Password = reader["Password"].ToString(); p.Email = reader["Email"].ToString(); p.PhoneNumber = reader["PhoneNumber"].ToString(); p.StaffStatus = Boolean.Parse(reader["StaffStatus"].ToString()); p.StartDate = DateTime.Parse(reader["StartDate"].ToString()); p.EndDate = DateTime.Parse(reader["EndDate"].ToString()); p.ModifiedDateTime = DateTime.Parse(reader["ModifiedDateTime"].ToString()); p.ModifiedUser = reader["ModifiedUser"].ToString(); } } } } return(p); }