Exemplo 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 == "6" || nodestr == "no" || treeList1.FocusedNode.GetValue("Col1").ToString().IndexOf("bind") != -1)
            {
                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_ElecPH table1 = new Ps_Table_ElecPH();
               // Class1.TreeNodeToDataObject<PSP_Types>(psp_Type, treeList1.FocusedNode);
                table1.ID = treeList1.FocusedNode.GetValue("ID").ToString();

                try
                {
                    //DeletePSP_ValuesByType里面删除数据和分类

                    Common.Services.BaseService.Delete <Ps_Table_ElecPH>(table1);//("DeletePs_Table_ElecPH", 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;
                }
            }
        }
Exemplo n.º 2
0
        public void AddTotalRow(ref IList list)
        {
            //合计110
            string conn = "ProjectID='" + GetProjectID + "' and Col2='110'";
            IList tList = Common.Services.BaseService.GetList("SelectPs_Table_ElecPHByConn", conn);
            int[] year = GetYears();
            Ps_Table_ElecPH table1 = new Ps_Table_ElecPH();
            table1.ID += "|" + GetProjectID;
            table1.Title = "110千伏供电量合计";
            table1.ParentID = "0";
            table1.ProjectID = GetProjectID;
            table1.Col2 = "110he";
            table1.Col1 = "bind1";
            table1.Sort = 1000;
            table1.BuildEd = "total";
            for (int j = year[1]; j <= year[2]; j++)
            {
                double first = 0.0;
                for (int k = 0; k < tList.Count; k++)
                {
                    first += double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                }
                table1.GetType().GetProperty("y" + j).SetValue(table1, first, null);
            }
            list.Add(table1);
            //220
            conn = "ProjectID='" + GetProjectID + "' and Col2='110he'";
            tList = Common.Services.BaseService.GetList("SelectPs_Table_ElecPHByConn", conn);
            Ps_Table_ElecPH table2 = new Ps_Table_ElecPH();
            table2 = (Ps_Table_ElecPH)table1.Clone();
            table2.Title = "220千伏供电量";
            table2.ParentID = "0";
            table2.ProjectID = GetProjectID;
            table2.Col2 = "220he";
            table2.Sort = 2000;
            table2.Col1 = "bind2";
            table2.BuildEd = "total";
            for (int j = year[1]; j <= year[2]; j++)
            {
                double first = double.Parse(table2.GetType().GetProperty("y" + j).GetValue(table2, null).ToString());
                for (int k = 0; k < tList.Count; k++)
                {
                    if (((Ps_Table_ElecPH)tList[k]).Title == "外网110千伏送出电量")
                        first += double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                    else
                        first -= double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                }
                table2.GetType().GetProperty("y" + j).SetValue(table2, first, null);
            }
            list.Add(table2);
            //500
            conn = "ProjectID='" + GetProjectID + "' and Col2='220he'";
            tList = Common.Services.BaseService.GetList("SelectPs_Table_ElecPHByConn", conn);
            Ps_Table_ElecPH table3 = new Ps_Table_ElecPH();
            Ps_Table_ElecPH table4 = new Ps_Table_ElecPH();
            table3 = (Ps_Table_ElecPH)table2.Clone();
            table3.Title = "500千伏供电量";
            table3.ParentID = "0";
            table3.ProjectID = GetProjectID;
            table3.Col2 = "500he";
            table3.Sort = 3000;
            table3.BuildEd = "total";
            table4 = (Ps_Table_ElecPH)table3.Clone();
            table4.Sort = 3001;
            table3.Col1 = "bind3";
            table4.Col1 = "bind4";
            int t = 1;
            string ji = "";
            for (int j = year[1]; j <= year[2]; j++)
            {
                double first = double.Parse(table3.GetType().GetProperty("y" + j).GetValue(table3, null).ToString());
                double sec = double.Parse(table4.GetType().GetProperty("y" + j).GetValue(table4, null).ToString());
                for (int k = 0; k < tList.Count; k++)
                {
                    if (((Ps_Table_ElecPH)tList[k]).Title == "外网220千伏送出电量")
                    {
                        first += double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                        sec += double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                    }
                    else if (((Ps_Table_ElecPH)tList[k]).Title == "220千伏大用户输电量")
                    {
                        if (t == 1)
                        {
                            conn = "ParentId='" + ((Ps_Table_ElecPH)tList[k]).ID + "'";
                            IList teList = Common.Services.BaseService.GetList("SelectPs_Table_ElecPHByConn", conn);
                            for (int z = 0; z < teList.Count; z++)
                            {
                                ji += ((Ps_Table_ElecPH)teList[z]).Title + (z == teList.Count - 1 ? ")" : "、");
                            }
                            t = 2;
                        }
                        sec += double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                    }
                    else
                    {
                        first -= double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                        sec -= double.Parse(((Ps_Table_ElecPH)tList[k]).GetType().GetProperty("y" + j).GetValue((Ps_Table_ElecPH)tList[k], null).ToString());
                    }

                }
                table3.GetType().GetProperty("y" + j).SetValue(table3, first, null);
                table4.GetType().GetProperty("y" + j).SetValue(table4, sec, null);
            }
            table3.Title = "500千伏供电量(不计"+ji;
            table4.Title = "500千伏供电量(计" + ji;
            list.Add(table3);
            list.Add(table4);
        }
