Esempio n. 1
0
        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }
            if (!base.DeleteRight)
            {
                MsgBox.Show("您没有权限进行此项操作!");
                return;
            }

            string nodestr = treeList1.FocusedNode.GetValue("Col1").ToString();
            if (nodestr == "1" || nodestr == "2" || nodestr == "3" || nodestr == "4" || nodestr == "5" || nodestr == "no")
            {
                MsgBox.Show("固定分类不许删除!");
                return;
            }
            string parentid = treeList1.FocusedNode["ParentID"].ToString();

            if (treeList1.FocusedNode.HasChildren)
            {
                MsgBox.Show("此分类下有子分类,请先删除子分类!");
                return;
            }

            if(MsgBox.ShowYesNo("是否删除分类 " + treeList1.FocusedNode.GetValue("Title") + "?") == DialogResult.Yes)
            {
                Ps_Table_110Result table1 = new Ps_Table_110Result();
               // Class1.TreeNodeToDataObject<PSP_Types>(psp_Type, treeList1.FocusedNode);
                table1.ID = treeList1.FocusedNode.GetValue("ID").ToString();

                try
                {
                    //DeletePSP_ValuesByType里面删除数据和分类
                    Common.Services.BaseService.Delete <Ps_Table_110Result>(table1);//("DeletePs_Table_110Result", table1);

                    TreeListNode brotherNode = null;
                    if(treeList1.FocusedNode.ParentNode.Nodes.Count > 1)
                    {
                        brotherNode = treeList1.FocusedNode.PrevNode;
                        if(brotherNode == null)
                        {
                            brotherNode = treeList1.FocusedNode.NextNode;
                        }
                    }
                    treeList1.DeleteNode(treeList1.FocusedNode);

                    //删除后,如果同级还有其它分类,则重新计算此类的所有年份数据
                    if(brotherNode != null)
                    {
                        foreach(TreeListColumn column in treeList1.Columns)
                        {
                            if (column.Caption.IndexOf("年") > 0)
                            {
                                CalculateSum(brotherNode, column);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    //MsgBox.Show("删除出错:" + ex.Message);
                    this.Cursor = Cursors.WaitCursor;
                    treeList1.BeginUpdate();
                    LoadData();
                    treeList1.EndUpdate();
                    this.Cursor = Cursors.Default;
                }
            }
        }
Esempio n. 2
0
 public void AddModelChild(string id,string pid)
 {
     Ps_Table_110Result table1 = new Ps_Table_110Result();
     table1.ID += "|" + GetProjectID;
     table1.Title = "其中:小水电";
     table1.ParentID = id;
     table1.ProjectID = GetProjectID;
     table1.Col1 = "child";
     table1.Col2 = "2";
     table1.Col3 = "shui";
     table1.Col4 = pid;
     table1.Sort = 0;
     Ps_Table_110Result table3 = new Ps_Table_110Result();
     table3.ID += "|" + GetProjectID;
     table3.Title = "其它";
     table3.Col1 = "child";
     table3.Col2 = "2";
     table3.ParentID = id;
     table3.ProjectID = GetProjectID;
     table3.Col3 = "other";
     table3.Col4 = pid;
     table3.Sort = 2;
     Ps_Table_110Result table2 = new Ps_Table_110Result();
     table2.ID += "|" + GetProjectID;
     table2.Title = "小火电";
     table2.Col1 = "child";
     table2.Col2 = "2";
     table2.ParentID = id;
     table2.ProjectID = GetProjectID;
     table2.Col3 = "huo";
     table2.Col4 = pid;
     table2.Sort = 1;
     Common.Services.BaseService.Create("InsertPs_Table_110Result", table1);
     Common.Services.BaseService.Create("InsertPs_Table_110Result", table3);
     Common.Services.BaseService.Create("InsertPs_Table_110Result", table2);
 }
Esempio n. 3
0
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            TreeListNode focusedNode = treeList1.FocusedNode;

            if (focusedNode == null)
            {
                return;
            }

            if (!base.AddRight)
            {
                MsgBox.Show("您没有权限进行此项操作!");
                return;
            }
            FindNodes(treeList1.FocusedNode);
            string nodestr = treenode.GetValue("Title").ToString();
            if (treeList1.FocusedNode.GetValue("Col1").ToString() == "no" || focusedNode.GetValue("ParentID").ToString()=="0")
            {
                MsgBox.Show( focusedNode.GetValue("Title").ToString()+"不允许添加子分类!");
                return;
            }

            FrmAddPN frm = new FrmAddPN();
            frm.Text = "增加" + focusedNode.GetValue("Title") + "的子分类";
            frm.SetLabelName = "子分类名称";
            if(frm.ShowDialog() == DialogResult.OK)
            {
                Ps_Table_110Result table1 = new Ps_Table_110Result();
                table1.ID += "|" + GetProjectID;
                table1.Title = frm.ParentName;
                table1.ParentID = focusedNode.GetValue("ID").ToString();
                table1.ProjectID = GetProjectID;
                table1.Col1 = "child";
                table1.Col2 = treeList1.FocusedNode.GetValue("Col1").ToString();
                table1.Sort = OperTable.Get110ResultMaxSort()+1;

                try
                {
                    Common.Services.BaseService.Create("InsertPs_Table_110Result", table1);
                    dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table1, dataTable.NewRow()));
                }
                catch(Exception ex)
                {
                    MsgBox.Show("增加子分类出错:" + ex.Message);
                }
            }
        }
