private void ShowEquipments() { var totalRecords = 0; var pageIndex = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value); pageIndex = (0 >= pageIndex ? 1 : pageIndex); var model = ParseInt(selectedModels.Value); var house = ParseInt(hidQueryWarehouse.Value); var list = EquipmentInstance.FindPageList <TB_Equipment>(pageIndex, PageSize, out totalRecords, f => f.Terminal == (int?)null && f.Deleted == false && (model <= 0 ? f.Model >= 0 : f.Model == model) && (house <= 0 ? (f.Warehouse >= 0 || f.Warehouse == (int?)null) : f.Warehouse == house) && (f.Number.IndexOf(txtQueryNumber.Value.Trim()) >= 0), null); var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0); string html = ""; if (totalRecords < 1) { html = "<tr><td colspan=\"11\">No records, You can change the condition and try again.</td></tr>"; } else { var cnt = (pageIndex - 1) * PageSize; var n = (int?)null; foreach (var obj in list) { cnt++; // 入库记录 var _in = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, true); // 出库记录 var _out = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, false); var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString())); html += "<tr title=\"click to dispatch work\">" + "<td class=\"in-tab-txt-b\">" + cnt + "</td>" + "<td class=\"in-tab-txt-b\">" + (n == obj.Model ? "-" : obj.TB_EquipmentModel.TB_EquipmentType.Code) + "</td>" + "<td class=\"in-tab-txt-b textoverflow\" style=\"text-align: left !important;\">" + (n == obj.Model ? "-" : ("<a>" + EquipmentInstance.GetFullNumber(obj) + "</a>")) + "</td>" + "<td class=\"in-tab-txt-b\" style=\"text-align: left !important;\">" + Utility.GetEquipmentFunctional(obj.Functional.Value) + "</td>" + "<td class=\"in-tab-txt-rb\" title=\"" + EquipmentInstance.GetStatusTitle(obj) + "\">" + EquipmentInstance.GetStatus(obj) + "</td>" + "<td class=\"in-tab-txt-b textoverflow\">" + (null == _in ? "-" : _in.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" + "<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_in) + "\">" + StoreInstance.GetStatus(_in) + "</td>" + "<td class=\"in-tab-txt-b textoverflow\">" + (null == _out ? "-" : _out.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" + "<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_out) + "\">" + StoreInstance.GetStatus(_out) + "</td>" + "<td class=\"in-tab-txt-b textoverflow\">" + (n == obj.Warehouse ? "-" : obj.TB_Warehouse.Name) + "</td>" + "<td class=\"in-tab-txt-b\"></td>" + "</tr>"; } } tbodyBody.InnerHtml = html; divPagging.InnerHtml = ""; if (totalRecords > 0) { ShowPaggings(pageIndex, totalPages, totalRecords, "./equipment_inquiry.aspx", divPagging); } }
private void ShowNotbindEquipments() { var totalRecords = 0; var pageIndex = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value); var list = EquipmentInstance.FindPageList <TB_Equipment>(pageIndex, PageSize, out totalRecords, f => f.Terminal == (int?)null && f.Number.IndexOf(txtEquipment.Value.Trim()) >= 0 && f.Functional == GetEquipmentTypeByTerminalType() && f.Deleted == false, null); var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0); string html = ""; if (totalRecords < 1) { html = "<tr><td colspan=\"9\">No equipment has unbind terminal.</td></tr>"; } else { var cnt = (pageIndex - 1) * PageSize; var n = (int?)null; foreach (var obj in list) { cnt++; html += "<tr style=\"cursor: pointer;\">" + "<td style=\"text-align: center;\">" + " <input type=\"radio\" name=\"bind\" id=\"radio_" + obj.id + "\" />" + "</td>" + "<td style=\"text-align: center;\">" + cnt + "</td>" + "<td>" + (n == obj.Model ? "-" : obj.TB_EquipmentModel.TB_EquipmentType.Code) + "</td>" + "<td>" + EquipmentInstance.GetFullNumber(obj) + "</td>" + "<td style=\"text-align: right;\">" + EquipmentBLL.GetRuntime(obj.Runtime + obj.InitializedRuntime, obj.CompensatedHours.Value) + "</td>" + "<td style=\"text-align: center;\" title=\"" + EquipmentInstance.GetStatusTitle(obj) + "\">" + EquipmentInstance.GetStatus(obj) + "</td>" + "<td>" + (n == obj.Terminal ? "not bind" : obj.TB_Terminal.Number) + "</td>" + "<td>" + (n == obj.Warehouse ? "-" : obj.TB_Warehouse.Name) + "</td>" + "<td>" + obj.GpsAddress + "</td>" + "<td></td>" + "</tr>"; } } tbodyBody.InnerHtml = html; divPagging.InnerHtml = ""; if (totalRecords > 0) { ShowPaggings(pageIndex, totalPages, totalRecords, "./equipment_terminal.aspx", divPagging); } }
private void ShowEquipments() { var query = txtQueryNumber.Value.Trim(); // 模糊查询时页码置为空 if (!string.IsNullOrEmpty(query)) { hidPageIndex.Value = ""; } var totalRecords = 0; var pageIndex = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value); pageIndex = (0 >= pageIndex ? 1 : pageIndex); var type = ParseInt(selectedTypes.Value); var model = ParseInt(selectedModels.Value); var house = 0;//ParseInt(hidQueryWarehouse.Value); var customer = ParseInt(hiddenCustomer.Value); // 表达式 Expression <Func <TB_Equipment, bool> > expression = PredicateExtensions.True <TB_Equipment>(); // 设备类型 if (type > 0) { expression = expression.And(a => a.TB_EquipmentModel.Type == type); } // 设备型号 if (model > 0) { expression = expression.And(a => a.Model == model); } // 仓库 if (house > 0) { expression = expression.And(a => a.Warehouse == house); } // 查询号码 if (!string.IsNullOrEmpty(query)) { expression = expression.And(a => a.Number.Contains(query) || a.TB_Customer.Code.Contains(query)); } // 客户号码 switch (customer) { case 3: // None expression = expression.And(a => a.Customer == (int?)null); break; case 2: // Bound expression = expression.And(a => a.Customer != (int?)null); //if (!string.IsNullOrEmpty(query)) //{ // expression = expression.And(a => a.TB_Customer.Code.Contains(query)); //} break; default: // Default break; } // 终端绑定状态 var terminal = ParseInt(hiddenTerminal.Value.Trim()); switch (terminal) { case 2: // 绑定终端了 expression = expression.And(a => a.Terminal != (int?)null); break; case 3: // 未绑定终端 expression = expression.And(a => a.Terminal == (int?)null); break; default: // 忽略的话就是不查询终端的绑定状态 break; } expression = expression.And(a => a.Deleted == false); var list = EquipmentInstance.FindPageList <TB_Equipment>(pageIndex, PageSize, out totalRecords, expression, null); var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0); hidTotalPages.Value = totalPages.ToString(); string html = ""; if (totalRecords < 1) { html = "<tr><td colspan=\"16\">No records, You can change the condition and try again.</td></tr>"; } else { var cnt = (pageIndex - 1) * PageSize; var n = (int?)null; foreach (var obj in list) { cnt++; // 入库记录 //var _in = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, true); // 出库记录 //var _out = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, false); var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString())); bool sat = n != obj.Terminal && n != obj.TB_Terminal.Satellite; // 锁车状态和报警信息 string arms = EquipmentInstance.GetLockEffectedStatus(obj); if (string.IsNullOrEmpty(arms)) { arms = EquipmentInstance.GetAlarmStatus(obj.Alarm); } html += "<tr>" + "<td class=\"in-tab-txt-b\">" + cnt + "</td>" + "<td class=\"in-tab-txt-b\">" + (n == obj.Model ? "-" : obj.TB_EquipmentModel.TB_EquipmentType.Code) + "</td>" + "<td class=\"in-tab-txt-b textoverflow\" style=\"text-align: left !important;\">" + (n == obj.Model ? "-" : ("<a href=\"./equipment_position.aspx?key=" + id + "\">" + EquipmentInstance.GetFullNumber(obj) + "</a>")) + "</td>" + "<td class=\"in-tab-txt-b\" style=\"text-align: left !important;\">" + Utility.GetEquipmentFunctional(obj.Functional.Value) + "</td>" + "<td class=\"in-tab-txt-b\" style=\"text-align: right !important;\">" + EquipmentBLL.GetRuntime(obj.Runtime + obj.InitializedRuntime, obj.CompensatedHours.Value) + "</td>" + "<td class=\"in-tab-txt-b\" style=\"padding: 2px !important; vertical-align: middle !important;\">" + EquipmentInstance.GetEngStatus(obj) + "</td>" + "<td class=\"in-tab-txt-b textoverflow\" title=\"" + obj.GpsAddress + "\" style=\"text-align: left !important;\">" + obj.GpsAddress + "</td>" + "<td class=\"in-tab-txt-rb\" title=\"" + EquipmentInstance.GetStatusTitle(obj) + "\">" + EquipmentInstance.GetStatus(obj) + "</td>" + //"<td class=\"in-tab-txt-b\">" + EquipmentInstance.GetOutdoorDays(obj) + "</td>" + //"<td class=\"in-tab-txt-rb textoverflow\">" + EquipmentInstance.GetAverageWorktime(obj) + "</td>" + "<td class=\"in-tab-txt-b\">" + (n == obj.Customer ? "-" : obj.TB_Customer.Code) + "</td>" + "<td class=\"in-tab-txt-rb textoverflow\" style=\"text-align: left !important;\" title=\"" + (n == obj.Customer ? "-" : obj.TB_Customer.Name) + "\">" + (n == obj.Customer ? "-" : obj.TB_Customer.Name) + "</td>" + //"<td class=\"in-tab-txt-b\">" + ((byte?)null == obj.Signal ? "-" : obj.Signal.ToString()) + "</td>" + "<td class=\"in-tab-txt-b\">" + Utility.GetOnlineStyle(obj.OnlineStyle, obj.OnlineTime) + "</td>" + "<td class=\"in-tab-txt-b\">" + arms + "</td>" + "<td class=\"in-tab-txt-b textoverflow\">" + ((DateTime?)null == obj.LastActionTime ? "" : obj.LastActionTime.Value.ToString("yyyy/MM/dd HH:mm")) + "</td>" + "<td class=\"in-tab-txt-b textoverflow\" title=\"" + EquipmentInstance.GetTerinalTitleInfo(obj) + "\">" + (n == obj.Terminal ? "-" : obj.TB_Terminal.Number) + "</td>" + "<td class=\"in-tab-txt-rb\" title=\"" + EquipmentInstance.GetSatelliteTitleInfo(obj) + "\"><span class=\"glyphicon glyphicon-" + (sat ? "ok" : "remove") + " text-" + (sat ? "success" : "danger") + "\" aria-hidden=\"true\"></span></td>" + //"<td class=\"in-tab-txt-b textoverflow\">" + (null == _in ? "-" : _in.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" + //"<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_in) + "\">" + StoreInstance.GetStatus(_in) + "</td>" + //"<td class=\"in-tab-txt-b textoverflow\">" + (null == _out ? "-" : _out.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" + //"<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_out) + "\">" + StoreInstance.GetStatus(_out) + "</td>" + "<td class=\"in-tab-txt-b textoverflow\">" + (n == obj.Warehouse ? "-" : obj.TB_Warehouse.Name) + "</td>" + //"<td class=\"in-tab-txt-b\">" + (n == obj.Terminal ? "-" : (n == obj.TB_Terminal.Satellite ? "-" : obj.TB_Terminal.TB_Satellite.CardNo)) + "</td>" + //"<td class=\"in-tab-txt-rb\">" + (n == obj.Terminal ? "-" : obj.TB_Terminal.Sim) + "</td>" + "</tr>"; } } tbodyBody.InnerHtml = html; divPagging.InnerHtml = ""; if (totalRecords > 0) { ShowPaggings(pageIndex, totalPages, totalRecords, "./equipment_inquiry.aspx", divPagging); } }
/// <summary> /// 按照查询条件显示设备列表 /// </summary> private void ShowEquipments() { var query = txtQueryNumber.Value.Trim(); // 模糊查询时页码置为空 if (!string.IsNullOrEmpty(query)) { hidPageIndex.Value = ""; } var totalRecords = 0; var pageIndex = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value); pageIndex = (0 >= pageIndex ? 1 : pageIndex); var type = ParseInt(selectedTypes.Value); var model = ParseInt(selectedModels.Value); var house = ParseInt(hidQueryWarehouse.Value); // 表达式 Expression <Func <TB_Equipment, bool> > expression = PredicateExtensions.True <TB_Equipment>(); expression = expression.And(a => a.TB_EquipmentStatusName.IsItInventory == true && a.Deleted == false && a.StoreTimes == 1 && a.Terminal != (int?)null); if (type > 0) { expression = expression.And(a => a.TB_EquipmentModel.Type == type); } if (model > 0) { expression = expression.And(a => a.Model == model); } if (house > 0) { expression = expression.And(a => a.Warehouse == house); } if (!string.IsNullOrEmpty(query)) { pageIndex = 1; expression = expression.And(a => a.Number.Contains(query)); } var list = EquipmentInstance.FindPageList <TB_Equipment>(pageIndex, PageSize, out totalRecords, expression, null); var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0); hidTotalPages.Value = totalPages.ToString(); string html = ""; if (totalRecords < 1) { html = "<tr><td colspan=\"18\">No records, You can change the condition and try again.</td></tr>"; } else { var cnt = (pageIndex - 1) * PageSize; var n = (int?)null; foreach (var obj in list) { cnt++; // 入库记录 //var _in = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, true); // 出库记录 //var _out = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, false); var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString())); html += "<tr>" + "<td class=\"in-tab-txt-b\">" + cnt + "</td>" + "<td class=\"in-tab-txt-b\">" + (n == obj.Model ? "-" : obj.TB_EquipmentModel.TB_EquipmentType.Code) + "</td>" + "<td class=\"in-tab-txt-b textoverflow\" style=\"text-align: left !important;\">" + (n == obj.Model ? "-" : ("<a href=\"./equipment_position.aspx?key=" + id + "\">" + EquipmentInstance.GetFullNumber(obj) + "</a>")) + "</td>" + "<td class=\"in-tab-txt-b\" style=\"text-align: left !important;\">" + Utility.GetEquipmentFunctional(obj.Functional.Value) + "</td>" + "<td class=\"in-tab-txt-b\" style=\"text-align: right !important;\">" + EquipmentBLL.GetRuntime(obj.Runtime + obj.InitializedRuntime, obj.CompensatedHours.Value) + "</td>" + "<td class=\"in-tab-txt-b\">" + EquipmentInstance.GetEngStatus(obj) + "</td>" + "<td class=\"in-tab-txt-b textoverflow\" title=\"" + obj.GpsAddress + "\">" + obj.GpsAddress + "</td>" + "<td class=\"in-tab-txt-rb\" title=\"" + EquipmentInstance.GetStatusTitle(obj) + "\">" + EquipmentInstance.GetStatus(obj) + "</td>" + "<td class=\"in-tab-txt-b\">" + EquipmentInstance.GetOutdoorDays(obj) + "</td>" + "<td class=\"in-tab-txt-rb textoverflow\">" + EquipmentInstance.GetAverageWorktime(obj) + "</td>" + //"<td class=\"in-tab-txt-b textoverflow\">" + (null == _in ? "-" : _in.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" + //"<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_in) + "\">" + StoreInstance.GetStatus(_in) + "</td>" + //"<td class=\"in-tab-txt-b textoverflow\">" + (null == _out ? "-" : _out.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" + //"<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_out) + "\">" + StoreInstance.GetStatus(_out) + "</td>" + "<td class=\"in-tab-txt-rb textoverflow\">" + obj.TB_Warehouse.Name + "</td>" + //"<td class=\"in-tab-txt-b\">" + ((byte?)null == obj.Signal ? "-" : obj.Signal.ToString()) + "</td>" + "<td class=\"in-tab-txt-b\">" + Utility.GetOnlineStyle(obj.OnlineStyle, obj.OnlineTime, false) + "</td>" + "<td class=\"in-tab-txt-b textoverflow\">" + ((DateTime?)null == obj.LastActionTime ? "" : obj.LastActionTime.Value.ToString("yyyy/MM/dd HH:mm")) + "</td>" + "<td class=\"in-tab-txt-b textoverflow\" title=\"" + EquipmentInstance.GetTerinalTitleInfo(obj) + "\">" + (n == obj.Terminal ? "-" : obj.TB_Terminal.Number) + "</td>" + "</tr>"; } } tbodyBody.InnerHtml = html; divPagging.InnerHtml = ""; if (totalRecords > 0) { ShowPaggings(pageIndex, totalPages, totalRecords, "./equipment_in_storage.aspx", divPagging); } }
private void ShowTerminalsBinded(int pageIndex) { var totalRecords = 0; // 表达式 Expression <Func <TB_Equipment, bool> > expression = PredicateExtensions.True <TB_Equipment>(); // 必须是绑定了终端的设备 expression = expression.And(f => f.Deleted == false && f.Terminal != (int?)null); // 设备type //var type = ddlEquipmentType.SelectedValue; //if (!string.IsNullOrEmpty(type)) //{ // expression = expression.And(a => a.TB_EquipmentModel.Type == ParseInt(type)); //} // 设备model //var model = selModel.Value; //if (!string.IsNullOrEmpty(model)) { expression = expression.And(a => a.Model == ParseInt(model)); } // 是否绑定卫星 // 是否绑定卫星 -1:ignore,0:not,1:bound var sat = int.Parse(selectedSatellite.Value); spanSatellite.InnerHtml = "Satellite:" + GotSelectedType(sat); if (sat >= 0) { if (sat == 0) { expression = expression.And(a => a.TB_Terminal.Satellite == null); } else { expression = expression.And(a => a.TB_Terminal.Satellite != null); } } // 号码查询 var query = txtNumber.Value.Trim(); if (!string.IsNullOrEmpty(query)) { expression = expression.And(a => a.Number.Contains(query) || a.TB_Terminal.Number.Contains(query) || a.TB_Terminal.TB_Satellite.CardNo.Contains(query)); } var list = EquipmentInstance.FindPageList <TB_Equipment>(pageIndex, PageSize, out totalRecords, expression, "Number"); var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0); string html = ""; if (totalRecords < 1) { html = "<tr><td colspan=\"13\">No records, You can change condition and try again or " + " <a href=\"./terminal_register.aspx\">ADD</a> 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=\"text-align: center;\" class=\"in-tab-txt-rb\"><input type=\"checkbox\" id=\"cb_" + id + "\" /></td>" + "<td style=\"text-align: center;\" class=\"in-tab-txt-rb\">" + cnt + "</td>" + "<td class=\"in-tab-txt-rb\" style=\"text-align: left !important;\"><a href=\"./terminal_register.aspx?key=" + id + "\" >" + CheckQueryString(obj.TB_Terminal.Number) + "</a></td>" + "<td class=\"in-tab-txt-rb\" style=\"text-align: left !important; cursor: pointer;\" title=\"Click to show advanced options\">" + CheckQueryString(TerminalInstance.GetSatellite(obj.TB_Terminal, true)) + "</td>" + "<td class=\"in-tab-txt-rb\">" + obj.TB_Terminal.Firmware + "</td>" + "<td class=\"in-tab-txt-rb\">" + obj.TB_Terminal.Revision.ToString() + "</td>" + "<td class=\"in-tab-txt-rb\" style=\"text-align: left !important;\">" + TerminalTypes.GetTerminalType(obj.TB_Terminal.Type.Value) + "</td>" + "<td class=\"in-tab-txt-rb\" style=\"text-align: left !important;\">" + obj.TB_Terminal.ProductionDate.Value.ToString("yyyy/MM/dd") + "</td>" + "<td class=\"in-tab-txt-rb\">yes</td>" + "<td class=\"in-tab-txt-rb\" style=\"text-align: left !important;\">" + CheckQueryString(GetEquipment(obj.TB_Terminal, obj)) + "</td>" + "<td class=\"in-tab-txt-b\">" + Utility.GetOnlineStyle(obj.OnlineStyle, obj.OnlineTime, false) + "</td>" + //"<td class=\"in-tab-txt-rb\">" + obj.TB_Terminal.Sim + "</td>" + "<td class=\"in-tab-txt-b\"></td>" + "</tr>"; } } ShowFooter(totalRecords, pageIndex, totalPages, html); }