Exemplo n.º 1
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;
                }
                PSP_Substation_Info area = new PSP_Substation_Info();
                //area.UID += "|" + ProjectID;
                area.AreaID = ProjectID;
                // area.CreateDate = DateTime.Now;

                foreach (DataColumn col in table.Columns)
                {
                    try
                    {
                        if (table.Rows[i][col] != null)
                        {
                            string inserted = table.Rows[i][col].ToString();
                            if (inserted == "规划" || inserted == "现状")
                            {
                                area.GetType().GetProperty("Flag").SetValue(area, inserted == "规划" ? "2" : "1", null);
                            }
                            else
                            {
                                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))
                                {
                                    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);
                                }
                                else if (type == typeof(DateTime))
                                {
                                }
                            }
                        }
                    }
                    catch { MessageBox.Show(string.Format("第{0}行{1}列插入有问题", i.ToString(), col.Caption)); }
                }
                DataService.Create <PSP_Substation_Info>(area);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 重绘
        /// </summary>
        /// <param name="FB"></param>
        /// <param name="obj"></param>
        /// <param name="strEndYear"></param>
        private void ReDraw(Itop.Client.Base.FormBase FB, FarPoint.Win.Spread.SheetView obj, string strEndYear)
        {
            PSP_Substation_Info psi = null;
            int IntColCount         = ColBDZlist.Count + 1;
            int IntRowCount         = RowBDZList.Count + 1 + 2 + 3;//标题占3行,分区类型占2行

            obj.RowCount      = 0;
            obj.ColumnCount   = 0;
            obj.Columns.Count = IntColCount;
            obj.Rows.Count    = IntRowCount;
            IntCol            = obj.Columns.Count;

            PF.Sheet_GridandCenter(obj);//画边线,居中
            m_PF.LockSheets(obj);

            string strTitle = "截至" + strEndYear + "年底铜陵县35kV变电站联络情况";

            IntRow        = 3;
            obj.SheetName = strTitle;
            PF.CreateSheetView(obj, IntRow, IntCol, 0, 0, strTitle);
            PF.SetSheetViewColumnsWidth(obj, 0, strTitle);
            IntCol = 1;

            strTitle = "单位:条";
            obj.AddSpanCell(IntRow, 0, 1, obj.Columns.Count);
            obj.SetValue(IntRow, 0, strTitle);
            PF.SetSheetViewColumnsWidth(obj, 0, strTitle);
            //右对齐
            obj.Rows[IntRow].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Right;
            //列标题
            strTitle = "     变  电  站     ";
            PF.CreateSheetView(obj, NextRowMerge += 1, NextColMerge, IntRow += 1, IntCol -= 1, strTitle);
            PF.SetSheetViewColumnsWidth(obj, IntCol, strTitle);
            for (int i = 0; i < ColBDZlist.Count; ++i)
            {
                psi = (PSP_Substation_Info)ColBDZlist[i];
                obj.AddSpanCell(IntRow, 1 + i, 2, 1);
                obj.SetValue(IntRow, i + 1, psi.Title);
            }
            //行标题

            for (int i = 0; i < RowBDZList.Count; ++i)
            {
                psi = (PSP_Substation_Info)RowBDZList[i];
                obj.SetValue(6 + i, 0, psi.Title);
            }
            NextRowMerge = 1;
            NextColMerge = 1;

            IntRow = 6;
            IntCol = 0;

            WriteData(FB, obj, strEndYear, IntRow);
        }
Exemplo n.º 3
0
        public override void Delete()
        {
            DataRow row = gridView1.GetDataRow(gridView1.FocusedRowHandle);

            if (row != null)
            {
                PSP_Substation_Info dev = Itop.Common.DataConverter.RowToObject <PSP_Substation_Info>(row);
                DialogResult        dr  = Itop.Common.MsgBox.ShowYesNo("是否确认删除变电站[" + dev.Title + "]?");
                if (dr == DialogResult.Yes)
                {
                    DataService.Delete <PSP_Substation_Info>(dev);
                    ((DataTable)gridControl1.DataSource).Rows.Remove(row);
                    //删除第二层数据

                    string delcon = "SvgUID='" + dev.UID + "'and ProjectID = '" + Itop.Client.MIS.ProgUID + "'";
                    DataService.Update("DeletePSPDEVbywhere", delcon);
                }
            }
        }