Esempio n. 4
0
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }
            //FindNodes(treeList1.FocusedNode);

            string nodestr = treeList1.FocusedNode.GetValue("Col1").ToString();

            string parentid = treeList1.FocusedNode["ParentID"].ToString();

            if (!base.EditRight)
            {
                MsgBox.Show("您没有权限进行此项操作!");
                return;
            }
            if (nodestr == "1" || nodestr == "2" || nodestr == "3" || nodestr == "4" || nodestr == "5" || nodestr == "no")
            {
                MsgBox.Show("固定分类不许修改!");
                return;
            }
            FrmAddPN frm = new FrmAddPN();
            //frm.TypeTitle = treeList1.FocusedNode.GetValue("Title").ToString();
            frm.ParentName = treeList1.FocusedNode.GetValue("Title").ToString();
            frm.Text = "修改分类名";
            frm.SetLabelName = "分类名称";
            if (frm.ShowDialog() == DialogResult.OK)
            {
                Ps_Table_110Result table1 = new Ps_Table_110Result();
                table1 = Common.Services.BaseService.GetOneByKey<Ps_Table_110Result>(treeList1.FocusedNode.GetValue("ID"));
                table1.Title = frm.ParentName;

                try
                {
                    Common.Services.BaseService.Update<Ps_Table_110Result>(table1);
                    treeList1.FocusedNode.SetValue("Title", frm.ParentName);
                }
                catch { }
                //catch(Exception ex)
                //{
                //    MsgBox.Show("修改出错:" + ex.Message);
                //}
            }
        }
Esempio n. 5
0
 public void UpdateFuHe(string pid,string col1,Ps_Table_110Result oldrs,Ps_Table_110Result newrs)
 {
     string conn = "ProjectID='" + GetProjectID + "' and Col1='"+col1+"' and ParentID='"+pid+"'";
     IList list = Common.Services.BaseService.GetList("SelectPs_Table_110ResultByConn", conn);
     if (list.Count > 0)
     {
         for(int i=yAnge.BeginYear;i<=yAnge.EndYear;i++)
         {
             double oldyf = double.Parse(oldrs.GetType().GetProperty("yf"+i.ToString()).GetValue(oldrs,null).ToString());
             double oldyk = double.Parse(oldrs.GetType().GetProperty("yk" + i.ToString()).GetValue(oldrs, null).ToString());
             double newyf = double.Parse(newrs.GetType().GetProperty("yf" + i.ToString()).GetValue(newrs, null).ToString());
             double newyk = double.Parse(newrs.GetType().GetProperty("yk" + i.ToString()).GetValue(newrs, null).ToString());
             double myyf = double.Parse(list[0].GetType().GetProperty("yf" + i.ToString()).GetValue(list[0], null).ToString());
             double myyk = double.Parse(list[0].GetType().GetProperty("yk" + i.ToString()).GetValue(list[0], null).ToString());
             list[0].GetType().GetProperty("yf" + i.ToString()).SetValue(list[0], Math.Round(myyf - oldyf + newyf,1), null);
             list[0].GetType().GetProperty("yk" + i.ToString()).SetValue(list[0], Math.Round(myyk - oldyk + newyk,1), null);
         }
         Common.Services.BaseService.Update<Ps_Table_110Result>((Ps_Table_110Result)list[0]);
     }
 }
Esempio n. 6
0
 private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     ClearChen();
     UpdateChen();
     IList pareList = Common.Services.BaseService.GetList("SelectPS_Table_AreaWHByConn", "ProjectID='" + GetProjectID +
         "' and ID not in (Select BuildIng From Ps_Table_110Result where ProjectID='" +
         GetProjectID + "' and ParentID='0') order by sort");
     for (int i = 0; i < pareList.Count; i++)
     {
         Ps_Table_110Result table_yd = new Ps_Table_110Result();
         table_yd.ID += "|" + GetProjectID;
         table_yd.Title = ((PS_Table_AreaWH)pareList[i]).Title;
         table_yd.ParentID = "0";
         table_yd.Sort = OperTable.Get110ResultMaxSort() + 1;
         table_yd.ProjectID = GetProjectID;
         table_yd.BuildIng = ((PS_Table_AreaWH)pareList[i]).ID;
         for (int j = yAnge.BeginYear; j <= yAnge.EndYear; j++)
         {
             table_yd.GetType().GetProperty("yf" + j.ToString()).SetValue(table_yd, null, null);
             table_yd.GetType().GetProperty("yk" + j.ToString()).SetValue(table_yd, null, null);
         }
         try
         {
             Common.Services.BaseService.Create("InsertPs_Table_110Result", table_yd);
         }
         catch (Exception ex)
         {
             MsgBox.Show("增加城区出错:" + ex.Message);
         }
         string[] lei = new string[6] { "一、负荷", "二、35千伏及以下地方电源出力", "三、35千伏及以下外网送入电力", "四、35千伏及以下送出外网电力", "五、220千伏变电站低压侧供电负荷", "六、110千伏供电负荷" };
         for (int k = 0; k < lei.Length; k++)
         {
             Ps_Table_110Result table1 = new Ps_Table_110Result();
             table1.ID += "|" + GetProjectID;
             table1.Title = lei[k];
             table1.ParentID = table_yd.ID;
             table1.ProjectID = GetProjectID;
             table1.Col1 = Convert.ToString(k + 1);
             if (k == 5)
             {
                 table1.Col1 = "no";
                 table1.Col2 = table_yd.Title;
             }
             if (k == 1)
                 AddModelChild(table1.ID, table_yd.Title);
             table1.Sort = k + 1;
             try
             {
                 Common.Services.BaseService.Create("InsertPs_Table_110Result", table1);
             }
             catch (Exception ex)
             {
                 MsgBox.Show("增加项目出错:" + ex.Message);
             }
         }
         this.Cursor = Cursors.WaitCursor;
         treeList1.BeginUpdate();
         //treeList1.ExpandAll();
         LoadData1();
         treeList1.EndUpdate();
         this.Cursor = Cursors.Default;
     }
 }
