示例#1
0
        private void ShowEquipmentModels()
        {
            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);
            var list         = ModelInstance.FindPageList <TB_EquipmentType>(pageIndex, PageSize, out totalRecords,
                                                                             f => f.Delete == false, "Type,Name");
            var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0);

            string html = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"6\">No records, you can change condition and try again, or " +
                       " <a>Add</a> some new one.</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * PageSize;
                foreach (var obj in list)
                {
                    cnt++;
                    var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString()));
                    html += "<tr>" +
                            "<td style=\"width: 40px; text-align: center;\"><input type=\"checkbox\" id=\"cb_" + id + "\" /></td>" +
                            "<td style=\"width: 40px; text-align: center;\">" + cnt + "</td>" +
                            "<td>" + ((int?)null == obj.Type ? "-" : obj.TB_EquipmentType.Name) + "</td>" +
                            "<td><a href=\"./equipment_model.aspx?key=" + id + "\" >" + ("" == obj.Name ? "-" : obj.Name) + "</a></td>" +
                            "<td>" + obj.Code + "</td>" +
                            "<td></td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "./equipment_model.aspx", divPagging);
            }
        }