Пример #1
0
        private void barButtonItem15_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 Col4 From Ps_Table_35PH where ProjectID='" +
                GetProjectID + "' and ParentID='0') order by sort");
            for (int i = 0; i < pareList.Count; i++)
            {
                Ps_Table_35PH table_yd = new Ps_Table_35PH();
                table_yd.ID = table_yd.ID + "|" + GetProjectID;
                table_yd.Title = ((PS_Table_AreaWH)pareList[i]).Title;
                table_yd.ParentID = "0";
                table_yd.Sort = OperTable.Get35MaxSort() + 1;
                table_yd.ProjectID = GetProjectID;
                table_yd.Col4 = ((PS_Table_AreaWH)pareList[i]).ID;
                try
                {
                    Common.Services.BaseService.Create("InsertPs_Table_35PH", table_yd);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("增加分类出错:" + ex.Message);
                }

                Ps_Table_35PH table1 = new Ps_Table_35PH();
                table1.ID += "|" + GetProjectID;
                table1.Title = "35千伏公用变电站供电负荷";
                table1.ParentID = table_yd.ID;
                table1.ProjectID = GetProjectID;
                table1.Col1 = "0";
                table1.Sort = 1;
                try
                {
                    Common.Services.BaseService.Create("InsertPs_Table_35PH", table1);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("增加项目出错:" + ex.Message);
                }
                UpdateFuHe(table_yd.Title, table_yd.ID,"yf");
                this.Cursor = Cursors.WaitCursor;
                treeList1.BeginUpdate();
                LoadData1(table_yd.ID);
                FoucsLocation(table_yd.ID, treeList1.Nodes);
                treeList1.EndUpdate();
                this.Cursor = Cursors.Default;
            }
        }
Пример #2
0
        public void AddRows(ref IList list, string con)
        {
            //IList list = new List<Ps_Table_35PH>();
            string conn = "ParentID='0' and ProjectID='" + GetProjectID + "'";

            int[] year = GetYears();
            IList pareList = Common.Services.BaseService.GetList("SelectPs_Table_35PHListByConn", con);
            try
            {
                for (int i = 0; i < pareList.Count; i++)
                {
                    Ps_Table_35PH ps_table1 = new Ps_Table_35PH();
                    ps_table1.ID = ps_table1.ID + "|" + GetProjectID;
                    //Ps_Table_35PH con = new Ps_Table_35PH();
                    //con.Col4 = rongZai220;
                    //con.Title = "ParentID='" + ((Ps_Table_35PH)pareList[i]).ID + "' and Col1='0'";
                    //IList childList1 = Common.Services.BaseService.GetList("SelectPs_Table_35PHJiByConn", con);
                    //CaleHeTable(ref childList1);
                    //ps_table1 = (Ps_Table_35PH)childList1[0];
                    for (int j = 0; j < list.Count; j++)
                    {
                        if (((Ps_Table_35PH)list[j]).ParentID == ((Ps_Table_35PH)pareList[i]).ID && ((Ps_Table_35PH)list[j]).Col1 == "0")
                        {
                            for (int k = year[1]; k <= year[2]; k++)
                            {
                                ps_table1.GetType().GetProperty("y" + k).SetValue(ps_table1, Math.Round(double.Parse(((Ps_Table_35PH)list[j]).GetType().GetProperty("y" + k).GetValue(((Ps_Table_35PH)list[j]), null).ToString()) * double.Parse(RongZai((Ps_Table_35PH)pareList[i])), 1), null);
                            }
                        }
                    }
                    ps_table1.ParentID = ((Ps_Table_35PH)pareList[i]).ID;
                    ps_table1.ID = Guid.NewGuid().ToString();
                    ps_table1.Sort = 2;
                    ps_table1.Col1 = "no";
                    ps_table1.Title = "35千伏需要容量(" + RongZai((Ps_Table_35PH)pareList[i]) + ")";
                    list.Add(ps_table1);

                    Ps_Table_35PH ps_table = new Ps_Table_35PH();
                    ps_table.ID = ps_table.ID + "|" + GetProjectID;
                    //conn = "ParentID='" + ((Ps_Table_35PH)pareList[i]).ID + "' and Col1='1'";
                    //IList childList = Common.Services.BaseService.GetList("SelectPs_Table_35PHSumByConn", conn);
                    //CaleHeTable(ref childList);
                    //ps_table = (Ps_Table_35PH)childList[0];
                    for (int j = 0; j < list.Count; j++)
                    {
                        if (((Ps_Table_35PH)list[j]).ParentID == ((Ps_Table_35PH)pareList[i]).ID && ((Ps_Table_35PH)list[j]).Col1 == "1")
                        {
                            for (int k = year[1]; k <= year[2]; k++)
                            {
                                ps_table.GetType().GetProperty("y" + k).SetValue(ps_table, double.Parse(ps_table.GetType().GetProperty("y" + k).GetValue(ps_table, null).ToString()) + double.Parse(((Ps_Table_35PH)list[j]).GetType().GetProperty("y" + k).GetValue(((Ps_Table_35PH)list[j]), null).ToString()), null);
                            }
                        }
                    }
                    ps_table.ParentID = ((Ps_Table_35PH)pareList[i]).ID;
                    ps_table.ID = Guid.NewGuid().ToString();
                    ps_table.Sort = 3;
                    ps_table.Col1 = "no";
                    ps_table.Title = "35千伏公用变电站总容量";
                    list.Add(ps_table);

                    // conn = "ParentID='" + ((Ps_Table_35PH)pareList[i]).ID + "' and Col1='0'";
                    Ps_Table_35PH temp = new Ps_Table_35PH();// (Ps_Table_35PH)Common.Services.BaseService.GetList("SelectPs_Table_35PHListByConn", conn)[0];
                    for (int j = 0; j < list.Count; j++)
                    {
                        if (((Ps_Table_35PH)list[j]).ParentID == ((Ps_Table_35PH)pareList[i]).ID && ((Ps_Table_35PH)list[j]).Col1 == "0")
                        {
                            temp = (Ps_Table_35PH)list[j];
                        }
                    }
                    Ps_Table_35PH ps_table2 = new Ps_Table_35PH();
                    ps_table2.ID = ps_table2.ID + "|" + GetProjectID;
                    for (int j = year[1]; j <= year[2]; j++)
                    {
                        double d = (double)temp.GetType().GetProperty("y" + j).GetValue(temp, null);
                        if (d != 0.0)
                        {
                            double chu = (double)ps_table.GetType().GetProperty("y" + j).GetValue(ps_table, null);
                            ps_table2.GetType().GetProperty("y" + j).SetValue(ps_table2, Math.Round(chu / d, 1), null);
                        }
                    }
                    ps_table2.ParentID = ((Ps_Table_35PH)pareList[i]).ID;
                    ps_table2.ID = Guid.NewGuid().ToString();
                    ps_table2.Sort = 1000;
                    ps_table2.Col1 = "no";
                    ps_table2.Title = "35千伏容载比";
                    list.Add(ps_table2);
                }

                //  CalcTotal(ref list);
            }
            catch (Exception e) { MessageBox.Show(e.Message); }
            //return list;
        }