Esempio n. 7
0
        private bool SaveCellValue(string year, string typeID, double value)
        {
            Ps_Table_110Result psp = new Ps_Table_110Result();
            Ps_Table_110Result old = Common.Services.BaseService.GetOneByKey<Ps_Table_110Result>(typeID);
            psp = (Ps_Table_110Result)old.Clone();
            psp.GetType().GetProperty(year).SetValue(psp, Math.Round(value,1),null);

            try
            {
                Common.Services.BaseService.Update<Ps_Table_110Result>(psp);
            }
            catch(Exception ex)
            {
                MsgBox.Show("保存数据出错:" + ex.Message);
                return false;
            }
            return true;
        }
Esempio n. 8
0
 public void DelAll(string suid)
 {
     string conn = "ParentId='" + suid + "'";
     IList<Ps_Table_110Result> list = Common.Services.BaseService.GetList<Ps_Table_110Result>("SelectPs_Table_110ResultByConn", conn);
     if (list.Count > 0)
     {
         foreach (Ps_Table_110Result var in list)
         {
             string child = var.ID;
             DelAll(child);
             Ps_Table_110Result ny = new Ps_Table_110Result();
             ny.ID = child;
             Common.Services.BaseService.Delete(ny);
         }
     }
     else
         return;
 }
Esempio n. 9
0
        private void barButtonItem9_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }
            if (!base.DeleteRight)
            {
                MsgBox.Show("您没有权限进行此项操作!");
                return;
            }
            if (treeList1.FocusedNode.GetValue("ParentID").ToString() != "0")
            {
                MsgBox.Show("此分类不是总分类!");
                return;
            }

            if (MsgBox.ShowYesNo("总分类及其下属分类都将删除,是否删除总分类 " + treeList1.FocusedNode.GetValue("Title") + "?") == DialogResult.Yes)
            {
                Ps_Table_110Result table1 = new Ps_Table_110Result();
                // Class1.TreeNodeToDataObject<PSP_Types>(psp_Type, treeList1.FocusedNode);
                table1.ID = treeList1.FocusedNode.GetValue("ID").ToString();
                DelAll(table1.ID);
                try
                {
                    //DeletePSP_ValuesByType里面删除数据和分类
                    Common.Services.BaseService.Delete<Ps_Table_110Result>(table1);//("DeletePs_Table_110Result", table1);

                    treeList1.DeleteNode(treeList1.FocusedNode);
                    //treeList1.ExpandAll();
                    //删除后,如果同级还有其它分类,则重新计算此类的所有年份数据

                }
                catch (Exception ex)
                {
                    //MsgBox.Show("删除出错:" + ex.Message);
                    this.Cursor = Cursors.WaitCursor;
                    treeList1.BeginUpdate();
                    LoadData();
                    treeList1.EndUpdate();
                    this.Cursor = Cursors.Default;
                }
            }
        }
Esempio n. 10
0
        public void AddTotalRow(ref IList list)
        {
            //合计
            string conn = "ParentID='0' and ProjectID='" + GetProjectID + "'";

            int[] year = GetYears();
            Ps_Table_110Result parent = new Ps_Table_110Result();
            parent.ID += "|" + GetProjectID;
            parent.ParentID = "0"; parent.Title = "110千伏合计"; parent.Sort = 1000;// OperTable.GetMaxSort() + 1;
            list.Add(parent);
            totoalParent = parent.ID;
            string[] lei = new string[6] { "一、负荷合计", "二、35千伏及以下地方电源出力", "三、35千伏及以下外网送入电力", "四、35千伏及以下送出外网电力", "五、220千伏变电站低压侧供电负荷", "六、110千伏供电负荷" };
            for (int i = 0; i < lei.Length; i++)
            {
                conn = "Col1='"+Convert.ToString(i+1)+"' and ProjectID='" + GetProjectID + "'";
                string conn1 = "ProjectID='" + GetProjectID + "' and Col2='"+Convert.ToString(i+1)+"'";
                if (i == 5)
                {
                    conn = "Col1='no' and ProjectID='" + GetProjectID + "'";
                    conn1 = "ProjectID='" + GetProjectID + "' and Col2='no'";
                }
                Ps_Table_110Result table1 = new Ps_Table_110Result();
                table1.ID += "|" + GetProjectID;
                table1.Title = lei[i];
                table1.ParentID = parent.ID;
                table1.ProjectID = GetProjectID;
                table1.Col1 = Convert.ToString(i + 1);
                table1.BuildEd = "total";
                if (i == 5)
                    table1.Col1 = "no";
                IList tList = Common.Services.BaseService.GetList("SelectPs_Table_110ResultByConn", conn);
                for (int j = year[1]; j <= year[2]; j++)
                {
                    double first = 0.0, sec = 0.0;
                    for (int k = 0; k < tList.Count; k++)
                    {
                        first += double.Parse(((Ps_Table_110Result)tList[k]).GetType().GetProperty("yf" + j).GetValue((Ps_Table_110Result)tList[k], null).ToString());
                        sec += double.Parse(((Ps_Table_110Result)tList[k]).GetType().GetProperty("yk" + j).GetValue((Ps_Table_110Result)tList[k], null).ToString());
                    }
                    table1.GetType().GetProperty("yf" + j).SetValue(table1,first, null);
                    table1.GetType().GetProperty("yk" + j).SetValue(table1, sec, null);
                }
                table1.Sort = i + 1;
                list.Add(table1);
                IList cList = Common.Services.BaseService.GetList("SelectPs_Table_110ResultByConn", conn1);
               // for (int j = 0; j < cList.Count; j++)
              //  {
              //      Ps_Table_110Result tablex = new Ps_Table_110Result();
              //      tablex = (Ps_Table_110Result)((Ps_Table_110Result)cList[j]).Clone();
              //      tablex.BuildEd = "total";
              //      tablex.ParentID = table1.ID;
              //      list.Add(tablex);
             //   }
            }
        }
