Example #1
0
        public override void Add()
        {
            frmBYQ3templatedlg dlg = new frmBYQ3templatedlg();

            dlg.Name        = "";
            dlg.ProjectSUID = this.ProjectID;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                //增加记录
                Template_PSPDEV dev = dlg.DeviceMx;
                //dev.ProjectID = this.ProjectID;
                UCDeviceBase.DataService.Create <Template_PSPDEV>(dev);
                DataRow row = datatable1.NewRow();
                if (dev.NodeType == "0")
                {
                    dev.NodeType = "平衡节点";
                }
                else if (dev.NodeType == "1")
                {
                    dev.NodeType = "PQ节点";
                }
                else if (dev.NodeType == "2")
                {
                    dev.NodeType = "PV节点";
                }
                else
                {
                    dev.NodeType = null;
                }
                if (dev.KSwitchStatus == "1")
                {
                    dev.KSwitchStatus = "退出运行";
                }
                else
                {
                    dev.KSwitchStatus = "投入运行";
                }
                if (dev.UnitFlag == "0")
                {
                    dev.UnitFlag = "p.u.";
                }
                else
                {
                    if (dev.Type == "01" || dev.Type == "04" || dev.Type == "12")
                    {
                        dev.UnitFlag = "kV/MW/MVar";
                    }
                    else
                    {
                        dev.UnitFlag = "Ohm/10-6Siem";
                    }
                }
                Itop.Common.DataConverter.ObjectToRow(dev, row);
                datatable1.Rows.Add(row);
            }
        }
Example #2
0
        public override void Delete()
        {
            //删除记录
            DataRow row = gridView1.GetDataRow(gridView1.FocusedRowHandle);

            if (row != null)
            {
                Template_PSPDEV dev = Itop.Common.DataConverter.RowToObject <Template_PSPDEV>(row);
                if (Itop.Common.MsgBox.ShowYesNo("是否确认删除[" + dev.TemplateType + "]?") == DialogResult.Yes)
                {
                    UCDeviceBase.DataService.Delete <Template_PSPDEV>(dev);
                    ((DataTable)gridControl1.DataSource).Rows.Remove(row);
                }
            }
        }
Example #3
0
        public static void CopyTemplate(Template_PSPDEV source, PSPDEV target)
        {
            Type t = typeof(PSPDEV);

            foreach (PropertyInfo p in t.GetProperties())
            {
                if (p.Name != "KName" && p.Name != "Name" && p.Name != "TemplateType" && p.Name != "AreaID" && p.Name != "SUID" && p.Name != "EleID" && p.Name != "SvgUID" && p.Name != "Type" && p.Name != "FirstNode" && p.Name != "LastNode" && p.Name != "IName" && p.Name != "JName" && p.Name != "KSwitchStatus" && p.Name != "Date1" && p.Name != "Date2" && p.Name != "OperationYear" && p.Name != "Number")
                {
                    if (source.GetType().GetProperty(p.Name) != null)
                    {
                        p.SetValue(target, source.GetType().GetProperty(p.Name).GetValue(source, null), null);
                    }
                }
            }
        }