Пример #3
0
 public string RongZai(Ps_Table_35PH cur)
 {
     if (cur == null || cur.BuildYear == null || cur.BuildYear == "")
         return rongZai220;
     return cur.BuildYear;
 }
Пример #4
0
        private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            ClearNoBuild();
            Ps_YearRange range = oper.GetYearRange("Col5='" + GetProjectID + "' and Col4='" + OperTable.ph110 + "'");
            string conn = "ProjectID='" + GetProjectID + "' and ParentID='0'";
            IList pList = Common.Services.BaseService.GetList("SelectPs_Table_35PHListByConn", conn);
            for (int i = 0; i < pList.Count; i++)
            {

                //从变电站情况表里读

                conn = "AreaID='" + GetProjectID + "' and AreaName='"+((Ps_Table_35PH)pList[i]).Title+"' and L1='35'and (Flag='1' or Flag='2')";
                IList pspList = Common.Services.BaseService.GetList("SelectSubstation_InfoByCon2", conn);
                for (int j = 0; j < pspList.Count; j++)
                {
                    bool KGflag = false;
                    if (((Substation_Info)pspList[j]).Title.Contains("扩建") || ((Substation_Info)pspList[j]).Title.Contains("改造"))
                    {
                        KGflag = true;
                        ((Substation_Info)pspList[j]).Title = ((Substation_Info)pspList[j]).Title.Replace("扩建", "");
                        ((Substation_Info)pspList[j]).Title = ((Substation_Info)pspList[j]).Title.Replace("改造", "");
                    }
                    conn = "ProjectID='" + GetProjectID + "' and ParentID='" + ((Ps_Table_35PH)pList[i]).ID + "' and Title='" + ((Substation_Info)pspList[j]).Title + "'";
                    IList oldList = Common.Services.BaseService.GetList("SelectPs_Table_35PHListByConn", conn);
                    Ps_Table_35PH ps = new Ps_Table_35PH();
                    if (oldList.Count > 0)
                    {
                        ps = oldList[0] as Ps_Table_35PH;
                    }
                    else
                    {
                        ps.ID += "|" + ProjectUID;
                        ps.ParentID = ((Ps_Table_35PH)pList[i]).ID;
                        ps.ProjectID = ProjectUID;
                        ps.Sort = OperTable.Get35MaxSort() + 1;
                        ps.Title = ((Substation_Info)pspList[j]).Title;
                        ps.Col1 = "1";
                        if (ps.Sort < 4)
                            ps.Sort = 4;
                        ps.Col3 = ((Substation_Info)pspList[j]).UID;
                    }
                   // for (int k = range.StartYear; k <= range.EndYear; k++)  //原来

                    int year = DateTime.Now.Year;
                    if (((Substation_Info)pspList[j]).S2.Length > 4)
                    {
                        string str = ((Substation_Info)pspList[j]).S2.Substring(0, 4);
                        int.TryParse(str, out year);
                    }
                    else
                    {
                        string str = ((Substation_Info)pspList[j]).S2.ToString();
                        int.TryParse(str, out year);
                    }
                    if (year<=range.EndYear)
                    {
                        if (year <= range.StartYear)
                        {
                            year = range.StartYear;
                        }
                        for (int k = year; k <= range.EndYear; k++)
                        {
                            if (KGflag)
                            {
                                double tempdb = 0;
                                string tempstr = "0";
                                if (ps.GetType().GetProperty("y" + k.ToString()) != null)
                                {
                                    tempstr = ps.GetType().GetProperty("y" + k.ToString()).GetValue(ps, null).ToString();
                                }
                                double.TryParse(tempstr, out tempdb);
                                double tempdb2 = ((Substation_Info)pspList[j]).L2 / 10;
                                ps.GetType().GetProperty("y" + k.ToString()).SetValue(ps, tempdb + tempdb2, null);
                            }
                            else
                            {
                                ps.GetType().GetProperty("y" + k.ToString()).SetValue(ps, ((Substation_Info)pspList[j]).L2 / 10, null);

                            }
                        }
                    }
                    try
                    {
                        if (oldList.Count == 0)
                        {
                            Common.Services.BaseService.Create("InsertPs_Table_35PH", ps);
                            CreateEdit(ps.ID, "", Convert.ToString(range.StartYear - 1), "新建", ((Substation_Info)pspList[j]).L2.ToString(), OperTable.ph35, ((Substation_Info)pspList[j]).UID);
                        }
                        else
                        {
                            Common.Services.BaseService.Update("UpdatePs_Table_35PH", ps);
                            ChangeEdit(ps.ID, "", Convert.ToString(range.StartYear - 1), "新建", ((Substation_Info)pspList[j]).L2.ToString(), OperTable.ph35, ((Substation_Info)pspList[j]).UID);
                        }
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show("更新变电站出错:" + ps.Title + ex.Message);
                    }
                }
                /*
                //从建设项目表中读
                conn = "ProjectID='" + GetProjectID + "' and AreaName='" + ((Ps_Table_35PH)pList[i]).Title + "' and FromID='35'";
                IList buildList = Common.Services.BaseService.GetList("SelectPs_Table_BuildProByConn", conn);
                for (int j = 0; j < buildList.Count; j++)
                {
                    if (((Ps_Table_BuildPro)buildList[j]).Col3 == "新建")
                    {
                        conn = "ProjectID='" + GetProjectID + "' and ParentID='" + ((Ps_Table_35PH)pList[i]).ID + "' and Title='" + ((Ps_Table_BuildPro)buildList[j]).Title + "'";
                        IList oldList = Common.Services.BaseService.GetList("SelectPs_Table_35PHListByConn", conn);
                        Ps_Table_35PH ps = new Ps_Table_35PH();
                        if (oldList.Count > 0)
                        {
                            ps = oldList[0] as Ps_Table_35PH;
                        }
                        else
                        {
                            ps.ID += "|" + ProjectUID;
                            ps.ParentID = ((Ps_Table_35PH)pList[i]).ID;
                            ps.ProjectID = ProjectUID;
                            ps.Sort = OperTable.Get35MaxSort() + 1;
                            ps.Title = ((Ps_Table_BuildPro)buildList[j]).Title;
                            ps.Col1 = "1";
                            if (ps.Sort < 4)
                                ps.Sort = 4;
                            ps.Col3 = ((Ps_Table_BuildPro)buildList[j]).ID;
                        }
                        int bYear = range.StartYear;
                        int.TryParse(((Ps_Table_BuildPro)buildList[j]).BuildEd, out bYear);
                        for (int k = bYear; k <= range.EndYear; k++)
                        {
                            ps.GetType().GetProperty("y" + k.ToString()).SetValue(ps, ((Ps_Table_BuildPro)buildList[j]).Volumn, null);
                        }
                        try
                        {
                            if (oldList.Count == 0)
                            {
                                Common.Services.BaseService.Create("InsertPs_Table_35PH", ps);
                                CreateEdit(ps.ID, ((Ps_Table_BuildPro)buildList[j]).BuildYear, bYear.ToString(), "新建", ((Ps_Table_BuildPro)buildList[j]).Volumn.ToString(), OperTable.ph110, ((Ps_Table_BuildPro)buildList[j]).ID);
                            }
                            else
                            {
                               Common.Services.BaseService.Update("UpdatePs_Table_35PH", ps);
                               ChangeEdit(ps.ID, ((Ps_Table_BuildPro)buildList[j]).BuildYear, bYear.ToString(), "新建", ((Ps_Table_BuildPro)buildList[j]).Volumn.ToString(), OperTable.ph110, ((Ps_Table_BuildPro)buildList[j]).ID);
                           }
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show("更新变电站出错:" + ps.Title + ex.Message);
                        }
                    }
                    else if (((Ps_Table_BuildPro)buildList[j]).Col3 == "扩建" || ((Ps_Table_BuildPro)buildList[j]).Col3 == "改造")
                    {
                        conn = "ProjectID='" + GetProjectID + "' and ParentID='" + ((Ps_Table_35PH)pList[i]).ID + "' and Title='" + ((Ps_Table_BuildPro)buildList[j]).Title + "'";
                        IList oldList = Common.Services.BaseService.GetList("SelectPs_Table_35PHListByConn", conn);
                        Ps_Table_35PH ps = new Ps_Table_35PH();
                        if (oldList.Count > 0)
                        {
                            ps = oldList[0] as Ps_Table_35PH;
                            int bYear = range.StartYear;
                            int.TryParse(((Ps_Table_BuildPro)buildList[j]).BuildEd, out bYear);
                            conn = "ProjectID='" + GetProjectID + "' and ParentID='" + ps.ID + "' and Col5='" + ((Ps_Table_BuildPro)buildList[j]).ID+ "'";
                            IList list = Common.Services.BaseService.GetList("SelectPs_Table_EditListByConn", conn);
                            if (list.Count > 0)
                            {
                                ChangeEdit(ps.ID, ((Ps_Table_BuildPro)buildList[j]).BuildYear, bYear.ToString(), ((Ps_Table_BuildPro)buildList[j]).Col3, ((Ps_Table_BuildPro)buildList[j]).Volumn.ToString(), OperTable.ph110, ((Ps_Table_BuildPro)buildList[j]).ID);
                            }
                            else
                            {
                                CreateEdit(ps.ID, ((Ps_Table_BuildPro)buildList[j]).BuildYear, bYear.ToString(), ((Ps_Table_BuildPro)buildList[j]).Col3, ((Ps_Table_BuildPro)buildList[j]).Volumn.ToString(), OperTable.ph110, ((Ps_Table_BuildPro)buildList[j]).ID);
                            }
                        }
                        else
                            continue;

                    }
                }
                */
            }
            Loaddata2();
        }