Esempio n. 11
0
        private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (!base.AddRight)
            {
                MsgBox.Show("您没有权限进行此项操作!");
                return;
            }
            Ps_YearRange range = yAnge;
            TreeListNode focusedNode = treeList1.FocusedNode;

            //if (focusedNode == null)
            //{
            //    return;
            //}

            FrmAddPN frm = new FrmAddPN();
            if (frm.ShowDialog() == DialogResult.OK)
            {
                Ps_Table_110Result table_yd = new Ps_Table_110Result();
                table_yd.ID += "|" + GetProjectID;
                table_yd.Title = frm.ParentName;
                table_yd.ParentID = "0";
                table_yd.Sort = OperTable.Get110ResultMaxSort() + 1;
                table_yd.ProjectID = GetProjectID;
                for (int i = range.BeginYear; i <= range.EndYear; i++)
                {
                    table_yd.GetType().GetProperty("yf" + i.ToString()).SetValue(table_yd, null, null);
                    table_yd.GetType().GetProperty("yk" + i.ToString()).SetValue(table_yd, null, null);
                }
                try
                {
                    Common.Services.BaseService.Create("InsertPs_Table_110Result", table_yd);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("增加城区出错:" + ex.Message);
                }
                string[] lei = new string[6] { "一、负荷", "二、35千伏及以下地方电源出力", "三、35千伏及以下外网送入电力", "四、35千伏及以下送出外网电力", "五、220千伏变电站低压侧供电负荷", "六、110千伏供电负荷" };
                for (int i = 0; i < lei.Length; i++)
                {
                    Ps_Table_110Result table1 = new Ps_Table_110Result();
                    table1.ID += "|" + GetProjectID;
                    table1.Title = lei[i];
                    table1.ParentID = table_yd.ID;
                    table1.ProjectID = GetProjectID;
                    table1.Col1 = Convert.ToString(i+1);
                    if (i == 5)
                    {
                        table1.Col1 = "no";
                        table1.Col2 = table_yd.Title;
                    }
                    if (i == 1)
                        AddModelChild(table1.ID,table_yd.Title);
                    table1.Sort = i+1;
                    try
                    {
                        Common.Services.BaseService.Create("InsertPs_Table_110Result", table1);
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show("增加项目出错:" + ex.Message);
                    }
                }
                this.Cursor = Cursors.WaitCursor;
                treeList1.BeginUpdate();
                //treeList1.ExpandAll();
                LoadData1();
                FoucsLocation(table_yd.ID, treeList1.Nodes);
                treeList1.EndUpdate();
                this.Cursor = Cursors.Default;
            }
        }
Esempio n. 12
0
        private void AddArea(string Areaname)
        {
            Ps_YearRange range = yAnge;
            Ps_Table_110Result table_yd = new Ps_Table_110Result();
            table_yd.ID += "|" + GetProjectID;
            table_yd.BuildYear = "1.9";
            table_yd.Title = Areaname;
            table_yd.ParentID = "0";
            table_yd.Sort = OperTable.Get110ResultMaxSort() + 1;
            table_yd.ProjectID = GetProjectID;
            for (int i = range.BeginYear; i <= range.EndYear; i++)
            {
                table_yd.GetType().GetProperty("yf" + i.ToString()).SetValue(table_yd, null, null);
                table_yd.GetType().GetProperty("yk" + i.ToString()).SetValue(table_yd, null, null);
            }
            try
            {
                Common.Services.BaseService.Create("InsertPs_Table_110Result", table_yd);
            }
            catch (Exception ex)
            {
                MsgBox.Show("增加城区出错:" + ex.Message);
            }
            // string[] lei = new string[7] { "一、110千伏以下负荷", "二、110千伏直供负荷","三、110千伏变电站低压侧供电负荷","四、110千伏及以下地方电源出力", "五、外网110千伏及以下送入电力", "六、外网110千伏及以下送出电力", "七、110千伏供电负荷" };
            string[] lei = new string[11] { "1、全社会最高负荷", "2、110kV以下电源", "3、直供负荷", "4、外区供电", "5、区内电源出力", "6、需110kV变电供电负荷", "7、需110kV主变容量", "8、安排110kV变电容量", "9、实际110kV容载比", "10、变电容量盈亏", "11、变电站个数" };

            for (int i = 0; i < lei.Length; i++)
            {
                Ps_Table_110Result table1 = new Ps_Table_110Result();
                table1.ID += "|" + GetProjectID;
                table1.Title = lei[i];
                table1.ParentID = table_yd.ID;
                table1.ProjectID = GetProjectID;
                table1.Col3 = Convert.ToString(i + 1);
                table1.Col1 = "no";
                if (i == 0 || i == 2 || i == 3)
                {
                    table1.Col1 = "";
                }
                //2、110kV以下电源
                if (i == 1 || i == 4 || i == 7 || i == 10)
                {
                    table1.Col1 = "no";
                }

                table1.Sort = i + 1;
                try
                {
                    Common.Services.BaseService.Create("InsertPs_Table_110Result", table1);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("增加项目出错:" + ex.Message);
                }
            }
            UpdataDY(table_yd.ID);
            UpDataRL(table_yd.ID);
            UpDataBDZ(table_yd.ID);
            UpData(table_yd.ID);

            this.Cursor = Cursors.WaitCursor;
            treeList1.BeginUpdate();
            //treeList1.ExpandAll();
            LoadData1();
            FoucsLocation(table_yd.ID, treeList1.Nodes);
            treeList1.EndUpdate();
            this.Cursor = Cursors.Default;
        }
