예제 #1
0
        /// <summary>
        /// ɾ���������
        /// </summary>
        public void DeleteObject(string lb)
        {
            //��ȡ�������
            PowerEachList obj = FocusedObject;
            if (obj == null)
            {
                bl = false;
                return;
            }

            int coun = 0;

            switch (lb)
            {
                case "xuqiu":
                PowerTypes pt = new PowerTypes();
                pt.Flag2 = obj.UID;
                IList<PowerTypes> li = Services.BaseService.GetList<PowerTypes>("SelectPowerTypesByFlag2", pt);
                coun = li.Count;

                    break;
                case "xihua":
                    PowerProjectTypes pt1 = new PowerProjectTypes();
                    pt1.Flag2 = obj.UID;
                    IList<PowerProjectTypes> li1 = Services.BaseService.GetList<PowerProjectTypes>("SelectPowerProjectTypesByFlag2", pt1);
                    coun = li1.Count;
                    break;
                case "shebei":
                    PowerStuffTypes pt2 = new PowerStuffTypes();
                    pt2.Flag2 = obj.UID;
                    IList<PowerStuffTypes> li2 = Services.BaseService.GetList<PowerStuffTypes>("SelectPowerStuffTypesByFlag2", pt2);
                    coun = li2.Count;
                    break;
                case "fanwei":
                    PowersTypes pt3 = new PowersTypes();
                    pt3.Flag2 = obj.UID;
                    IList<PowersTypes> li3 = Services.BaseService.GetList<PowersTypes>("SelectPowersTypesByFlag2", pt3);
                    coun = li3.Count;
                    break;
                case "sb":
                    PowerProTypes pt4 = new PowerProTypes();
                    pt4.Flag2 = obj.UID;
                    IList<PowerProTypes> li4 = Services.BaseService.GetList<PowerProTypes>("SelectPowerProTypesByFlag2INParent", pt4);
                    coun = li4.Count;
                    break;
                case "gusuan":
                    PSP_PowerProValues_LangFang pt5 = new PSP_PowerProValues_LangFang();
                    pt5.Flag2 = obj.UID;
                    IList<PSP_PowerProValues_LangFang> li5 = Services.BaseService.GetList<PSP_PowerProValues_LangFang>("SelectPSP_PowerProValues_LangFangByFlag2INParent", pt5);
                    coun = li5.Count;
                    break;
            }

            if (coun > 0)
            {
                MsgBox.Show("�÷��������м�¼���޷�ɾ��");
                bl = false;
                return;
            }

            //����ȷ��
            if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes)
            {
                bl = false;
                return;
            }

            //ִ��ɾ������
            try
            {
                Services.BaseService.Delete<PowerEachList>(obj);

                if (lb == "sb")
                {
                    Services.BaseService.Update("DeletePowerPicSelect1", obj.UID);
                    Services.BaseService.Update("DeletePowerProTypesInFlag2", obj.UID);
                }
                if (lb == "gusuan")
                {
                    Services.BaseService.Update("DeletePowerPicSelect1", obj.UID);
                    Services.BaseService.Update("DeletePowerProTypesInFlag2", obj.UID);
                }
            }
            catch
            {
                //Debug.Fail(exc.Message);
                //HandleException.TryCatch(exc);
                return;
            }

            this.gridView.BeginUpdate();
            //��ס��ǰ����������
            int iOldHandle = this.gridView.FocusedRowHandle;
            //��������ɾ��
            ObjectList.Remove(obj);
            //ˢ�±��
            gridControl.RefreshDataSource();
            //�����µĽ���������
            GridHelper.FocuseRowAfterDelete(this.gridView, iOldHandle);
            this.gridView.EndUpdate();
        }