Пример #5
0
 //删除所有
 public void DelAll(string suid)
 {
     string conn = "ParentId='" + suid + "'";
     IList<Ps_Table_35PH> list = Common.Services.BaseService.GetList<Ps_Table_35PH>("SelectPs_Table_35PHListByConn", conn);
     if (list.Count > 0)
     {
         foreach (Ps_Table_35PH var in list)
         {
             string child = var.ID;
             //if (var.Sort != "1")
             //    DelAll(child);
             Ps_Table_35PH ny = new Ps_Table_35PH();
             ny.ID = child;
             Common.Services.BaseService.Delete(ny);
         }
     }
 }
Пример #6
0
        public void EditPsTable()
        {
            TreeListNode focusedNode = treeList1.FocusedNode;

            if (focusedNode == null)
            {
                return;
            }

            if (!base.EditRight)
            {
                MsgBox.Show("您没有权限进行此项操作!");
                return;
            }

            Ps_YearRange range = oper.GetYearRange("Col5='" + GetProjectID + "' and Col4='" + OperTable.ph110 + "'");
            if (focusedNode.GetValue("Col1") != null && focusedNode.GetValue("Col1").ToString() == "0")
            {
                FrmChangeBian frm = new FrmChangeBian();
                frm.GetProject = GetProjectID;
                frm.Mark = OperTable.ph110;
                frm.Text = "修改" + focusedNode.GetValue("Title");
                Hashtable ht = new Hashtable();
                for (int i = range.StartYear; i <= range.FinishYear; i++)
                {
                    ht.Add("y" + i.ToString(), focusedNode.GetValue("y" + i.ToString()).ToString());
                }
                frm.TextAttr = ht;
                frm.Title = focusedNode.GetValue("Title").ToString();
                if (focusedNode.GetValue("Col1").ToString() == "0")
                {
                    frm.SetEnable();
                    frm.BFuHe = true;
                }
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    Ps_Table_35PH table = new Ps_Table_35PH();
                    table.ID = focusedNode.GetValue("ID").ToString();
                    table.Title = frm.Title;
                    table.ParentID = focusedNode.GetValue("ParentID").ToString();
                    for (int i = range.StartYear; i <= range.FinishYear; i++)
                    {
                        table.GetType().GetProperty("y" + i.ToString()).SetValue(table, Convert.ToDouble(frm.TextAttr["y" + i.ToString()]), null);
                    }
                    double end = Convert.ToDouble(frm.TextAttr["y" + range.FinishYear.ToString()]);
                    for (int j = range.FinishYear + 1; j <= range.EndYear; j++)
                    {
                        table.GetType().GetProperty("y" + j.ToString()).SetValue(table, end, null);
                    }
                    table.Col1 = focusedNode.GetValue("Col1").ToString();
                    table.ProjectID = GetProjectID;
                    table.Sort = int.Parse(focusedNode.GetValue("Sort").ToString());
                    try
                    {
                        Common.Services.BaseService.Update("UpdatePs_Table_35PH", table);
                        LoadData1(table.ParentID);
                        FoucsLocation(table.ID, treeList1.Nodes);
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show("修改项目出错:" + ex.Message);
                    }
                }
            }
            else if (focusedNode.GetValue("Col1") != null && focusedNode.GetValue("Col1").ToString() == "1")
            {
                string conn = "ParentID='" + focusedNode.GetValue("ID").ToString() + "'";
                IList<Ps_Table_Edit> eList = Common.Services.BaseService.GetList<Ps_Table_Edit>("SelectPs_Table_EditListByConn", conn);

                FrmPsEditWH frm = new FrmPsEditWH();
                frm.Mark = OperTable.ph110;
                frm.GetProject = GetProjectID;
                frm.GridData = eList;
                frm.Title = focusedNode.GetValue("Title").ToString();
                frm.ParentID = focusedNode.GetValue("ID").ToString();
                string curVolumn = focusedNode.GetValue("y" + range.EndYear).ToString();
                frm.CurVolumn = curVolumn;
                frm.TypeTable = "35";
                frm.MaxYear = GetChildMaxYear(conn);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    Ps_Table_35PH table = new Ps_Table_35PH();
                    table = Common.Services.BaseService.GetOneByKey<Ps_Table_35PH>(focusedNode.GetValue("ID"));
                    //table.ID = focusedNode.GetValue("ID").ToString();
                    table.Title = frm.Title;

                    //table.ParentID = focusedNode.GetValue("ParentID").ToString();
                    //table.Col1 = focusedNode.GetValue("Col1").ToString();
                    //table.Sort = int.Parse(focusedNode.GetValue("Sort").ToString());
                    //table.Title = frm.StrResult[0];
                    //if (frm.GetStatus == "已有")
                    //{
                    //    for (int i = range.BeginYear; i <= range.EndYear; i++)
                    //    {
                    //        if (table.GetType().GetProperty("y" + i.ToString()).GetValue(table, null).ToString() == curVolumn)
                    //            table.GetType().GetProperty("y" + i.ToString()).SetValue(table, double.Parse(frm.StrResult[2]), null);
                    //    }
                    //}
                    //else if (frm.GetStatus == "扩建")
                    //{
                    //    for (int i = int.Parse(frm.StrResult[1]); i <= range.EndYear; i++)
                    //    {
                    //        table.GetType().GetProperty("y" + i.ToString()).SetValue(table, double.Parse(frm.StrResult[2]), null);
                    //    }
                    //}
                    //else if (frm.GetStatus == "拆除")
                    //{
                    //    for (int i = int.Parse(frm.StrResult[1]); i <= range.EndYear; i++)
                    //    {
                    //        table.GetType().GetProperty("y" + i.ToString()).SetValue(table, 0.0, null);
                    //    }
                    //    table.ParentID = "-1";
                    //}
                    try
                    {
                        Common.Services.BaseService.Update("UpdatePs_Table_35PH", table);
                        LoadData1(table.ParentID);
                        FoucsLocation(table.ID, treeList1.Nodes);
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show("修改项目出错:" + ex.Message);
                    }
                }
            }
            else if (focusedNode.GetValue("ParentID").ToString() == "0")
            {
                FrmAddPN frm = new FrmAddPN();
                frm.ParentName = focusedNode.GetValue("Title").ToString();
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    Ps_Table_35PH table1 = new Ps_Table_35PH();
                    table1.ID = focusedNode.GetValue("ID").ToString();
                    table1.ParentID = focusedNode.GetValue("ParentID").ToString();
                    table1.Sort = int.Parse(focusedNode.GetValue("Sort").ToString());
                    table1.Title = frm.ParentName;
                    table1.ProjectID = GetProjectID;
                    table1.BuildYear = focusedNode.GetValue("BuildYear").ToString();
                    try
                    {
                        Common.Services.BaseService.Update("UpdatePs_Table_35PH", table1);
                        LoadData1(table1.ID);
                        FoucsLocation(table1.ID, treeList1.Nodes);
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show("修改分类出错:" + ex.Message);
                    }
                }
            }
            else
                MsgBox.Show("不能修改此行");
        }