Esempio n. 13
0
        /// <summary>
        /// 更新容量
        /// </summary>
        /// <param name="ParentID"></param>
        public void UpDataRL(string ParentID)
        {
            Hashtable rtable = new Hashtable();
            Ps_Table_110Result pt = Common.Services.BaseService.GetOneByKey<Ps_Table_110Result>(ParentID);
            string AreaName = pt.Title;

            string conn = "ProjectID='" + GetProjectID + "' and ParentID='" + ParentID + "'";

            Ps_Table_110Result col8;

            IList<Ps_Table_110Result> listchild = Common.Services.BaseService.GetList<Ps_Table_110Result>("SelectPs_Table_110ResultByConn", conn);
            for (int i = 0; i < listchild.Count; i++)
            {
                rtable.Add(listchild[i].Col3, listchild[i]);
            }
            col8 = (Ps_Table_110Result)rtable["8"];

            //删除其下的
            string conncol8 = "ProjectID='" + GetProjectID + "' and ParentID='" + col8.ID + "'";

            IList<Ps_Table_110Result> col8list = Common.Services.BaseService.GetList<Ps_Table_110Result>("SelectPs_Table_110ResultByConn", conncol8);
            foreach (Ps_Table_110Result ptr in col8list)
            {
                Common.Services.BaseService.Delete<Ps_Table_110Result>(ptr);
            }

            //更新安排110kV变电容量

            string conn1 = " AreaID='" + GetProjectID + "' and AreaName='" + AreaName + "' and L1=110";
            IList<PSP_Substation_Info> list = Common.Services.BaseService.GetList<PSP_Substation_Info>("SelectPSP_Substation_InfoListByWhere", conn1);

            int startyear = yAnge.BeginYear;
            int endyear = yAnge.EndYear;

            int startyear2 = yAnge.BeginYear;
            int endyear2 = yAnge.EndYear;

            double yf = 0;
            double yk = 0;
            for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++)
            {
                col8.GetType().GetProperty("yf" + i.ToString()).SetValue(col8, 0, null);
                col8.GetType().GetProperty("yk" + i.ToString()).SetValue(col8, 0, null);
            }
            for (int j = 0; j < list.Count; j++)
            {
                string dyid = list[j].UID;
                Ps_Table_110Result newdy = new Ps_Table_110Result();
                newdy.ParentID = col8.ID;
                newdy.ProjectID = GetProjectID;
                newdy.Col1 = "no";
                newdy.Title = list[j].Title;

                startyear = yAnge.BeginYear;
                endyear = yAnge.EndYear;

                if (list[j].S2 != string.Empty)
                {
                    int.TryParse(list[j].S2, out startyear);
                }
                if (list[j].L29 != string.Empty)
                {
                    int.TryParse(list[j].L29, out endyear);
                }

                string connjz = " where SvgUID ='" + dyid + "' and (Type='02'  or Type='03')";
                IList<PSPDEV> listatt = Common.Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", connjz);

                for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++)
                {

                    //变电站下是否有机组容量,如果没有机组则直接用源的容量,如果有机组,将所有机组按年份计算求和
                    if (listatt.Count > 0)
                    {
                        for (int k = 0; k < listatt.Count; k++)
                        {
                            startyear2 = yAnge.BeginYear;
                            endyear2 = yAnge.EndYear;

                            if (listatt[k].OperationYear != string.Empty)
                            {
                                int.TryParse(listatt[k].OperationYear, out startyear2);
                            }
                            if (listatt[k].Date2 != string.Empty)
                            {
                                int.TryParse(listatt[k].Date2, out endyear2);
                            }

                            if (startyear2 <= i && i < endyear2)
                            {
                                double dyf = double.Parse(newdy.GetType().GetProperty("yf" + i.ToString()).GetValue(newdy, null).ToString());
                                double dyk = double.Parse(newdy.GetType().GetProperty("yk" + i.ToString()).GetValue(newdy, null).ToString());

                                if (listatt[k].Type == "02")
                                {
                                    double tempdb = double.Parse(listatt[k].Burthen.ToString());
                                    // 累计机组容量
                                    newdy.GetType().GetProperty("yf" + i.ToString()).SetValue(newdy, Math.Round(dyf + tempdb, 2), null);
                                    newdy.GetType().GetProperty("yk" + i.ToString()).SetValue(newdy, Math.Round(dyk + tempdb, 2), null);
                                }
                                else
                                {
                                    double tempdb = listatt[k].SiN;
                                    // 累计机组容量
                                    newdy.GetType().GetProperty("yf" + i.ToString()).SetValue(newdy, Math.Round(dyf + tempdb, 2), null);
                                    newdy.GetType().GetProperty("yk" + i.ToString()).SetValue(newdy, Math.Round(dyk + tempdb, 2), null);
                                }

                            }

                        }

                    }
                    else
                    {
                        if (startyear <= i && i < endyear)
                        {

                            newdy.GetType().GetProperty("yf" + i.ToString()).SetValue(newdy, Math.Round(list[j].L2, 2), null);
                            newdy.GetType().GetProperty("yk" + i.ToString()).SetValue(newdy, Math.Round(list[j].L2, 2), null);

                        }
                    }

                    double d8f = double.Parse(col8.GetType().GetProperty("yf" + i.ToString()).GetValue(col8, null).ToString());
                    double d8k = double.Parse(col8.GetType().GetProperty("yk" + i.ToString()).GetValue(col8, null).ToString());

                    double ddyf = double.Parse(newdy.GetType().GetProperty("yf" + i.ToString()).GetValue(newdy, null).ToString());
                    double ddyk = double.Parse(newdy.GetType().GetProperty("yk" + i.ToString()).GetValue(newdy, null).ToString());

                    col8.GetType().GetProperty("yf" + i.ToString()).SetValue(col8, Math.Round(d8f + ddyf, 2), null);
                    col8.GetType().GetProperty("yk" + i.ToString()).SetValue(col8, Math.Round(d8k + ddyk, 2), null);
                }

                Common.Services.BaseService.Create<Ps_Table_110Result>(newdy);
            }
            Common.Services.BaseService.Update<Ps_Table_110Result>(col8);
        }
