Esempio n. 1
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_35Result table_yd = new Ps_Table_35Result();
                table_yd.ID += "|" + GetProjectID;
                table_yd.Title = frm.ParentName;
                table_yd.ParentID = "0";
                table_yd.Sort = OperTable.Get35ResultMaxSort() + 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_35Result", table_yd);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("增加城区出错:" + ex.Message);
                }
                string[] lei = new string[7] { "一、负荷", "二、10千伏及以下地方电源出力", "三、10千伏及以下外网送入电力", "四、10千伏及以下送出外网电力", "五、220千伏变电站10KV出线供电负荷", "六、110千伏变电站10KV出线供电负荷", "七、35千伏供电负荷" };
                for (int i = 0; i < lei.Length; i++)
                {
                    Ps_Table_35Result table1 = new Ps_Table_35Result();
                    table1.ID += "|" + GetProjectID;
                    table1.Title = lei[i];
                    table1.ParentID = table_yd.ID;
                    table1.ProjectID = GetProjectID;
                    table1.Col1 = Convert.ToString(i+1);
                    if (i == 6)
                    {
                        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_35Result", 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. 2
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")
            {
                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_35Result table1 = new Ps_Table_35Result();
               // Class1.TreeNodeToDataObject<PSP_Types>(psp_Type, treeList1.FocusedNode);
                table1.ID = treeList1.FocusedNode.GetValue("ID").ToString();

                try
                {
                    //DeletePSP_ValuesByType里面删除数据和分类
                    Common.Services.BaseService.Delete <Ps_Table_35Result>(table1);//("DeletePs_Table_35Result", 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. 3
0
 public void AddModelChild(string id,string pid)
 {
     Ps_Table_35Result table1 = new Ps_Table_35Result();
     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_35Result table3 = new Ps_Table_35Result();
     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_35Result table2 = new Ps_Table_35Result();
     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_35Result", table1);
     Common.Services.BaseService.Create("InsertPs_Table_35Result", table3);
     Common.Services.BaseService.Create("InsertPs_Table_35Result", table2);
 }
Esempio n. 4
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_35Result table1 = new Ps_Table_35Result();
                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.Get35ResultMaxSort()+1;

                try
                {
                    Common.Services.BaseService.Create("InsertPs_Table_35Result", table1);
                    dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table1, dataTable.NewRow()));
                }
                catch(Exception ex)
                {
                    MsgBox.Show("增加子分类出错:" + ex.Message);
                }
            }
        }
Esempio n. 5
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")
            {
                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_35Result table1 = new Ps_Table_35Result();
                table1 = Common.Services.BaseService.GetOneByKey<Ps_Table_35Result>(treeList1.FocusedNode.GetValue("ID"));
                table1.Title = frm.ParentName;

                try
                {
                    Common.Services.BaseService.Update<Ps_Table_35Result>(table1);
                    treeList1.FocusedNode.SetValue("Title", frm.ParentName);
                }
                catch { }
                //catch(Exception ex)
                //{
                //    MsgBox.Show("修改出错:" + ex.Message);
                //}
            }
        }
Esempio n. 6
0
 public void UpdateFuHe(string pid,string col1,Ps_Table_35Result oldrs,Ps_Table_35Result newrs)
 {
     string conn = "ProjectID='" + GetProjectID + "' and Col1='"+col1+"' and ParentID='"+pid+"'";
     IList list = Common.Services.BaseService.GetList("SelectPs_Table_35ResultByConn", 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,2), null);
             list[0].GetType().GetProperty("yk" + i.ToString()).SetValue(list[0], Math.Round(myyk - oldyk + newyk,2), null);
         }
         Common.Services.BaseService.Update<Ps_Table_35Result>((Ps_Table_35Result)list[0]);
     }
 }
Esempio n. 7
0
 public void DelAll(string suid)
 {
     string conn = "ParentId='" + suid + "'";
     IList<Ps_Table_35Result> list = Common.Services.BaseService.GetList<Ps_Table_35Result>("SelectPs_Table_35ResultByConn", conn);
     if (list.Count > 0)
     {
         foreach (Ps_Table_35Result var in list)
         {
             string child = var.ID;
             DelAll(child);
             Ps_Table_35Result ny = new Ps_Table_35Result();
             ny.ID = child;
             Common.Services.BaseService.Delete(ny);
         }
     }
     else
         return;
 }
Esempio n. 8
0
        private bool SaveCellValue(string year, string typeID, double value)
        {
            Ps_Table_35Result psp = new Ps_Table_35Result();
            Ps_Table_35Result old = Common.Services.BaseService.GetOneByKey<Ps_Table_35Result>(typeID);
            psp = (Ps_Table_35Result)old.Clone();
            psp.GetType().GetProperty(year).SetValue(psp, Math.Round(value,3),null);

            try
            {
                Common.Services.BaseService.Update<Ps_Table_35Result>(psp);
            }
            catch(Exception ex)
            {
                MsgBox.Show("保存数据出错:" + ex.Message);
                return false;
            }
            return true;
        }
Esempio n. 9
0
        public void AddTotalRow(ref IList list)
        {
            //合计
            string conn = "ParentID='0' and ProjectID='" + GetProjectID + "'";

            int[] year = GetYears();
            Ps_Table_35Result parent = new Ps_Table_35Result();
            parent.ID += "|" + GetProjectID;
            parent.ParentID = "0"; parent.Title = "35千伏合计"; parent.Sort = 1000;// OperTable.GetMaxSort() + 1;
            list.Add(parent);
            totoalParent = parent.ID;
            string[] lei = new string[7] { "一、负荷合计", "二、10千伏及以下地方电源出力", "三、10千伏及以下外网送入电力", "四、10千伏及以下送出外网电力", "五、220千伏变电站10KV出线供电负荷", "六、110千伏变电站10KV出线供电负荷", "七、35千伏供电负荷" };
            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 == 6)
                {
                    conn = "Col1='no' and ProjectID='" + GetProjectID + "'";
                    conn1 = "ProjectID='" + GetProjectID + "' and Col2='no'";
                }
                Ps_Table_35Result table1 = new Ps_Table_35Result();
                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 == 6)
                    table1.Col1 = "no";
                IList tList = Common.Services.BaseService.GetList("SelectPs_Table_35ResultByConn", 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_35Result)tList[k]).GetType().GetProperty("yf" + j).GetValue((Ps_Table_35Result)tList[k], null).ToString());
                        sec += double.Parse(((Ps_Table_35Result)tList[k]).GetType().GetProperty("yk" + j).GetValue((Ps_Table_35Result)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_35ResultByConn", conn1);
               // for (int j = 0; j < cList.Count; j++)
              //  {
              //      Ps_Table_35Result tablex = new Ps_Table_35Result();
              //      tablex = (Ps_Table_35Result)((Ps_Table_35Result)cList[j]).Clone();
              //      tablex.BuildEd = "total";
              //      tablex.ParentID = table1.ID;
              //      list.Add(tablex);
             //   }
            }
        }
Esempio n. 10
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_35Result table1 = new Ps_Table_35Result();
                // 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_35Result>(table1);//("DeletePs_Table_35Result", 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;
                }
            }
        }