Пример #7
0
        //添加父分类
        private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (!base.AddRight)
            {
                MsgBox.Show("您没有权限进行此项操作!");
                return;
            }

            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_35PH table_yd = new Ps_Table_35PH();
                table_yd.ID = table_yd.ID + "|" + GetProjectID;
                table_yd.Title = frm.ParentName;
                table_yd.ParentID = "0";
                table_yd.Sort = OperTable.Get35MaxSort() + 1;
                table_yd.ProjectID = GetProjectID;
                try
                {
                    Common.Services.BaseService.Create("InsertPs_Table_35PH", table_yd);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("增加分类出错:" + ex.Message);
                }

                Ps_Table_35PH table1 = new Ps_Table_35PH();
                table1.ID += "|" + GetProjectID;
                table1.Title = "35千伏公用变电站供电负荷";
                table1.ParentID = table_yd.ID;
                table1.ProjectID = GetProjectID;
                table1.Col1 = "0";
                table1.Sort = 1;
                try
                {
                    Common.Services.BaseService.Create("InsertPs_Table_35PH", table1);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("增加项目出错:" + ex.Message);
                }
                UpdateFuHe(table_yd.Title, table_yd.ID,"yf");
                this.Cursor = Cursors.WaitCursor;
                treeList1.BeginUpdate();
                LoadData1(table_yd.ID);
                FoucsLocation(table_yd.ID, treeList1.Nodes);
                treeList1.EndUpdate();
                this.Cursor = Cursors.Default;
            }
        }