Esempio n. 14
0
        /// <summary>
        /// 更新电源
        /// </summary>
        /// <param name="ParentID"></param>
        public void UpdataDY(string ParentID)
        {
            Hashtable rtable = new Hashtable();
            Ps_Table_110Result pt = Common.Services.BaseService.GetOneByKey<Ps_Table_110Result>(ParentID);
            string AreaName = pt.Title;

            string conn = "ProjectID='" + GetProjectID + "' and ParentID='" + ParentID + "'";

            Ps_Table_110Result col2, col5;

            IList<Ps_Table_110Result> listchild = Common.Services.BaseService.GetList<Ps_Table_110Result>("SelectPs_Table_110ResultByConn", conn);
            for (int i = 0; i < listchild.Count; i++)
            {
                rtable.Add(listchild[i].Col3, listchild[i]);
            }
            col2 = (Ps_Table_110Result)rtable["2"];

            //删除其下的
            string conncol2 = "ProjectID='" + GetProjectID + "' and ParentID='" + col2.ID + "'";

            IList<Ps_Table_110Result> col2list = Common.Services.BaseService.GetList<Ps_Table_110Result>("SelectPs_Table_110ResultByConn", conncol2);
            foreach (Ps_Table_110Result ptr in col2list)
            {
                Common.Services.BaseService.Delete<Ps_Table_110Result>(ptr);
            }

            col5 = (Ps_Table_110Result)rtable["5"];

            //更新110kV以下电源  更新 5、区内电源出力
            //
            string conn1 = " AreaID='" + GetProjectID + "' and S9='" + AreaName + "' and cast(S1 as int)<110";
            IList<PSP_PowerSubstation_Info> list = Common.Services.BaseService.GetList<PSP_PowerSubstation_Info>("SelectPSP_PowerSubstation_InfoListByWhere", conn1);

            int startyear = yAnge.BeginYear;
            int endyear = yAnge.EndYear;

            int startyear2 = yAnge.BeginYear;
            int endyear2 = yAnge.EndYear;

            double yf = 0;
            double yk = 0;
            for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++)
            {
                col2.GetType().GetProperty("yf" + i.ToString()).SetValue(col2, 0, null);
                col2.GetType().GetProperty("yk" + i.ToString()).SetValue(col2, 0, null);

                col5.GetType().GetProperty("yf" + i.ToString()).SetValue(col5, 0, null);
                col5.GetType().GetProperty("yk" + i.ToString()).SetValue(col5, 0, null);
            }

            for (int j = 0; j < list.Count; j++)
            {
                string dyid = list[j].UID;
                Ps_Table_110Result newdy = new Ps_Table_110Result();
                newdy.ParentID = col2.ID;
                newdy.ProjectID = GetProjectID;
                newdy.Col1 = "no";
                newdy.Title = list[j].Title;

                startyear = yAnge.BeginYear;
                endyear = yAnge.EndYear;

                if (list[j].S2 != string.Empty)
                {
                    int.TryParse(list[j].S2, out startyear);
                }
                if (list[j].S30 != string.Empty)
                {
                    int.TryParse(list[j].S30, out endyear);
                }

                string connjz = " where SvgUID ='" + dyid + "' and Type='04' ";
                IList<PSPDEV> listatt = Common.Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", connjz);
                for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++)
                {
                    //电源下是否有机组容量,如果没有机组则直接用源的容量,如果有机组,将所有机组按年份计算求和
                    if (listatt.Count > 0)
                    {
                        for (int k = 0; k < listatt.Count; k++)
                        {
                            startyear2 = yAnge.BeginYear;
                            endyear2 = yAnge.EndYear;
                            if (listatt[k].OperationYear != string.Empty)
                            {
                                int.TryParse(listatt[k].OperationYear, out startyear2);
                            }
                            if (listatt[k].Date2 != string.Empty)
                            {
                                int.TryParse(listatt[k].Date2, out endyear2);
                            }

                            if (startyear2 <= i && i < endyear2)
                            {
                                double dyf = double.Parse(newdy.GetType().GetProperty("yf" + i.ToString()).GetValue(newdy, null).ToString());
                                double dyk = double.Parse(newdy.GetType().GetProperty("yk" + i.ToString()).GetValue(newdy, null).ToString());

                                // 累计机组容量

                                double tempdb = listatt[k].P0;

                                newdy.GetType().GetProperty("yf" + i.ToString()).SetValue(newdy, Math.Round(dyf + tempdb, 2), null);
                                newdy.GetType().GetProperty("yk" + i.ToString()).SetValue(newdy, Math.Round(dyk + tempdb, 2), null);

                                double d5f = double.Parse(col5.GetType().GetProperty("yf" + i.ToString()).GetValue(col5, null).ToString());
                                double d5k = double.Parse(col5.GetType().GetProperty("yk" + i.ToString()).GetValue(col5, null).ToString());
                                // 累计机组容量*丰期机组出力率  或枯期机组出力率

                                col5.GetType().GetProperty("yf" + i.ToString()).SetValue(col5, Math.Round(d5f + tempdb * listatt[k].HuganTQ1, 2), null);
                                col5.GetType().GetProperty("yk" + i.ToString()).SetValue(col5, Math.Round(d5k + tempdb * listatt[k].HuganTQ2, 2), null);

                            }

                        }

                    }
                    else
                    {
                        if (startyear <= i && i < endyear)
                        {
                            double.TryParse(list[j].S2, out yf);
                            newdy.GetType().GetProperty("yf" + i.ToString()).SetValue(newdy, Math.Round(yf, 2), null);
                            newdy.GetType().GetProperty("yk" + i.ToString()).SetValue(newdy, Math.Round(yf, 2), null);
                            double d5f = double.Parse(col5.GetType().GetProperty("yf" + i.ToString()).GetValue(col5, null).ToString());
                            double d5k = double.Parse(col5.GetType().GetProperty("yk" + i.ToString()).GetValue(col5, null).ToString());

                            col5.GetType().GetProperty("yf" + i.ToString()).SetValue(col5, Math.Round(d5f + yf, 2), null);
                            col5.GetType().GetProperty("yk" + i.ToString()).SetValue(col5, Math.Round(d5k + yf, 2), null);

                        }
                    }

                    double d2f = double.Parse(col2.GetType().GetProperty("yf" + i.ToString()).GetValue(col2, null).ToString());
                    double d2k = double.Parse(col2.GetType().GetProperty("yk" + i.ToString()).GetValue(col2, null).ToString());

                    double ddyf = double.Parse(newdy.GetType().GetProperty("yf" + i.ToString()).GetValue(newdy, null).ToString());
                    double ddyk = double.Parse(newdy.GetType().GetProperty("yk" + i.ToString()).GetValue(newdy, null).ToString());

                    col2.GetType().GetProperty("yf" + i.ToString()).SetValue(col2, Math.Round(d2f + ddyf, 2), null);
                    col2.GetType().GetProperty("yk" + i.ToString()).SetValue(col2, Math.Round(d2k + ddyk, 2), null);
                }

                Common.Services.BaseService.Create<Ps_Table_110Result>(newdy);
            }
            Common.Services.BaseService.Update<Ps_Table_110Result>(col2);
            Common.Services.BaseService.Update<Ps_Table_110Result>(col5);
        }