Exemplo 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" && focusedNode.GetValue("Col1").ToString().IndexOf("bind") == -1))
            {
                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_ElecPH table1 = new Ps_Table_ElecPH();
                table1.ID += "|" + GetProjectID;
                if (treeList1.FocusedNode.GetValue("Title").ToString() == "地区装机规模")
                {
                    table1.Title = "       "+frm.ParentName;
                }
                else
                {
                    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.GetElecMaxSort()+1;

                try
                {
                    Common.Services.BaseService.Create("InsertPs_Table_ElecPH", table1);
                    dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table1, dataTable.NewRow()));
                }
                catch(Exception ex)
                {
                    MsgBox.Show("增加子分类出错:" + ex.Message);
                }
            }
        }
Exemplo 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 == "6" || nodestr == "no" || treeList1.FocusedNode.GetValue("Col1").ToString().IndexOf("bind") != -1)
            {
                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_ElecPH table1 = new Ps_Table_ElecPH();
                table1 = Common.Services.BaseService.GetOneByKey<Ps_Table_ElecPH>(treeList1.FocusedNode.GetValue("ID"));
                table1.Title = frm.ParentName;

                try
                {
                    Common.Services.BaseService.Update<Ps_Table_ElecPH>(table1);
                    treeList1.FocusedNode.SetValue("Title", frm.ParentName);
                }
                catch { }
                //catch(Exception ex)
                //{
                //    MsgBox.Show("修改出错:" + ex.Message);
                //}
            }
        }
Exemplo n.º 5
0
 public void UpdateFuHe(string pid, string col1, Ps_Table_ElecPH oldrs, Ps_Table_ElecPH newrs)
 {
     string conn = "ProjectID='" + GetProjectID + "' and Col1='" + col1 + "' and ParentID='" + pid + "'";
     IList list = Common.Services.BaseService.GetList("SelectPs_Table_ElecPHByConn", conn);
     if (list.Count > 0)
     {
         for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++)
         {
             double oldyf = double.Parse(oldrs.GetType().GetProperty("y" + i.ToString()).GetValue(oldrs, null).ToString());
             double newyf = double.Parse(newrs.GetType().GetProperty("y" + i.ToString()).GetValue(newrs, null).ToString());
             double myyf = double.Parse(list[0].GetType().GetProperty("y" + i.ToString()).GetValue(list[0], null).ToString());
             list[0].GetType().GetProperty("y" + i.ToString()).SetValue(list[0], Math.Round(myyf - oldyf + newyf, 1), null);
         }
         Common.Services.BaseService.Update<Ps_Table_ElecPH>((Ps_Table_ElecPH)list[0]);
     }
 }