Пример #8
0
        private void CalcTotal(ref IList list)
        {
            //合计
            string conn = "ParentID='0' and ProjectID='" + GetProjectID + "'";

            int[] year = GetYears();
            Ps_Table_35PH parent = new Ps_Table_35PH();
            parent.ID = parent.ID + "|" + GetProjectID;
            parent.ParentID = "0"; parent.Title = "全网35千伏合计"; parent.Sort = 1000;// OperTable.GetMaxSort() + 1;
            list.Add(parent);
            totoalParent = parent.ID;
            Ps_Table_35PH tablex = new Ps_Table_35PH();
            conn = "Col1='0' and ProjectID='" + GetProjectID + "'";
            IList childx = Common.Services.BaseService.GetList("SelectPs_Table_35PHSumByConn", conn);
            tablex = (Ps_Table_35PH)childx[0];
            tablex.ParentID = parent.ID;
            tablex.ID = Guid.NewGuid().ToString();
            tablex.ID += "|" + GetProjectID;
            tablex.Sort = 1;
            tablex.Col1 = "no";
            tablex.Title = "35千伏主变供电负荷";
            list.Add(tablex);

            Ps_Table_35PH table1 = new Ps_Table_35PH();
            // Ps_Table_35PH con1 = new Ps_Table_35PH();
            // con1.Col4 = rongZai220;
            conn = "Col1='0' and ProjectID='" + GetProjectID + "'";// con1.Title = "Col1='0'";
            //IList child1 = Common.Services.BaseService.GetList("SelectPs_Table_35PHSumByConn", conn);
            table1 = (Ps_Table_35PH)tablex.Clone();// (Ps_Table_35PH)child1[0];
            for (int j = year[1]; j <= year[2]; j++)
            {
                double d = (double)table1.GetType().GetProperty("y" + j).GetValue(table1, null);
                table1.GetType().GetProperty("y" + j).SetValue(table1, Math.Round(double.Parse(rongZai220) * d, 1), null);

            }
            table1.ParentID = parent.ID;
            table1.ID = Guid.NewGuid().ToString();
            table1.ID += "|" + GetProjectID;
            table1.Sort = 2;
            table1.Col1 = "no";
            table1.Title = "35千伏需主变容量(" + rongZai220 + ")";
            list.Add(table1);

            Ps_Table_35PH table = new Ps_Table_35PH();
            //conn = "Col1='1'";
            //IList child = Common.Services.BaseService.GetList("SelectPs_Table_35PHSumByConn", conn);
            //table = (Ps_Table_35PH)child[0];
            for (int j = 0; j < list.Count; j++)
            {
                if (((Ps_Table_35PH)list[j]).Col1 == "1")
                {
                    for (int k = year[1]; k <= year[2]; k++)
                    {
                        table.GetType().GetProperty("y" + k).SetValue(table, double.Parse(table.GetType().GetProperty("y" + k).GetValue(table, null).ToString()) + double.Parse(((Ps_Table_35PH)list[j]).GetType().GetProperty("y" + k).GetValue(((Ps_Table_35PH)list[j]), null).ToString()), null);
                    }
                }
            }
            table.ParentID = parent.ID;
            table.ID = Guid.NewGuid().ToString();
            table.ID += "|" + GetProjectID;
            table.Sort = 3;
            table.Col1 = "no";
            table.Title = "35千伏主变总容量";
            list.Add(table);

            //IList allChild = Common.Services.BaseService.GetList("SelectPs_Table_35PHListByConn", conn);
            for (int k = 0; k < list.Count; k++)
            {
                if (((Ps_Table_35PH)list[k]).Col1 == "1")
                {
                    Ps_Table_35PH ps1 = new Ps_Table_35PH();

                    ps1 = (Ps_Table_35PH)((Ps_Table_35PH)list[k]).Clone();
                    ps1.ID = Guid.NewGuid().ToString();
                    ps1.ID += "|" + GetProjectID;
                    ps1.ParentID = parent.ID;
                    ps1.Col1 = "no";
                    ps1.BuildEd = "total";
                    list.Add(ps1);
                }
            }

            //conn = "Col1='0'";
            //Ps_Table_35PH temp1 = (Ps_Table_35PH)Common.Services.BaseService.GetList("SelectPs_Table_35PHListByConn", conn)[0];
            Ps_Table_35PH table2 = new Ps_Table_35PH();
            for (int j = year[1]; j <= year[2]; j++)
            {
                double d = (double)tablex.GetType().GetProperty("y" + j).GetValue(tablex, null);
                if (d != 0.0)
                {
                    double chu = (double)table.GetType().GetProperty("y" + j).GetValue(table, null);
                    table2.GetType().GetProperty("y" + j).SetValue(table2, Math.Round(chu / d, 1), null);
                }
            }
            table2.ParentID = parent.ID;
            table2.ID = Guid.NewGuid().ToString();
            table2.ID += "|" + GetProjectID;
            table2.Sort = 1000;
            table2.Col1 = "no";
            table2.Title = "35千伏容载比";
            list.Add(table2);
        }
