/// <summary> /// 添加监测项信息的业务逻辑 /// </summary> private void AddItem() { if (!ValidateItem())//验证 { DevComponents.DotNetBar.MessageBoxEx.Show("请填写完整监测项信息!", "[提示]", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Service.Model.YY_RTU_ITEM model = new Service.Model.YY_RTU_ITEM(); model.ItemID = textBox_ItemID.Text.Trim(); model.ItemName = textBox_ItemName.Text.Trim(); model.ItemCode = textBox_ItemCode.Text.Trim(); model.Units = textBox_ItemUnites.Text.Trim(); if (comboBox_ItemDecimal.SelectedItem.ToString() == "其他") { model.ItemDecimal = -1; } else { model.ItemDecimal = int.Parse(comboBox_ItemDecimal.SelectedItem.ToString()); } if (comboBox_ItemInteger.SelectedItem.ToString() == "其他") { model.ItemInteger = -1; } else { model.ItemInteger = int.Parse(comboBox_ItemInteger.SelectedItem.ToString()); } model.PlusOrMinus = checkBox_ItemPlusOrMinus.Checked; string Where = " where ItemID='" + textBox_ItemID.Text.Trim() + "'"; IList <Service.Model.YY_RTU_ITEM> ItemList = PublicBD.db.GetItemList(Where); //查重 if (ItemList.Count() > 0) { PublicBD.db.UdpItem(model, Where); //更新 } else { PublicBD.db.AddItem(model); //添加 } checkedListBox_Item_Init(); //更新控件 } }
private void comboBox_Item_Init(DevComponents.DotNetBar.Controls.ComboBoxEx cb) { IList <Service.Model.YY_RTU_ITEM> ItemList = PublicBD.db.GetItemList(" where ItemCode!='-1' and ItemCode!='0000000000'"); if (ItemList != null && ItemList.Count > 0) { Service.Model.YY_RTU_ITEM item = new Service.Model.YY_RTU_ITEM(); item.ItemName = "全部"; item.ItemID = "-1"; ItemList.Insert(0, item); if (Program.wrx.XMLObj.dllfile.ToLower() == "gsprotocol.dll") { var items = from il in ItemList where il.ItemID == "180" || il.ItemID == "181" || il.ItemID == "182" || il.ItemID == "183" || il.ItemID == "184" || il.ItemID == "185" select il; if (items.Count() > 0) { foreach (var tem in items.ToArray <Service.Model.YY_RTU_ITEM>()) { ItemList.Remove(tem); } (from il in ItemList where il.ItemID == "12" select il).First().ItemName = "雨量"; (from il in ItemList where il.ItemID == "15" select il).First().ItemName = "水位1"; (from il in ItemList where il.ItemID == "16" select il).First().ItemName = "水位2"; } } ITEMList = ItemList; cb.DataSource = ItemList; cb.DisplayMember = "ItemName"; cb.ValueMember = "ItemID"; cb.SelectedIndex = 0; } }