Пример #1
0
        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }

            if (treeList1.FocusedNode.ParentNode == null)
            {
                MsgBox.Show("一级分类为固定内容,不能删除!");
                return;
            }
            string parentid = treeList1.FocusedNode["ParentID"].ToString();
            string flag = treeList1.FocusedNode["flag"].ToString();

            if (parentid == "0" && (flag == "2" || flag == "3" || flag == "5" || flag == "7"))
            {
                MsgBox.Show("固定分类,不能删除!");
                return;
            }

            if (treeList1.FocusedNode["Title"].ToString().IndexOf("居民") > -1 && parentid == "233")
            {
                MsgBox.Show("固定分类,不能删除!");
                return;
            }

            string nodestr = treeList1.FocusedNode.GetValue("Title").ToString();
            if (nodestr == "B、城乡居民生活用电合计")
            {
                MsgBox.Show("不允许删除" + treeList1.FocusedNode.GetValue("Title").ToString() + "名称!");
                return;
            }

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

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

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

                try
                {
                    //DeletePSP_ValuesByType里面删除数据和分类
                    Common.Services.BaseService.Update("DeletePSP_ValuesByType", psp_Values);

                    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.FieldName.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;
                }
            }
        }
Пример #2
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.ParentNode == null)
            //{
            //    MsgBox.Show("一级分类为固定内容,不能删除!");
            //    return;
            //}

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

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

                try
                {
                    //DeletePSP_ValuesByType里面删除数据和分类
                    Common.Services.BaseService.Update("DeletePSP_ValuesByType", psp_Values);

                    TreeListNode brotherNode = null;
                    if (treeList1.FocusedNode.ParentNode!=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.FieldName.IndexOf("年") > 0)
                            {
                                CalculateSum(brotherNode, column);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MsgBox.Show("删除出错:" + ex.Message);
                }
            }
        }
Пример #3
0
        //��ȡ��ʷ����
        private void LoadHistoryValue()
        {
            PSP_P_Years psp_Year = new PSP_P_Years();
            psp_Year.Flag = forecastReport.ID;
            IList<PSP_P_Years> listYears = Common.Services.BaseService.GetList<PSP_P_Years>("SelectPSP_P_YearsListByFlag", psp_Year);

            foreach (PSP_P_Years item in listYears)
            {
                dataTable.Columns.Add(item.Year + "Y", typeof(double));

                TreeListColumn column = treeList1.Columns.Add();
                column.FieldName = item.Year + "Y";
                column.Tag = item.Year;
                column.VisibleIndex = -1;
            }

            PSP_Values psp_Values = new PSP_Values();
            psp_Values.ID = forecastReport.ID;//��ID�ֶδ��Flag2��ֵ

            IList<PSP_P_Values> listValues = Common.Services.BaseService.GetList<PSP_P_Values>("SelectPSP_P_ValuesListByFlag2", psp_Values);

            foreach (PSP_P_Values value in listValues)
            {
                TreeListNode node = treeList1.FindNodeByFieldValue("ID", value.TypeID);
                if (node != null)
                {
                    node.SetValue(value.Year + "Y", value.Value);

                    if (value.Year == forecastReport.StartYear)
                    {
                        node.SetValue(value.Year + "��", value.Value);
                    }
                }
            }
        }
Пример #4
0
        private void SetValuesTo0()
        {
            PSP_Values psp_Values = new PSP_Values();
            psp_Values.ID = typeFlag2;//用ID字段存放Flag2的值

            IList<PSP_Values> listValues = Common.Services.BaseService.GetList<PSP_Values>("SelectPSP_ValuesListByFlag2", psp_Values);

            foreach (PSP_Values value in listValues)
            {
                value.Value = 0;
                Common.Services.BaseService.Update<PSP_Values>(value);

            }
        }
Пример #5
0
        private bool SaveCellValue(int year, int typeID, double value)
        {
            PSP_Values PowerValues = new PSP_Values();
            PowerValues.TypeID = typeID;
            PowerValues.Value = value;
            PowerValues.Year = year;

            try
            {
                Common.Services.BaseService.Update<PowerValues>(PowerValues);
            }
            catch(Exception ex)
            {
                MsgBox.Show("保存数据出错:" + ex.Message);
                return false;
            }
            return true;
        }
Пример #6
0
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedColumn == null)
            {
                return;
            }

            //不是年份列
            if (treeList1.FocusedColumn.FieldName.IndexOf("年") == -1)
            {
                return;
            }

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

            if (MsgBox.ShowYesNo("是否删除 " + treeList1.FocusedColumn.FieldName + " 及该年的所有数据?") != DialogResult.Yes)
            {
                return;
            }

            PSP_Values psp_Values = new PSP_Values();
            psp_Values.ID = typeFlag2;//借用ID属性存放Flag2
            psp_Values.Year = (int)treeList1.FocusedColumn.Tag;

            try
            {
                //DeletePSP_ValuesByYear删除数据和年份
                int colIndex = treeList1.FocusedColumn.AbsoluteIndex;
                Common.Services.BaseService.Update("DeletePSP_ValuesByYear", psp_Values);
                dataTable.Columns.Remove(treeList1.FocusedColumn.FieldName);
                treeList1.Columns.Remove(treeList1.FocusedColumn);
                if (colIndex >= treeList1.Columns.Count)
                {
                    colIndex--;
                }
                treeList1.FocusedColumn = treeList1.Columns[colIndex];
            }
            catch (Exception ex)
            {
                MsgBox.Show("删除出错:" + ex.Message);
            }
        }
