public override string ToString() { return($"{Itemcode.PadRight(10)} - {Quantity} - {Price}"); }
public ResultDevice GetDeviceList(QueryDevice2 query) { var pAction = new ExecuteProcess(); try { StringBuilder sbTree = new StringBuilder(); List<Device> deviceList; if (query.ItemCode == "00000") { if (query.ObjType == AreaType.Area) { deviceList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(" and areaid=" + query.ObjectId, " order by deviceid"); } else { deviceList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(" and areaid2=" + query.ObjectId, " order by deviceid"); } } else { string itemCodeAll = query.ItemCode; Itemcode objItem = new Itemcode(); var itemcodeList = objItem.GetItemcodeList(" and ItemCodeNumber='" + query.ItemCode + "'", " order by itemcodeid")[0]; var itemcodeListChild = objItem.GetItemcodeList(" and ParentID=" + itemcodeList.ItemcodeID, " order by itemcodeid"); itemCodeAll = itemcodeListChild.Aggregate("'" + itemCodeAll + "'", (current, itemcode) => current + ("," + "'" + itemcode.ItemCodeNumber + "'")); if (query.ObjType == AreaType.Area) { deviceList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(" and ItemCodeID in (" + itemCodeAll + ") and areaid=" + query.ObjectId, " order by deviceid"); } else { deviceList = new NTS.WEB.BLL.BaseLayerObject().GetDeviceObjectList(" and ItemCodeID in (" + itemCodeAll + ") and areaid2=" + query.ObjectId, " order by deviceid"); } } //sbTree.Append("["); //for (var device = 0; device < deviceList.Count; device++) //{ // sbTree.Append("{\"text\": \"" + deviceList[device].DeviceName + "\",\"id\": " + deviceList[device].DeviceID + ",\"classes\": \"equip\"}"); // sbTree.Append(device == deviceList.Count - 1 ? "" : ","); //} //sbTree.Append("]"); List<DeviceUnit> lstDvc = new List<DeviceUnit>(); foreach (var device in deviceList) { DeviceUnit du = new DeviceUnit(); du.DeviceID = device.DeviceID; du.DeviceName = device.DeviceName; lstDvc.Add(du); } ResultDevice result = new ResultDevice(); result.DeviceUnitList = lstDvc; pAction.Success = true; result.ActionInfo = pAction; return result; } catch (Exception ex) { pAction.Success = false; pAction.ExceptionMsg = ex.Message; return new ResultDevice() { ActionInfo = pAction }; } }
/// <summary> /// 导出所有能源信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public string ExportItemEnergy(string starttime, string endtime, string objectid, string timeunit, string counttype, string SavePath) { try { Itemcode itemcodeBll = new Itemcode(); ReportQueryModelNew model = new ReportQueryModelNew(); model.startime = DateTime.Parse(starttime); model.endtime = DateTime.Parse(endtime); model.objectid = objectid; model.timeunit = (ReportStyleNew)(int.Parse(timeunit)); model.objecttype = 0; model.itemcode = counttype; string strPath = SavePath; // AppDomain.CurrentDomain.BaseDirectory + "temp_file\\"; string strTemPath = AppDomain.CurrentDomain.BaseDirectory + "ExcelTemplate\\项目能耗查询.xls"; IList<Model.Itemcode> itemcode = itemcodeBll.GetItemcodeList( " and itemcodenumber = '" + counttype + "'", ""); string strUnit = "mch"; if(itemcode.Count>0) { strUnit = itemcode[0].Unit; } #region 第2种方法 DataTable dtlist = GetItemcodeData(model); string name = GetBaseLayerObjectName(model.objectid); #endregion if (dtlist != null) { string temp_path = strPath; //AppDomain.CurrentDomain.BaseDirectory + "temp_file\\"; if (!Directory.Exists(temp_path)) { Directory.CreateDirectory(temp_path); string[] files = Directory.GetFiles(temp_path); foreach (string fn in files) { File.Delete(temp_path + fn); } } string save_path = DateTime.Now.Ticks + ".xls"; string templatePath = strTemPath; // AppDomain.CurrentDomain.BaseDirectory + "template\\区域能耗查询.xls"; string datetime = model.startime.ToString("yyyy-MM-dd") + "~" + (model.timeunit == ReportStyleNew.DayStyle ? model.endtime.ToString("yyyy-MM-dd HH:59:59") : model.endtime.ToString("yyyy-MM-dd")); TemplateParam param = new TemplateParam(name, new CellParam(0, 0), datetime, new CellParam(3, 0), false, new CellParam(4, 0)); //param.DataColumn = new[] { 0, 3, 6, 7, 8, 9}; param.DataColumn = new[] { 0, 1, 3, 6, 7 }; param.ItemUnit = "能耗值:(" + strUnit + ")"; param.ItemUnitCell = new CellParam(4, 4); dtlist.TableName = "能耗查询统计"; string strDownFile = temp_path + save_path; //return "{\"status\":\"success\",\"msg\":\"" + "/temp_file/" + save_path + "\"}"; ExportHelper.ExportExcel(dtlist, strDownFile, strTemPath, param); //return "{\"status\":\"success\",\"msg\":\"" + "/temp_file/" + save_path + "\"}"; return "{\"status\":\"success\",\"msg\":\"" + "/temp_file/" + save_path + "\"}"; } else { return "{\"status\":\"error\",\"msg\":\"导出失败:当前无任何数据\"}"; } } catch (Exception ex) { return "{\"status\":\"error\",\"msg\":\"导出失败:没有数据!\"}"; } }
private void InitailizeControls() { try { // Create GridView dgvBatchDetails.AutoGenerateColumns = false; dgvBatchDetails.DataSource = null; DataGridView dgvItemsNew = Common.GetDataGridViewColumns(dgvBatchDetails, GRIDVIEW_XML_PATH); dgvBatchDetails.AutoGenerateColumns = false; dgvBatchDetails.DataSource = null; CoreComponent.MasterData.BusinessObjects.ItemDetails itemDetail = new CoreComponent.MasterData.BusinessObjects.ItemDetails(); ItemDetails objnew = new ItemDetails(); //itemDetail.ItemId = objnew.ToItemId; itemDetail.ItemCode = Itemcode.ToUpper(); List <CoreComponent.MasterData.BusinessObjects.ItemDetails> items = itemDetail.Search(); List <CoreComponent.MasterData.BusinessObjects.ItemDetails> lstItem; if (items != null && items.Count > 0) { var query = from a in items where a.ItemCode.ToUpper() == Itemcode.ToUpper() select a; lstItem = (List <CoreComponent.MasterData.BusinessObjects.ItemDetails>)query.ToList(); if (lstItem.Count > 0) { m_expiryMonth = lstItem[0].ExpiryDuration; } } dtpExpiryDate.Value = DateTime.Today.AddMonths(m_expiryMonth); if (ItemInventory.BatchDetailList != null && ItemInventory.BatchDetailList.Count > 0) { var query = (from p in ItemInventory.BatchDetailList select p.SerialNo).Max(); m_SerialNo = Convert.ToInt32(query) + 1; } else { m_SerialNo++; } if (ItemInventory.BatchDetailList == null || ItemInventory.BatchDetailList.Count == 0) { dgvBatchDetails.AutoGenerateColumns = false; dgvBatchDetails.DataSource = null; dgvBatchDetails.DataSource = new List <ItemBatchDetails>(); } ResetGrid(); btnAdd.Enabled = EnableControl; txtManuBatchNo.ReadOnly = !EnableControl; dtpExpiryDate.Enabled = EnableControl; dtpMfgDate.Enabled = EnableControl; dgvBatchDetails.Columns[CON_GRID_Remove].Visible = EnableControl; } catch (Exception ex) { throw ex; } }
private void dgvBatchDetails_SelectionChanged(object sender, EventArgs e) { try { if (dgvBatchDetails.SelectedRows.Count > 0) { errorAdd.Clear(); if (ItemInventory.BatchDetailList != null && ItemInventory.BatchDetailList.Count > 0) { var query = from a in ItemInventory.BatchDetailList where a.ToItemCode.ToUpper() == Itemcode.ToUpper() select a; List <CoreComponent.MasterData.BusinessObjects.ItemBatchDetails> lstItem; lstItem = (List <CoreComponent.MasterData.BusinessObjects.ItemBatchDetails>)query.ToList(); foreach (ItemBatchDetails cn in lstItem) { CurrentSerialno = cn.SerialNo; int s = cn.SerialNo; m_CurrentBatch = ItemInventory.BatchDetailList[0]; } ItemBatchDetails batch = CopyObject(m_CurrentBatch); ResetValues(batch); //m_returnObject = dgvBatchDetails.SelectedRows[0].DataBoundItem; //DialogResult = DialogResult.OK; } } } catch (Exception ex) { MessageBox.Show(Common.GetMessage("10002"), Common.GetMessage("30007"), MessageBoxButtons.OK, MessageBoxIcon.Error); Common.LogException(ex); } }
private void AddItem() { try { ValidateAdd(); StringBuilder sbError; sbError = GenerateAddError(); if (sbError.ToString().Trim().Equals(string.Empty)) { DialogResult saveResult = MessageBox.Show(Common.GetMessage("5010", "Add"), Common.GetMessage("10001"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (saveResult == DialogResult.Yes) { if (ItemInventory.BatchDetailList != null && ItemInventory.BatchDetailList.Count > 0) { var query = from a in ItemInventory.BatchDetailList where a.ToItemCode.ToUpper() == Itemcode.ToUpper() select a; if (query.Count(c => c.ToItemCode == Itemcode) > 0) { MessageBox.Show(Common.GetMessage("INF0227"), Common.GetMessage("10001"), MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (query.Count(c => c.ToItemCode == Itemcode) == 0) { ItemBatchDetails batch = new ItemBatchDetails(); batch.ToItemCode = Itemcode.Trim().ToString(); batch.ManufactureBatchNo = txtManuBatchNo.Text.Trim(); batch.Expiry = dtpExpiryDate.Value.ToShortDateString(); batch.Manufacure = dtpMfgDate.Value.ToShortDateString(); //batch.DisplayMfgDate = dtpMfgDate.Value.ToString(Common.DTP_DATE_FORMAT); batch.SerialNo = m_SerialNo++; if (ItemInventory.BatchDetailList == null) { ItemInventory.BatchDetailList = new List <ItemBatchDetails>(); } ItemInventory.BatchDetailList.Add(batch); ResetGrid(); //m_ParentGridView.Refresh(); ClearItem(); MessageBox.Show(Common.GetMessage("INF0055", "Batch", "Added"), Common.GetMessage("10001"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { ItemBatchDetails batch = new ItemBatchDetails(); batch.ToItemCode = Itemcode.Trim().ToString(); batch.ManufactureBatchNo = txtManuBatchNo.Text.Trim(); batch.Expiry = dtpExpiryDate.Value.ToShortDateString(); //batch.DisplayExpDate = dtpExpiryDate.Value.ToString(Common.DTP_DATE_FORMAT); //batch.ItemId = m_CurrentGRNDetail.ItemId; batch.Manufacure = dtpMfgDate.Value.ToShortDateString(); //batch.DisplayMfgDate = dtpMfgDate.Value.ToString(Common.DTP_DATE_FORMAT); batch.SerialNo = m_SerialNo++; if (ItemInventory.BatchDetailList == null) { ItemInventory.BatchDetailList = new List <ItemBatchDetails>(); } ItemInventory.BatchDetailList.Add(batch); ResetGrid(); //m_ParentGridView.Refresh(); ClearItem(); MessageBox.Show(Common.GetMessage("INF0055", "Batch", "Added"), Common.GetMessage("10001"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { MessageBox.Show(sbError.ToString(), Common.GetMessage("30007"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { throw ex; } }
private void EditItem() { try { ValidateEdit(); StringBuilder sbError; sbError = GenerateAddError(); if (sbError.ToString().Trim().Equals(string.Empty)) { DialogResult saveResult = MessageBox.Show(Common.GetMessage("5010", "Edit"), Common.GetMessage("10001"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (saveResult == DialogResult.Yes) { if (ItemInventory.BatchDetailList != null && ItemInventory.BatchDetailList.Count > 0) { var query = from a in ItemInventory.BatchDetailList where a.ToItemCode.ToUpper() == Itemcode.ToUpper() select a; List <CoreComponent.MasterData.BusinessObjects.ItemBatchDetails> lstItem; lstItem = (List <CoreComponent.MasterData.BusinessObjects.ItemBatchDetails>)query.ToList(); //int s = 0; foreach (ItemBatchDetails cn in lstItem) { CurrentSerialno = cn.SerialNo; int s = cn.SerialNo; ItemInventory.BatchDetailList[s].ItemCode = Itemcode.Trim().ToString(); ItemInventory.BatchDetailList[s].ExpDate = dtpExpiryDate.Value.ToShortDateString(); ItemInventory.BatchDetailList[s].MfgDate = dtpMfgDate.Value.ToShortDateString(); ItemInventory.BatchDetailList[s].ManufactureBatchNo = txtManuBatchNo.Text.Trim(); ItemInventory.BatchDetailList[s].DisplayExpDate = dtpExpiryDate.Value.ToString(Common.DTP_DATE_FORMAT); ItemInventory.BatchDetailList[s].DisplayMfgDate = dtpMfgDate.Value.ToString(Common.DTP_DATE_FORMAT); } ResetGrid(); //m_ParentGridView.Refresh(); ClearItem(); MessageBox.Show(Common.GetMessage("INF0055", "Batch", "Updated"), Common.GetMessage("10001"), MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { MessageBox.Show(sbError.ToString(), Common.GetMessage("30007"), MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { throw ex; } }
private void ResetGrid() { try { dgvBatchDetails.DataSource = null; //dgvBatchDetails.DataSource = new List<ItemBatchDetails>(); if (ItemInventory.BatchDetailList != null && ItemInventory.BatchDetailList.Count > 0) { var query = from a in ItemInventory.BatchDetailList where a.ToItemCode.ToUpper() == Itemcode.ToUpper() select a; if (query.Count(c => c.ToItemCode == Itemcode) > 0) { List <CoreComponent.MasterData.BusinessObjects.ItemBatchDetails> lstItem; lstItem = (List <CoreComponent.MasterData.BusinessObjects.ItemBatchDetails>)query.ToList(); //int s = 0; foreach (ItemBatchDetails cn in lstItem) { CurrentSerialno = cn.SerialNo; if (dgvBatchDetails.Rows.Count == 0) { dgvBatchDetails.Rows.Add(); } //int s = cn.SerialNo; //dgvBatchDetails.Rows[0].Cells[0].Value = " X "; dgvBatchDetails.Rows[0].Cells[1].Value = lstItem[0].ManufactureBatchNo; dgvBatchDetails.Rows[0].Cells[2].Value = lstItem[0].DisplayManufacure; dgvBatchDetails.Rows[0].Cells[3].Value = lstItem[0].DisplayExpiry; //s++; } } //else if() //{ //foreach (ItemBatchDetails cn in ItemDetail.GRNBatchDetailList) //{ // int s = cn.SerialNo - 1; // dgvBatchDetails.Rows[s].Cells[1].Value = ItemDetail.GRNBatchDetailList[0].ManufactureBatchNo; // dgvBatchDetails.Rows[s].Cells[2].Value = ItemDetail.GRNBatchDetailList[0].DisplayMfgDate; // dgvBatchDetails.Rows[s].Cells[3].Value = ItemDetail.GRNBatchDetailList[0].DisplayExpDate; //} dgvBatchDetails.ClearSelection(); m_bindingMgr = (CurrencyManager)this.BindingContext[ItemInventory.BatchDetailList]; m_bindingMgr.Refresh(); } dgvBatchDetails.ClearSelection(); } catch (Exception ex) { throw ex; } }