public ActionResult index(tblJobMaster _model, string shour, string ehour, string smin, string emin, string sampm, string eampm) { int adminId = Convert.ToInt16(Session["AdminId"]); jobServices _services = new jobServices(); contactServices _ser = new contactServices(); ViewData["users"] = _ser.GetaAllContactsByAdminId(adminId); ViewData["type"] = _services.getAllJobtypes(adminId); ViewData["status"] = _services.getAllStatus(); var date1 = _model.StartDate.Value.Date.ToShortDateString() + " " + shour + ":" + smin + ":00 " + sampm; var date2 = _model.EndDate.Value.Date.ToShortDateString() + " " + ehour + ":" + emin + ":00 " + eampm; _model.EndDate = Convert.ToDateTime(date2); _model.StartDate = Convert.ToDateTime(date1); if (_model.EndDate < _model.StartDate) { ViewData["error"] = "Start Date Can't be grater then End date"; } else { var msg = _services.AddNewjob(_model, adminId); if (msg.Contains("Error")) { ViewData["error"] = msg; return(View("job", _model)); } else { TempData["error"] = msg; return(RedirectToAction("GetJobs")); } } return(View("job", _model)); }
public string updatejob(bool IsActive, int id, string EndDate, string StartDate, string poNumber, string name, int TypeId, int StatusId, int AssignTo, string description) { int adminId = Convert.ToInt16(Session["AdminId"]); jobServices _services = new jobServices(); contactServices _ser = new contactServices(); tblJobMaster _model = new tblJobMaster(); _model.AssignTo = AssignTo; _model.Detail = description; _model.PoNumber = poNumber; _model.StartDate = Convert.ToDateTime(StartDate); _model.EndDate = Convert.ToDateTime(EndDate); _model.Name = name; _model.StatusId = StatusId; _model.TypeId = TypeId; _model.IsActive = IsActive; _model.Id = id; if (_model.EndDate < _model.StartDate) { return("Error : Start Date Can't be grater then End date"); } else { return(_services.updatejobbyId(_model)); } }
public string updatejobbyId(tblJobMaster jobs) { string message = "Job Updated Succesfully"; Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var job = _idc.tblJobMasters.Where(a => a.Id == jobs.Id).FirstOrDefault(); job.AssignTo = jobs.AssignTo; job.Detail = jobs.Detail; job.EndDate = jobs.EndDate; job.Name = jobs.Name; job.PoNumber = jobs.PoNumber; job.StartDate = jobs.StartDate; job.StatusId = jobs.StatusId; job.TypeId = jobs.TypeId; job.IsActive = jobs.IsActive; _idc.SubmitChanges(); } catch (Exception ex) { message = "Error " + ex.Message; } finally { _idc.Dispose(); } return(message); }
public tblJobMaster GetjobbyId(int id) { tblJobMaster _profile = new tblJobMaster(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var p = _idc.tblJobMasters.Where(a => a.Id == id).FirstOrDefault(); return(p); } catch (Exception ex) { } finally { _idc.Dispose(); } return(_profile); }
public ActionResult index(int?id, int?statusId) { int adminId = Convert.ToInt16(Session["AdminId"]); tblJobMaster _model = new tblJobMaster(); jobServices _services = new jobServices(); contactServices _ser = new contactServices(); ViewData["users"] = _ser.GetaAllContactsByAdminId(adminId); ViewData["type"] = _services.getAllJobtypes(adminId); ViewData["status"] = _services.getAllStatus(); ViewData["statusId"] = statusId ?? 0; if (id.HasValue) { _model = _services.GetjobbyId(id.Value); return(View("editjob", _model)); } if (TempData["error"] != null) { ViewData["error"] = TempData["error"].ToString(); } return(View("job", _model)); }
public string AddNewjob(tblJobMaster jobs, int adminId) { string message = "Job Created Succesfully"; Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { jobs.CreatedDate = DateTime.Now; jobs.OpenBy = adminId.ToString(); jobs.IsActive = true; _idc.tblJobMasters.InsertOnSubmit(jobs); _idc.SubmitChanges(); } catch (Exception ex) { message = "Error " + ex.Message; } finally { _idc.Dispose(); } return(message); }