Пример #7
0
        private void ReLoadData(string baseyear)
        {
            int year = Convert.ToInt32(baseyear);
            if (dataTable != null)
            {
                dataTable.Columns.Clear();
                treeList1.Columns.Clear();
            }

            PSP_GDPTypes psp_Type = new PSP_GDPTypes();
            psp_Type.Flag2 = typeFlag2;
            IList listTypes = Common.Services.BaseService.GetList("SelectPSP_GDPTypes", null);

            dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(PSP_GDPTypes));

            treeList1.DataSource = dataTable;

            treeList1.Columns["Title"].Caption = "分类名";
            treeList1.Columns["Title"].Width = 180;
            treeList1.Columns["Title"].OptionsColumn.AllowEdit = false;
            treeList1.Columns["Title"].OptionsColumn.AllowSort = false;
            treeList1.Columns["Flag"].VisibleIndex = -1;
            treeList1.Columns["Flag"].OptionsColumn.ShowInCustomizationForm = false;
            treeList1.Columns["Flag2"].VisibleIndex = -1;
            treeList1.Columns["Flag2"].OptionsColumn.ShowInCustomizationForm = false;

            PSP_GDPYeas psp_Year = new PSP_GDPYeas();
            psp_Year.Flag = typeFlag2;
            Hashtable ha = new Hashtable();
            ha.Add("Flag", typeFlag2);
            ha.Add("Year", year);
            IList<PSP_GDPYeas> listYears = Common.Services.BaseService.GetList<PSP_GDPYeas>("SelectPSP_YeasListByFlagAndYear", ha);

            al.Clear();
                foreach (PSP_GDPYeas item in listYears)
                {
                    al.Add(item.Year);
                }

            Application.DoEvents();
            if (al.Contains(year))
            {
                PSP_GDPBaseYear byear = new PSP_GDPBaseYear();
                byear.BaseYear = baseyear;
                Common.Services.BaseService.Update("UpdatePSP_GDPBaseYearbyid", byear);
            }

            if (!al.Contains(year))
            {
                MessageBox.Show("数据库中不存在"+year+"年!");

                PSP_GDPBaseYear BaseYear = (PSP_GDPBaseYear)Common.Services.BaseService.GetObject("SelectPSP_GDPBaseYearList", null);
                if (BaseYear == null)
                {
                    ha.Clear();
                    ha.Add("Flag", typeFlag2);
                    ha.Add("Year", "1990");
                    listYears.Clear();
                  listYears = Common.Services.BaseService.GetList<PSP_GDPYeas>("SelectPSP_YeasListByFlagAndYear", ha);
                  year = 1990;

                }
                else
                {
                    ha.Clear();
                    ha.Add("Flag", typeFlag2);
                    ha.Add("Year", BaseYear.BaseYear);
                    listYears.Clear();
                     listYears = Common.Services.BaseService.GetList<PSP_GDPYeas>("SelectPSP_YeasListByFlagAndYear", ha);
                     year = Convert.ToInt32( BaseYear.BaseYear);
                }

            }

            foreach (PSP_GDPYeas item in listYears)
            {
                AddColumn(item.Year);
            }
            LoadValues(year);

            firstyearValues(year);

            foreach (PSP_GDPYeas item in listYears)
            {
                if (item.Year > year)
                {
                    ComputeValues(item.Year);
                }
            }

            PSP_Types psp_T = new PSP_Types();
            psp_T.Flag2 = typeFlag2;

            IList<PSP_Types> listT = Common.Services.BaseService.GetList<PSP_Types>("SelectPSP_TypesByFlag2", psp_T);
            PSP_Values pspval = new PSP_Values();
            pspval.TypeID = -1;
            foreach (PSP_Types psp in listT)
            {
                if (psp.Title == "人口(万人)")
                {
                    pspval.TypeID = psp.ID;
                    break;
                }
            }
            if (pspval.TypeID != -1)
            {
                ha.Clear();
                ha.Add("TypeID", pspval.TypeID);
               // ha.Add("Year", year);
                IList<PSP_Values> listvalue = Common.Services.BaseService.GetList<PSP_Values>("SelectPSP_ValuesList", ha);
                foreach (PSP_Values it in listvalue)
                {
                    if (al.Contains(it.Year))
                    {
                        if (treeList1.Nodes[2][it.Year + "年"].ToString() != "")
                        {
                            treeList1.Nodes[3].SetValue(it.Year + "年", Convert.ToDouble(treeList1.Nodes[2].GetValue(it.Year + "年")) / it.Value);
                        }
                    }
                }
            }
            foreach (PSP_GDPYeas item in listYears)
            {
                ComputeBiZhong(item.Year);
            }

            treeList1.ExpandAll();
        }