Exemplo n.º 4
0
        //排除设备
        void barDeleteDevice_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (strID == null || curDevice == null)
            {
                MessageBox.Show("选择有问题!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (curDevice.SelectedDevice != null)
            {
                if (curDevice.SelectedDevice.GetType() == typeof(PSPDEV))
                {
                    PSPDEV        dev       = curDevice.SelectedDevice as PSPDEV;
                    PSP_ElcDevice elcdevice = new PSP_ElcDevice();
                    elcdevice.ProjectSUID = strID;
                    elcdevice.DeviceSUID  = dev.SUID;
                    Services.BaseService.Delete <PSP_ElcDevice>(elcdevice);
                }
                else if (curDevice.SelectedDevice.GetType() == typeof(PSP_Substation_Info))
                {
                    PSP_Substation_Info dev       = curDevice.SelectedDevice as PSP_Substation_Info;
                    PSP_ElcDevice       elcdevice = new PSP_ElcDevice();
                    elcdevice.ProjectSUID = strID;
                    elcdevice.DeviceSUID  = dev.UID;
                    Services.BaseService.Delete <PSP_ElcDevice>(elcdevice);
                }
                else if (curDevice.SelectedDevice.GetType() == typeof(PSP_PowerSubstation_Info))
                {
                    PSP_PowerSubstation_Info dev       = curDevice.SelectedDevice as PSP_PowerSubstation_Info;
                    PSP_ElcDevice            elcdevice = new PSP_ElcDevice();
                    elcdevice.ProjectSUID = strID;
                    elcdevice.DeviceSUID  = dev.UID;
                    Services.BaseService.Delete <PSP_ElcDevice>(elcdevice);
                }
            }


            if (curDevice != null)
            {
                curDevice.strCon = ",psp_elcdevice where psp_elcdevice.devicesuid = pspdev.suid and psp_elcdevice.projectsuid = '" + strID + "' and ";
                curDevice.Init();
            }
        }
Exemplo n.º 5
0
        public override void Alldel()
        {
            if (Itop.Common.MsgBox.ShowYesNo("是否确认删除所有数据") == DialogResult.Yes)
            {
                DataTable dat = gridView1.GridControl.DataSource as DataTable;
                foreach (DataRow dr in dat.Rows)
                {
                    if (dr != null)
                    {
                        PSP_Substation_Info dev = Itop.Common.DataConverter.RowToObject <PSP_Substation_Info>(dr);
                        UCDeviceBase.DataService.Delete <PSP_Substation_Info>(dev);
                        //删除第二层数据

                        string delcon = "SvgUID='" + dr["UID"].ToString() + "'and ProjectID = '" + Itop.Client.MIS.ProgUID + "'";
                        DataService.Update("DeletePSPDEVbywhere", delcon);
                    }
                }
                dat.Clear();
                gridView1.GridControl.DataSource = dat;
            }
        }
Exemplo n.º 6
0
        public override void Edit()
        {
            frmBDZdlg dlg = new frmBDZdlg();

            dlg.CsbuttonVisble(true);
            DataRow row = gridView1.GetDataRow(gridView1.FocusedRowHandle);

            if (row != null)
            {
                PSP_Substation_Info dev = Itop.Common.DataConverter.RowToObject <PSP_Substation_Info>(row);
                dlg.DeviceMx = dev;
                dlg.IsRead   = false;
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    //更新记录
                    dev        = dlg.DeviceMx;
                    dev.AreaID = Itop.Client.MIS.ProgUID;
                    DataService.Update <PSP_Substation_Info>(dev);
                    Itop.Common.DataConverter.ObjectToRow(dev, row);
                }
            }
        }
Exemplo n.º 7
0
        public override void Add()
        {
            frmBDZdlg dlg = new frmBDZdlg();

            dlg.ProjectID = Itop.Client.MIS.ProgUID;
            dlg.Name      = "";
            dlg.CsbuttonVisble(true);
            dlg.IsRead = false;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                //增加记录
                PSP_Substation_Info dev = dlg.DeviceMx;
                dev.AreaID = Itop.Client.MIS.ProgUID;
                if (dlg.bcflag)   //在点击设备参数的时候 已经进行了保存
                {
                    DataService.Update <PSP_Substation_Info>(dev);
                }
                else
                {
                    DataService.Create <PSP_Substation_Info>(dev);
                }
                DataRow row = datatable1.NewRow();
                Itop.Common.DataConverter.ObjectToRow(dev, row);
                datatable1.Rows.Add(row);
            }
            else
            {
                if (dlg.bcflag)
                {
                    PSP_Substation_Info dev = dlg.DeviceMx;
                    dev.AreaID = Itop.Client.MIS.ProgUID;
                    DataService.Update <PSP_Substation_Info>(dev);
                    DataRow row = datatable1.NewRow();
                    Itop.Common.DataConverter.ObjectToRow(dev, row);
                    datatable1.Rows.Add(row);
                }
            }
        }
