Esempio n. 1
0
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }
            //FindNodes(treeList1.FocusedNode);

            string parentid = treeList1.FocusedNode["ParentID"].ToString();

            if (!base.EditRight)
            {
                MsgBox.Show("您没有权限进行此项操作!");
                return;
            }
            if (parentid == "0")
            {
                FrmAddBuild frm = new FrmAddBuild();
                //frm.TypeTitle = treeList1.FocusedNode.GetValue("Title").ToString();
                frm.ParentName = treeList1.FocusedNode.GetValue("Title").ToString();
                frm.Text = "修改分类名";
                frm.SetLabelName = "分类名称";
                frm.GetV = treeList1.FocusedNode.GetValue("FromID").ToString();
                frm.Conn = tong + "ParentID='0' and ProjectID='" + GetProjectID + "' and FromID=";
                frm.BEdit = true;

                if (frm.ShowDialog() == DialogResult.OK)
                {
                    Ps_Table_TZGS table1 = new Ps_Table_TZGS();
                    table1 = Common.Services.BaseService.GetOneByKey<Ps_Table_TZGS>(treeList1.FocusedNode.GetValue("ID"));
                    table1.Title = frm.ParentName;
                    table1.FromID = frm.GetV;
                    table1.Col2 = "no";
                    try
                    {
                        Common.Services.BaseService.Update<Ps_Table_TZGS>(table1);
                        treeList1.FocusedNode.SetValue("Title", frm.ParentName);
                    }
                    catch { }
                    //catch(Exception ex)
                    //{
                    //    MsgBox.Show("修改出错:" + ex.Message);
                    //}
                }
            }
            else
            {
                FrmAddTzgsBBPW frm = new FrmAddTzgsBBPW();
                Ps_Table_TZGS table = new Ps_Table_TZGS();
                table = Common.Services.BaseService.GetOneByKey<Ps_Table_TZGS>(treeList1.FocusedNode.GetValue("ID"));
               // frm.ParentName = treeList1.FocusedNode.GetValue("Title").ToString();

                try
                {
                    frm.V = int.Parse(treeList1.FocusedNode.GetValue("FromID").ToString());
                }
                catch { }
                frm.AreaName = treeList1.FocusedNode.GetValue("AreaName").ToString();
                frm.ProjectID = ProjectUID;
                if (treeList1.FocusedNode.GetValue("Col4") != null)
                {
                    if (treeList1.FocusedNode.GetValue("Col4").ToString() == "line")
                        frm.Line = true;
                }
                frm.Text = "修改工程";
                frm.StrType = table.Col4;

                frm.ParentName = table.Title;
                if (treeList1.FocusedNode.ParentNode!=null)
                {
                    frm.Stat = treeList1.FocusedNode.ParentNode.GetValue("Col2").ToString();
                }

                frm.BianInfo = table.BianInfo;
                frm.LineInfo = table.LineInfo;
                frm.StartYear = table.BuildYear;
                frm.FinishYear = table.BuildEd;
                frm.LineLen = table.Length;
                frm.BieZhu = table.Col1;
                frm.Col3 = table.Col3;
                frm.Vol = table.Volumn;
                frm.TzgsXs = double.Parse(yAngeXs.Col1);
                frm.DQ = table.DQ;
                frm.Num1 = table.Num1;
                frm.Num2 = table.Num2;
                frm.uid = table.ID;
                frm.operatorflag = false;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    AddChildVol(table, false);
                    table.Title = frm.ParentName;
                    table.BuildYear = frm.StartYear;
                    table.BuildEd = frm.FinishYear;
                    table.Length = frm.LineLen;
                    table.Volumn = frm.Vol;
                    double temp = frm.AllVol - table.AllVolumn;
                    table.AllVolumn = frm.AllVol;
                    table.AftVolumn += temp;
                    for (int i = yAnge.BeginYear; i <= yAnge.EndYear; i++)
                    {
                        table.GetType().GetProperty("y" + i).SetValue(table, 0, null);
                    }
                    table.GetType().GetProperty("y" + Convert.ToString(frm.FinishYear)).SetValue(table, table.AftVolumn, null);
                    table.Col1 = frm.BieZhu;
                    table.Col3 = frm.Col3;
                    //table.Col4 = frm.StrType;
                    table.BianInfo = frm.BianInfo;
                    table.LineInfo = frm.LineInfo;
                    table.DQ = frm.DQ;
                    table.Num1 = frm.Num1;
                    table.Num2 = frm.Num2;
                    try
                    {
                        Common.Services.BaseService.Update<Ps_Table_TZGS>(table);
                        AddChildVol(table, true);
                        LoadData1();
                        FoucsLocation(table.ID, treeList1.Nodes);
                    }
                    catch { }
                }
            }
        }
Esempio n. 2
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 ( focusedNode.GetValue("ParentID").ToString()!="0")
            if (focusedNode.ParentNode!=null)
            {
                //MsgBox.Show( focusedNode.GetValue("Title").ToString()+"不允许添加子分类!");
                //return;
                focusedNode = focusedNode.ParentNode;
            }

            FrmAddTzgsBBPW frm = new FrmAddTzgsBBPW();
            //frm.Text = "增加" + focusedNode.GetValue("Title") + "的子分类";
            //frm.Stat = focusedNode.GetValue("Col2").ToString();
            frm.StrType = "bian";
            frm.TzgsXs = double.Parse(yAngeXs.Col1);
            frm.AreaName = focusedNode.GetValue("AreaName").ToString();
            try
            {
                frm.V = int.Parse(focusedNode.GetValue("FromID").ToString());
            }
            catch { }
            frm.ProjectID = ProjectUID;
            Ps_Table_TZGS table1 = new Ps_Table_TZGS();
            table1.ID += "|" + GetProjectID;
            frm.uid = table1.ID;
            frm.operatorflag = true;
               // frm.SetLabelName = "子分类名称";
            if(frm.ShowDialog() == DialogResult.OK)
            {

                table1.Title = frm.ParentName;
                table1.ParentID = focusedNode.GetValue("ID").ToString();
                table1.ProjectID = GetProjectID;
                table1.BuildYear = frm.StartYear;
                table1.BuildEd = frm.FinishYear;
                table1.FromID = "0";
                table1.Length = frm.LineLen;
                table1.Volumn = frm.Vol;
                table1.AllVolumn = frm.AllVol;
              //  table1.BefVolumn = frm.AllVol;
                table1.AftVolumn = frm.AllVol;
                table1.LineInfo = frm.LineInfo;
                table1.BianInfo = frm.BianInfo;
                table1.GetType().GetProperty("y" + Convert.ToString(frm.FinishYear)).SetValue(table1, frm.AllVol, null);
                //table1.Col2 = treeList1.FocusedNode.GetValue("Col1").ToString();
                table1.Sort = OperTable.GetTZGSMaxSort()+1;
                table1.Col3 = frm.Col3;
                table1.Col1 = frm.BieZhu;
                table1.Col4 = "bian";
                table1.DQ = frm.DQ;
                table1.Num1 = frm.Num1;
                table1.Num2 = frm.Num2;
                try
                {
                    Common.Services.BaseService.Create("InsertPs_Table_TZGS", table1);
                    dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(table1, dataTable.NewRow()));
                    AddChildVol(table1, true);
                    LoadData1();
                    FoucsLocation(table1.ID, treeList1.Nodes);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("增加工程出错:" + ex.Message);
                }
            }
        }