Пример #8
0
        private void InsertLineData1()
        {
            string columnname = "";

            if (treeList1.Nodes.Count == 0)
            {
                return;
            }

            IList<PSP_Values> pvlist = new List<PSP_Values>();
            pvlist.Clear();
                   try
                   {
                       DataTable dts = new DataTable();
                       OpenFileDialog op = new OpenFileDialog();
                       op.Filter = "Excel文件(*.xls)|*.xls";
                       if (op.ShowDialog() == DialogResult.OK)
                       {
                           dts = GetExcel(op.FileName);
                               //////    string LL2 = "";
                               //////    try
                               //////    {
                               //////        LL2 = dts.Rows[i][dc.ColumnName].ToString();
                               //////    }
                               //////    catch { }
                               //////m2.GetType().GetProperty(dc.ColumnName).SetValue(m2, LL2, null);
                           ArrayList al = new ArrayList();
                           al.Clear();
                           foreach (TreeListColumn tcl in treeList1.Columns)
                           {
                               al.Add(tcl.Caption);
                           }

                             foreach (DataColumn dc in dts.Columns)
                             {
                                 int j = 0;
                                   columnname = dc.ColumnName;

                                   try
                                   {
                                       if (dc.ColumnName.ToString().Substring(4,1)=="年" &&dc.ColumnName.ToString().Length == 5)
                                       {
                                           if (!al.Contains(dc.ColumnName))
                                           {
                                               NewYear(int.Parse(dc.ColumnName.ToString().Substring(0, 4)));
                                           }
                                           foreach (TreeListColumn tcl in treeList1.Columns)
                                           {
                                               try
                                               {
                                                   if (tcl.Caption.ToString().Substring(4, 1) == "年" && tcl.Caption.ToString().Length == 5)
                                                   {
                                                       if (tcl.Caption == dc.ColumnName)
                                                       {
                                                           if (MessageBox.Show(tcl.Caption + "列已经存在!是否更新此列的数据!", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                                                               continue;
                                                           for (int i = 0; i < dts.Rows.Count; i++)
                                                          {
                                                              PSP_Values m1 = new PSP_Values();
                                                              if (dts.Rows[i][dc.ColumnName].ToString() == null || dts.Rows[i][dc.ColumnName].ToString() == "")
                                                              {
                                                                  m1.Year = int.Parse(dc.ColumnName.ToString().Substring(0, 4));
                                                              }
                                                              else
                                                              {
                                                                 m1.Value = double.Parse(dts.Rows[i][dc.ColumnName].ToString());
                                                                 m1.Year = int.Parse(dc.ColumnName.ToString().Substring(0, 4));
                                                              }
                                                                m1.TypeID = int.Parse(treeList1.Nodes[j]["ID"].ToString());
                                                                pvlist.Add(m1);
                                                             if (treeList1.Nodes[j].HasChildren == true)
                                                             {
                                                                for (int m = 0; m < treeList1.Nodes[j].Nodes.Count; m++)
                                                                 {
                                                                    CalChildNode1(treeList1.Nodes[j].Nodes[m], ref i, dts, dc, ref pvlist);
                                                                 }
                                                            }
                                                           j++;
                                                          }
                                                        }
                                                    }
                                               }
                                               catch { }
                                             }
                                       }
                                       else
                                       {
                                           continue;
                                       }
                                   }
                                   catch  { }
                               }
                               foreach (PSP_Values pv in pvlist)
                                   Common.Services.BaseService.Update("UpdatePSP_Values", pv);
                       }
                       ReLoad();

                   }
                   catch { MsgBox.Show("导入格式不正确!"); }
        }
Пример #9
0
        private void DeletFixedVoltageRows(TreeListNode node)
        {
            PSP_Types psp_Type = new PSP_Types();
            psp_Type.Flag2 = typeFlag2;
            psp_Type.ID = Convert.ToInt32(node["ID"]);
            IList listTypes = Common.Services.BaseService.GetList("SelectPSP_TypesByParentID", psp_Type);
            try
            {
                foreach (PSP_Types psp_Typetemp in listTypes)
                {

                    PSP_Values psp_Values = new PSP_Values();
                    psp_Values.TypeID = psp_Typetemp.ID;

                    //DeletePSP_ValuesByType里面删除数据和分类
                    Common.Services.BaseService.Update("DeletePSP_ValuesByType", psp_Values);

                    PSP_Types psp_Type2 = new PSP_Types();
                    psp_Type2.Flag2 = typeFlag2;
                    psp_Type2.ID = psp_Typetemp.ID;
                    IList listTypes2 = Common.Services.BaseService.GetList("SelectPSP_TypesByParentID", psp_Type2);
                    foreach (PSP_Types psp_Typetemp2 in listTypes2)
                    {

                        psp_Values.TypeID = psp_Typetemp2.ID;

                        //DeletePSP_ValuesByType里面删除数据和分类
                        Common.Services.BaseService.Update("DeletePSP_ValuesByType", psp_Values);
                    }
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #10
0
        private void LoadData( string baseyear )
        {
            int year = Convert.ToInt32(baseyear);
            if (dataTable != null)
            {
                dataTable.Columns.Clear();
                treeList1.Columns.Clear();
            }

            PSP_GDPTypes psp_Type = new PSP_GDPTypes();
            psp_Type.Flag2 = typeFlag2;
            IList listTypes = Common.Services.BaseService.GetList("SelectPSP_GDPTypes", null);

            dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(PSP_GDPTypes));

            treeList1.DataSource = dataTable;

            treeList1.Columns["Title"].Caption = "分类名";
            treeList1.Columns["Title"].Width = 180;
            treeList1.Columns["Title"].OptionsColumn.AllowEdit = false;
            treeList1.Columns["Title"].OptionsColumn.AllowSort = false;
            treeList1.Columns["Flag"].VisibleIndex = -1;
            treeList1.Columns["Flag"].OptionsColumn.ShowInCustomizationForm = false;
            treeList1.Columns["Flag2"].VisibleIndex = -1;
            treeList1.Columns["Flag2"].OptionsColumn.ShowInCustomizationForm = false;

            PSP_GDPYeas psp_Year = new PSP_GDPYeas();
            psp_Year.Flag = typeFlag2;
            Hashtable ha = new Hashtable();
            ha.Add("Flag",typeFlag2);
            ha.Add("Year", year);
            IList<PSP_GDPYeas> listYears = Common.Services.BaseService.GetList<PSP_GDPYeas>("SelectPSP_YeasListByFlagAndYear", ha);
              //  PSP_YearVisibleIndex yvi = new PSP_YearVisibleIndex();
               // yvi.ModuleFlag = ModuleFlag;
               // yvi.Year = year.ToString() ;
               // IList<PSP_YearVisibleIndex> yearvisi = Common.Services.BaseService.GetList<PSP_YearVisibleIndex>("SelectPSP_YearVisibleIndexByModuleFlagSort", yvi);
            //if (yearvisi.Count == 0)
               // {
            al.Clear();
                foreach (PSP_GDPYeas item in listYears)
                {
                    AddColumn(item.Year);

                    al.Add(item.Year);
                }
               // }
               // else
            //{
            //    foreach (PSP_YearVisibleIndex item in yearvisi)
             //   {
            //        AddColumn(Convert.ToInt32(item.Year),item.VisibleIndex);
            //    }
               // }

            Application.DoEvents();

            LoadValues(year);

            firstyearValues(year);

            foreach (PSP_GDPYeas item in listYears)
            {
                if (item.Year > year)
                {

                        ComputeValues(item.Year);

                }
            }

            PSP_Types psp_T = new PSP_Types();
            psp_T.Flag2 = typeFlag2;

            IList<PSP_Types> listT = Common.Services.BaseService.GetList<PSP_Types>("SelectPSP_TypesByFlag2", psp_T);
            PSP_Values pspval = new PSP_Values();
            pspval.TypeID = -1;
            foreach (PSP_Types psp in listT)
            {
                if (psp.Title == "人口(万人)")
                {
                    pspval.TypeID = psp.ID;
                    break;
                }
            }
            if (pspval.TypeID != -1)
            {
                ha.Clear();
                ha.Add("TypeID", pspval.TypeID);
               // ha.Add("Year", year);
                IList<PSP_Values> listvalue = Common.Services.BaseService.GetList<PSP_Values>("SelectPSP_ValuesList", ha);
                foreach (PSP_Values it in listvalue)
                {
                    if (al.Contains(it.Year))
                    {
                        if (treeList1.Nodes[2][it.Year + "年"].ToString() != "")
                        {
                            treeList1.Nodes[3].SetValue(it.Year + "年",Convert.ToInt32(Convert.ToDouble(treeList1.Nodes[2].GetValue(it.Year + "年"))/ it.Value));
                        }
                    }

                }
            }
            foreach (PSP_GDPYeas item in listYears)
            {
                 ComputeBiZhong(item.Year);
            }

            LoadValues1();
            treeList1.ExpandAll();
        }
Пример #11
0
        //统计
        private void barButtonItem6_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FormChooseYears frm = new FormChooseYears();
            foreach (TreeListColumn column in treeList1.Columns)
            {
                if (column.FieldName.IndexOf("年") > 0)
                {
                    frm.ListYearsForChoose.Add((int)column.Tag);
                }
            }
            frm.NoIncreaseRate = true;
            DataTable dt = new DataTable();
            PSP_Types psp_Type = new PSP_Types();
            psp_Type.Flag2 = typeFlag2;
            IList listTypes = Common.Services.BaseService.GetList("SelectPSP_TypesByFlag2", psp_Type);
            dt = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(PSP_Types));
            PSP_Years psp_Year = new PSP_Years();
            psp_Year.Flag = typeFlag2;
            IList<PSP_Years> listYears = Common.Services.BaseService.GetList<PSP_Years>("SelectPSP_YearsListByFlag", psp_Year);

            foreach (PSP_Years item in listYears)
            {
                dt.Columns.Add(item.Year + "年", typeof(double));
            }
            PSP_Values psp_Values = new PSP_Values();
            psp_Values.ID = typeFlag2;//用ID字段存放Flag2的值

            IList<PSP_Values> listValues = Common.Services.BaseService.GetList<PSP_Values>("SelectPSP_ValuesListByFlag2", psp_Values);
            foreach (PSP_Values psptemp in listValues)
            {
                foreach (DataRow dttemp in dt.Rows)
                {
                    if (Convert.ToInt32(dttemp["ID"].ToString()) == psptemp.TypeID)
                        dttemp[psptemp.Year + "年"] = psptemp.Value;
                }
            }
            if(frm.ShowDialog() == DialogResult.OK)
            {

                FrmBalanceOfPowerRegionPrint frma = new FrmBalanceOfPowerRegionPrint();
                frma.IsSelect = _isSelect;
                frma.HASH = hash;
                frma.HASH2 = hash2;
                frma.Text = "南北区电力平衡表";

                frma.GridDataTable = ResultDataTable(dt, frm.ListChoosedYears);
                frma.ISPrint = PrintRight;
                if (frma.ShowDialog() == DialogResult.OK && _isSelect)
                {

                    DialogResult = DialogResult.OK;
                }

            }
        }
Пример #12
0
        private void Insertdata()
        {
            //LayoutList ll1 = this.ctrlLayoutList1.FocusedObject;
            //if (ll1 == null)
            //    return;

            string columnname = "";

                DataTable dts = new DataTable();
                OpenFileDialog op = new OpenFileDialog();
                op.Filter = "Excel文件(*.xls)|*.xls";
                if (op.ShowDialog() == DialogResult.OK)
                {
                    WaitDialogForm wait = new WaitDialogForm("", "正在导入数据, 请稍候...");
                   try
            {
                    dts = GetExcel(op.FileName);
                    IList<PSP_Types> lii = new List<PSP_Types>();
                    IList<PSP_Values> liiValues = new List<PSP_Values>();
                    DateTime s8 = DateTime.Now;
                    PSP_Values psp_Values = new PSP_Values();
                    int x = 0;
                    for (int i = 0; i < dts.Rows.Count; i++)
                    {

                        this.Cursor = Cursors.WaitCursor;
                        PSP_Types l1 = new PSP_Types();

                        l1.ID = i;
                        l1.Flag2 = typeFlag2;
                        l1.ProjectID = ProjectUID;
                        foreach (DataColumn dc in dts.Columns)
                        {
                            columnname = dc.ColumnName;
                            //if (dts.Rows[i][dc.ColumnName].ToString() == "")
                            //    continue;
                            psp_Values = new PSP_Values();
                            switch (dc.ColumnName)
                            {
                                case "Title":

                                    l1.GetType().GetProperty(dc.ColumnName).SetValue(l1, dts.Rows[i][dc.ColumnName], null);
                                    break;

                                case "ParentID":

                                    if (dts.Rows[i][dc.ColumnName] == null || dts.Rows[i][dc.ColumnName].ToString() == "" || dts.Rows[i][dc.ColumnName] == DBNull.Value)
                                    {
                                        l1.GetType().GetProperty(dc.ColumnName).SetValue(l1, 0, null);
                                        break;
                                    }
                                    l1.GetType().GetProperty(dc.ColumnName).SetValue(l1, Convert.ToInt32(dts.Rows[i][dc.ColumnName]), null);
                                    break;

                                default:
                                    if (dts.Rows[i][dc.ColumnName] == null || dts.Rows[i][dc.ColumnName].ToString() == "" || dts.Rows[i][dc.ColumnName] == DBNull.Value)
                                    {
                                        psp_Values.Value = 0;

                                    }
                                    else
                                    psp_Values.Value= Convert.ToDouble(dts.Rows[i][dc.ColumnName]);
                                    psp_Values.Year = Convert.ToInt32(dc.ColumnName.Replace("年",""));
                                    psp_Values.TypeID = i;
                                    psp_Values.ID = typeFlag2;
                                    liiValues.Add(psp_Values);

                                    break;
                            }
                        }

                        lii.Add(l1);

                    }
                    int parenti = -4;
                    //foreach (Ps_History l1 in lii)
                    PSP_Types psl1;
                    PSP_Values psp_values;

                    int ti = 0;
                    for (int i = 0,j=0; i < lii.Count; i++)
                    {

                        psl1 = lii[i];

                        ti = psl1.ID;
                        string con = "Flag2='" + typeFlag2 + "' and Title='" + psl1.Title + "'and ParentID ='" + psl1.ParentID + "' and ProjectID='"+ProjectUID+"'";
                        object obj = Services.BaseService.GetObject("SelectPSP_TypesByWhere", con);
                        if (obj != null)
                        {
                            psl1.ID = ((PSP_Types)obj).ID;

                            if (psl1.ParentID < 0)
                            {
                                psl1.ParentID = ((PSP_Types)obj).ParentID;
                                psl1.Flag = ((PSP_Types)obj).Flag;
                            }
                            Services.BaseService.Update<PSP_Types>(psl1);
                        }
                        else
                        {
                           Services.BaseService.Create<PSP_Types>(psl1);
                           obj = Services.BaseService.GetObject("SelectPSP_TypesByWhere", con);
                           if (obj != null)
                           {
                               psl1.ID = ((PSP_Types)obj).ID;

                           }
                        }
                        for (int jtemp = i + 1; jtemp < lii.Count; jtemp++)
                        {
                            if (lii[jtemp].ParentID == parenti)
                            {
                                lii[jtemp].ParentID = psl1.ID;

                                lii[jtemp].Flag = psl1.Flag;
                            }
                        }

                        for (; j < liiValues.Count; j++)
                        {
                            psp_values = liiValues[j];
                            if (psp_values.TypeID > ti)
                                break;

                            con = "TypeID='" + psl1.ID + "' and Year='" + psp_values.Year + "'";
                            obj = Services.BaseService.GetObject("SelectPSP_ValuesByWhere", con);
                            psp_values.TypeID = psl1.ID;
                            if (obj != null)
                            {
                                psp_values.ID = ((PSP_Values)obj).ID;

                                Services.BaseService.Update<PSP_Values>(psp_values);
                            }
                            else
                            {

                                Services.BaseService.Create<PSP_Values>(psp_values);
                            }
                        }

                        parenti--;
                    }

                    this.Cursor = Cursors.Default;

                    wait.Close();
                    treeList1.BeginUpdate();
                    LoadData();
                    treeList1.EndUpdate();
                    MsgBox.Show("导入成功!");
                }
                catch (Exception ex)
                {
                    this.Cursor = Cursors.Default;
                    wait.Close();
                    MsgBox.Show(columnname + ex.Message); MsgBox.Show("导入格式不正确!");
                }
                }
        }
Пример #13
0
        private void barButtonItem9_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (MsgBox.ShowYesNo("该操作将清除所有数据,清除数据以后无法恢复,可能对其他用户的数据产生影响,请谨慎操作,你确定继续吗?") == DialogResult.No)
                return;
            PSP_Types psp_Type = new PSP_Types();
            PSP_Values psp_Values = new PSP_Values();
            foreach (DataRow dr  in dataTable.Rows)
            {
                if (dr["Title"].ToString().Contains("全社会"))
                    continue;

               // Class1.TreeNodeToDataObject<PSP_Types>(psp_Type, treeList1.FocusedNode);

                psp_Values.TypeID = Convert.ToInt32(dr["id"]);
                //DeletePSP_ValuesByType里面删除数据和分类

                Common.Services.BaseService.Update("DeletePSP_ValuesByType", psp_Values);

            }
            Application.DoEvents();
            SetValuesTo0();
            this.Cursor = Cursors.WaitCursor;
            treeList1.BeginUpdate();
            LoadData();
            treeList1.EndUpdate();
            this.Cursor = Cursors.Default;
        }
Пример #14
0
        private void NewDemandLata2(ref DataTable datatemp)
        {
            PSP_Types psp_Type = new PSP_Types();
            psp_Type.Flag2 = 1;
            IList listTypes = Common.Services.BaseService.GetList("SelectPSP_TypesByFlag2", psp_Type);
            foreach (PSP_Types psptemp in listTypes)
            {
                if (psptemp.Title != "")
                    if (!psptemp.Title.Contains("ȫ����õ���"))
                        continue;
                IList listTypes2 = Common.Services.BaseService.GetList("SelectPSP_TypesByParentID", psptemp);
                foreach (PSP_Types psptemp2 in listTypes2)
                {
                    if (psptemp2.Title.Contains("ȫ��ҵ�õ�ϼ�"))
                    {
                        IList listTypes3 = Common.Services.BaseService.GetList("SelectPSP_TypesByParentID", psptemp2);
                        foreach (PSP_Types psptemp3 in listTypes3)
                        {
                            DataRow dt = datatemp.NewRow();
                            dt["Title"] = psptemp3.Title;
                            dt["TypeID"] = psptemp3.ID;
                            datatemp.Rows.Add(dt);
                        }
                    }
                    else if (psptemp2.Title.Contains("������������õ�ϼ�"))
                    {
                        DataRow dt = datatemp.NewRow();
                        dt["Title"] = psptemp2.Title;
                        dt["TypeID"] = psptemp2.ID;
                        datatemp.Rows.Add(dt);
                    }
                }
            }
            PSP_Values psp_Values = new PSP_Values();
            psp_Values.ID = 1;//��ID�ֶδ��Flag2��ֵ

            IList<PSP_Values> listValues = Common.Services.BaseService.GetList<PSP_Values>("SelectPSP_ValuesListByFlag2", psp_Values);

            foreach (PSP_Values value in listValues)
            {
                DataRow[] drselc = datatemp.Select("TypeID=" + value.TypeID);
                  if(drselc!=null)
                      if (drselc.Length == 1)
                      {
                          if (datatemp.Columns.Contains(value.Year + "��"))
                          {
                              drselc[0][value.Year + "��"] = value.Value;

                          }

                      }

            }
        }
Пример #15
0
        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }

            if (treeList1.FocusedNode.ParentNode == null)
            {
                MsgBox.Show("һ������Ϊ�̶����ݣ�����ɾ����");
                return;
            }

            if (treeList1.FocusedNode.HasChildren)
            {
                MsgBox.Show("�˷��������ӷ��࣬����ɾ���ӷ��࣡");
                return;
            }

            if (!base.DeleteRight)
            {
                MsgBox.Show("��û��Ȩ�޽��д��������");
                return;
            }

            if (MsgBox.ShowYesNo("�Ƿ�ɾ������ " + treeList1.FocusedNode.GetValue("Title") + "��") == DialogResult.Yes)
            {
                PSP_Types psp_Type = new PSP_Types();
                Class1.TreeNodeToDataObject<PSP_Types>(psp_Type, treeList1.FocusedNode);
                PSP_Values psp_Values = new PSP_Values();
                psp_Values.TypeID = psp_Type.ID;

                try
                {
                    //DeletePSP_ValuesByType����ɾ�����ݺͷ���
                    Common.Services.BaseService.Update("DeletePSP_ValuesByType", psp_Values);

                    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.FieldName.IndexOf("��") > 0)
                            {
                                CalculateSum(brotherNode, column);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MsgBox.Show("ɾ�������" + ex.Message);
                }
            }
        }
