Example #1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            dt.Clear();
            object obj = comboBox1.SelectedItem;

            if (obj != null)
            {
                DataRowView row1 = obj as DataRowView;
                string      id   = row1.Row["id"].ToString();
                IList       list = null;
                if (id == "20")
                {
                    string con = " AreaID = '" + Itop.Client.MIS.ProgUID + "'";

                    list = Services.BaseService.GetList("SelectPSP_Substation_InfoListByWhere", con);
                    foreach (PSP_Substation_Info dev in list)
                    {
                        PSP_GprogElevice pspDev = new PSP_GprogElevice();
                        pspDev.DeviceSUID = dev.UID;
                        pspDev.GprogUID   = ProjectSUID;
                        pspDev.Type       = "变电站";
                        IList list1 = Services.BaseService.GetList("SelectPSP_GprogEleviceByKey", pspDev);
                        if (list1.Count > 0)
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.UID;
                            row["B"] = dev.Title;
                            row["C"] = true;
                            row["D"] = "变电站";
                            dt.Rows.Add(row);
                        }
                        else
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.UID;
                            row["B"] = dev.Title;
                            row["C"] = false;
                            row["D"] = "变电站";
                            dt.Rows.Add(row);
                        }
                    }
                }
                else if (id == "30")
                {
                    string con = " AreaID = '" + Itop.Client.MIS.ProgUID + "'";

                    list = Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoListByWhere", con);
                    foreach (PSP_PowerSubstation_Info dev in list)
                    {
                        PSP_GprogElevice pspDev = new PSP_GprogElevice();
                        pspDev.DeviceSUID = dev.UID;
                        pspDev.GprogUID   = ProjectSUID;
                        pspDev.Type       = "电源";
                        IList list1 = Services.BaseService.GetList("SelectPSP_GprogEleviceByKey", pspDev);
                        if (list1.Count > 0)
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.UID;
                            row["B"] = dev.Title;
                            row["C"] = true;
                            row["D"] = "电源";
                            dt.Rows.Add(row);
                        }
                        else
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.UID;
                            row["B"] = dev.Title;
                            row["C"] = false;
                            row["D"] = "电源";
                            dt.Rows.Add(row);
                        }
                    }
                }
                else if (id == "05")
                {
                    string con  = " where type = '" + id + "'";
                    string con2 = " and ProjectID = '" + this.ProjectID + "'";
                    con  = con + con2;
                    list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV dev in list)
                    {
                        PSP_GprogElevice pspDev = new PSP_GprogElevice();
                        pspDev.DeviceSUID = dev.SUID;
                        pspDev.GprogUID   = ProjectSUID;
                        pspDev.Type       = "线路";
                        IList list1 = Services.BaseService.GetList("SelectPSP_GprogEleviceByKey", pspDev);
                        if (list1.Count > 0)
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.SUID;
                            row["B"] = dev.Name;
                            row["C"] = true;
                            row["D"] = "线路";
                            dt.Rows.Add(row);
                        }
                        else
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.SUID;
                            row["B"] = dev.Name;
                            row["C"] = false;
                            row["D"] = "线路";
                            dt.Rows.Add(row);
                        }
                    }
                }
                else if (id == "02")
                {
                    string con  = " where type = '" + id + "'";
                    string con2 = " and ProjectID = '" + this.ProjectID + "'";
                    con  = con + con2;
                    list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV dev in list)
                    {
                        PSP_GprogElevice pspDev = new PSP_GprogElevice();
                        pspDev.DeviceSUID = dev.SUID;
                        pspDev.GprogUID   = ProjectSUID;
                        pspDev.Type       = "两绕组变压器";
                        IList list1 = Services.BaseService.GetList("SelectPSP_GprogEleviceByKey", pspDev);
                        if (list1.Count > 0)
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.SUID;
                            row["B"] = dev.Name;
                            row["C"] = true;
                            row["D"] = "两绕组变压器";
                            dt.Rows.Add(row);
                        }
                        else
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.SUID;
                            row["B"] = dev.Name;
                            row["C"] = false;
                            row["D"] = "两绕组变压器";
                            dt.Rows.Add(row);
                        }
                    }
                }
                else if (id == "03")
                {
                    string con  = " where type = '" + id + "'";
                    string con2 = " and ProjectID = '" + this.ProjectID + "'";
                    con  = con + con2;
                    list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV dev in list)
                    {
                        PSP_GprogElevice pspDev = new PSP_GprogElevice();
                        pspDev.DeviceSUID = dev.SUID;
                        pspDev.GprogUID   = ProjectSUID;
                        pspDev.Type       = "三绕组变压器";
                        IList list1 = Services.BaseService.GetList("SelectPSP_GprogEleviceByKey", pspDev);
                        if (list1.Count > 0)
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.SUID;
                            row["B"] = dev.Name;
                            row["C"] = true;
                            row["D"] = "三绕组变压器";
                            dt.Rows.Add(row);
                        }
                        else
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.SUID;
                            row["B"] = dev.Name;
                            row["C"] = false;
                            row["D"] = "三绕组变压器";
                            dt.Rows.Add(row);
                        }
                    }
                }
                else if (id == "04")
                {
                    string con  = " where type = '" + id + "'";
                    string con2 = " and ProjectID = '" + this.ProjectID + "'";
                    con  = con + con2;
                    list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV dev in list)
                    {
                        PSP_GprogElevice pspDev = new PSP_GprogElevice();
                        pspDev.DeviceSUID = dev.SUID;
                        pspDev.GprogUID   = ProjectSUID;
                        pspDev.Type       = "发电机";
                        IList list1 = Services.BaseService.GetList("SelectPSP_GprogEleviceByKey", pspDev);
                        if (list1.Count > 0)
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.SUID;
                            row["B"] = dev.Name;
                            row["C"] = true;
                            row["D"] = "发电机";
                            dt.Rows.Add(row);
                        }
                        else
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.SUID;
                            row["B"] = dev.Name;
                            row["C"] = false;
                            row["D"] = "发电机";
                            dt.Rows.Add(row);
                        }
                    }
                }
                else if (id == "12")
                {
                    string con  = " where type = '" + id + "'";
                    string con2 = " and ProjectID = '" + this.ProjectID + "'";
                    con  = con + con2;
                    list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                    foreach (PSPDEV dev in list)
                    {
                        PSP_GprogElevice pspDev = new PSP_GprogElevice();
                        pspDev.DeviceSUID = dev.SUID;
                        pspDev.GprogUID   = ProjectSUID;
                        pspDev.Type       = "负荷";
                        IList list1 = Services.BaseService.GetList("SelectPSP_GprogEleviceByKey", pspDev);
                        if (list1.Count > 0)
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.SUID;
                            row["B"] = dev.Name;
                            row["C"] = true;
                            row["D"] = "负荷";
                            dt.Rows.Add(row);
                        }
                        else
                        {
                            DataRow row = dt.NewRow();
                            row["A"] = dev.SUID;
                            row["B"] = dev.Name;
                            row["C"] = false;
                            row["D"] = "负荷";
                            dt.Rows.Add(row);
                        }
                    }
                }
            }
            gridControl1.DataSource = dt;
        }
