private void frmCardDevice_Load(object sender, EventArgs e) { this.cboDeviceList.Items.Clear(); this.cboDeviceList.Items.Add("[终端列表]"); if (InfoSys.ListDevices != null && InfoSys.ListDevices.Count > 0) { foreach (Device device in InfoSys.ListDevices) { //this.cboDeviceList.Items.Add(device.AddressCode1 + "-" + device.AddressCode2 + "-" + Tools.RepeatStr("0", 3 - device.AddressCode3.ToString().Length) + device.AddressCode3 + "-" + device.Description); District d5 = InfoSys.GetDistrictById(device.DistrictId); District d4 = InfoSys.GetDistrictById(d5.ParentId); District d3 = InfoSys.GetDistrictById(d4.ParentId); District d2 = InfoSys.GetDistrictById(d3.ParentId); District d1 = InfoSys.GetDistrictById(d2.ParentId); this.cboDeviceList.Items.Add(d1.DistrictCode + d2.DistrictCode + d3.DistrictCode + "-" + d4.DistrictCode + d5.DistrictCode + "-" + device.DeviceNo.PadLeft(3, '0') + "-" + device.DeviceName); } } this.cboTypeCode.Items.Clear(); this.cboTypeCode.Items.Add("00 - 请选择"); if (InfoSys.ListDeviceTypeCodes != null && InfoSys.ListDeviceTypeCodes.Count > 0) { foreach (DeviceTypeCode code in InfoSys.ListDeviceTypeCodes) { this.cboTypeCode.Items.Add(code.k.ToString().PadLeft(3, '0') + "-" + code.v); } } this.comboBox1.Items.Clear(); this.comboBox1.Items.Add("00 - 单站"); this.comboBox1.Items.Add("01 - 主站"); this.comboBox1.Items.Add("02 - 从站"); clear(); }
private void cboDeviceList_SelectedIndexChanged(object sender, EventArgs e) { this.textBox1.Text = "0"; if (this.cboDeviceList.SelectedIndex > 0) { string[] ss = this.cboDeviceList.SelectedItem.ToString().Split('-'); try { this.txtAddressCode1.Text = ss[0]; this.txtAddressCode2.Text = ss[1]; this.txtAddressCode3.Text = ss[2]; if (InfoSys.ListDevices != null && InfoSys.ListDevices.Count > 0) { foreach (Device device in InfoSys.ListDevices) { District d5 = InfoSys.GetDistrictById(device.DistrictId); District d4 = InfoSys.GetDistrictById(d5.ParentId); District d3 = InfoSys.GetDistrictById(d4.ParentId); District d2 = InfoSys.GetDistrictById(d3.ParentId); District d1 = InfoSys.GetDistrictById(d2.ParentId); if (d1.DistrictCode + d2.DistrictCode + d3.DistrictCode == ss[0] && d4.DistrictCode + d5.DistrictCode == ss[1] && int.Parse(device.DeviceNo) == int.Parse(ss[2])) { this.txtYearExploitation.Text = device.YearExploitation.ToString(); this.txtAlertAvailableWater.Text = device.AlertAvailableWater.ToString(); this.txtAlertAvailableElectric.Text = device.AlertAvailableElectric.ToString(); this.txtMeterPulse.Text = device.MeterPulse.ToString(); this.txtAlertWaterLevel.Text = device.AlertWaterLevel.ToString(); foreach (object item in this.cboTypeCode.Items) { if (int.Parse(item.ToString().Split('-')[0]) == device.DeviceTypeCodeId) { this.cboTypeCode.SelectedItem = item; break; } } foreach (object item in this.comboBox1.Items) { if (int.Parse(item.ToString().Split('-')[0]) == device.StationType) { this.comboBox1.SelectedItem = item; break; } } this.txtStationCode.Text = device.StationCode.ToString(); if (device.MainId > 0) { foreach (Device device1 in InfoSys.ListDevices) { if (device1.Id == device.MainId) { this.textBox1.Text = device1.DeviceNo; } } } } } } } catch { } } }