Exemplo n.º 6
0
 private void barButtonItem13_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     string conn = "(Title='110千伏地方电源发电量' or Title='外网110千伏送入电量' or Title='外网110千伏送出电量' or Title='220千伏大用户输电量' or Title='220千伏电源发电量' or Title='外网220千伏送入电量' or Title='外网220千伏送出电量') and ProjectID='"+GetProjectID+"'";
     IList list = Common.Services.BaseService.GetList("SelectPs_Table_ElecPHByConn", conn);
     if (list.Count > 0)
     {
         MessageBox.Show("已有固定列!");
         return;
     }
     Ps_Table_ElecPH table1 = new Ps_Table_ElecPH();
     table1.ID += "|" + GetProjectID;
     table1.Title = "110千伏地方电源发电量";
     table1.Sort = 1001;
     table1.ProjectID = GetProjectID;
     table1.ParentID = "0";
     table1.Col1 = "bind1";
     table1.Col2 = "110he";
     Common.Services.BaseService.Create<Ps_Table_ElecPH>(table1);
     Ps_Table_ElecPH table2 = new Ps_Table_ElecPH();
     table2.ID += "|" + GetProjectID;
     table2.Title = "外网110千伏送入电量";
     table2.Sort = 1002;
     table2.ProjectID = GetProjectID;
     table2.ParentID = "0";
     table2.Col1 = "bind1";
     table2.Col2 = "110he";
     Common.Services.BaseService.Create<Ps_Table_ElecPH>(table2);
     Ps_Table_ElecPH table3 = new Ps_Table_ElecPH();
     table3.ID += "|" + GetProjectID;
     table3.Title = "外网110千伏送出电量";
     table3.Sort = 1003;
     table3.ProjectID = GetProjectID;
     table3.ParentID = "0";
     table3.Col1 = "bind1";
     table3.Col2 = "110he";
     Common.Services.BaseService.Create<Ps_Table_ElecPH>(table3);
     Ps_Table_ElecPH table4 = new Ps_Table_ElecPH();
     table4.ID += "|" + GetProjectID;
     table4.Title = "220千伏大用户输电量";
     table4.Sort = 2001;
     table4.ProjectID = GetProjectID;
     table4.ParentID = "0";
     table4.Col1 = "bind2";
     table4.Col2 = "220he";
     Common.Services.BaseService.Create<Ps_Table_ElecPH>(table4);
     Ps_Table_ElecPH table5 = new Ps_Table_ElecPH();
     table5.ID += "|" + GetProjectID;
     table5.Title = "220千伏电源发电量";
     table5.Sort = 2002;
     table5.ProjectID = GetProjectID;
     table5.ParentID = "0";
     table5.Col1 = "bind2";
     table5.Col2 = "220he";
     Common.Services.BaseService.Create<Ps_Table_ElecPH>(table5);
     Ps_Table_ElecPH table6 = new Ps_Table_ElecPH();
     table6.ID += "|" + GetProjectID;
     table6.Title = "外网220千伏送入电量";
     table6.Sort = 2003;
     table6.ProjectID = GetProjectID;
     table6.ParentID = "0";
     table6.Col1 = "bind2";
     table6.Col2 = "220he";
     Common.Services.BaseService.Create<Ps_Table_ElecPH>(table6);
     Ps_Table_ElecPH table7 = new Ps_Table_ElecPH();
     table7.ID += "|" + GetProjectID;
     table7.Title = "外网220千伏送出电量";
     table7.Sort = 2004;
     table7.ProjectID = GetProjectID;
     table7.ParentID = "0";
     table7.Col1 = "bind2";
     table7.Col2 = "220he";
     Common.Services.BaseService.Create<Ps_Table_ElecPH>(table7);
     LoadData1();
 }
Exemplo n.º 7
0
 public void DelAll(string suid)
 {
     string conn = "ParentId='" + suid + "'";
     IList<Ps_Table_ElecPH> list = Common.Services.BaseService.GetList<Ps_Table_ElecPH>("SelectPs_Table_ElecPHByConn", conn);
     if (list.Count > 0)
     {
         foreach (Ps_Table_ElecPH var in list)
         {
             string child = var.ID;
             DelAll(child);
             Ps_Table_ElecPH ny = new Ps_Table_ElecPH();
             ny.ID = child;
             Common.Services.BaseService.Delete(ny);
         }
     }
     else
         return;
 }
