Esempio n. 1
0
        /// <summary>
        /// 删除某一年份
        /// </summary>

        private void barButtonItem5_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_GDPValues psp_Values = new PSP_GDPValues();

            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_GDPValuesByYear", psp_Values);

                // deleColumnsToGDPCompute(psp_Values.Year.ToString());

                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);
            }
        }
Esempio n. 2
0
        //读取数据
        private void LoadValues()
        {
            PSP_GDPValues psp_Values = new PSP_GDPValues();

            psp_Values.ID = typeFlag2;//用ID字段存放Flag2的值


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

            foreach (PSP_GDPValues value in listValues)
            {
                TreeListNode node = treeList1.FindNodeByFieldValue("ID", value.TypeID);
                if (node != null)
                {
                    node.SetValue(value.Year + "年", Convert.ToDouble(value.Value));
                }
            }
        }
Esempio n. 3
0
        private bool SaveCellValue(int year, int typeID, double value)
        {
            PSP_GDPValues psp_values = new PSP_GDPValues();

            psp_values.TypeID = typeID;
            psp_values.Value  = value;
            psp_values.Year   = year;

            try
            {
                Common.Services.BaseService.Update <PSP_GDPValues>(psp_values);
            }
            catch (Exception ex)
            {
                MsgBox.Show("保存数据出错:" + ex.Message);
                return(false);
            }
            return(true);
        }
Esempio n. 4
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 (!base.DeleteRight)
            {
                MsgBox.Show("您没有权限进行此项操作!");
                return;
            }

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

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

                    Common.Services.BaseService.Update("DeletePSP_GDPValuesByType", 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);
                }
            }
        }