Пример #9
0
        //删除
        private void barButtonItem3_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")
            {
                string conn = "ParentID='" + treeList1.FocusedNode.GetValue("ID").ToString() + "' and Col1='1'";
                IList list = Common.Services.BaseService.GetList("SelectPs_Table_35PHListByConn", conn);
                if (list.Count > 0)
                {
                    MsgBox.Show("这条记录下面有子记录,请先删除子记录!");
                    return;
                }
            }
            if (treeList1.FocusedNode.GetValue("Col1").ToString() == "no")
            {
                MsgBox.Show("不能删除此行!");
                return;
            }

            if (MsgBox.ShowYesNo("是否删除 " + treeList1.FocusedNode.GetValue("Title") + "?") == DialogResult.Yes)
            {
                try
                {
                    Ps_Table_35PH ny = new Ps_Table_35PH();
                    ny.ID = treeList1.FocusedNode.GetValue("ID").ToString();

                    string teID = "";
                    try
                    {
                        teID = treeList1.FocusedNode.NextNode.GetValue("ID").ToString();
                    }
                    catch { }
                    string pare = treeList1.FocusedNode.GetValue("ParentID").ToString();
                    Common.Services.BaseService.Delete(ny);
                    DelAll(ny.ID);
                    if (pare != "0")
                        LoadData1(pare);// 1(ny.ParentID);
                    else
                        LoadData1(ny.ID);

                    FoucsLocation(teID, treeList1.Nodes);
                }
                catch { }
            }
        }