Пример #16
0
        //��ȡ����
        private void LoadValues1(Hashtable htt)
        {
            PSP_Values psp_Values = new PSP_Values();
            psp_Values.ID = typeFlag2;//��ID�ֶδ��Flag2��ֵ

            IList<PSP_Values> listValues = Common.Services.BaseService.GetList<PSP_Values>("SelectPSP_ValuesListByFlag2", psp_Values);

            foreach (PSP_Values value in listValues)
            {
                if (!htt.ContainsValue(value.Year))
                    continue;

                TreeListNode node = treeList1.FindNodeByFieldValue("ID", value.TypeID);
                if (node != null)
                {
                    node.SetValue(value.Year + "��", value.Value);
                }
            }
        }
Пример #17
0
        private void barButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string baseyear = "";
            baseyear = EnsureBaseYear(baseyear);
            if (treeList1.FocusedColumn == null)
            {
                return;
            }

            //���������
            if (treeList1.FocusedColumn.FieldName.IndexOf("��") == -1)
            {
                return;
            }
            if (treeList1.FocusedColumn.FieldName.Contains(baseyear) && baseyear != "")
            {
                return;
            }
            if (!base.DeleteRight)
            {
                MsgBox.Show("��û��Ȩ�޽��д��������");
                return;
            }

            if (MsgBox.ShowYesNo("�Ƿ�ɾ�� " + treeList1.FocusedColumn.FieldName + " ��������������ݣ�") != DialogResult.Yes)
            {
                return;
            }

            PSP_Values psp_Values = new PSP_Values();
            psp_Values.ID = typeFlag2;//����ID���Դ��Flag2
            psp_Values.Year = (int)treeList1.FocusedColumn.Tag;

            try
            {
                //DeletePSP_ValuesByYearɾ�����ݺ����
                int colIndex = treeList1.FocusedColumn.AbsoluteIndex;
                Common.Services.BaseService.Update("DeletePSP_ValuesByYear", psp_Values);
                dataTable.Columns.Remove(treeList1.FocusedColumn.FieldName);
                treeList1.Columns.Remove(treeList1.FocusedColumn);

                if (colIndex >= treeList1.Columns.Count)
                {
                    colIndex--;
                }
                treeList1.FocusedColumn = treeList1.Columns[colIndex];
            }
            catch (Exception ex)
            {
                MsgBox.Show("ɾ�������" + ex.Message);
            }
        }