Exemplo n.º 8
0
        private bool SaveCellValue(string year, string typeID, double value)
        {
            Ps_Table_ElecPH psp = new Ps_Table_ElecPH();
            Ps_Table_ElecPH old = Common.Services.BaseService.GetOneByKey<Ps_Table_ElecPH>(typeID);
            psp = (Ps_Table_ElecPH)old.Clone();
            psp.GetType().GetProperty(year).SetValue(psp, Math.Round(value,1),null);

            try
            {
                Common.Services.BaseService.Update<Ps_Table_ElecPH>(psp);
            }
            catch(Exception ex)
            {
                MsgBox.Show("保存数据出错:" + ex.Message);
                return false;
            }
            return true;
        }
Exemplo 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 (treeList1.FocusedNode.GetValue("Col1").ToString().IndexOf("bind") != -1)
            {
                MsgBox.Show("固定分类不能删除!");
                return;
            }

            if (MsgBox.ShowYesNo("总分类及其下属分类都将删除,是否删除总分类 " + treeList1.FocusedNode.GetValue("Title") + "?") == DialogResult.Yes)
            {
                Ps_Table_ElecPH table1 = new Ps_Table_ElecPH();
                // 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_ElecPH>(table1);//("DeletePs_Table_ElecPH", 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;
                }
            }
        }
Exemplo n.º 10
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)
            {
                FrmAreaStyle frmas = new FrmAreaStyle();
                if (frmas.ShowDialog() == DialogResult.OK)
                {
                    Ps_Table_ElecPH table_yd = new Ps_Table_ElecPH();
                    table_yd.ID += "|" + GetProjectID;
                    table_yd.Title = frm.ParentName;
                    table_yd.ParentID = "0";
                    table_yd.Sort = OperTable.GetElecMaxSort() + 1;
                    table_yd.ProjectID = GetProjectID;
                    //for (int i = range.BeginYear; i <= range.EndYear; i++)
                    //{
                    //    table_yd.GetType().GetProperty("y" + 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_ElecPH", table_yd);
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show("增加城区出错:" + ex.Message);

                    }
                    string[] lei;
                    if (frmas.comBoxTEXT == "送端地区")
                    {
                        lei = new string[6] { "地区最大负荷", "平均高峰负荷", "地区装机规模", "地区电源满发时供电能力", "机组满发时高峰电力盈亏", "机组满发时平均高峰电力盈亏 " };//, "三、220千伏及以下地方电源出力", "四、220千伏及以下外网送入电力", "五、500千伏供电负荷" };
                    }
                    else if(frmas.comBoxTEXT == "抽水蓄能地区")
                    {
                        lei = new string[8] { "地区最大负荷", "负荷备用(5%)", "夏季低谷负荷", "地区装机规模", "地区电源满发时供电能力(含抽蓄出力)", "地区抽水蓄能机组低谷抽水负荷", "机组满发时高峰电力盈亏", "夏季低谷时(含抽蓄抽水) 电力盈亏" };//, "三、220千伏及以下地方电源出力", "四、220千伏及以下外网送入电力", "五、500千伏供电负荷" };
                    }
                    else
                    {
                        lei = new string[7] { "地区最大负荷", "负荷备用(5%)", "地区装机规模", "地区电源满发时供电能力(枯水年)", "停最大单机时供电能力(枯水年)", "机组满发时高峰电力盈亏", "停最大单机时高峰电力盈亏" };//, "三、220千伏及以下地方电源出力", "四、220千伏及以下外网送入电力", "五、500千伏供电负荷" };
                    }

                    for (int i = 0; i < lei.Length; i++)
                    {
                        Ps_Table_ElecPH table1 = new Ps_Table_ElecPH();
                        table1.ID += "|" + GetProjectID;
                        table1.Title = lei[i];
                        table1.ParentID = table_yd.ID;
                        table1.ProjectID = GetProjectID;
                        table1.Col1 = Convert.ToString(i + 1);
                        table1.Col2 = "110child";
                        if (i == 2)
                        {
                            //table1.Col1 = "no";
                            table1.Col2 = "110";
                        }
                        table1.Sort = i + 1;
                        try
                        {
                            Common.Services.BaseService.Create("InsertPs_Table_ElecPH", table1);
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show("增加项目出错:" + ex.Message);
                        }
                        if (lei[i] == "地区装机规模")
                        {
                            Ps_Table_ElecPH table2 = new Ps_Table_ElecPH();
                            table2.ID += "|" + GetProjectID;
                            table2.Title = "其中:    电厂";
                            table2.ParentID = table1.ID;
                            table2.ProjectID = GetProjectID;
                            table2.Col1 = Convert.ToString("child");
                            // table2.Col2 = "110child";
                            table1.Sort = i + 1;
                            Ps_Table_ElecPH table3 = new Ps_Table_ElecPH();
                            table3.ID += "|" + GetProjectID;
                            table3.Title = "    电厂";
                            table3.ParentID = table1.ID;
                            table3.ProjectID = GetProjectID;
                            table3.Col1 = Convert.ToString("child");
                            // table3.Col2 = "110child";
                            table3.Sort = i + 2;
                            try
                            {
                                Common.Services.BaseService.Create("InsertPs_Table_ElecPH", table2);
                                Common.Services.BaseService.Create("InsertPs_Table_ElecPH", table3);
                            }
                            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;
                }
                else
                {
                    return;
                }

            }
        }