Example #2
0
        public void Init()
        {
            dt.Columns.Add("A");
            dt.Columns.Add("B");
            dt.Columns.Add("C", typeof(bool));
            dt.Columns.Add("D");
            //Stream fs = Assembly.GetExecutingAssembly().GetManifestResourceStream("Itop.TLPSP.DEVICE.devicetypes.xml");
            string path = System.Windows.Forms.Application.StartupPath + "\\" + "devicetypes.xml";
            //Assembly.GetExecutingAssembly().GetManifestResourceStream
            XmlDocument xml = new XmlDocument();

            xml.Load(path);
            XmlNodeList nodes = xml.GetElementsByTagName("device");
            DataTable   table = new DataTable();

            table.Columns.Add("id", typeof(string));
            table.Columns.Add("name", typeof(string));
            table.Columns.Add("class", typeof(string));
            foreach (XmlNode node in nodes)
            {
                if (((XmlElement)node).GetAttribute("name") == "变电站" || ((XmlElement)node).GetAttribute("name") == "电源" || ((XmlElement)node).GetAttribute("name") == "线路" || ((XmlElement)node).GetAttribute("name") == "两绕组变压器" || ((XmlElement)node).GetAttribute("name") == "三绕组变压器" || ((XmlElement)node).GetAttribute("name") == "发电机" || ((XmlElement)node).GetAttribute("name") == "负荷")
                {
                    DataRow row = table.NewRow();
                    row["id"]    = node.Attributes["id"].Value;
                    row["name"]  = node.Attributes["name"].Value;
                    row["class"] = node.Attributes["class"].Value;
                    table.Rows.Add(row);
                }
            }
            comboBox1.DataSource    = table;
            comboBox1.DisplayMember = "name";
            {
                dt.Clear();
                object obj = comboBox1.SelectedItem;
                if (obj != null)
                {
                    DataRowView row1 = obj as DataRowView;
                    string      id   = row1.Row["id"].ToString();
                    IList       list = null;
                    if (id == "20")
                    {
                        string con = " AreaID = '" + Itop.Client.MIS.ProgUID + "'";

                        list = Services.BaseService.GetList("SelectPSP_Substation_InfoListByWhere", con);
                        foreach (PSP_Substation_Info dev in list)
                        {
                            PSP_GprogElevice pspDev = new PSP_GprogElevice();
                            pspDev.DeviceSUID = dev.UID;
                            pspDev.GprogUID   = ProjectSUID;
                            pspDev.Type       = "变电站";
                            IList list1 = Services.BaseService.GetList("SelectPSP_GprogEleviceByKey", pspDev);
                            if (list1.Count > 0)
                            {
                                DataRow row = dt.NewRow();
                                row["A"] = dev.UID;
                                row["B"] = dev.Title;
                                row["C"] = true;
                                row["D"] = "变电站";
                                dt.Rows.Add(row);
                            }
                            else
                            {
                                DataRow row = dt.NewRow();
                                row["A"] = dev.UID;
                                row["B"] = dev.Title;
                                row["C"] = false;
                                row["D"] = "变电站";
                                dt.Rows.Add(row);
                            }
                        }
                    }
                    else if (id == "30")
                    {
                        string con = " AreaID = '" + Itop.Client.MIS.ProgUID + "'";

                        list = Services.BaseService.GetList("SelectPSP_PowerSubstation_InfoListByWhere", con);
                        foreach (PSP_PowerSubstation_Info dev in list)
                        {
                            PSP_GprogElevice pspDev = new PSP_GprogElevice();
                            pspDev.DeviceSUID = dev.UID;
                            pspDev.GprogUID   = ProjectSUID;
                            pspDev.Type       = "电源";
                            IList list1 = Services.BaseService.GetList("SelectPSP_GprogEleviceByKey", pspDev);
                            if (list1.Count > 0)
                            {
                                DataRow row = dt.NewRow();
                                row["A"] = dev.UID;
                                row["B"] = dev.Title;
                                row["C"] = true;
                                row["D"] = "电源";
                                dt.Rows.Add(row);
                            }
                            else
                            {
                                DataRow row = dt.NewRow();
                                row["A"] = dev.UID;
                                row["B"] = dev.Title;
                                row["C"] = false;
                                row["D"] = "电源";
                                dt.Rows.Add(row);
                            }
                        }
                    }
                    else if (id == "05")
                    {
                        string con  = " where type = '" + id + "'";
                        string con2 = " and ProjectID = '" + this.ProjectID + "'";
                        con  = con + con2;
                        list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                        foreach (PSPDEV dev in list)
                        {
                            PSP_GprogElevice pspDev = new PSP_GprogElevice();
                            pspDev.DeviceSUID = dev.SUID;
                            pspDev.GprogUID   = ProjectSUID;
                            pspDev.Type       = "线路";
                            IList list1 = Services.BaseService.GetList("SelectPSP_GprogEleviceByKey", pspDev);
                            if (list1.Count > 0)
                            {
                                DataRow row = dt.NewRow();
                                row["A"] = dev.SUID;
                                row["B"] = dev.Name;
                                row["C"] = true;
                                row["D"] = "线路";
                                dt.Rows.Add(row);
                            }
                            else
                            {
                                DataRow row = dt.NewRow();
                                row["A"] = dev.SUID;
                                row["B"] = dev.Name;
                                row["C"] = false;
                                row["D"] = "线路";
                                dt.Rows.Add(row);
                            }
                        }
                    }
                    else if (id == "02")
                    {
                        string con  = " where type = '" + id + "'";
                        string con2 = " and ProjectID = '" + this.ProjectID + "'";
                        con  = con + con2;
                        list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                        foreach (PSPDEV dev in list)
                        {
                            PSP_GprogElevice pspDev = new PSP_GprogElevice();
                            pspDev.DeviceSUID = dev.SUID;
                            pspDev.GprogUID   = ProjectSUID;
                            pspDev.Type       = "两绕组变压器";
                            IList list1 = Services.BaseService.GetList("SelectPSP_GprogEleviceByKey", pspDev);
                            if (list1.Count > 0)
                            {
                                DataRow row = dt.NewRow();
                                row["A"] = dev.SUID;
                                row["B"] = dev.Name;
                                row["C"] = true;
                                row["D"] = "两绕组变压器";
                                dt.Rows.Add(row);
                            }
                            else
                            {
                                DataRow row = dt.NewRow();
                                row["A"] = dev.SUID;
                                row["B"] = dev.Name;
                                row["C"] = false;
                                row["D"] = "两绕组变压器";
                                dt.Rows.Add(row);
                            }
                        }
                    }
                    else if (id == "03")
                    {
                        string con  = " where type = '" + id + "'";
                        string con2 = " and ProjectID = '" + this.ProjectID + "'";
                        con  = con + con2;
                        list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                        foreach (PSPDEV dev in list)
                        {
                            PSP_GprogElevice pspDev = new PSP_GprogElevice();
                            pspDev.DeviceSUID = dev.SUID;
                            pspDev.GprogUID   = ProjectSUID;
                            pspDev.Type       = "三绕组变压器";
                            IList list1 = Services.BaseService.GetList("SelectPSP_GprogEleviceByKey", pspDev);
                            if (list1.Count > 0)
                            {
                                DataRow row = dt.NewRow();
                                row["A"] = dev.SUID;
                                row["B"] = dev.Name;
                                row["C"] = true;
                                row["D"] = "三绕组变压器";
                                dt.Rows.Add(row);
                            }
                            else
                            {
                                DataRow row = dt.NewRow();
                                row["A"] = dev.SUID;
                                row["B"] = dev.Name;
                                row["C"] = false;
                                row["D"] = "三绕组变压器";
                                dt.Rows.Add(row);
                            }
                        }
                    }
                    else if (id == "04")
                    {
                        string con  = " where type = '" + id + "'";
                        string con2 = " and ProjectID = '" + this.ProjectID + "'";
                        con  = con + con2;
                        list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                        foreach (PSPDEV dev in list)
                        {
                            PSP_GprogElevice pspDev = new PSP_GprogElevice();
                            pspDev.DeviceSUID = dev.SUID;
                            pspDev.GprogUID   = ProjectSUID;
                            pspDev.Type       = "发电机";
                            IList list1 = Services.BaseService.GetList("SelectPSP_GprogEleviceByKey", pspDev);
                            if (list1.Count > 0)
                            {
                                DataRow row = dt.NewRow();
                                row["A"] = dev.SUID;
                                row["B"] = dev.Name;
                                row["C"] = true;
                                row["D"] = "发电机";
                                dt.Rows.Add(row);
                            }
                            else
                            {
                                DataRow row = dt.NewRow();
                                row["A"] = dev.SUID;
                                row["B"] = dev.Name;
                                row["C"] = false;
                                row["D"] = "发电机";
                                dt.Rows.Add(row);
                            }
                        }
                    }
                    else if (id == "12")
                    {
                        string con  = " where type = '" + id + "'";
                        string con2 = " and ProjectID = '" + this.ProjectID + "'";
                        con  = con + con2;
                        list = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                        foreach (PSPDEV dev in list)
                        {
                            PSP_GprogElevice pspDev = new PSP_GprogElevice();
                            pspDev.DeviceSUID = dev.SUID;
                            pspDev.GprogUID   = ProjectSUID;
                            pspDev.Type       = "负荷";
                            IList list1 = Services.BaseService.GetList("SelectPSP_GprogEleviceByKey", pspDev);
                            if (list1.Count > 0)
                            {
                                DataRow row = dt.NewRow();
                                row["A"] = dev.SUID;
                                row["B"] = dev.Name;
                                row["C"] = true;
                                row["D"] = "负荷";
                                dt.Rows.Add(row);
                            }
                            else
                            {
                                DataRow row = dt.NewRow();
                                row["A"] = dev.SUID;
                                row["B"] = dev.Name;
                                row["C"] = false;
                                row["D"] = "负荷";
                                dt.Rows.Add(row);
                            }
                        }
                    }
                }
                gridControl1.DataSource = dt;
            }
        }