Пример #18
0
        //读取数据
        private void LoadValues()
        {
            PSP_Values psp_Values = new PSP_Values();
            psp_Values.ID = typeFlag2;//用ID字段存放Flag2的值

            IList<PSP_Values> listValues = Common.Services.BaseService.GetList<PSP_Values>("SelectPSP_ValuesListByFlag2", psp_Values);

            foreach(PSP_Values value in listValues)
            {
                TreeListNode node = treeList1.FindNodeByFieldValue("ID", value.TypeID);
                if(node != null)
                {
                    node.SetValue(value.Year + "年", value.Value);
                }
            }
        }
Пример #19
0
        //��ȡ����
        private void LoadValues(bool Isfirstload)
        {
            string baseyear = "";
            baseyear = EnsureBaseYear(baseyear);
            PSP_Values psp_Values = new PSP_Values();
            IList<PSP_Values> listValues;
            if (baseyear == "")
            {
                psp_Values.ID = typeFlag2;//��ID�ֶδ��Flag2��ֵ
                listValues = Common.Services.BaseService.GetList<PSP_Values>("SelectPSP_ValuesListByFlag2", psp_Values);

            }
            else
            {
                Hashtable ha = new Hashtable();
                ha.Add("ID", typeFlag2);
                ha.Add("Year", Convert.ToInt32(baseyear));
                listValues = Common.Services.BaseService.GetList<PSP_Values>("SelectPSP_ValuesListByFlag2Year", ha);
            }
            foreach (PSP_Values value in listValues)
            {

                TreeListNode node = treeList1.FindNodeByFieldValue("ID", value.TypeID);
                if (node != null)
                {

                    if(Isfirstload) node.SetValue(value.Year + "��",Math.Round(value.Value,2));
                    SetRateYearValue(node, Math.Round(value.Value,2));
                }
            }
        }
