public ActionResult OrderIndex() { string page = "1"; //so phan trang hien tai var pagesize = 25; //so ban ghi tren 1 trang var numOfNews = 0; //tong so ban ghi co duoc truoc khi phan trang int curpage = 0; // trang hien tai dung cho phan trang if (Request["page"] != null) { page = Request["page"]; curpage = Convert.ToInt32(page) - 1; } var all = db.Ords.ToList(); var pages = all.Skip(curpage * pagesize).Take(pagesize).ToList(); //var pages = db.sp_Order_Phantrang(page, pagesize, "", "").ToList(); var url = Request.Path; numOfNews = all.Count; ViewBag.Pager = Phantrang.PhanTrang(25, curpage, numOfNews, url); string Chuoi = ""; for (int i = 0; i < pages.Count; i++) { int pid = pages[i].IdCus; var cus = db.sp_Customer_GetById(pid).ToList(); if (cus.Count > 0) { if (i % 2 == 0) { Chuoi += "<tr id=\"trOdd_" + i + "\" class=\"trOdd\" onmousemove=\"Javascript:chkSelect_OnMouseMove1(this)\" onmouseout=\"Javascript:chkSelect_OnMouseOut1(this," + i + ")\">"; Chuoi += "<td class=\"CheckBoxsmall\"><input id='chkSelect' name='chk" + pages[i].Id + "' onclick = 'Javascript:chkSelect_OnClick(this,0)' class=\"chk\" type='checkbox'/></td>"; Chuoi += "<td class='Text'>" + cus[0].Name + "</td>"; Chuoi += "<td class='Text'>" + cus[0].Address + "</td>"; Chuoi += "<td class='DateTime'>" + pages[i].SDate + "</td>"; Chuoi += "<td class='TextSmall'>" + StringClass.ShowStateBill(pages[i].Status.ToString()) + "</td>"; Chuoi += "<td class='Function'>"; Chuoi += "<a href='/OrderEdit/" + pages[i].Id + "' class='vedit'>Sửa</a>"; Chuoi += "<a href='/OrderDelete/" + pages[i].Id + "' onclick='return DeleteConfirm()' class='vdelete'>Xóa</a>"; Chuoi += "</td>"; Chuoi += "</tr>"; } else { Chuoi += "<tr id=\"trEven_" + i + "\" class=\"trEven\" onmousemove=\"Javascript:chkSelect_OnMouseMove1(this)\" onmouseout=\"Javascript:chkSelect_OnMouseOut1(this," + i + ")\">"; Chuoi += "<td class=\"CheckBoxsmall\"><input id='chkSelect' name='chk" + pages[i].Id + "' onclick = 'Javascript:chkSelect_OnClick(this,0)' class=\"chk\" type='checkbox'/></td>"; Chuoi += "<td class='Text'>" + cus[0].Name + "</td>"; Chuoi += "<td class='Text'>" + cus[0].Address + "</td>"; Chuoi += "<td class='DateTime'>" + pages[i].SDate + "</td>"; Chuoi += "<td class='TextSmall'>" + StringClass.ShowStateBill(pages[i].Status.ToString()) + "</td>"; Chuoi += "<td class='Function'>"; Chuoi += "<a href='/OrderEdit/" + pages[i].Id + "' class='vedit'>Sửa</a>"; Chuoi += "<a href='/OrderDelete/" + pages[i].Id + "' onclick='return DeleteConfirm()' class='vdelete'>Xóa</a>"; Chuoi += "</td>"; Chuoi += "</tr>"; } } } ViewBag.View = Chuoi; return(View()); }