Пример #10
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;
            }

            Ps_YearRange range = oper.GetYearRange("Col5='" + GetProjectID + "' and Col4='" + OperTable.ph110 + "'");
            Ps_Table_35PH table = new Ps_Table_35PH();
            table.ID += "|" + GetProjectID;
            FrmPsNew frm = new FrmPsNew();
            frm.GetProject = GetProjectID;
            frm.ParentID = table.ID;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                table.Title = frm.GetTitle;
                if (focusedNode.GetValue("ParentID").ToString() == "0")
                {
                    table.ParentID = focusedNode.GetValue("ID").ToString();
                }
                else
                    table.ParentID = focusedNode.GetValue("ParentID").ToString();
                table.Col1 = "1";
                table.ProjectID = GetProjectID;
                table.Sort = OperTable.Get35MaxSort()+ 1;
                if (table.Sort < 4)
                    table.Sort = 4;
                int sYear = int.Parse(frm.GetYear);
                for (int i = sYear; i <= range.EndYear; i++)
                {
                    table.GetType().GetProperty("y" + i.ToString()).SetValue(table, double.Parse(frm.GetVolumn), null);
                }
                try
                {
                    Common.Services.BaseService.Create("InsertPs_Table_35PH", table);
                    //dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table, dataTable.NewRow()));
                    LoadData1(table.ParentID);
                    FoucsLocation(table.ID, treeList1.Nodes);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("增加项目出错:" + ex.Message);
                }
            }
            //FrmChangeBian frm = new FrmChangeBian();
            //frm.Text = "增加" + focusedNode.GetValue("Title") + "的子项目";
            //Hashtable ht = new Hashtable();
            //for (int i = range.StartYear; i <= range.FinishYear; i++)
            //{
            //    ht.Add("y" + i.ToString(), focusedNode.GetValue("y" + i.ToString()).ToString());
            //}
            //frm.TextAttr = ht;
            //if(frm.ShowDialog() == DialogResult.OK)
            //{
            //    Ps_Table_35PH table = new Ps_Table_35PH();
            //    table.Title = frm.Title;
            //    table.ParentID = focusedNode.GetValue("ID").ToString();
            //    for (int i = range.StartYear; i <= range.FinishYear; i++)
            //    {
            //        table.GetType().GetProperty("y" + i.ToString()).SetValue(table, Convert.ToDouble(frm.TextAttr["y" + i.ToString()]), null);
            //    }
            //    double end = Convert.ToDouble(frm.TextAttr["y" + range.FinishYear.ToString()]);
            //    for (int j = range.FinishYear + 1; j <= range.EndYear; j++)
            //    {
            //        table.GetType().GetProperty("y" + j.ToString()).SetValue(table, end, null);
            //    }
            //    table.Col1 = "1";
            //    table.Sort = OperTable.GetMaxSort() + 1;
            //    try
            //    {
            //        Common.Services.BaseService.Create("InsertPs_Table_35PH", table);
            //        //dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table, dataTable.NewRow()));
            //        LoadData();
            //    }
            //    catch(Exception ex)
            //    {
            //        MsgBox.Show("增加项目出错:" + ex.Message);
            //    }
            //}
        }
Пример #11
0
        //添加地区
        private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (!base.AddRight)
            {
                MsgBox.Show("您没有权限进行此项操作!");
                return;
            }
            TreeListNode focusedNode = treeList1.FocusedNode;
            FrmAddPN frm = new FrmAddPN();
            frm.SetCheckVisible();
            frm.SetCheckText("不计特殊");
            frm.checkEdit1.Visible = false;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                string title = frm.ParentName;
                string connstr=" Title='"+title+"' and ProjectID='"+GetProjectID+"'";
                IList templist = Common.Services.BaseService.GetList("SelectPs_Table_35PHListByConn", connstr);
                if (templist.Count>0)
                {
                    MessageBox.Show(title + " 地区已存在!", "提示");
                    return;
                }
                Ps_Table_35PH table_yd = new Ps_Table_35PH();
                table_yd.ID += "|" + GetProjectID;
                table_yd.Title = frm.ParentName;
                table_yd.ParentID = "0";
                table_yd.Sort = OperTable.Get35MaxSort() + 1;
                table_yd.ProjectID = GetProjectID;
                try
                {
                    Common.Services.BaseService.Create("InsertPs_Table_35PH", table_yd);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("增加分类出错:" + ex.Message);
                    return;
                }
                string[] lei = new string[14] { "最大供电负荷", "110kV主变10kV侧直供负荷", "当地电厂10kV及以下供电能力", "其中35kV大用户负荷", "需35kV降压供电负荷", "年初已有35kV降压变电容量", "年初综合容载比", "需35kV变电容量", "本区变电容量盈亏", "目前已立项的变电容量", "规划新增变电容量", "当年末合计35kV变电容量", "年末容载比", "备注" };
                for (int i = 0; i < lei.Length; i++)
                {
                    string parentID = "";
                    Ps_Table_35PH table1 = new Ps_Table_35PH();
                    table1.ID += "|" + GetProjectID;
                    parentID = table1.ID;
                    table1.Title = lei[i];
                    table1.ParentID = table_yd.ID;
                    table1.ProjectID = GetProjectID;
                    table1.Col1 = "0";
                    if (frm.BCheck)
                        table1.Col2 = "no";
                    else
                        table1.Col2 = "no1";
                    table1.Sort = i + 1;
                    try
                    {
                        Common.Services.BaseService.Create("InsertPs_Table_35PH", table1);
                    }
                    catch (Exception ex)
                    {
                        MsgBox.Show("增加项目出错:" + ex.Message);
                        return;
                    }
                    if (lei[i].ToString() == "目前已立项的变电容量")
                    {
                        //根据地区计算相应结果填入
                        IList yllist = Common.Services.BaseService.GetList("SelectPs_Table_35PHListByConn", " ID='" + table1.ID + "' and ProjectID='" + GetProjectID + "'");
                        Ps_Table_35PH psr = yllist[0] as Ps_Table_35PH;
                        string AreaName = title;
                        for (int j = yAnge.BeginYear; j <= yAnge.EndYear; j++)
                        {
                            string year=j.ToString();
                             string con = "and a.BuildEd='" + year + "' and a.ProjectID='" + ProjectUID + "' and a.AreaName='" + AreaName + "' and substring(a.BianInfo,1,charindex('@',a.BianInfo,0)-1)='35'";
                             double vol = Convert.ToDouble(Common.Services.BaseService.GetObject("SelectTZGSsubLL", con));
                            psr.GetType().GetProperty("y" + j.ToString()).SetValue(psr, Math.Round(vol, 2), null);
                        }
                        try
                        {
                            Common.Services.BaseService.Update<Ps_Table_35PH>(psr);
                        }
                        catch (Exception ex)
                        {
                            MsgBox.Show("计算已立项的变电容量出错:" + ex.Message);
                            return;
                        }
                    }
                }
                //UpdateFuHe(table_yd.Title, table_yd.ID,"yf");
                this.Cursor = Cursors.WaitCursor;
                treeList1.BeginUpdate();
                LoadData();
                FoucsLocation(table_yd.ID, treeList1.Nodes);
                treeList1.EndUpdate();

                this.Cursor = Cursors.Default;
            }
        }