Пример #20
0
        private void barButtonItem14_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }

            //if(treeList1.FocusedNode.ParentNode == null)
            //{
            //    MsgBox.Show("一级分类为固定内容,不能删除!");
            //    return;
            //}

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

            if (MsgBox.ShowYesNo("是否删除项目 " + treeList1.FocusedNode.GetValue("Title") + "?") == DialogResult.Yes)
            {
               // PSP_PowerTypes_Liao psp_Type = new PSP_PowerTypes_Liao();
               // Class1.TreeNodeToDataObject<PSP_PowerTypes_Liao>(psp_Type, treeList1.FocusedNode);
                PSP_Values PowerValues = new PSP_Values();
                PowerValues.TypeID = int.Parse(treeList1.FocusedNode["ID"].ToString());

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

                    Common.Services.BaseService.Update("DeletePSP_ValuesByType", PowerValues);

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

                    //删除后,如果同级还有其它分类,则重新计算此类的所有年份数据

                    if (brotherNode != null)
                    {
                        foreach (TreeListColumn column in treeList1.Columns)
                        {
                            if (column.FieldName.IndexOf("年") > 0)
                            {
                                CalculateSum(brotherNode, column);
                            }
                        }
                    }
                }
                catch //(Exception ex)
                {
                    //MsgBox.Show("删除出错:" + ex.Message);
                }
            }
        }
