protected override void Add() { //if (curDevice != null) //{ //} TreeListNode node = treeList1.FocusedNode; if (node == null) { MessageBox.Show("请选择设备类型以后再进行检索", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { XtraSelectfrm selecfrm = new XtraSelectfrm(); selecfrm.type = curDevice.GetType(); selecfrm.ShowDialog(); if (selecfrm.DialogResult == DialogResult.OK) { if (curDevice is UCDeviceBDZ) { if (selecfrm.getselecindex == 0) { curDevice.strCon = " AreaID = '" + Itop.Client.MIS.ProgUID + "' AND Title like'%" + selecfrm.DeviceName + "%'"; curDevice.SelDevices(); } else if (selecfrm.getselecindex == 1) { curDevice.strCon = " AreaID = '" + Itop.Client.MIS.ProgUID + "' AND L1 ='" + selecfrm.devicevolt + "'"; curDevice.SelDevices(); } else if (selecfrm.getselecindex == 2) { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSP_Substation_Info>(selecfrm.vistsubstationflag), typeof(PSP_Substation_Info)); curDevice.gridControl1.DataSource = datatable; } } else if (curDevice is UCDeviceDY) { if (selecfrm.getselecindex == 0) { curDevice.strCon = " AreaID = '" + Itop.Client.MIS.ProgUID + "' AND Title like'%" + selecfrm.DeviceName + "%'"; curDevice.SelDevices(); } else if (selecfrm.getselecindex == 1) { curDevice.strCon = " AreaID = '" + Itop.Client.MIS.ProgUID + "' AND S1 ='" + selecfrm.devicevolt + "'"; curDevice.SelDevices(); } else if (selecfrm.getselecindex == 2) { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSP_PowerSubstation_Info>(selecfrm.vistpowerflag), typeof(PSP_PowerSubstation_Info)); curDevice.gridControl1.DataSource = datatable; } } else { if (selecfrm.getselecindex != 2) { //if (shortflag) //{ // GetDevice.strCon = ",psp_elcdevice where psp_elcdevice.devicesuid = pspdev.suid and psp_elcdevice.projectsuid = '" + ProjectSuid + "'" + selecfrm.Sqlcondition; //} //else curDevice.strCon = " where 1=1 " + selecfrm.Sqlcondition; curDevice.SelDevices(); } else { if (curDevice.GetType() == "01") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistbusflag), typeof(PSPDEV)); curDevice.gridControl1.DataSource = datatable; } else if (curDevice.GetType() == "05") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistlineflag), typeof(PSPDEV)); curDevice.gridControl1.DataSource = datatable; } else if (curDevice.GetType() == "02") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.visttrans2flag), typeof(PSPDEV)); curDevice.gridControl1.DataSource = datatable; } else if (curDevice.GetType() == "03") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.visttrans3flag), typeof(PSPDEV)); curDevice.gridControl1.DataSource = datatable; } else if (curDevice.GetType() == "04") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistfdjflag), typeof(PSPDEV)); curDevice.gridControl1.DataSource = datatable; } else if (curDevice.GetType() == "04") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistfdjflag), typeof(PSPDEV)); curDevice.gridControl1.DataSource = datatable; } else if (curDevice.GetType() == "06") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistdlqflag), typeof(PSPDEV)); curDevice.gridControl1.DataSource = datatable; } else if (curDevice.GetType() == "09") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistbldrflag), typeof(PSPDEV)); curDevice.gridControl1.DataSource = datatable; } else if (curDevice.GetType() == "10") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistcldkflag), typeof(PSPDEV)); curDevice.gridControl1.DataSource = datatable; } else if (curDevice.GetType() == "11") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistbldkflag), typeof(PSPDEV)); curDevice.gridControl1.DataSource = datatable; } else if (curDevice.GetType() == "12") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistfhflag), typeof(PSPDEV)); curDevice.gridControl1.DataSource = datatable; } else if (curDevice.GetType() == "13") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistmlflag), typeof(PSPDEV)); curDevice.gridControl1.DataSource = datatable; } else if (curDevice.GetType() == "14") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistml2flag), typeof(PSPDEV)); curDevice.gridControl1.DataSource = datatable; } } } } } }
private void simpleButton3_Click(object sender, EventArgs e) { if (comboBox1.Text == null) { MessageBox.Show("请选择设备类型以后再进行检索", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { object obj = comboBox1.SelectedItem; DataRowView row1 = obj as DataRowView; string id = row1.Row["id"].ToString(); XtraSelectfrm selecfrm = new XtraSelectfrm(); selecfrm.type = id; selecfrm.ShowDialog(); if (selecfrm.DialogResult == DialogResult.OK) { if (selecfrm.getselecindex != 2) { dt.Clear(); if (obj != null) { string con = " where type = '" + id + "'"; string con2 = " and ProjectID = '" + this.ProjectID + "'"; con = con + con2 + selecfrm.Sqlcondition; IList list = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); if (!string.IsNullOrEmpty(belongyear)) //根据参与计算设备属于那一年先进行一次筛选 { for (int i = 0; i < list.Count; i++) { if (!string.IsNullOrEmpty((list[i] as PSPDEV).OperationYear) && (list[i] as PSPDEV).OperationYear.Length == 4 && belongyear.Length == 4) { if (Convert.ToInt32((list[i] as PSPDEV).OperationYear) > Convert.ToInt32(belongyear)) { list.RemoveAt(i); i--; continue; } } if (!string.IsNullOrEmpty((list[i] as PSPDEV).Date2) && (list[i] as PSPDEV).Date2.Length == 4 && belongyear.Length == 4) { if (Convert.ToInt32((list[i] as PSPDEV).Date2) > Convert.ToInt32(belongyear)) { list.RemoveAt(i); i--; continue; } } } } foreach (PSPDEV dev in list) { DataRow row = dt.NewRow(); row["A"] = dev.SUID; row["B"] = dev.Name; row["C"] = true; dt.Rows.Add(row); } } gridControl1.DataSource = dt; } else { if (id == "01") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistbusflag), typeof(PSPDEV)); selectelement(datatable); } else if (id == "05") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistlineflag), typeof(PSPDEV)); selectelement(datatable); } else if (id == "02") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.visttrans2flag), typeof(PSPDEV)); selectelement(datatable); } else if (id == "03") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.visttrans3flag), typeof(PSPDEV)); selectelement(datatable); } else if (id == "04") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistfdjflag), typeof(PSPDEV)); selectelement(datatable); } else if (id == "06") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistdlqflag), typeof(PSPDEV)); selectelement(datatable); } else if (id == "08") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistcldrflag), typeof(PSPDEV)); selectelement(datatable); } else if (id == "09") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistbldrflag), typeof(PSPDEV)); selectelement(datatable); } else if (id == "10") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistcldkflag), typeof(PSPDEV)); selectelement(datatable); } else if (id == "11") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistbldkflag), typeof(PSPDEV)); selectelement(datatable); } else if (id == "12") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistfhflag), typeof(PSPDEV)); selectelement(datatable); } else if (id == "13") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistmlflag), typeof(PSPDEV)); selectelement(datatable); } else if (id == "14") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistml2flag), typeof(PSPDEV)); selectelement(datatable); } } } } }
private void simpleButton3_Click(object sender, EventArgs e) { TreeListNode node = treeList1.FocusedNode; if (node == null) { MessageBox.Show("请选择设备类型以后再进行检索", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { if (GetDevice == null) { MessageBox.Show("请选择设备类型以后再进行检索", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } XtraSelectfrm selecfrm = new XtraSelectfrm(); selecfrm.type = GetDevice.GetType(); selecfrm.ShowDialog(); if (selecfrm.DialogResult == DialogResult.OK) { if (GetDevice is UCDeviceBDZ) { if (selecfrm.getselecindex == 0) { DataTable dt = GetDevice.gridControl1.DataSource as DataTable; DataRow[] dtcol = dt.Select(" AreaID = '" + Itop.Client.MIS.ProgUID + "' AND Title like'%" + selecfrm.DeviceName + "%'"); DataTable dt1 = new DataTable(); dt1 = dt.Clone(); foreach (DataRow dr in dtcol) { DataRow dr1 = dt1.NewRow(); for (int i = 0; i < dt.Columns.Count; i++) { dr1[i] = dr[i]; } dt1.Rows.Add(dr1); // list.Add(Itop.Common.DataConverter.RowToObject<PSP_Substation_Info>(dr)); } GetDevice.gridControl1.DataSource = dt1; //GetDevice.strCon = " AreaID = '" + Itop.Client.MIS.ProgUID + "' AND Title like'%" + selecfrm.DeviceName + "%'"; //GetDevice.SelDevices(); } else if (selecfrm.getselecindex == 1) { DataTable dt = GetDevice.gridControl1.DataSource as DataTable; DataRow[] dtcol = dt.Select(" AreaID = '" + Itop.Client.MIS.ProgUID + "' AND L1 ='" + selecfrm.devicevolt + "'"); DataTable dt1 = new DataTable(); dt1 = dt.Clone(); foreach (DataRow dr in dtcol) { DataRow dr1 = dt1.NewRow(); for (int i = 0; i < dt.Columns.Count; i++) { dr1[i] = dr[i]; } dt1.Rows.Add(dr1); // list.Add(Itop.Common.DataConverter.RowToObject<PSP_Substation_Info>(dr)); } GetDevice.gridControl1.DataSource = dt1; //GetDevice.strCon = " AreaID = '" + Itop.Client.MIS.ProgUID + "' AND L1 ='" + selecfrm.devicevolt + "'"; //GetDevice.SelDevices(); } else if (selecfrm.getselecindex == 2) { DataTable dt = GetDevice.gridControl1.DataSource as DataTable; DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSP_Substation_Info>(selecfrm.vistsubstationflag), typeof(PSP_Substation_Info)); DataTable dt1 = new DataTable(); dt1 = dt.Clone(); foreach (DataRow dr in datatable.Rows) { foreach (DataRow dr1 in dt.Rows) { if (dr["UID"].ToString().Equals(dr1["UID"].ToString())) { DataRow dr2 = dt1.NewRow(); for (int i = 0; i < dt.Columns.Count; i++) { dr2[i] = dr[i]; } dt1.Rows.Add(dr2); } } // list.Add(Itop.Common.DataConverter.RowToObject<PSP_Substation_Info>(dr)); } GetDevice.gridControl1.DataSource = dt1; } } else if (GetDevice is UCDeviceDY) { if (selecfrm.getselecindex == 0) { DataTable dt = GetDevice.gridControl1.DataSource as DataTable; DataRow[] dtcol = dt.Select(" AreaID = '" + Itop.Client.MIS.ProgUID + "' AND Title like'%" + selecfrm.DeviceName + "%'"); DataTable dt1 = new DataTable(); dt1 = dt.Clone(); foreach (DataRow dr in dtcol) { DataRow dr1 = dt1.NewRow(); for (int i = 0; i < dt.Columns.Count; i++) { dr1[i] = dr[i]; } dt1.Rows.Add(dr1); // list.Add(Itop.Common.DataConverter.RowToObject<PSP_Substation_Info>(dr)); } GetDevice.gridControl1.DataSource = dt1; //GetDevice.strCon = " AreaID = '" + Itop.Client.MIS.ProgUID + "' AND Title like'%" + selecfrm.DeviceName + "%'"; //GetDevice.SelDevices(); } else if (selecfrm.getselecindex == 1) { DataTable dt = GetDevice.gridControl1.DataSource as DataTable; DataRow[] dtcol = dt.Select(" AreaID = '" + Itop.Client.MIS.ProgUID + "' AND S1 ='" + selecfrm.devicevolt + "'"); DataTable dt1 = new DataTable(); dt1 = dt.Clone(); foreach (DataRow dr in dtcol) { DataRow dr1 = dt1.NewRow(); for (int i = 0; i < dt.Columns.Count; i++) { dr1[i] = dr[i]; } dt1.Rows.Add(dr1); // list.Add(Itop.Common.DataConverter.RowToObject<PSP_Substation_Info>(dr)); } GetDevice.gridControl1.DataSource = dt1; // GetDevice.strCon = " AreaID = '" + Itop.Client.MIS.ProgUID + "' AND S1 ='" + selecfrm.devicevolt + "'"; // GetDevice.SelDevices(); } else if (selecfrm.getselecindex == 2) { DataTable dt = GetDevice.gridControl1.DataSource as DataTable; DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSP_PowerSubstation_Info>(selecfrm.vistpowerflag), typeof(PSP_PowerSubstation_Info)); DataTable dt1 = new DataTable(); dt1 = dt.Clone(); foreach (DataRow dr in datatable.Rows) { foreach (DataRow dr1 in dt.Rows) { if (dr["UID"].ToString().Equals(dr1["UID"].ToString())) { DataRow dr2 = dt1.NewRow(); for (int i = 0; i < dt.Columns.Count; i++) { dr2[i] = dr[i]; } dt1.Rows.Add(dr2); } } // list.Add(Itop.Common.DataConverter.RowToObject<PSP_Substation_Info>(dr)); } GetDevice.gridControl1.DataSource = dt1; } } else { if (selecfrm.getselecindex != 2) { if (shortflag) { GetDevice.strCon = ",psp_elcdevice where psp_elcdevice.devicesuid = pspdev.suid and psp_elcdevice.projectsuid = '" + ProjectSuid + "'" + selecfrm.Sqlcondition; } else { GetDevice.strCon = " where 1=1 " + selecfrm.Sqlcondition; } GetDevice.SelDevices(); } else { if (GetDevice.GetType() == "01") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistbusflag), typeof(PSPDEV)); GetDevice.gridControl1.DataSource = datatable; } else if (GetDevice.GetType() == "05") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistlineflag), typeof(PSPDEV)); GetDevice.gridControl1.DataSource = datatable; } else if (GetDevice.GetType() == "02") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.visttrans2flag), typeof(PSPDEV)); GetDevice.gridControl1.DataSource = datatable; } else if (GetDevice.GetType() == "03") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.visttrans3flag), typeof(PSPDEV)); GetDevice.gridControl1.DataSource = datatable; } else if (GetDevice.GetType() == "04") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistfdjflag), typeof(PSPDEV)); GetDevice.gridControl1.DataSource = datatable; } else if (GetDevice.GetType() == "04") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistfdjflag), typeof(PSPDEV)); GetDevice.gridControl1.DataSource = datatable; } else if (GetDevice.GetType() == "06") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistdlqflag), typeof(PSPDEV)); GetDevice.gridControl1.DataSource = datatable; } else if (GetDevice.GetType() == "09") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistbldrflag), typeof(PSPDEV)); GetDevice.gridControl1.DataSource = datatable; } else if (GetDevice.GetType() == "10") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistcldkflag), typeof(PSPDEV)); GetDevice.gridControl1.DataSource = datatable; } else if (GetDevice.GetType() == "11") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistbldkflag), typeof(PSPDEV)); GetDevice.gridControl1.DataSource = datatable; } else if (GetDevice.GetType() == "12") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistfhflag), typeof(PSPDEV)); GetDevice.gridControl1.DataSource = datatable; } else if (GetDevice.GetType() == "13") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistmlflag), typeof(PSPDEV)); GetDevice.gridControl1.DataSource = datatable; } else if (GetDevice.GetType() == "14") { DataTable datatable = new DataTable(); datatable = Itop.Common.DataConverter.ToDataTable(convertdirecttolist <PSPDEV>(selecfrm.vistml2flag), typeof(PSPDEV)); GetDevice.gridControl1.DataSource = datatable; } } } } } }