예제 #2
0
파일: Form1.cs 프로젝트: EdgarEDT/myitoppsp
        private void InsertLineData1()
        {
            PowerTypes m2 = new PowerTypes();

            PowerValues m1 = new PowerValues();

            PowerYears z1 = new PowerYears();

            PowerTypes psp_Type = new PowerTypes();
            object obj = Services.BaseService.GetObject("SelectPowerTypesList", "");
            int z_typeID = (int)Common.Services.BaseService.Create("InsertPowerTypes", psp_Type)-2;

            try
            {
                DataTable dts = new DataTable();
                OpenFileDialog op = new OpenFileDialog();
                op.Filter = "Excel文件(*.xls)|*.xls";
                if (op.ShowDialog() == DialogResult.OK)
                {
                    dts = GetExcel(op.FileName);

                    for (int i = 1; i < dts.Rows.Count; i++)
                    {

                        foreach (DataColumn dc in dts.Columns)
                        {
                            if (dc.Caption.IndexOf("年") > 0)
                            {
                                try
                                {
                                    if (dts.Rows[i][dc.ColumnName].ToString() == "")
                                    { m1.Value = 0; }
                                    else
                                    {
                                        m1.Value = double.Parse(dts.Rows[i][dc.ColumnName].ToString());
                                    }
                                    m1.TypeID = z_typeID + 3;

                                    int eq = dc.ColumnName.IndexOf("年");
                                    string h = dc.ColumnName.Substring(0, eq);
                                    m1.Year = int.Parse(h);
                                    Services.BaseService.Create<PowerValues>(m1);

                                }
                                catch { }

                            }
                            if (dc.Caption.IndexOf("项目名称") >= 0)
                            {

                             try
                                {
                                    m2.Title = dts.Rows[i][dc.ColumnName].ToString();
                              }
                                catch { }
                            }

                            if (dc.Caption.IndexOf("静态总投资") >= 0)
                            {   try
                                {
                                if (dts.Rows[i][dc.ColumnName].ToString() == "")
                                { m2.Jingtai = 0; }
                                else
                                    m2.Jingtai = double.Parse(dts.Rows[i][dc.ColumnName].ToString());
                              }
                                catch { }
                            }
                            if (dc.Caption.IndexOf("建设期间代款利息") >= 0)
                            {   try
                                {
                                if (dts.Rows[i][dc.ColumnName].ToString() == "")
                                { m2.Lixi = 0; }
                                else
                                    m2.Lixi = double.Parse(dts.Rows[i][dc.ColumnName].ToString());
                                   }
                                catch { }
                            }
                            if (dc.Caption.IndexOf("价格预备费") >= 0)
                            {   try
                                {
                                if (dts.Rows[i][dc.ColumnName].ToString() == "")
                                { m2.Yubei = 0; }
                                else
                                    m2.Yubei = double.Parse(dts.Rows[i][dc.ColumnName].ToString());
                                   }
                                catch { }
                            }
                            if (dc.Caption.IndexOf("动态投资") >= 0)
                            {   try
                                {
                                if (dts.Rows[i][dc.ColumnName].ToString() == "")
                                { m2.Dongtai = 0; }
                                else
                                    m2.Dongtai = double.Parse(dts.Rows[i][dc.ColumnName].ToString());
                            }
                            catch { }
                            }

                        }
                        m2.Flag2 = this.ctrlPowerEachList1.FocusedObject.UID;
                        z_typeID = z_typeID + 1;
                        Services.BaseService.Create<PowerValues>(m1);
                        Services.BaseService.Create<PowerTypes>(m2);

                    }

                    ReLaodData();
               }
            }

            catch { MsgBox.Show("导入格式不正确!"); }
        }
예제 #3
0
        /// <summary>
        /// ɾ���������
        /// </summary>
        public void DeleteObject(string lb)
        {
            //��ȡ�������
            PSP_EachList obj = FocusedObject;
            if (obj == null)
            {
                bl = false;
                return;
            }

            int coun = 0;

            switch (lb)
            {
                case "xuqiu":
                    PowerTypes pt = new PowerTypes();
                    pt.Flag2 = obj.ID.ToString();
                    IList<PowerTypes> li = Services.BaseService.GetList<PowerTypes>("SelectPowerTypesByFlag2", pt);
                    coun = li.Count;
                    break;
            }

            if (coun > 0)
            {
                MsgBox.Show("�÷��������м�¼���޷�ɾ��");
                bl = false;
                return;
            }

            //����ȷ��
            if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes)
            {
                bl = false;
                return;
            }

            //ִ��ɾ������
            try
            {
                Services.BaseService.Delete<PSP_EachList>(obj);

                if (lb == "sb")
                {
                    Services.BaseService.Update("DeletePowerPicSelect1", obj.ID);
                    Services.BaseService.Update("DeletePowerProTypesInFlag2", obj.ID);
                }
            }
            catch
            {
                //Debug.Fail(exc.Message);
                //HandleException.TryCatch(exc);
                return;
            }

            this.gridView.BeginUpdate();
            //��ס��ǰ����������
            int iOldHandle = this.gridView.FocusedRowHandle;
            //��������ɾ��
            ObjectList.Remove(obj);
            //ˢ�±��
            gridControl.RefreshDataSource();
            //�����µĽ���������
            GridHelper.FocuseRowAfterDelete(this.gridView, iOldHandle);
            this.gridView.EndUpdate();
        }