Пример #21
0
        //读取历史数据
        private void LoadHistoryValue()
        {
            IList<PSP_P_Years> listYears;
            if (!formselect)
            {
                PSP_P_Years psp_Year = new PSP_P_Years();
                psp_Year.Flag = forecastReport.ID;
                listYears = Common.Services.BaseService.GetList<PSP_P_Years>("SelectPSP_P_YearsListByFlag", psp_Year);
            }

            else
            {
                PSP_P_Years psp_Year = new PSP_P_Years();

                psp_Year.Flag = forecastReport.ID;

                psp_Year.Flag2 = typeFlag;
                listYears = Common.Services.BaseService.GetList<PSP_P_Years>("SelectPSP_P_YearsListhaveflag2ByFlag", psp_Year);

            }
                foreach (PSP_P_Years item in listYears)
                {
                    try
                    {
                        dataTable2.Columns.Add(item.Year + "Y", typeof(double));

                        TreeListColumn column = treeList2.Columns.Add();
                        column.FieldName = item.Year + "Y";
                        column.Tag = item.Year;
                        column.VisibleIndex = -1;
                    }
                    catch { }
                }

                PSP_Values psp_Values = new PSP_Values();
                psp_Values.ID = forecastReport.ID;//用ID字段存放Flag2的值

                IList<PSP_P_Values> listValues = Common.Services.BaseService.GetList<PSP_P_Values>("SelectPSP_P_ValuesListByFlag2", psp_Values);

                foreach (PSP_P_Values value in listValues)
                {
                    TreeListNode node = treeList2.FindNodeByFieldValue("ID", value.TypeID);
                    if (node != null)
                    {
                        node.SetValue(value.Year + "Y", value.Value);

                        if (value.Year == forecastReport.StartYear)
                        {
                            node.SetValue(value.Year + "年", value.Value);
                        }
                    }
                }
        }