Esempio n. 15
0
        /// <summary>
        /// 更新变电站
        /// </summary>
        /// <param name="ParentID"></param>
        public void UpDataBDZ(string ParentID)
        {
            Hashtable rtable = new Hashtable();
            Ps_Table_110Result pt = Common.Services.BaseService.GetOneByKey<Ps_Table_110Result>(ParentID);
            string AreaName = pt.Title;

            string conn = "ProjectID='" + GetProjectID + "' and ParentID='" + ParentID + "'";

            Ps_Table_110Result col11;

            IList<Ps_Table_110Result> listchild = Common.Services.BaseService.GetList<Ps_Table_110Result>("SelectPs_Table_110ResultByConn", conn);
            for (int i = 0; i < listchild.Count; i++)
            {
                rtable.Add(listchild[i].Col3, listchild[i]);
            }
            col11 = (Ps_Table_110Result)rtable["11"];

            //删除其下的
            string conncol11 = "ProjectID='" + GetProjectID + "' and ParentID='" + col11.ID + "'";

            IList<Ps_Table_110Result> col11list = Common.Services.BaseService.GetList<Ps_Table_110Result>("SelectPs_Table_110ResultByConn", conncol11);
            foreach (Ps_Table_110Result ptr in col11list)
            {
                Common.Services.BaseService.Delete<Ps_Table_110Result>(ptr);
            }

            //更新变电站数量  11.变电站个数

            int startyear = yAnge.BeginYear;
            int endyear = yAnge.EndYear;

            int startyear2 = yAnge.BeginYear;
            int endyear2 = yAnge.EndYear;

            Ps_Table_110Result yybdz = new Ps_Table_110Result();
            yybdz.Title = "已有变电站";
            yybdz.ProjectID = GetProjectID;
            yybdz.Col1 = "no";
            yybdz.Sort = 0;
            yybdz.ParentID = col11.ID;

            Ps_Table_110Result xzbdz = new Ps_Table_110Result();
            xzbdz.Title = "新增变电站";
            xzbdz.ProjectID = GetProjectID;
            xzbdz.Col1 = "no";
            xzbdz.Sort = 1;
            xzbdz.ParentID = col11.ID;

            for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++)
            {
                //已有变电站
                string conn1 = " AreaID='" + GetProjectID + "' and AreaName='" + AreaName + "' and L1=110  and cast(S2 as int)<" + i;
                IList<PSP_Substation_Info> list1 = Common.Services.BaseService.GetList<PSP_Substation_Info>("SelectPSP_Substation_InfoListByWhere", conn1);

                int yybdznumber = 0;

                for (int j = 0; j < list1.Count; j++)
                {

                    string dyid = list1[j].UID;
                    //string connjz = " RelatetableID ='" + dyid + "' and (S2='新建' or S2='扩容')";

                    //IList<Psp_Attachtable> listatt = Common.Services.BaseService.GetList<Psp_Attachtable>("SelectPsp_AttachtableByCont", connjz);

                    string connjz = " where SvgUID ='" + dyid + "' and (Type='02'  or Type='03')";
                    IList<PSPDEV> listatt = Common.Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", connjz);

                    //如果变站下没有机组,则变电站有效
                    if (listatt.Count > 0)
                    {
                        int jznumber = 0;
                        //找到是否有指定年份还在使用的机组,如果有则变电站有效
                        for (int k = 0; k < listatt.Count; k++)
                        {
                            startyear2 = yAnge.BeginYear;
                            endyear2 = yAnge.EndYear;

                            if (listatt[k].OperationYear != string.Empty)
                            {
                                int.TryParse(listatt[k].OperationYear, out startyear2);
                            }
                            if (listatt[k].Date2 != string.Empty)
                            {
                                int.TryParse(listatt[k].Date2, out endyear2);
                            }
                            if (startyear2 <= i && i <= endyear2)
                            {
                                jznumber++;
                                break;
                            }
                        }
                        if (jznumber > 0)
                        {
                            yybdznumber++;
                        }

                    }
                    else
                    {
                        yybdznumber++;
                    }

                }
                yybdz.GetType().GetProperty("yf" + i.ToString()).SetValue(yybdz, yybdznumber, null);
                yybdz.GetType().GetProperty("yk" + i.ToString()).SetValue(yybdz, yybdznumber, null);

                //新增变电站
                string conn2 = " AreaID='" + GetProjectID + "' and AreaName='" + AreaName + "' and L1=110  and cast(S2 as int)=" + i;
                IList<PSP_Substation_Info> list2 = Common.Services.BaseService.GetList<PSP_Substation_Info>("SelectPSP_Substation_InfoListByWhere", conn2);
                int xzbdznumber = 0;

                for (int j = 0; j < list2.Count; j++)
                {

                    string dyid = list2[j].UID;
                    //string connjz = " RelatetableID ='" + dyid + "' and (S2='新建' or S2='扩容')";

                    //IList<Psp_Attachtable> listatt = Common.Services.BaseService.GetList<Psp_Attachtable>("SelectPsp_AttachtableByCont", connjz);

                    string connjz = " where SvgUID ='" + dyid + "' and (Type='02'  or Type='03')";
                    IList<PSPDEV> listatt = Common.Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", connjz);

                    //如果变站下没有机组,则变电站有效
                    if (listatt.Count > 0)
                    {
                        int jznumber = 0;
                        //找到是否有指定年份还在使用的机组,如果有则变电站有效
                        for (int k = 0; k < listatt.Count; k++)
                        {
                            startyear2 = yAnge.BeginYear;
                            endyear2 = yAnge.EndYear;

                            if (listatt[k].OperationYear != string.Empty)
                            {
                                int.TryParse(listatt[k].OperationYear, out startyear2);
                            }
                            if (listatt[k].Date2 != string.Empty)
                            {
                                int.TryParse(listatt[k].Date2, out endyear2);
                            }
                            if (startyear2 <= i && i <= endyear2)
                            {
                                jznumber++;
                                break;
                            }
                        }
                        if (jznumber > 0)
                        {
                            xzbdznumber++;
                        }

                    }
                    else
                    {
                        xzbdznumber++;
                    }

                }
                xzbdz.GetType().GetProperty("yf" + i.ToString()).SetValue(xzbdz, xzbdznumber, null);
                xzbdz.GetType().GetProperty("yk" + i.ToString()).SetValue(xzbdz, xzbdznumber, null);

                col11.GetType().GetProperty("yf" + i.ToString()).SetValue(col11, yybdznumber + xzbdznumber, null);
                col11.GetType().GetProperty("yk" + i.ToString()).SetValue(col11, yybdznumber + xzbdznumber, null);

            }

            Common.Services.BaseService.Create<Ps_Table_110Result>(yybdz);
            Common.Services.BaseService.Create<Ps_Table_110Result>(xzbdz);
            Common.Services.BaseService.Update<Ps_Table_110Result>(col11);
        }