Example #4
0
        public override void Edit()
        {
            frmBYQ3templatedlg dlg = new frmBYQ3templatedlg();
            DataRow            row = gridView1.GetDataRow(gridView1.FocusedRowHandle);

            if (row != null)
            {
                Template_PSPDEV dev = Itop.Common.DataConverter.RowToObject <Template_PSPDEV>(row);
                if (dev.NodeType == "平衡节点")
                {
                    dev.NodeType = "0";
                }
                else if (dev.NodeType == "PQ节点")
                {
                    dev.NodeType = "1";
                }
                else if (dev.NodeType == "PV节点")
                {
                    dev.NodeType = "2";
                }
                if (dev.KSwitchStatus == "退出运行")
                {
                    dev.KSwitchStatus = "1";
                }
                else
                {
                    dev.KSwitchStatus = "0";
                }
                if (dev.UnitFlag == "p.u.")
                {
                    dev.UnitFlag = "0";
                }
                else
                {
                    dev.UnitFlag = "1";
                }
                dlg.DeviceMx    = dev;
                dlg.ProjectSUID = dev.ProjectID;
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    //更新记录
                    dev           = dlg.DeviceMx;
                    dev.ProjectID = this.ProjectID;
                    UCDeviceBase.DataService.Update <Template_PSPDEV>(dev);
                    if (dev.NodeType == "0")
                    {
                        dev.NodeType = "平衡节点";
                    }
                    else if (dev.NodeType == "1")
                    {
                        dev.NodeType = "PQ节点";
                    }
                    else if (dev.NodeType == "2")
                    {
                        dev.NodeType = "PV节点";
                    }
                    else
                    {
                        dev.NodeType = null;
                    }
                    if (dev.KSwitchStatus == "1")
                    {
                        dev.KSwitchStatus = "退出运行";
                    }
                    else
                    {
                        dev.KSwitchStatus = "投入运行";
                    }
                    if (dev.UnitFlag == "0")
                    {
                        dev.UnitFlag = "p.u.";
                    }
                    else
                    {
                        if (dev.Type == "01" || dev.Type == "04" || dev.Type == "12")
                        {
                            dev.UnitFlag = "kV/MW/MVar";
                        }
                        else
                        {
                            dev.UnitFlag = "Ohm/10-6Siem";
                        }
                    }
                    Itop.Common.DataConverter.ObjectToRow(dev, row);
                    //string sql = "S1='" + dev.Name + "'and S4='三绕组变压器'";
                    //IList<Psp_Attachtable> ilist = UCDeviceBase.DataService.GetList<Psp_Attachtable>("SelectPsp_AttachtableByCont", sql);
                    //if (ilist.Count > 0)
                    //{
                    //    Psp_Attachtable pdr = ilist[0];
                    //    pdr.ZHI =dev.SiN;
                    //    pdr.S3 = dev.OperationYear;
                    //    pdr.startYear = dev.Date1;
                    //    pdr.endYear = dev.Date2;
                    //    UCDeviceBase.DataService.Update<Psp_Attachtable>(pdr);
                    //}
                }
            }
        }
Example #5
0
        public override void UpdateIn(DataTable table)
        {
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (table.Rows[i][0].ToString().IndexOf("合计") > 0 || table.Rows[i][1].ToString().IndexOf("合计") > 0)
                {
                    continue;
                }
                Template_PSPDEV area = new Template_PSPDEV();
                //area.ProjectID = projectid;
                foreach (DataColumn col in table.Columns)
                {
                    try
                    {
                        if (table.Rows[i][col] != null)
                        {
                            string inserted = table.Rows[i][col].ToString();
                            Type   type     = area.GetType().GetProperty(col.ColumnName).PropertyType;//.GetValue(area, null).GetType();
                            if (type == typeof(int))
                            {
                                area.GetType().GetProperty(col.ColumnName).SetValue(area, int.Parse(inserted == "" ? "0" : inserted), null);
                            }
                            else if (type == typeof(string))
                            {
                                if (inserted == "投入运行")
                                {
                                    inserted = "0";
                                }
                                if (inserted == "退出运行")
                                {
                                    inserted = "1";
                                }
                                if (inserted == "平衡节点")
                                {
                                    inserted = "0";
                                }
                                if (inserted == "PQ节点")
                                {
                                    inserted = "1";
                                }
                                if (inserted == "PV节点")
                                {
                                    inserted = "2";
                                }
                                if (inserted == "kV/MW/MVar" || inserted == "Ohm/10-6Siem")
                                {
                                    inserted = "1";
                                }
                                if (inserted == "p.u.")
                                {
                                    inserted = "0";
                                }
                                if (inserted == "投入")
                                {
                                    inserted = "0";
                                }
                                if (inserted == "退出")
                                {
                                    inserted = "1";
                                }
                                area.GetType().GetProperty(col.ColumnName).SetValue(area, inserted, null);
                            }

                            else if (type == typeof(decimal))
                            {
                                area.GetType().GetProperty(col.ColumnName).SetValue(area, decimal.Parse(inserted == "" ? "0" : inserted), null);
                            }
                            else if (type == typeof(double))
                            {
                                area.GetType().GetProperty(col.ColumnName).SetValue(area, double.Parse(inserted == "" ? "0.0" : inserted), null);
                            }
                        }
                    }
                    catch { MessageBox.Show(string.Format("第{0}行{1}列插入有问题", i.ToString(), col.Caption)); }
                }
                if (!string.IsNullOrEmpty(ParentID))
                {
                    area.SvgUID = ParentID;
                }
                area.Type = GetType();
                UCDeviceBase.DataService.Create <Template_PSPDEV>(area);
            }
        }