Пример #22
0
 private void CalChildNode1(TreeListNode node,ref int i,DataTable dt,DataColumn dc, ref IList<PSP_Values> psplist)
 {
     i++;
     PSP_Values m1=new PSP_Values();
     if (dt.Rows[i][dc.ColumnName].ToString() == null || dt.Rows[i][dc.ColumnName].ToString() == "")
      {
          m1.Year = int.Parse(dc.ColumnName.ToString().Substring(0, 4));
      }
     else
      {
          m1.Value = double.Parse(dt.Rows[i][dc.ColumnName].ToString());
          m1.Year = int.Parse(dc.ColumnName.ToString().Substring(0, 4));
      }
      m1.TypeID =int.Parse(node["ID"].ToString());
      psplist.Add(m1);
      for (int m = 0; m < node.Nodes.Count; m++)
         {
             CalChildNode1(node.Nodes[m], ref i, dt, dc,ref psplist);
         }
 }
Пример #23
0
        //��ȡ��ʷ����
        private void LoadHistoryValue()
        {
            PSP_Years psp_Year = new PSP_Years();
            psp_Year.Flag = 1;
            IList<PSP_Years> listYears = Common.Services.BaseService.GetList<PSP_Years>("SelectPSP_YearsListByFlag", psp_Year);
            Hashtable ht = new Hashtable();
            foreach (PSP_Years item in listYears)
            {
                dataTable.Columns.Add(item.Year + "Y", typeof(double));

                TreeListColumn column = treeList1.Columns.Add();
                column.FieldName = item.Year + "Y";
                column.Tag = item.Year;
                column.VisibleIndex = -1;
                if (!ht.ContainsKey(item.Year + "Y"))
                    ht.Add(item.Year + "Y", "");
            }

            PSP_Values psp_Values = new PSP_Values();

            foreach (DataRow dr in dataTable.Rows)
            {
                psp_Values.TypeID = (int)dr["ID"];

                IList<PSP_Values> listValues = Common.Services.BaseService.GetList<PSP_Values>("SelectPSP_ValuesList", psp_Values);

                foreach (PSP_Values value in listValues)
                {
                    TreeListNode node = treeList1.FindNodeByFieldValue("ID", value.TypeID);
                    if (node != null)
                    {

                        if (!ht.ContainsKey(value.Year + "Y"))
                        {
                            dataTable.Columns.Add(value.Year + "Y", typeof(double));
                            TreeListColumn column = treeList1.Columns.Add();
                            column.FieldName = value.Year + "Y";
                            column.Tag = value.Year;
                            column.VisibleIndex = -1;
                            ht.Add(value.Year + "Y", "");
                        }

                        node.SetValue(value.Year + "Y", value.Value);

                        if (value.Year == forecastReport.StartYear)
                        {
                            node.SetValue(value.Year + "��", value.Value);
                        }

                    }
                }
            }
        }
Пример #24
0
 private void InitValues(PSP_Values pv, PSP_P_Values pv1)
 {
     pv1.ID = pv.ID;
     pv1.TypeID = pv.TypeID;
     pv1.Flag2 = typeFlag2;
     pv1.Value = pv.Value;
     pv1.Year = pv.Year;
 }
Пример #25
0
        //��ȡ��ʷ����
        private void LoadHistoryValue()
        {
            PSP_P_Years psp_Year = new PSP_P_Years();
            psp_Year.Flag = forecastReport.ID;
            IList<PSP_P_Years> listYears = Common.Services.BaseService.GetList<PSP_P_Years>("SelectPSP_P_YearsListByFlag", psp_Year);

            //Hashtable hs = new Hashtable();
            //foreach (TreeListColumn tlc in treeList1.Columns)
            //{
            //    if (!hs.ContainsKey(tlc.FieldName))
            //        hs.Add(tlc.FieldName, "");

            //}
            Hashtable ht = new Hashtable();
            foreach (PSP_P_Years item in listYears)
            {
                //if (hs.ContainsKey(item.Year + "Y"))
                //    continue;

                dataTable.Columns.Add(item.Year + "Y", typeof(double));
                TreeListColumn column = treeList1.Columns.Add();
                column.FieldName = item.Year + "Y";
                column.Tag = item.Year;
                column.VisibleIndex = -1;
                if (!ht.ContainsKey(item.Year + "Y"))
                    ht.Add(item.Year + "Y", "");
            }

            PSP_Values psp_Values = new PSP_Values();
            psp_Values.ID = forecastReport.ID;//��ID�ֶδ��Flag2��ֵ

            IList<PSP_P_Values> listValues = Common.Services.BaseService.GetList<PSP_P_Values>("SelectPSP_P_ValuesListByFlag2", psp_Values);

            foreach (PSP_P_Values value in listValues)
            {
                TreeListNode node = treeList1.FindNodeByFieldValue("ID", value.TypeID);
                if (node != null)
                {
                    if (!ht.ContainsKey(value.Year + "Y"))
                    {
                        dataTable.Columns.Add(value.Year + "Y", typeof(double));
                        TreeListColumn column = treeList1.Columns.Add();
                        column.FieldName = value.Year + "Y";
                        column.Tag = value.Year;
                        column.VisibleIndex = -1;
                        ht.Add(value.Year + "Y", "");
                    }

                    node.SetValue(value.Year + "Y", value.Value);

                    if (value.Year == forecastReport.StartYear)
                    {
                        node.SetValue(value.Year + "��", value.Value);
                    }

                }
            }
        }