Пример #12
0
        //设置容载比
        private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string tempID = treeList1.FocusedNode.GetValue("ID").ToString();
            FrmRZ frm = new FrmRZ();
            string conn = "ParentID='0' and ProjectID='" + GetProjectID + "'";
            IList pareList = Common.Services.BaseService.GetList("SelectPs_Table_35PHListByConn", conn);
            for (int i = 0; i < pareList.Count; i++)
            {
                string by = ((Ps_Table_35PH)pareList[i]).BuildYear;
                if (by == null || by == "")
                    ((Ps_Table_35PH)pareList[i]).BuildYear = rongZai110; ;
            }
            frm.BindList = pareList;
            frm.BRst = false;
            frm.RZ = rongZai110;
            if (frm.ShowDialog() == DialogResult.OK)
            {
               //更新容载比

                string connstr = "ProjectID='" + GetProjectID + "' and ParentID='0'";
                IList pList = Common.Services.BaseService.GetList("SelectPs_Table_35PHListByConn", connstr);
                for (int k = 0; k < pList.Count; k++)
                {

                    Ps_Table_35PH table = new Ps_Table_35PH();
                    //DataTable temptable = new DataTable();
                    string rzconn = "ProjectID='" + GetProjectID + "'  and Title = '年末容载比'  and ParentID='" + ((Ps_Table_35PH)pList[k]).ID.ToString() + "'";
                    IList rzlist = Common.Services.BaseService.GetList("SelectPs_Table_35PHListByConn", rzconn);
                   // Ps_Table_35PH table =(Ps_Table_35PH)Itop.Common.DataConverter.ToDataTable(rzlist, typeof(Ps_Table_35PH));
                    Ps_YearRange range = yAnge;
                    table.ID = ((Ps_Table_35PH)rzlist[0]).ID.ToString();
                    table.Title = ((Ps_Table_35PH)rzlist[0]).Title.ToString();
                    table.Sort = ((Ps_Table_35PH)rzlist[0]).Sort;
                    table.ProjectID = GetProjectID;
                    table.ParentID = ((Ps_Table_35PH)rzlist[0]).ParentID.ToString();
                    table.Col1 = ((Ps_Table_35PH)rzlist[0]).Col1.ToString();
                    table.Col2 = ((Ps_Table_35PH)rzlist[0]).Col2.ToString();
                    double tempdb=double.Parse(((Ps_Table_35PH)pList[k]).BuildYear.ToString());
                    for (int i = range.StartYear; i <= range.FinishYear; i++)
                    {
                        table.GetType().GetProperty("y" + i.ToString()).SetValue(table,tempdb , null);
                    }

                    for (int j = range.FinishYear + 1; j <= range.EndYear; j++)
                    {
                        table.GetType().GetProperty("y" + j.ToString()).SetValue(table, tempdb, null);
                    }
                    try
                    {
                        Common.Services.BaseService.Update("UpdatePs_Table_35PH", table);
                    }
                    catch (Exception ew)
                    {

                        MessageBox.Show("设置容载比出错!" + ew.Message);
                    }
                    //更新相关数据关系
                    DataChange(table.Sort, table.ID, table.ParentID);

                }

                RongZai110 = frm.RZ;
                LoadData();
                FoucsLocation(tempID, treeList1.Nodes);
            }
        }
Пример #13
0
        //删除
        private void barButtonItem3_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;
            }
            else
            {
                if (MsgBox.ShowYesNo("是否删除 " + treeList1.FocusedNode.GetValue("Title") + " 地区记录?") == DialogResult.Yes)
                {
                    try
                    {
                        Ps_Table_35PH ny = new Ps_Table_35PH();
                        ny.ID = treeList1.FocusedNode.GetValue("ID").ToString();
                        string teID = "";
                        try
                        {
                            teID = treeList1.FocusedNode.NextNode.GetValue("ID").ToString();
                        }
                        catch { }
                        string pare = treeList1.FocusedNode.GetValue("ParentID").ToString();
                        Common.Services.BaseService.Delete(ny);
                        DelAll(ny.ID);
                        //if (pare != "0")
                        //    LoadData1(pare);// 1(ny.ParentID);
                        //else
                        //    LoadData1(ny.ID);
                        LoadData();

                        FoucsLocation(teID, treeList1.Nodes);
                    }
                    catch { }
                }
            }
        }