public JsonResult Save_Kpi_Month(string DataJson) { JsonResult Data = new JsonResult(); ReportKpiServices services = new ReportKpiServices(); string nguoitao = Session["userid"].ToString(); string iresult = services.Save_Kpi_Month(DataJson, nguoitao); if (iresult != "1") { return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false }, JsonRequestBehavior.AllowGet)); } }
public JsonResult SelectRows_KpiReport_Month(KpiReport_MonthModels model, int curentPage) { KpiReport_MonthModels param = new KpiReport_MonthModels(); ReportKpiServices service = new ReportKpiServices(); param.nguoitao = int.Parse(Session["userid"].ToString()); param.chucdanh = Session["chucdanhkpi"].ToString().Trim(); param.hovaten = model.hovaten; param.maphongban = model.maphongban; param.thangnam = model.thangnam; param.kiemtra = model.kiemtra; if (Session["loginid"].ToString().Trim().ToLower() == "admin" || Session["grouptk"].ToString().Trim() == "1") { param.xoa = "1"; } int tongsodong = service.CountRows_ReportKpi_Month(param); int sotrang = 1; if (tongsodong > 21) { if (tongsodong % 21 > 0) { sotrang = (tongsodong / 21) + 1; } else { sotrang = (tongsodong / 21); } } int trangbd = 1; int trangkt = 21; if (curentPage != 1 && curentPage <= sotrang) { trangbd = (trangkt * (curentPage - 1)) + 1; trangkt = trangkt * curentPage; } List <KpiReport_MonthModels> lstResult = new List <KpiReport_MonthModels>(); if (curentPage <= sotrang) { lstResult = service.SelectRow_ReportKpi_Month(param, trangbd, trangkt); } else if (curentPage != 1 && curentPage > sotrang) { curentPage = curentPage - 1; } StringBuilder sbResult = new StringBuilder(); StringBuilder sbRows = new StringBuilder(); int tongdong = 0; if (lstResult.Count > 0) { string strSTT = ""; int i = trangbd; foreach (var item in lstResult) { strSTT = i.ToString(); sbRows.Append(PrepareDataJson_KpiReport_Month(item, strSTT)); if (item.groupcha != "1") { i++; } else { i = 1; } } tongdong = i - 1; if (sbRows.Length > 0) { sbRows.Remove(sbRows.Length - 1, 1); } } if (tongsodong == 0) { sotrang = 0; } sbResult.Append("{"); sbResult.Append("\"isHeader\":\"" + "111" + "\","); sbResult.Append("\"tongdong\":\"" + "" + tongsodong + "" + "\","); sbResult.Append("\"Pages\":\"" + "" + sotrang + "" + "\","); sbResult.Append("\"SubRow\":\"" + "false" + "\","); sbResult.Append("\"data\":[" + sbRows.ToString() + "]"); sbResult.Append("}"); return(Json(sbResult.ToString(), JsonRequestBehavior.AllowGet)); }