public ActionResult EditEmployee(int id) { dbmanage db = new dbmanage(); using (con = db.newconection()) { using (com = new SqlCommand()) { con.Open(); com.Connection = con; com.CommandText = "SELECT * FROM employee WHERE EmployeeId='" + id + "'"; using (var reader = com.ExecuteReader()) { while (reader.Read()) { ViewBag.EmployeeId = int.Parse(reader["EmployeeId"].ToString()); ViewBag.Username = reader["Username"].ToString(); ViewBag.Fname = reader["Fname"].ToString(); ViewBag.Lname = reader["Lname"].ToString(); ViewBag.Department = reader["Department"].ToString(); ViewBag.Roles = reader["Roles"].ToString(); ViewBag.CreDate = reader["CreDate"].ToString(); ViewBag.Email = reader["Email"].ToString(); } } con.Close(); } } return(View("AddUser")); }
public List <ReportView> GetReports(int eid) { List <ReportView> Report = new List <ReportView>(); string MN = DateTime.Now.ToString("MM"); dbmanage db = new dbmanage(); using (con = db.newconection()) { using (com = new SqlCommand()) { con.Open(); com.Connection = con; com.CommandText = "SELECT * FROM Report WHERE EmployeeId= '" + eid + "'AND Dates LIKE '__-" + MN + "%' ORDER BY Dates ASC"; using (var reader = com.ExecuteReader()) { while (reader.Read()) { Report.Add(new ReportView { Id = int.Parse(reader["Id"].ToString()), EmployeeName = reader["EmployeeName"].ToString(), EmployeeId = int.Parse(reader["EmployeeId"].ToString()), TaskId = int.Parse(reader["TaskId"].ToString()), TaskName = reader["TaskName"].ToString(), Dates = Convert.ToDateTime(reader["Dates"].ToString()) }); } } } } return(Report); }
public List <EmployeeView> EmployeeDetails() { List <EmployeeView> Employeelist = new List <EmployeeView>(); dbmanage db = new dbmanage(); using (con = db.newconection()) { using (com = new SqlCommand()) { con.Open(); com.Connection = con; com.CommandText = "SELECT * FROM employee WHERE NOT Fname='Admin' ORDER BY EmployeeId DESC"; using (var reader = com.ExecuteReader()) { while (reader.Read()) { Employeelist.Add(new EmployeeView { EmployeeId = int.Parse(reader["EmployeeId"].ToString()), Username = reader["Username"].ToString(), Fname = reader["Fname"].ToString(), Lname = reader["Lname"].ToString(), Name = reader["Fname"].ToString() + ' ' + reader["Lname"].ToString(), Department = reader["Department"].ToString(), Roles = reader["Roles"].ToString(), CreDate = reader["CreDate"].ToString(), Email = reader["Email"].ToString() }); } } } } return(Employeelist); }
public ActionResult Verify(Login login) { dbmanage db = new dbmanage(); using (con = db.newconection()) { using (com = new SqlCommand()) { con.Open(); com.Connection = con; com.CommandText = "SELECT * FROM employee WHERE Username = '******' AND Passwords = '" + login.password + "'"; dr = com.ExecuteReader(); if (dr.Read()) { Session["Name"] = dr["Fname"].ToString() + " " + dr["Lname"].ToString(); Session["Username"] = dr["Username"].ToString(); Session["Department"] = dr["Department"].ToString(); Session["Email"] = dr["Email"].ToString(); Session["EmployeeId"] = dr["EmployeeId"]; Session["Password"] = dr["Passwords"].ToString(); Session["Roles"] = dr["Roles"].ToString(); Session["CreDate"] = dr["CreDate"].ToString(); con.Close(); return(RedirectToAction("Dashboard", "Home")); } else { con.Close(); ViewBag.error = "UPW"; return(View("Index")); } } } }
public List <TaskView> TotalTaskList(string dept, string id) { List <TaskView> Tasklist = new List <TaskView>(); dbmanage db = new dbmanage(); using (con = db.newconection()) { using (com = new SqlCommand()) { con.Open(); com.Connection = con; com.CommandText = "SELECT * FROM Task WHERE Department= '" + dept + "'AND Resource LIKE '%E-" + id + "%'"; using (var reader = com.ExecuteReader()) { while (reader.Read()) { List <string> name = new List <string>(); String[] strlist = reader["Resource"].ToString().Split(','); foreach (string s in strlist) { string s1 = s.Replace(" ", ""); s1 = s1.Replace("E-", ""); name.Add(EmployeName(int.Parse(s1))); } Tasklist.Add(new TaskView { TaskId = int.Parse(reader["TaskId"].ToString()), TaskName = reader["TaskName"].ToString(), SDate = reader["SDate"].ToString(), EDate = reader["EDate"].ToString(), Resource = reader["Resource"].ToString(), RPerson = int.Parse(reader["RPerson"].ToString()), ProjectManager = int.Parse(reader["ProjectManager"].ToString()), Status = reader["Status"].ToString(), Department = reader["Department"].ToString(), RNPerson = EmployeName(int.Parse(reader["RPerson"].ToString())), ProjectManagerName = EmployeName(int.Parse(reader["ProjectManager"].ToString())), ResourceName = name }); } reader.Close(); } } } return(Tasklist); }
public ActionResult ModifyEmployee(EmployeeView EV) { dbmanage db = new dbmanage(); using (con = db.newconection()) { using (com = new SqlCommand()) { con.Open(); com.Connection = con; com.CommandText = "UPDATE employee SET Roles= '" + EV.Roles + "', Email= '" + EV.Email + "' WHERE EmployeeId='" + EV.EmployeeId + "'"; dr = com.ExecuteReader(); con.Close(); } } return(View("ModifyUser")); }
public ActionResult DeleteUser(int id) { dbmanage db = new dbmanage(); using (con = db.newconection()) { using (com = new SqlCommand()) { con.Open(); com.Connection = con; com.CommandText = "DELETE FROM employee WHERE EmployeeId='" + id + "'"; dr = com.ExecuteReader(); con.Close(); } } return(View("ModifyUser")); }
public ActionResult Reports(ReportView RV) { string[] s = RV.TaskName.Split('-'); if (RV.TaskName == "None") { } else { RV.TaskId = Int32.Parse(s[1]); RV.TaskName = s[0]; RV.EmployeeId = Int32.Parse(Session["EmployeeId"].ToString()); RV.EmployeeName = Session["Name"].ToString(); dbmanage db = new dbmanage(); using (con = db.newconection()) { using (com = new SqlCommand()) { con.Open(); com.Connection = con; if (RV.bto == "Delete") { com.CommandText = "DELETE FROM Report WHERE Id='" + RV.Id + "'"; dr = com.ExecuteReader(); } else { if (RV.Id == 0) { com.CommandText = "INSERT INTO Report (EmployeeName, Dates, TaskName, EmployeeId, TaskId) VALUES('" + RV.EmployeeName + "', '" + RV.Dates.ToShortDateString() + "', '" + RV.TaskName + "', '" + RV.EmployeeId + "', '" + RV.TaskId + "' ) "; dr = com.ExecuteReader(); } else { com.CommandText = "UPDATE Report SET TaskName='" + RV.TaskName + "', TaskId='" + RV.TaskId + "' WHERE Id='" + RV.Id + "'"; dr = com.ExecuteReader(); } } con.Close(); } } } return(RedirectToAction("ModifyReport", "Home")); }
public ActionResult SaveEmployee(EmployeeView EV) { EV.Passwords = PasswordGenerator(10).ToString(); EV.Status = "ADD"; dbmanage db = new dbmanage(); using (con = db.newconection()) { using (com = new SqlCommand()) { con.Open(); com.Connection = con; com.CommandText = "INSERT INTO employee (Username, Fname, Lname, Department, Roles, CreDate, Email, Passwords, Status) VALUES('" + EV.Username + "', '" + EV.Fname + "', '" + EV.Lname + "', '" + EV.Department + "','" + EV.Roles + "','" + EV.CreDate + "','" + EV.Email + "','" + EV.Passwords + "','" + EV.Status + "' ) "; dr = com.ExecuteReader(); con.Close(); } } return(View("Index")); }
public string EmployeName(int id) { dbmanage db = new dbmanage(); using (con = db.newconection()) { using (com = new SqlCommand()) { con.Open(); com.Connection = con; com.CommandText = "SELECT * FROM employee WHERE EmployeeId= '" + id + "' "; using (var dr = com.ExecuteReader()) { string s = " "; if (dr.Read()) { s = dr["Fname"].ToString() + " " + dr["Lname"].ToString(); dr.Close(); } return(s); } } } }