Exemplo n.º 8
0
        private void fpfhyj(PSP_Substation_Info sub, ref double zgfh, ref Dictionary <PSP_Substation_Info, IList <PSPDEV> > listfhfp)
        {
            //首先需找最低压母线
            string         con     = "where SvgUID='" + sub.UID + "'and Type='01' and ProjectID='" + Itop.Client.MIS.ProgUID + "' order by RateVolt";
            IList <PSPDEV> list    = UCDeviceBase.DataService.GetList <PSPDEV>("SelectPSPDEVByCondition", con);
            List <int>     listnum = new List <int>(); //记录那几个母线 要进行考虑到系统分析中\
            IList <PSPDEV> list1   = new List <PSPDEV>();
            double         minv    = sub.L1;

            if (list.Count == 0)
            {
                return;
            }
            bool flag = false;

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].RateVolt <= minv)
                {
                    minv = list[i].RateVolt;
                }
                if (list[i].RateVolt == sub.L1)
                {
                    flag = true;
                }
            }

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].RateVolt == minv)
                {
                    con = "where IName='" + list[i].Name + "'and Type='12' and ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                    PSPDEV obj = UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con) as PSPDEV;
                    if (obj != null)
                    {
                        list1.Add(obj);
                    }
                    else
                    {
                        list1.Add(list[i]);
                    }
                }
                if (flag)
                {
                    if (list[i].RateVolt == sub.L1)
                    {
                        con = "where IName='" + list[i].Name + "'and Type='12' and ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                        PSPDEV obj = UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con) as PSPDEV;
                        if (obj != null)
                        {
                            zgfh += obj.OutP;
                        }
                        else
                        {
                            zgfh += list[i].HuganTQ1;
                        }
                    }
                }
            }

            listfhfp[sub] = list1;
        }
Exemplo n.º 9
0
        private void repositoryItemHyperLinkEdit1_Click(object sender, EventArgs e)
        {
            int ihand = gridView1.FocusedRowHandle;

            if (ihand < 0)
            {
                return;
            }
            DataRow             dr = gridView1.GetDataRow(ihand);
            PSP_Substation_Info pj = Itop.Common.DataConverter.RowToObject <PSP_Substation_Info>(dr);
            double rl  = 0;
            int    bts = 0;
            frmDeviceManager_children frmc = new frmDeviceManager_children();

            frmc.ParentObj = pj;
            string[] types = new string[] { "01", "02", "03", "12" };
            frmc.childrendevice(types);
            if (frmc.DialogResult == DialogResult.OK)
            {
                string rlgc = "";
                string where = "where projectid='" + Itop.Client.MIS.ProgUID + "'and type in ('02','03')and SvgUID='" + pj.UID + "'";
                IList <PSPDEV> list = UCDeviceBase.DataService.GetList <PSPDEV>("SelectPSPDEVByCondition", where);
                foreach (PSPDEV pd in list)
                {
                    if (!string.IsNullOrEmpty(pd.OperationYear) && !string.IsNullOrEmpty(pd.Date2) && pd.Date2.Length == 4 && !string.IsNullOrEmpty(pj.L29) && !string.IsNullOrEmpty(pj.L28))
                    {
                        if (Convert.ToInt32(pd.OperationYear) >= Convert.ToInt32(pj.L28) && Convert.ToInt32(pd.Date2) <= Convert.ToInt32(pj.L29))
                        {
                            if (pd.Type == "03")
                            {
                                rl   += pd.SiN;
                                rlgc += pd.SiN.ToString("G") + "+";
                            }
                            else
                            {
                                rl   += (double)pd.Burthen;
                                rlgc += ((double)pd.Burthen).ToString("G") + "+";
                            }

                            bts++;
                        }
                    }
                    else
                    {
                        if (pd.Type == "03")
                        {
                            rl   += pd.SiN;
                            rlgc += pd.SiN.ToString("G") + "+";
                        }
                        else
                        {
                            rl   += (double)pd.Burthen;
                            rlgc += ((double)pd.Burthen).ToString("G") + "+";
                        }


                        bts++;
                    }
                }
                if (rlgc.Length > 0)
                {
                    pj.L4    = rlgc.Substring(0, rlgc.Length - 1);
                    dr["L4"] = pj.L4;
                }
                if (rl != 0)
                {
                    pj.L2 = rl;
                    pj.L3 = bts;

                    dr["L2"] = rl;
                    dr["L3"] = bts;
                }


                UCDeviceBase.DataService.Update <PSP_Substation_Info>(pj);
            }
        }