public JsonResult FilterData([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel, string searchprm) { SearchFilter searchFilter = ScanTimeApprovalManager.SearchData(requestModel); ScanTimeApprovalSqlParameters parameters = new ScanTimeApprovalSqlParameters(); var dateTimeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter { DateTimeFormat = "dd/MM/yyyy" }; SearchParams param = new SearchParams(); if (!string.IsNullOrEmpty(searchprm)) { param = JsonConvert.DeserializeObject <SearchParams>(searchprm, dateTimeConverter); } parameters.FromDate = param.StartDate ?? SystemConfig.CurrentDate.AddDays(-30); parameters.ToDate = param.EndDate ?? SystemConfig.CurrentDate; parameters.UserLoggedIn = CustomerAuthorize.CurrentUser.EmployeeCode; parameters.ShowWaiting = param.ShowMissing == "on"; parameters.StartRow = (requestModel.Start / requestModel.Length) + 1; parameters.EndRow = requestModel.Length; parameters.OrderBy = string.IsNullOrEmpty(searchFilter.OrderBy) ? "EmployeeNo" : searchFilter.OrderBy; parameters.OrderDirection = searchFilter.OrderDirection == "ASC" ? 1 : 0; parameters.FilterBy = parameters.FilterBy = requestModel.Search.Value; parameters.ShowUnNoReg = false; ScanTimeApprovalCollection collection = ScanTimeApprovalManager.GetAll(parameters); int totalRecord = 0; if (collection.Count > 0) { totalRecord = collection[0].TotalRecord; } return(Json(new DataTablesResponse(requestModel.Draw, collection, totalRecord, totalRecord), JsonRequestBehavior.AllowGet)); }
public static ScanTimeApprovalCollection Search(ScanTimeApprovalSqlParameters value) { ScanTimeApprovalCollection items = new ScanTimeApprovalCollection(); string key = string.Format(SETTINGS_Search_KEY, value.Keyword, value.Page, value.PageSize, value.OrderBy, value.OrderDirection, value.Condition); if (SystemConfig.AllowSearchCache) { object obj2 = HttpCache.Get(key); if ((obj2 != null)) { return((ScanTimeApprovalCollection)obj2); } } using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue)) { HttpResponseMessage response = client.PostAsJsonAsync(Resource + "/Get", value).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { items = response.Content.ReadAsAsync <ScanTimeApprovalCollection>().GetAwaiter().GetResult(); } } if (SystemConfig.AllowSearchCache && items.Count > 0) { HttpCache.Max(key, items); } return(items); }
public JsonResult GetData([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel) { SearchFilter searchFilter = ScanTimeApprovalManager.SearchData(requestModel); ScanTimeApprovalSqlParameters parameters = new ScanTimeApprovalSqlParameters(); parameters.FromDate = SystemConfig.CurrentDate.AddDays(-30); parameters.ToDate = SystemConfig.CurrentDate; parameters.UserLoggedIn = CustomerAuthorize.CurrentUser.EmployeeCode; parameters.ShowWaiting = true; parameters.StartRow = (requestModel.Start / requestModel.Length) + 1; parameters.EndRow = requestModel.Length; parameters.OrderBy = string.IsNullOrEmpty(searchFilter.OrderBy) ? "EmployeeNo" : searchFilter.OrderBy; parameters.OrderDirection = searchFilter.OrderDirection == "ASC" ? 1 : 0; parameters.FilterBy = requestModel.Search.Value; parameters.ShowUnNoReg = false; parameters.Condition = requestModel.Search.Value; ScanTimeApprovalCollection collection = ScanTimeApprovalManager.GetAll(parameters); int totalRecord = 0; if (collection.Count > 0) { totalRecord = collection[0].TotalRecord; } return(Json(new DataTablesResponse(requestModel.Draw, collection, totalRecord, totalRecord), JsonRequestBehavior.AllowGet)); }
public static ScanTimeApprovalCollection GetAllItemByManager(ScanTimeApprovalSqlParameters SearchKey) { ScanTimeApprovalCollection collection = new ScanTimeApprovalCollection(); var pars = new SqlParameter[] { new SqlParameter("@FromDate", SearchKey.FromDate), new SqlParameter("@ToDate", SearchKey.ToDate), new SqlParameter("@User", SearchKey.UserLoggedIn), new SqlParameter("@ShowWaiting", SearchKey.ShowWaiting), new SqlParameter("@StartRow", SearchKey.StartRow), new SqlParameter("@EndRow", SearchKey.EndRow), new SqlParameter("@OrderBy", SearchKey.OrderBy), new SqlParameter("@OrderDirection", SearchKey.OrderDirection), new SqlParameter("@FilterBy", SearchKey.FilterBy), new SqlParameter("@ShowUnNoReg", SearchKey.ShowUnNoReg) }; using (var reader = SqlHelper.ExecuteReaderService(ModuleConfig.MyConnection, "DNH_TimesheetApproval_Get", pars)) { while (reader.Read()) { ScanTimeApprovalReceiver obj = new ScanTimeApprovalReceiver(); obj = GetItemFromReader(reader); obj.TimeIn = MergeTime(obj.RootIn, obj.ManualIn, "in"); obj.TimeOut = MergeTime(obj.RootOut, obj.ManualOut, "out"); collection.Add(obj); } } return(collection); }
public static ScanTimeApprovalCollection Search(ScanTimeApprovalSqlParameters SearchKey) { ScanTimeApprovalCollection collection = new ScanTimeApprovalCollection(); var pars = new SqlParameter[] { new SqlParameter("@FromDate", SearchKey.FromDate), new SqlParameter("@ToDate", SearchKey.ToDate), new SqlParameter("@User", SearchKey.UserLoggedIn), new SqlParameter("@ShowWaiting", SearchKey.ShowWaiting), new SqlParameter("@StartRow", SearchKey.StartRow), new SqlParameter("@EndRow", SearchKey.EndRow), new SqlParameter("@OrderBy", SearchKey.OrderBy), new SqlParameter("@OrderDirection", SearchKey.OrderDirection), new SqlParameter("@FilterBy", SearchKey.FilterBy), new SqlParameter("@ShowUnNoReg", SearchKey.ShowUnNoReg) }; using (var reader = SqlHelper.ExecuteReaderService(ModuleConfig.MyConnection, "USP_TMS_ApproveTimeSheet_Get", pars)) { while (reader.Read()) { ScanTimeApprovalReceiver obj = new ScanTimeApprovalReceiver(); obj = GetItemFromReader(reader); collection.Add(obj); } } return(collection); }
public JsonResult ButtonSubmitEvent(ScanTimeApprovalCollection objItem, string Event) { var result = 0; var timesheetCollection = new TimesheetEntryCollection(); TimesheetApproveReject timesheetApproveReject = new TimesheetApproveReject(); foreach (ScanTimeApproval item in objItem) { if (item.isSelect == "on") { var timesheetEntry = new TimesheetEntry() { EmployeeCode = item.EmployeeCode, WorkDate = item.WorkDate, ManualIn = item.ManualIn, ManualOut = item.ManualOut, RequestorNote = item.RequestorNote, ApproverNote = item.ApproverNote, }; timesheetCollection.Add(timesheetEntry); } } switch (Event) { case "approve": timesheetApproveReject.IsApproved = true; break; case "reject": timesheetApproveReject.IsApproved = false; break; } timesheetApproveReject.TimesheetEntryCollection = timesheetCollection; timesheetApproveReject.UserLoggedIn = CurrentUser.EmployeeCode; if (timesheetCollection.Count > 0) { result = ScanTimeApprovalManager.Update(timesheetApproveReject); } return(Json(new { objItem, Event, result, JsonRequestBehavior.AllowGet })); }
public static ScanTimeApprovalCollection GetAll(ScanTimeApprovalSqlParameters value) { ScanTimeApprovalCollection items = new ScanTimeApprovalCollection(); string key = SETTINGS_ALL_KEY; object obj2 = HttpCache.Get(key); if ((obj2 != null) && value.IsOrdering) { return((ScanTimeApprovalCollection)obj2); } using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue)) { HttpResponseMessage response = client.PostAsJsonAsync(string.Format(Resource), value).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { items = response.Content.ReadAsAsync <ScanTimeApprovalCollection>().GetAwaiter().GetResult(); } } HttpCache.Max(key, items); return(items); }
public static ScanTimeApprovalCollection GetAllByUser(string createdUser) { ScanTimeApprovalCollection items = new ScanTimeApprovalCollection(); string key = String.Format(SETTINGS_User_KEY, createdUser); object obj2 = HttpCache.Get(key); if ((obj2 != null)) { return((ScanTimeApprovalCollection)obj2); } using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue)) { HttpResponseMessage response = client.GetAsync(Resource + $"/GetbyUser?usr={createdUser}").GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { items = response.Content.ReadAsAsync <ScanTimeApprovalCollection>().GetAwaiter().GetResult(); } } HttpCache.Max(key, items); return(items); }