public DataSourceResult GetPage(int page, int pageSize, string whereCondition) { List <SqlParameter> param = new List <SqlParameter>(); param.Add(new SqlParameter("@Page", page)); param.Add(new SqlParameter("@PageSize", pageSize)); param.Add(new SqlParameter("@WhereCondition", whereCondition)); DataTable dt = new SqlHelper().ExecuteQuery("p_Master_Calendar_Select_By_Page", param); var lst = new List <Master_Calendar>(); foreach (DataRow row in dt.Rows) { var item = new Master_Calendar(); item.Date = !row.IsNull("Date") ? DateTime.Parse(row["Date"].ToString()) : DateTime.Parse("01/01/1900"); item.Week = !row.IsNull("Week") ? row["Week"].ToString() : ""; item.Month = !row.IsNull("Month") ? row["Month"].ToString() : ""; item.Year = !row.IsNull("Year") ? row["Year"].ToString() : ""; item.Holiday = !row.IsNull("Holiday") ? row["Holiday"].ToString() : ""; item.RowCreatedAt = !row.IsNull("RowCreatedAt") ? DateTime.Parse(row["RowCreatedAt"].ToString()) : DateTime.Parse("01/01/1900"); item.RowCreatedBy = !row.IsNull("RowCreatedBy") ? row["RowCreatedBy"].ToString() : ""; lst.Add(item); } DataSourceResult result = new DataSourceResult(); result.Data = lst; result.Total = dt.Rows.Count > 0 ? Convert.ToInt32(dt.Rows[0]["RowCount"]) : 0; return(result); }
public List <Master_Calendar> GetAllWeek() { List <Master_Calendar> lst = new List <Master_Calendar>(); List <SqlParameter> param = new List <SqlParameter>(); DataTable dt = new SqlHelper().ExecuteQuery("p_Master_Calendar_Select_All_Week", param); foreach (DataRow row in dt.Rows) { Master_Calendar item = new Master_Calendar(); item.Week = !row.IsNull("Week") ? row["Week"].ToString() : ""; item.WeekDetail = !row.IsNull("WeekDetail") ? row["WeekDetail"].ToString() : ""; lst.Add(item); } return(lst); }
public List<Master_Calendar> GetAllWeek() { List<Master_Calendar> lst = new List<Master_Calendar>(); List<SqlParameter> param = new List<SqlParameter>(); DataTable dt = new SqlHelper().ExecuteQuery("p_Master_Calendar_Select_All_Week", param); foreach (DataRow row in dt.Rows) { Master_Calendar item = new Master_Calendar(); item.Week = !row.IsNull("Week") ? row["Week"].ToString() : ""; item.WeekDetail = !row.IsNull("WeekDetail") ? row["WeekDetail"].ToString() : ""; lst.Add(item); } return lst; }
public DataSourceResult GetPage(int page, int pageSize, string whereCondition) { List<SqlParameter> param = new List<SqlParameter>(); param.Add(new SqlParameter("@Page", page)); param.Add(new SqlParameter("@PageSize", pageSize)); param.Add(new SqlParameter("@WhereCondition", whereCondition)); DataTable dt = new SqlHelper().ExecuteQuery("p_Master_Calendar_Select_By_Page", param); var lst = new List<Master_Calendar>(); foreach (DataRow row in dt.Rows) { var item = new Master_Calendar(); item.Date = !row.IsNull("Date") ? DateTime.Parse(row["Date"].ToString()) : DateTime.Parse("01/01/1900"); item.Week = !row.IsNull("Week") ? row["Week"].ToString() : ""; item.Month = !row.IsNull("Month") ? row["Month"].ToString() : ""; item.Year = !row.IsNull("Year") ? row["Year"].ToString() : ""; item.Holiday = !row.IsNull("Holiday") ? row["Holiday"].ToString() : ""; item.RowCreatedAt = !row.IsNull("RowCreatedAt") ? DateTime.Parse(row["RowCreatedAt"].ToString()) : DateTime.Parse("01/01/1900"); item.RowCreatedBy = !row.IsNull("RowCreatedBy") ? row["RowCreatedBy"].ToString() : ""; lst.Add(item); } DataSourceResult result = new DataSourceResult(); result.Data = lst; result.Total = dt.Rows.Count > 0 ? Convert.ToInt32(dt.Rows[0]["RowCount"]) : 0; return result; }
public ActionResult Read([DataSourceRequest]DataSourceRequest request) { log4net.Config.XmlConfigurator.Configure(); string whereCondition = ""; if (request.Filters.Count > 0) { whereCondition = " AND " + new KendoApplyFilter().ApplyFilter(request.Filters[0]); } var data = new Master_Calendar().GetPage(request.Page, request.PageSize, whereCondition); return Json(data); }