Example #3
0
        private void button5_Click_1(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            frmGHDeviceList frmDevList = new frmGHDeviceList();

            frmDevList.ProjectID   = Itop.Client.MIS.ProgUID;
            frmDevList.ProjectSUID = ctrlPSP_GProg1.FocusedObject.UID;
            frmDevList.Init();
            if (frmDevList.ShowDialog() == DialogResult.OK)
            {
                foreach (DataRow row in frmDevList.DT.Rows)
                {
                    try {
                        if ((bool)row["C"])
                        {
                            PSP_GprogElevice elcDevice = new PSP_GprogElevice();
                            elcDevice.DeviceSUID = row["A"].ToString();
                            elcDevice.GprogUID   = ctrlPSP_GProg1.FocusedObject.UID;
                            elcDevice            = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", elcDevice);
                            if (elcDevice != null)
                            {
                                elcDevice.Type = row["D"].ToString();
                                elcDevice.L2   = "0";
                                Services.BaseService.Update <PSP_GprogElevice>(elcDevice);
                            }
                            else
                            {
                                elcDevice            = new PSP_GprogElevice();
                                elcDevice.DeviceSUID = row["A"].ToString();
                                elcDevice.GprogUID   = ctrlPSP_GProg1.FocusedObject.UID;
                                elcDevice.Type       = row["D"].ToString();
                                elcDevice.L2         = "0";
                                Services.BaseService.Create <PSP_GprogElevice>(elcDevice);
                            }
                        }
                        else
                        {
                            PSP_GprogElevice elcDevice = new PSP_GprogElevice();
                            elcDevice.DeviceSUID = row["A"].ToString();
                            elcDevice.GprogUID   = ctrlPSP_GProg1.FocusedObject.UID;

                            Services.BaseService.Delete <PSP_GprogElevice>(elcDevice);
                        }
                    } catch (System.Exception ex) {
                    }
                }
            }
            else
            {
                return;
            }
            //在此处将其选择的元件设备的属性进行更改

            LayerGrade l1 = new LayerGrade();

            l1.Type       = "1";
            l1.SvgDataUid = svguid;
            IList ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            int   yy1 = System.DateTime.Now.Year, yy2 = System.DateTime.Now.Year, yy3 = System.DateTime.Now.Year;

            if (ttlist.Count > 0)
            {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy1 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            l1.Type       = "2";
            l1.SvgDataUid = svguid;
            ttlist        = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            if (ttlist.Count > 0)
            {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy2 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            l1.Type       = "3";
            l1.SvgDataUid = svguid;
            ttlist        = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            if (ttlist.Count > 0)
            {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy3 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            string con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '变电站'";

            IList list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);

            foreach (PSP_GprogElevice pg in list)
            {
                PSP_Substation_Info ps = new PSP_Substation_Info();
                ps.UID = pg.DeviceSUID;
                ps     = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoByKey", ps);
                if (ps != null)
                {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.S2))
                    {
                        s2 = Convert.ToInt32(ps.S2);
                    }
                    if (s2 <= System.DateTime.Now.Year)
                    {
                        pg.L1 = "现行";
                    }
                    else if (s2 > System.DateTime.Now.Year && Convert.ToInt32(ps.S2) <= yy1)
                    {
                        pg.L1 = "近期";
                    }
                    else if (s2 > yy1 && Convert.ToInt32(ps.S2) <= yy2)
                    {
                        pg.L1 = "中期";
                    }
                    else if (s2 > yy2 && Convert.ToInt32(ps.S2) <= yy3)
                    {
                        pg.L1 = "远期";
                    }
                    Services.BaseService.Update <PSP_GprogElevice>(pg);
                }
                else
                {
                    Services.BaseService.Delete <PSP_GprogElevice>(pg);
                }
            }
            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '电源'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list)
            {
                PSP_PowerSubstation_Info ps = new PSP_PowerSubstation_Info();
                ps.UID = pg.DeviceSUID;
                ps     = (PSP_PowerSubstation_Info)Services.BaseService.GetObject("SelectPSP_PowerSubstation_InfoByKey", ps);
                if (ps != null)
                {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.S3))
                    {
                        s2 = Convert.ToInt32(ps.S3);
                    }
                    if (s2 <= System.DateTime.Now.Year)
                    {
                        pg.L1 = "现行";
                    }
                    else if (s2 > System.DateTime.Now.Year && Convert.ToInt32(ps.S3) <= yy1)
                    {
                        pg.L1 = "近期";
                    }
                    else if (s2 > yy1 && Convert.ToInt32(ps.S3) <= yy2)
                    {
                        pg.L1 = "中期";
                    }
                    else if (s2 > yy2 && Convert.ToInt32(ps.S3) <= yy3)
                    {
                        pg.L1 = "远期";
                    }
                    Services.BaseService.Update <PSP_GprogElevice>(pg);
                }
                else
                {
                    Services.BaseService.Delete <PSP_GprogElevice>(pg);
                }
            }
            //变电站里判断两绕和三绕是哪个时期的

            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '变电站'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list)
            {
                con = "c.UID='" + pg.DeviceSUID + "'and a.Type='02'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                IList uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist)
                {
                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '两绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null)
                    {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update <PSP_GprogElevice>(pglr);
                    }
                }
                con     = "c.UID='" + pg.DeviceSUID + "'and a.Type='03'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist)
                {
                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '三绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null)
                    {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update <PSP_GprogElevice>(pglr);
                    }
                }
            }
            //发电厂里两绕和三绕组是哪个时期的
            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '电源'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list)
            {
                con = "c.UID='" + pg.DeviceSUID + "'and a.Type='02'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                IList uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist)
                {
                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '两绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null)
                    {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update <PSP_GprogElevice>(pglr);
                    }
                }
                con     = "c.UID='" + pg.DeviceSUID + "'and a.Type='03'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist)
                {
                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '三绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null)
                    {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update <PSP_GprogElevice>(pglr);
                    }
                }
            }
            //判断设备参数中有没有在规划设备中的两绕,三绕组变压器,发电机和负荷 如果没有则删掉

            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND (Type= '两绕组变压器'or Type= '三绕组变压器'or Type= '负荷'or Type= '发电机')";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list)
            {
                PSPDEV ps = new PSPDEV();
                ps.SUID = pg.DeviceSUID;
                ps      = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", ps);
                if (ps == null)
                {
                    Services.BaseService.Delete <PSP_GprogElevice>(pg);
                }
            }
            //线路信息
            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '线路'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list)
            {
                PSPDEV ps = new PSPDEV();
                ps.SUID = pg.DeviceSUID;
                ps      = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", ps);
                if (ps != null)
                {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.OperationYear))
                    {
                        s2 = Convert.ToInt32(ps.OperationYear);
                    }
                    if (s2 <= System.DateTime.Now.Year)
                    {
                        pg.L1         = "运行";
                        ps.LineStatus = "运行";
                    }
                    else
                    {
                        pg.L1         = "待选";
                        ps.LineStatus = "待选";
                    }
                    Services.BaseService.Update <PSP_GprogElevice>(pg);
                    Services.BaseService.Update <PSPDEV>(ps);
                }
                else
                {
                    Services.BaseService.Delete <PSP_GprogElevice>(pg);
                }
            }
        }