public PartialViewResult Create_Employee() { jugglecontext dbcon = new jugglecontext(); int userid = Convert.ToInt32(Session["User_Id"]); var content = from p in dbcon.tbl_worktype where p.user_id == userid select new { p.work_id, p.name }; var attribute = from p in dbcon.tbl_attribute_data where p.user_id == userid select new { p.attribute_id, p.attribute_name }; var x = content.ToList().Select(c => new SelectListItem { Text = c.name.ToString(), Value = c.work_id.ToString(), }).ToList(); ViewBag.emp_qualifiedservicetypeslist = x; var attri = attribute.ToList().Select(c => new SelectListItem { Text = c.attribute_name.ToString(), Value = c.attribute_id.ToString(), }).ToList(); ViewBag.attributelist = attri; return(PartialView()); }
public ActionResult employee_delete(Int32 emp_id) { using (jugglecontext dbcon = new jugglecontext()) { if (Session["User_Id"] != null) { // when employee delete at that time his/her assigned appointment will be upassign SqlConnection connection = new SqlConnection(dbcon.connectionString()); var command = new SqlCommand("[updatedata]", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@emp_id", emp_id); command.Parameters.AddWithValue("@startdate", 0); command.Parameters.AddWithValue("@enddate", 0); command.Parameters.AddWithValue("@StartTime", 0); command.Parameters.AddWithValue("@endTime", 0); command.Parameters.AddWithValue("@user_id", Convert.ToInt32(Session["User_Id"])); command.Parameters.AddWithValue("@attribute_id", 0); command.Parameters.AddWithValue("@client_id", 0); command.Parameters.AddWithValue("@appointment_id", 0); command.Parameters.AddWithValue("@StatementType", "emp_data"); connection.Open(); SqlDataReader rdr = command.ExecuteReader(); tbl_employee_info objEmpl = dbcon.tbl_employee_info.Find(emp_id); dbcon.tbl_employee_info.Remove(objEmpl); dbcon.SaveChanges(); } return(RedirectToAction("Employee", "Employee")); } }
/// <summary> /// Employees the availability. /// </summary> /// <returns></returns> public ActionResult EmployeeAvailability() { if (Session["User_Id"] != null) { using (jugglecontext dbcon = new jugglecontext()) { int userid = Convert.ToInt32(Session["User_Id"]); var employeeavailabilit = (from a in dbcon.tbl_employee_availability join b in dbcon.tbl_employee_info on a.emp_id equals b.emp_id where a.userid == userid orderby a.empavailability_id descending select new { a.start_date, a.end_date, a.time_range_start, a.time_range_end, a.empavailability_id, Empname = b.emp_firstname + " " + b.emp_lastname, }).ToList(); return(View(employeeavailabilit)); } } else { return(RedirectToAction("Login", "Account")); } }
public ActionResult ForgotPassword(juggle.Models.Forgotpassword_Model Fpss) { var female = Fpss.Email.ToString(); using (jugglecontext dbcon = new jugglecontext()) { var getPass = dbcon.tbl_user.Where(useremail => useremail.email == female).SingleOrDefault(); if (getPass != null) { var Password = dbcon.Decrypt(getPass.password.ToString()); var UseraName = getPass.username.ToString(); try { string Body = "Your Username : '******' and password :'******'"; dbcon.SendMail(Fpss.Email, "Forgot Password - Juggle", Body, Password, UseraName); ViewBag.Isokay = "auth"; } catch { ModelState.AddModelError("", "Invalid user!"); } } else { } } return(View()); }
public ActionResult Create_Worktype(juggle.Models.tbl_worktype work_type) { using (jugglecontext dbcon = new jugglecontext()) { try { tbl_worktype worktype = new tbl_worktype(); worktype.name = work_type.name.Trim(); worktype.color = work_type.color; var time = Request.Form["multiple"]; worktype.time = time; worktype.user_id = Convert.ToInt32(Session["User_Id"]); worktype.created_date = DateTime.Now; dbcon.tbl_worktype.Add(worktype); dbcon.SaveChanges(); return(RedirectToAction("Work_type", "Work_type")); } catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } return(View(work_type)); } } }
// Get appointment public ActionResult Appointment() // banse { if (Session["User_Id"] != null) { using (jugglecontext dbcon = new jugglecontext()) { int userid = Convert.ToInt32(Session["User_Id"]); var appointment = (from a in dbcon.tbl_appointment join b in dbcon.tbl_client on a.client_id equals b.client_id join d in dbcon.tbl_worktype on a.work_id equals d.work_id where a.user_id == userid orderby a.appointment_id descending select new { a.appointment_id, a.description, a.start_date, a.end_date, a.time_range_start, a.time_range_end, client_id = b.client_firstname + " " + b.client_lastname, work_id = d.name, a.time, a.emp_id }).ToList(); return(View(appointment)); } } else { return(RedirectToAction("Login", "Account")); } }
public ActionResult Worktype_Edit(juggle.Models.tbl_worktype work_type) { try { using (jugglecontext dbcon = new jugglecontext()) { tbl_worktype worktype = new tbl_worktype(); worktype.name = work_type.name.Trim(); worktype.color = work_type.color; var time = Request.Form["multiple"]; worktype.time = time; worktype.work_id = work_type.work_id; worktype.updated_date = DateTime.Now; worktype.user_id = work_type.user_id; worktype.created_date = work_type.created_date; dbcon.Entry(worktype).State = System.Data.Entity.EntityState.Modified; dbcon.SaveChanges(); return(RedirectToAction("Work_type", "Work_type")); } } catch { return(View()); } }
public ActionResult Worktype_Edit(Int32 work_id) // banse { jugglecontext dbcon1 = new jugglecontext(); var content = from p in dbcon1.tbl_worktype select new { p.work_id, p.name }; var wname = content.ToList().Select(c => new SelectListItem { Text = c.name.ToString(), Value = c.work_id.ToString(), Selected = (c.work_id == work_id) }).ToList(); ViewBag.CurrencyList = wname; try { using (jugglecontext dbcon = new jugglecontext()) { tbl_worktype work_type = dbcon.tbl_worktype.Where(x => x.work_id == work_id).FirstOrDefault(); tbl_worktype prod = new tbl_worktype(); prod.work_id = work_type.work_id; prod.name = work_type.name; prod.color = work_type.color; prod.worktypecat_id = work_type.worktypecat_id; prod.user_id = work_type.user_id; prod.created_date = work_type.created_date; return(View(prod)); } } catch (Exception ex) { return(View()); } }
/// <summary> /// Get Works type data. /// </summary> /// <returns></returns> public ActionResult Work_type() { if (Session["User_Id"] != null && Session["User_Roll_Id"].ToString() == "2") { int userid = Convert.ToInt32(Session["User_Id"]); using (jugglecontext dbcon = new jugglecontext()) { var worktypecate = (from a in dbcon.tbl_worktype where a.user_id == userid orderby a.work_id descending select new { a.work_id, a.user_id, a.name, a.color, a.created_date, a.updated_date, }).ToList(); return(View(worktypecate)); } } else { return(RedirectToAction("Login", "Account")); } }
/// <summary> /// Get Clients data. /// </summary> /// <returns></returns> public ActionResult Client() { if (Session["User_Id"] != null && Session["User_Roll_Id"].ToString() == "2") { using (jugglecontext dbcon = new jugglecontext()) { var userId = Convert.ToInt32(Session["User_Id"]); var client_list = (from a in dbcon.tbl_client where a.user_id == userId orderby a.client_id descending select new { clientname = a.client_firstname + " " + a.client_lastname, a.client_contact_info, a.client_address, a.client_id }).ToList(); return(View(client_list)); } } else { return(RedirectToAction("Login", "Account")); } }
public JsonResult doesphoneExist(string client_contact_info, int client_id = 0) { try { jugglecontext dbcon = new jugglecontext(); int userid = Convert.ToInt32(Session["User_Id"]); var does_emp_email = (from a in dbcon.tbl_employee_info where a.emp_contactinfo == client_contact_info && a.user_id == userid select a).ToList(); if (does_emp_email.Count > 0) { return(Json(string.Format("{0} already exists.", client_contact_info))); } return(dbcon.tbl_client.Any(x => x.client_id != client_id && x.client_contact_info == client_contact_info && x.user_id == userid) ? Json(string.Format("{0} already exists.", client_contact_info), JsonRequestBehavior.AllowGet) : Json(true, JsonRequestBehavior.AllowGet)); } catch { return(Json("error", JsonRequestBehavior.AllowGet)); } }
public ActionResult Employeeavailibility_Edit(Int32 empavailability_id) { using (jugglecontext dbcon = new jugglecontext()) { jugglecontext dbcon1 = new jugglecontext(); int userid = Convert.ToInt32(Session["User_Id"]); tbl_employee_availability employee = dbcon.tbl_employee_availability.Where(x => x.empavailability_id == empavailability_id).FirstOrDefault(); tbl_employee_availability empl = new tbl_employee_availability(); empl.start_date = Convert.ToDateTime(employee.start_date); empl.end_date = Convert.ToDateTime(employee.end_date); empl.time_range_start = employee.time_range_start; empl.time_range_end = employee.time_range_end; empl.emp_id = Convert.ToInt32(employee.emp_id); empl.created_date = employee.created_date; empl.updated_date = DateTime.Now; var emplist = (from a in dbcon.tbl_employee_info where a.user_id == userid select new { a.emp_id, a.emp_firstname, a.emp_lastname }); var empdropdown = emplist.ToList().Select(c => new SelectListItem { Text = c.emp_firstname.ToString() + " " + c.emp_lastname.ToString(), Value = c.emp_id.ToString(), Selected = (c.emp_id == employee.emp_id) }).ToList(); ViewBag.emp_list = empdropdown; return(View(empl)); } }
public JsonResult checktimerangeend(string time_range_end = null, string time_range_start = null, string start_date = null, string end_date = null) { try { string timezone = Session["timezone"].ToString(); TimeZoneInfo targetZone = TimeZoneInfo.FindSystemTimeZoneById(timezone); DateTime newDT = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, targetZone); DateTime today = newDT; string dating = today.ToString("MM/dd/yyyy"); if (string.IsNullOrEmpty(time_range_start)) { return(Json(string.Format("Please Select Start Time"), JsonRequestBehavior.AllowGet)); } jugglecontext dbcon = new jugglecontext(); TimeSpan timestart = TimeSpan.Parse(time_range_start); TimeSpan timeend = TimeSpan.Parse(time_range_end); DateTime startstart = Convert.ToDateTime(time_range_start); DateTime dt = Convert.ToDateTime(start_date + " " + time_range_start); if (timestart == timeend) { return(Json(string.Format("End time cannot be the same as start time."), JsonRequestBehavior.AllowGet)); } else { return(Json(true, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { Logfile.WriteCDNLog(ex.ToString(), "checktimerangeend"); return(Json("Invalid Time", JsonRequestBehavior.AllowGet)); } }
public ActionResult Employee_Edit(Int32 emp_id) { int userid = Convert.ToInt32(Session["User_Id"]); using (jugglecontext dbcon = new jugglecontext()) { jugglecontext dbcon1 = new jugglecontext(); var content = from p in dbcon.tbl_worktype where p.user_id == userid select new { p.work_id, p.name }; var attribute = from p in dbcon.tbl_attribute_data where p.user_id == userid select new { p.attribute_id, p.attribute_name }; var getmultipledata = (from a in dbcon.tbl_employee_info where a.emp_id == emp_id select a ).ToList(); string multipleattribute = getmultipledata[0].attribute_id.ToString(); string multipleservicetype = getmultipledata[0].emp_qualifiedservicetypes.ToString(); tbl_employee_info employee = dbcon.tbl_employee_info.Where(x => x.emp_id == emp_id).FirstOrDefault(); tbl_employee_info empl = new tbl_employee_info(); empl.emp_id = employee.emp_id; empl.emp_firstname = employee.emp_firstname; empl.emp_lastname = employee.emp_lastname; empl.emp_qualifiedservicetypes = employee.emp_qualifiedservicetypes; empl.emp_contactinfo = employee.emp_contactinfo; empl.emp_code = autogenerateid(); empl.user_id = employee.user_id; empl.emp_transportion = employee.emp_transportion; empl.created_date = employee.created_date; empl.emp_note = employee.emp_note; empl.attribute_id = employee.attribute_id; empl.emp_googlecalendarID = employee.emp_googlecalendarID; empl.emp_note = employee.emp_note; empl.emp_password = dbcon.Decrypt(employee.emp_password); var emp_list = content.ToList().Select(c => new SelectListItem { Text = c.name.ToString(), Value = c.work_id.ToString(), }).ToList(); ViewBag.emp_qualifiedservicetypeslist = emp_list; var attri = attribute.ToList().Select(c => new SelectListItem { Text = c.attribute_name.ToString(), Value = c.attribute_id.ToString(), }).ToList(); ViewBag.attributelist = attri; return(View(empl)); } }
public JsonResult getStatus() { using (jugglecontext dbcon = new jugglecontext()) { var query = new SelectList(dbcon.tbl_status.OrderByDescending(x => x.status_id).ToList(), "status_id", "status"); return(Json(query, JsonRequestBehavior.AllowGet)); } }
public ActionResult Create_Workers(tbl_user user) { var autopassword = ""; if (Session["User_Id"] != null) { int getstatusID = Convert.ToInt32(Request.Form["Status_hidden"]); if (getstatusID == 0) { getstatusID = 1; } using (jugglecontext dbcon = new jugglecontext()) { try { var userId = Convert.ToInt32(Session["User_Id"]); tbl_user tblusr = new tbl_user(); tblusr.firstName = user.firstName.Trim(); tblusr.lastName = user.lastName.Trim(); tblusr.address = user.address.Trim(); tblusr.phoneno = user.phoneno.Trim(); tblusr.email = user.email.Trim(); tblusr.username = user.username.Trim(); autopassword = dbcon.GeneratePassword(6).Trim(); tblusr.password = dbcon.Encrypt(autopassword.Trim()); tblusr.created_date = DateTime.Now; tblusr.status = getstatusID; tblusr.supervisor_id = userId; tblusr.role_id = 3; tblusr.user_id = userId; dbcon.tbl_user.Add(tblusr); dbcon.SaveChanges(); string Password = autopassword; string Body = "Your password '" + Password + "' "; dbcon.SendMail(tblusr.email, "Password", Body, Password); return(RedirectToAction("ManageWorkers", "Workers")); } catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } return(View(user)); } } } else { return(View(user)); } }
public ActionResult Employeeavailibility_Edit(tbl_employee_availability employee) { if (Session["User_Id"] != null) { using (jugglecontext dbcon = new jugglecontext()) { try { tbl_employee_availability empl = new tbl_employee_availability(); empl.emp_id = employee.emp_id; empl.start_date = Convert.ToDateTime(employee.start_date); empl.end_date = Convert.ToDateTime(employee.end_date); empl.userid = Convert.ToInt32(Session["User_Id"]); empl.time_range_start = employee.time_range_start; empl.time_range_end = employee.time_range_end; empl.created_date = employee.created_date; empl.updated_date = DateTime.Now; empl.empavailability_id = Convert.ToInt32(employee.empavailability_id); dbcon.Entry(empl).State = System.Data.Entity.EntityState.Modified; dbcon.SaveChanges(); // when employee delete at that time his/her assigned appointment will be upassign SqlConnection connection = new SqlConnection(dbcon.connectionString()); var command = new SqlCommand("[updateempavailibility]", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@startdate", Convert.ToDateTime(employee.start_date)); command.Parameters.AddWithValue("@enddate", Convert.ToDateTime(employee.end_date)); command.Parameters.AddWithValue("@StartTime", employee.time_range_start); command.Parameters.AddWithValue("@endTime", employee.time_range_end); command.Parameters.AddWithValue("@emp_id", Convert.ToInt32(employee.emp_id)); command.Parameters.AddWithValue("@type", "edit"); connection.Open(); SqlDataReader rdr = command.ExecuteReader(); return(RedirectToAction("EmployeeAvailability", "EmployeeAvailability")); } catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } } } } else { return(RedirectToAction("Login", "Account")); } return(View()); }
/// <summary> /// Manages the supervisors. /// </summary> /// <returns></returns> public ActionResult ManageSupervisors() { try { //if (Session["User_Id"] != null && Session["User_Roll_Id"].ToString() == "2") if (Session["User_Id"] != null) { using (jugglecontext dbcon = new jugglecontext()) { var userId = Convert.ToInt32(Session["User_Id"]); //var supervisoruser = (from a in dbcon.tbl_user // join b in dbcon.tbl_status on a.status equals b.status_id // where a.role_id == 2 && a.user_id == userId // orderby a.user_id descending // select new // { // username = a.username, // address = a.address, // phoneno = a.phoneno, // Status = b.status, // user_id = a.user_id // } // ).ToList(); var supervisoruser = (from a in dbcon.tbl_user join b in dbcon.tbl_status on a.status equals b.status_id where a.supervisor_id == userId //&& a.user_id == userId orderby a.user_id descending select new { username = a.username, address = a.address, phoneno = a.phoneno, Status = b.status, user_id = a.user_id, a.firstName, a.profile_pict } ).ToList(); //Session["firstname"] = supervisoruser[0].firstName; //Session["profile_pict"] = supervisoruser[0].profile_pict; return(View(supervisoruser)); } } else { return(RedirectToAction("Login", "Account")); } } catch (Exception ex) { Logfile.WriteCDNLog(ex.ToString(), "ManageSupervisors"); return(RedirectToAction("Login", "Account")); } }
public JsonResult checktimerangestart(string time_range_start = null, string start_date = null, string end_date = null) { try { string timezone = Session["timezone"].ToString(); //TimeZoneInfo targetZone = TimeZoneInfo.FindSystemTimeZoneById("Hawaiian Standard Time"); TimeZoneInfo targetZone = TimeZoneInfo.FindSystemTimeZoneById(timezone); DateTime newDT = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, targetZone); DateTime today = newDT; //DateTime today = DateTime.Now; string dating = today.ToString("MM/dd/yyyy"); TimeSpan time24 = TimeSpan.Parse(time_range_start); // convert time start into specific format DateTime startstart = Convert.ToDateTime(time_range_start); string test = startstart.ToString("h:mm tt", CultureInfo.CurrentCulture); DateTime dt; jugglecontext dbcon = new jugglecontext(); // check whether the time start is given time slot or not (EX: 8:00 AM, 10:00 AM,12:00 AM) var gettimeintervaltime = (from a in dbcon.tbl_time_interval where a.time_start == test select a).ToList(); if (gettimeintervaltime.Count <= 0) { return(Json(string.Format("Select only Hopper Start time"), JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(start_date)) { dt = Convert.ToDateTime(dating + " " + time_range_start); } else { dt = Convert.ToDateTime(start_date + " " + time_range_start); } if (dt < today) { return(Json(string.Format("This time slot has already passed."), JsonRequestBehavior.AllowGet)); } else { return(Json(true, JsonRequestBehavior.AllowGet)); } } catch { return(Json("Invalid Time", JsonRequestBehavior.AllowGet)); } }
public ActionResult Worktype_delete(Int32 work_id) { if (Session["User_Id"] != null) { try { using (jugglecontext dbcon = new jugglecontext()) { if (Session["User_Id"] != null) { string workid = work_id.ToString(); var employee_detail = (from a in dbcon.tbl_employee_info where a.emp_qualifiedservicetypes.Contains(workid) select a).ToList(); for (int i = 0; i < employee_detail.Count; i++) { string emp_worktype = employee_detail[i].emp_qualifiedservicetypes.ToString(); emp_worktype = emp_worktype.Replace(workid, ""); SqlConnection connection = new SqlConnection(dbcon.connectionString()); var command = new SqlCommand("[updatedata]", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@client_id", 0); command.Parameters.AddWithValue("@attribute_id", emp_worktype); command.Parameters.AddWithValue("@appointment_id", 0); command.Parameters.AddWithValue("@StatementType", "worktype_data"); command.Parameters.AddWithValue("@emp_id", Convert.ToInt32(employee_detail[i].emp_id)); command.Parameters.AddWithValue("@startdate", 0); command.Parameters.AddWithValue("@enddate", 0); command.Parameters.AddWithValue("@StartTime", 0); command.Parameters.AddWithValue("@endTime", 0); command.Parameters.AddWithValue("@user_id", Convert.ToInt32(Session["User_Id"])); connection.Open(); SqlDataReader rdr = command.ExecuteReader(); } tbl_worktype objEmp = dbcon.tbl_worktype.Find(work_id); dbcon.tbl_worktype.Remove(objEmp); dbcon.SaveChanges(); } return(RedirectToAction("Work_type", "Work_type")); } } catch { return(View()); } } else { return(View("Login", "Account")); } }
public ActionResult changePassword(changePassword changepass) { if (Session["User_Id"] != null) { using (jugglecontext dbcon = new jugglecontext()) { var old_pass = changepass.oldPassword.ToString().Trim(); var new_pass = dbcon.Encrypt(changepass.NewPassword.ToString()); tbl_user user = null; var user_id = Convert.ToInt32(Session["User_Id"].ToString()); string password_fromdb; var getuser_pass = dbcon.tbl_user.SingleOrDefault(user_id_db => user_id_db.user_id == user_id); user = dbcon.tbl_user.Where(s => s.user_id == user_id).FirstOrDefault <tbl_user>(); if (getuser_pass != null) { password_fromdb = dbcon.Decrypt(getuser_pass.password.ToString()); if (password_fromdb == old_pass) { user.password = Convert.ToString(new_pass); dbcon.tbl_user.Attach(user); dbcon.Entry(user).State = System.Data.Entity.EntityState.Modified; dbcon.SaveChanges(); ViewBag.message = "Your password has been changed."; } else { if (string.IsNullOrEmpty(old_pass)) { ModelState.AddModelError("oldPassword", "Please enter old password."); } else { ModelState.AddModelError("", "Invalid old password!"); } } } else { ViewBag.InvalidUser = "******"; } } } else { return(RedirectToAction("Login", "Account")); } return(View()); }
public ActionResult Edit_Supervisorprofile(tbl_user tbluser) { if (Session["User_Id"] != null) { using (jugglecontext dbcon = new jugglecontext()) { tbl_user users = new tbl_user(); var userId = Convert.ToInt32(Session["User_Id"]); users.supervisor_id = tbluser.supervisor_id; users.user_id = tbluser.user_id; users.firstName = tbluser.firstName; users.lastName = tbluser.lastName; users.address = tbluser.address; users.phoneno = tbluser.phoneno; users.email = tbluser.email; users.status = tbluser.status; users.username = tbluser.username; users.password = tbluser.password; users.created_date = tbluser.created_date; users.updated_date = DateTime.Now; users.timezoneid = "Central Standard Time"; Session["firstname"] = tbluser.firstName; Session["profile_pict"] = tbluser.profile_pict; if (Request.Files.Count > 0) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); users.profile_pict = fileName; var path = Path.Combine(Server.MapPath("~/Profile_Picture/"), fileName); file.SaveAs(path); } else { users.profile_pict = tbluser.profile_pict; } } users.role_id = 2; dbcon.Entry(users).State = System.Data.Entity.EntityState.Modified; dbcon.SaveChanges(); return(RedirectToAction("Index", "SupervisorProfile")); } } else { return(RedirectToAction("Login", "Account")); } }
public JsonResult doesemployeeavailability(int emp_id, int empavailability_id = 0, string time_range_start = null, string time_range_end = null, string start_date = null, string end_date = null, string day = null, Boolean recurring = false) { try { jugglecontext dbcon = new jugglecontext(); DateTime start_Date_check = Convert.ToDateTime(start_date); if (string.IsNullOrEmpty(end_date)) { end_date = start_date; } int userid = Convert.ToInt32(Session["User_Id"]); DateTime end_Date_check = Convert.ToDateTime(end_date); TimeSpan time_range_start_timespan = TimeSpan.Parse(time_range_start); TimeSpan time_range_end_timespan = TimeSpan.Parse(time_range_end); DateTime time_range_start_timespandate = Convert.ToDateTime(start_date + " " + time_range_start); DateTime time_range_end_timespandate = Convert.ToDateTime(end_date + " " + time_range_end); var id = (from a in dbcon.tbl_employee_availability where a.emp_id == emp_id && a.empavailability_id != empavailability_id select a).ToList(); for (int i = 0; i < id.Count; i++) { SqlConnection connection = new SqlConnection(dbcon.connectionString()); var command = new SqlCommand("compare_client_Availibility", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@startdate", Convert.ToDateTime(start_date)); command.Parameters.AddWithValue("@enddate", Convert.ToDateTime(end_date)); command.Parameters.AddWithValue("@StartTime", time_range_start.ToString()); command.Parameters.AddWithValue("@endTime", time_range_end.ToString()); command.Parameters.AddWithValue("@emp_id", Convert.ToInt32(emp_id)); command.Parameters.AddWithValue("@empavailability_id", Convert.ToInt32(empavailability_id)); command.Parameters.AddWithValue("@userid", userid); connection.Open(); SqlDataReader rdr = command.ExecuteReader(); while (rdr.Read()) { connection.Close(); return(Json(string.Format("This Employee has already availability."), JsonRequestBehavior.AllowGet)); } } return(Json(true, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Logfile.WriteCDNLog(ex.ToString(), "doesemployeeavailability"); return(Json("", JsonRequestBehavior.AllowGet)); } }
// Get work type public ActionResult Worktype_category() { if (Session["User_Id"] != null && Session["User_Roll_Id"].ToString() == "2") { using (jugglecontext dbcon = new jugglecontext()) { List <tbl_worktype_category> worktype_category = dbcon.tbl_worktype_category.OrderByDescending(x => x.worktypecategory_name).ToList <tbl_worktype_category>(); return(View(worktype_category)); } } else { return(RedirectToAction("Login", "Account")); } }
public JsonResult doescolorExist(string color, int work_id = 0) { try { jugglecontext dbcon = new jugglecontext(); return(dbcon.tbl_worktype.Any(x => x.color == color && x.work_id != work_id) ? Json(string.Format("color already exist"), JsonRequestBehavior.AllowGet) : Json(true, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("error", JsonRequestBehavior.AllowGet)); } }
// Get work type public ActionResult Worktype() { if (Session["User_Id"] != null) { using (jugglecontext dbcon = new jugglecontext()) { List <tbl_worktype> worktype = dbcon.tbl_worktype.OrderByDescending(x => x.name).ToList <tbl_worktype>(); return(View(worktype)); } } else { return(RedirectToAction("Login", "Account")); } }
public PartialViewResult Create_Supervisor() { jugglecontext dbcon = new jugglecontext(); var status = from p in dbcon.tbl_status select new { p.status_id, p.status }; var statusname = status.ToList().Select(c => new SelectListItem { Text = c.status.ToString(), Value = c.status_id.ToString(), }).ToList(); ViewBag.status = statusname; return(PartialView()); }
public JsonResult doesNameExist(string name, int work_id = 0) { try { jugglecontext dbcon = new jugglecontext(); return(dbcon.tbl_worktype.Any(x => x.name == name.Trim() && x.work_id != work_id) ? Json(string.Format("{0} already exists.", name), JsonRequestBehavior.AllowGet) : Json(true, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("error", JsonRequestBehavior.AllowGet)); } }
public ActionResult Employee_Edit(tbl_employee_info employee) { if (Session["User_Id"] != null) { using (jugglecontext dbcon = new jugglecontext()) { try { string multipleattribute = Request.Form["attribute_id_multiple"].ToString(); string multipleservice = Request.Form["emp_qualifiedservicetypes_multiple"].ToString(); tbl_employee_info empl = new tbl_employee_info(); empl.emp_id = employee.emp_id; empl.emp_firstname = employee.emp_firstname; empl.emp_lastname = employee.emp_lastname; empl.emp_qualifiedservicetypes = multipleservice; empl.user_id = employee.user_id; empl.created_date = employee.created_date; empl.emp_code = autogenerateid(); empl.updated_date = DateTime.Now; empl.emp_contactinfo = employee.emp_contactinfo; empl.attribute_id = multipleattribute; empl.emp_transportion = employee.emp_transportion; empl.emp_googlecalendarID = employee.emp_googlecalendarID; empl.emp_note = employee.emp_note; empl.emp_password = dbcon.Encrypt(employee.emp_password); dbcon.Entry(empl).State = System.Data.Entity.EntityState.Modified; dbcon.SaveChanges(); return(RedirectToAction("Employee", "Employee")); } catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage); } } } } } else { return(RedirectToAction("Login", "Account")); } return(View()); }
public PartialViewResult Create_Client() { jugglecontext dbcon = new jugglecontext(); int userid = Convert.ToInt32(Session["User_Id"]); var attribute = from p in dbcon.tbl_attribute_data where p.user_id == userid select new { p.attribute_id, p.attribute_name }; var attri = attribute.ToList().Select(c => new SelectListItem { Text = c.attribute_name.ToString(), Value = c.attribute_id.ToString(), }).ToList(); ViewBag.attributelist = attri; return(PartialView()); }