Exemplo 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)
            {
                for (int i = 0; i < treeList1.Nodes.Count; i++)
                {
                    if (treeList1.Nodes[i].GetValue("Title").ToString() == frm.ParentName && treeList1.Nodes[i].GetValue("ParentID").ToString() == "0")
                    {
                        MessageBox.Show(frm.ParentName + " 地区已存在!");
                        return;
                    }
                }
                Ps_Table_ElecPH table_yd = new Ps_Table_ElecPH();
                table_yd.ID += "|" + GetProjectID;
                table_yd.Title = frm.ParentName;
                table_yd.ParentID = "0";
                table_yd.Sort = OperTable.GetElecMaxSort() + 1;
                table_yd.ProjectID = GetProjectID;
                //for (int i = range.BeginYear; i <= range.EndYear; i++)
                //{
                //    table_yd.GetType().GetProperty("y" + 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_ElecPH", table_yd);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("增加城区出错:" + ex.Message);
                }
                string[] lei = new string[3] { "需电量", "35千伏及以下地方电源发电量","110千伏供电量"};//, "三、220千伏及以下地方电源出力", "四、220千伏及以下外网送入电力", "五、500千伏供电负荷" };
                for (int i = 0; i < lei.Length; i++)
                {
                    Ps_Table_ElecPH table1 = new Ps_Table_ElecPH();
                    table1.ID += "|" + GetProjectID;
                    table1.Title = lei[i];
                    table1.ParentID = table_yd.ID;
                    table1.ProjectID = GetProjectID;
                    table1.Col1 = Convert.ToString(i+1);
                    table1.Col2 = "110child";
                    if (i == 2)
                    {
                        table1.Col1 = "no";
                        table1.Col2 = "110";
                    }
                    table1.Sort = i+1;
                    try
                    {
                        Common.Services.BaseService.Create("InsertPs_Table_ElecPH", table1);
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show("增加项目出错:" + ex.Message);
                    }
                    if (i == 1)
                    {
                        Ps_Table_ElecPH table2 = new Ps_Table_ElecPH();
                        table2.ID += "|" + GetProjectID;
                        table2.Title = "其中:小水电";
                        table2.ParentID = table1.ID;
                        table2.ProjectID = GetProjectID;
                        table2.Col1 = Convert.ToString(i + 1);
                       // table2.Col2 = "110child";
                        table1.Sort = i + 1;
                        Ps_Table_ElecPH table3 = new Ps_Table_ElecPH();
                        table3.ID += "|" + GetProjectID;
                        table3.Title = "小火电";
                        table3.ParentID = table1.ID;
                        table3.ProjectID = GetProjectID;
                        table3.Col1 = Convert.ToString(i + 1);
                       // table3.Col2 = "110child";
                        table3.Sort = i + 2;
                        try
                        {
                            Common.Services.BaseService.Create("InsertPs_Table_ElecPH", table2);
                            Common.Services.BaseService.Create("InsertPs_Table_ElecPH", table3);
                        }
                        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;
            }
        }