예제 #4
0
파일: Form1.cs 프로젝트: EdgarEDT/myitoppsp
        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)
            {
                PowerTypes psp_Type = new PowerTypes();
                Class1.TreeNodeToDataObject<PowerTypes>(psp_Type, treeList1.FocusedNode);
                PowerValues PowerValues = new PowerValues();
                PowerValues.TypeID = psp_Type.ID;

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

                    Common.Services.BaseService.Update("DeletePowerValuesByType", 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);
                }
            }
        }
예제 #5
0
파일: Form1.cs 프로젝트: EdgarEDT/myitoppsp
        private void barButtonItem13_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }

            //if (treeList1.FocusedNode.ParentNode == null)
            //{
            //    MsgBox.Show("一级分类名称不能修改!");
            //    return;
            //}

            FormTypeTitle frm = new FormTypeTitle();
            frm.TypeTitle = treeList1.FocusedNode.GetValue("Title").ToString();
            frm.Text = "修改项目名";

            if (frm.ShowDialog() == DialogResult.OK)
            {
                PowerTypes psp_Type = new PowerTypes();
                Class1.TreeNodeToDataObject<PowerTypes>(psp_Type, treeList1.FocusedNode);
                psp_Type.Title = frm.TypeTitle;

                try
                {
                    Common.Services.BaseService.Update<PowerTypes>(psp_Type);
                    treeList1.FocusedNode.SetValue("Title", frm.TypeTitle);
                }
                catch (Exception ex)
                {
                    //MsgBox.Show("修改出错:" + ex.Message);
                }
            }
        }
예제 #6
0
파일: Form1.cs 프로젝트: EdgarEDT/myitoppsp
        private void barButtonItem12_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            TreeListNode focusedNode = treeList1.FocusedNode;

            if (focusedNode == null)
            {
                return;
            }

            FormTypeTitle frm = new FormTypeTitle();
            frm.Text = "增加" + focusedNode.GetValue("Title") + "的子项目";

            if (frm.ShowDialog() == DialogResult.OK)
            {
                PowerTypes psp_Type = new PowerTypes();
                psp_Type.Title = frm.TypeTitle;
                psp_Type.Flag = (int)focusedNode.GetValue("Flag");
                psp_Type.Flag2 = (string)focusedNode.GetValue("Flag2");
                psp_Type.ParentID = (int)focusedNode.GetValue("ID");

                try
                {
                    psp_Type.ID = (int)Common.Services.BaseService.Create("InsertPowerTypes", psp_Type);
                    dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow()));
                }
                catch (Exception ex)
                {
                    MsgBox.Show("增加子项目出错:" + ex.Message);
                }
            }
        }
예제 #7
0
파일: Form1.cs 프로젝트: EdgarEDT/myitoppsp
        private void barButtonItem11_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //typeFlag2 = this.ctrlPowerEachList1.FocusedObject.UID;
            FormTypeTitle frm = new FormTypeTitle();
            frm.Text = "增加项目";

            if (frm.ShowDialog() == DialogResult.OK)
            {
                PowerTypes psp_Type = new PowerTypes();
                psp_Type.Title = frm.TypeTitle;
                psp_Type.Flag = 0;
                psp_Type.Flag2 = typeFlag2;
                psp_Type.ParentID = 0;

                try
                {
                    psp_Type.ID = (int)Common.Services.BaseService.Create("InsertPowerTypes", psp_Type);
                    dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow()));
                }
                catch (Exception ex)
                {
                    MsgBox.Show("增加项目出错:" + ex.Message);
                }
            }
        }
예제 #8
0
파일: Form1.cs 프로젝트: EdgarEDT/myitoppsp
        private void LoadData()
        {
            try
            {
                if (dataTable != null)
                {
                    dataTable.Columns.Clear();
                    treeList1.Columns.Clear();
                }

                PowerTypes psp_Type = new PowerTypes();
                psp_Type.Flag2 = typeFlag2;
                IList listTypes = new ArrayList();
                try
                {
                    listTypes = Common.Services.BaseService.GetList("SelectPowerTypesByFlag2", psp_Type);

                }
                catch (Exception ex)
                { MsgBox.Show(ex.Message); }
                dataTable = Itop.Common.DataConverter.ToDataTable(listTypes, typeof(PowerTypes));

                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;

                PowerYears psp_Year = new PowerYears();
                psp_Year.Flag = typeFlag2;
                IList<PowerYears> listYears = Common.Services.BaseService.GetList<PowerYears>("SelectPowerYearsListByFlag", psp_Year);

                foreach (PowerYears item in listYears)
                {
                    AddColumn(item.Year);
                }

                AddColumn1();
                AddColumn2();
                AddColumn3();
                AddColumn4();

                Application.DoEvents();

                LoadValues();

                treeList1.ExpandAll();
            }
            catch (Exception ex)
            {
                MsgBox.Show(ex.Message);

            }
        }