public ActionResult SaveCS(AF_ChangeSchedulefiling Filing, string Reasons, string EmployeeNos) { List <string> ReasonList = Reasons.Split(',').ToList(); List <string> EmployeeNosLis = EmployeeNos.Split(',').ToList(); int emploCounter = 0; string CSRefnow = helper.GenerateCSRef(); string Section = ""; foreach (string reason in ReasonList) { string EmploNos = EmployeeNosLis[emploCounter]; AF_ChangeSchedulefiling csfile = new AF_ChangeSchedulefiling(); csfile.CS_RefNo = CSRefnow; csfile.CSType = Filing.CSType; csfile.BIPH_Agency = Filing.BIPH_Agency; csfile.EmployeeNo = EmploNos; csfile.FileType = Filing.FileType; csfile.Section = (from c in db.M_Employee_CostCenter where c.EmployNo == EmploNos orderby c.ID descending select c.CostCenter_AMS).FirstOrDefault(); Section = (from c in db.M_Cost_Center_List where c.Cost_Center == csfile.Section orderby c.ID descending select c.GroupSection).FirstOrDefault();//otfile.Section;//csfile.Section; csfile.DateFrom = Filing.DateFrom.Date; csfile.DateTo = Filing.DateTo.AddHours(23).AddMinutes(59).AddSeconds(59); csfile.CSin = Filing.CSin; csfile.CSout = Filing.CSout; csfile.Reason = reason; csfile.Status = 0; csfile.StatusMax = 2; csfile.CreateID = user.UserName; csfile.CreateDate = DateTime.Now; csfile.UpdateID = user.UserName; csfile.UpdateDate = DateTime.Now; csfile.Schedule = Filing.Schedule; //if (EmploNos.Contains("BIPH")) //{ csfile.EmployeeAccept = db.TT_GETTIME().FirstOrDefault(); //DateTime.Now;; //} try { db.AF_ChangeSchedulefiling.Add(csfile); db.SaveChanges(); } catch (Exception err) { Error_Logs error = new Error_Logs(); error.PageModule = "Application Form - Change Schedule"; error.ErrorLog = err.Message; error.DateLog = db.TT_GETTIME().FirstOrDefault(); //DateTime.Now;; error.Username = user.UserName; db.Error_Logs.Add(error); db.SaveChanges(); } emploCounter++; } #region Generate CS Status db.AF_EmailCSRequestApprovers(); db.AF_EmailCSRequest(CSRefnow); #endregion #region REmoved //M_Section_ApproverStatus checker = (from c in db.M_Section_ApproverStatus where c.RefNo == CSRefnow select c).FirstOrDefault(); //if (checker == null) //{ // #region GET approver & Email // //string SectionID = (from c in db.M_Cost_Center_List // // where c.Cost_Center == Section // // select c.ID).FirstOrDefault().ToString(); // List<M_Section_Approver> approver = (from c in db.M_Section_Approver // where c.Section == Section // && c.Position != "GeneralManager" // && c.Position != "FactoryGeneralManager" // select c).ToList(); // #endregion // #region Generate CS Status // db.AF_EmailCSRequestApprovers(); // //foreach (M_Section_Approver approv in approver) // //{ // // M_Section_ApproverStatus approverstat = new M_Section_ApproverStatus(); // // approverstat.Position = approv.Position; // // approverstat.EmployeeNo = approv.EmployeeNo; // // approverstat.Section = Section; // // approverstat.RefNo = CSRefnow; // // approverstat.Approved = 0; // // approverstat.OverTimeType = ""; // // approverstat.CreateID = user.UserName; // // approverstat.CreateDate = DateTime.Now; // // approverstat.UpdateID = user.UserName; // // approverstat.UpdateDate = DateTime.Now; // // db.M_Section_ApproverStatus.Add(approverstat); // // db.SaveChanges(); // //} // #endregion //} //db.AF_EmailCSRequest(CSRefnow); #endregion return(Json(new { CSRefnow = CSRefnow }, JsonRequestBehavior.AllowGet)); }
public ActionResult GetEmployeeList(string Agency, string Section, Nullable <long> lINEID, string employeeNo, List <string> ChosenEmployees, long?Schedule, string TransType) { System.Web.HttpContext.Current.Session["Searchvalueot"] = Request["search[value]"]; System.Web.HttpContext.Current.Session["lINEID"] = lINEID; int start = (Convert.ToInt32(Request["start"]) == 0) ? 0 : (Convert.ToInt32(Request["start"]) / Convert.ToInt32(Request["length"])); int length = Convert.ToInt32(Request["length"]); string searchValue = Request["search[value]"]; searchValue = (searchValue == null) ? "" : searchValue; string sortColumnName = Request["columns[" + Request["order[0][column]"] + "][name]"]; string sortDirection = Request["order[0][dir]"]; ObjectParameter totalCount = new ObjectParameter("TotalCount", typeof(int)); List <GET_Employee_OTFiling_Result> list = new List <GET_Employee_OTFiling_Result>(); string currentRefno = ""; switch (TransType) { case "OT": currentRefno = helper.GenerateOTRef(); list = db.GET_Employee_OTFiling(Agency, user.CostCode, lINEID, employeeNo, start, length, searchValue, totalCount).ToList(); list = list.OrderBy(x => x.EmpNo).ToList(); //list = list.Where(x => x.Section == user.CostCode).ToList(); //List<AF_OTfiling> AlreadyApplied = (from c in db.AF_OTfiling where c.OT_RefNo == currentRefno && c.Status >= 0 select c).ToList(); //list = list.Where(p => !AlreadyApplied.Any(p2 => p2.EmployeeNo == p.EmpNo)).ToList(); break; case "CS": currentRefno = helper.GenerateCSRef(); list = db.GET_Employee_OTFiling(Agency, user.CostCode, lINEID, employeeNo, start, length, searchValue, totalCount).ToList(); list = list.OrderBy(x => x.EmpNo).ToList(); //if (Schedule != null) //{ // string Schedulename = (from c in db.M_Schedule where c.ID == Schedule select c.Timein + " - " + c.TimeOut).FirstOrDefault(); // list = list.Where(x => x.Schedule == Schedulename).ToList(); //} // list = list.Where(x => x.Section == user.Section).ToList(); // List<AF_ChangeSchedulefiling> AlreadyAppliedcs = (from c in db.AF_ChangeSchedulefiling where c.CS_RefNo == currentRefno && c.Status >= 0 select c).ToList(); // list = list.Where(p => !AlreadyAppliedcs.Any(p2 => p2.EmployeeNo == p.EmpNo)).ToList(); break; case "DTR": currentRefno = helper.GenerateDTRRef(); list = db.GET_Employee_OTFiling(Agency, user.CostCode, lINEID, employeeNo, start, length, searchValue, totalCount).ToList(); list = list.OrderBy(x => x.EmpNo).ToList(); // list = list.Where(x => x.Section == user.Section).ToList(); // List<AF_DTRfiling> AlreadyApplieddtr = (from c in db.AF_DTRfiling where c.DTR_RefNo == currentRefno && c.Status >= 0 select c).ToList(); // list = list.Where(p => !AlreadyApplieddtr.Any(p2 => p2.EmployeeNo == p.EmpNo)).ToList(); break; } if (ChosenEmployees != null) { #region null remover list = list.Where(xx => xx.EmpNo != null).ToList(); list = list.Where(xx => xx.First_Name != null).ToList(); list = list.Where(xx => xx.Family_Name != null).ToList(); #endregion list = (from c in list where ChosenEmployees.Contains(c.EmpNo) select c).ToList(); } int?totalrows = Convert.ToInt32(totalCount.Value); //list.Count; int?totalrowsafterfiltering = Convert.ToInt32(totalCount.Value); //list.Count; return(Json(new { data = list, draw = Request["draw"], recordsTotal = totalrows, recordsFiltered = totalrowsafterfiltering }, JsonRequestBehavior.AllowGet)); }