Beispiel #1
0
        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)
            {
                try
                {
                    PowerStuffTypes psp_Type = Services.BaseService.GetOneByKey <PowerStuffTypes>(treeList1.FocusedNode["ID"].ToString());
                    psp_Type.Title = frm.TypeTitle;


                    Common.Services.BaseService.Update <PowerStuffTypes>(psp_Type);
                    treeList1.FocusedNode.SetValue("Title", frm.TypeTitle);
                }
                catch (Exception ex)
                {
                    MsgBox.Show("修改出错:" + ex.Message);
                }
            }
        }
Beispiel #2
0
        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)
            {
                PowerStuffTypes psp_Type = new PowerStuffTypes();
                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("InsertPowerStuffTypes", psp_Type);
                    dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow()));
                }
                catch (Exception ex)
                {
                    MsgBox.Show("增加子项目出错:" + ex.Message);
                }
            }
        }
Beispiel #3
0
        private void barButtonItem11_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FormTypeTitle frm = new FormTypeTitle();

            frm.Text = "增加项目";

            if (frm.ShowDialog() == DialogResult.OK)
            {
                PowerStuffTypes psp_Type = new PowerStuffTypes();
                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("InsertPowerStuffTypes", psp_Type);
                    dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow()));
                }
                catch (Exception ex)
                {
                    MsgBox.Show("增加项目出错:" + ex.Message);
                }
            }
        }
        /// <summary>
        /// 修改焦点对象
        /// </summary>
        public void UpdateObject()
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }

            string         uid = treeList1.FocusedNode["UID"].ToString();
            PowerEachTotal obj = Services.BaseService.GetOneByKey <PowerEachTotal>(uid);
            //PowerEachTotal objCopy = new PowerEachTotal();
            //DataConverter.CopyTo<PowerEachTotal>(obj, objCopy);

            FormTypeTitle frm = new FormTypeTitle();

            frm.Text      = "修改项目";
            frm.TypeTitle = obj.StuffName;

            if (frm.ShowDialog() == DialogResult.OK)
            {
                obj.StuffName = frm.TypeTitle;
                try
                {
                    Services.BaseService.Update <PowerEachTotal>(obj);
                    treeList1.FocusedNode.SetValue("StuffName", obj.StuffName);
                    //dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow()));
                    //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);
                }
            }



            //////Services.BaseService.Update<PowerEachTotal>(obj);


            //////FrmPowerEachTotalDialog dlg = new FrmPowerEachTotalDialog();
            //////dlg.Object = objCopy;

            //////if (dlg.ShowDialog() != DialogResult.OK)
            //////{
            //////    return;
            //////}

            //DataConverter.CopyTo<PowerEachTotal>(objCopy, obj);
            //treeList1.FocusedNode.SetValue("StuffName", obj.StuffName);
            //treeList1.FocusedNode.SetValue("LCount", obj.LCount);
            //treeList1.FocusedNode.SetValue("Lengths", obj.Lengths);
            //treeList1.FocusedNode.SetValue("Volume", obj.Volume);
            //treeList1.FocusedNode.SetValue("Type", obj.Type);
            //treeList1.FocusedNode.SetValue("Total", obj.Total);
            //treeList1.FocusedNode.SetValue("Remark", obj.Remark);
            //treeList1.FocusedNode.SetValue("IsSum", obj.IsSum);
            //treeList1.FocusedNode.SetValue("ItSum", obj.ItSum);
        }
        /// <summary>
        /// 添加对象
        /// </summary>
        public void AddObject1()
        {
            int    count    = 0;
            string parentid = "";

            if (treeList1.FocusedNode == null)
            {
                return;
            }

            if (treeList1.FocusedNode != null)
            {
                parentid = treeList1.FocusedNode["UID"].ToString();
            }

            object objs = Services.BaseService.GetObject("SelectPowerEachTotalBySortID", parentid);

            if (objs != null)
            {
                count = (int)objs;
            }


            FormTypeTitle frm = new FormTypeTitle();

            frm.Text = "增加项目";

            if (frm.ShowDialog() == DialogResult.OK)
            {
                PowerEachTotal obj = new PowerEachTotal();
                obj.SortID       = count + 1;
                obj.ParentID     = parentid;
                obj.PowerLineUID = lineuid;
                obj.StuffName    = frm.TypeTitle;

                try
                {
                    Services.BaseService.Create <PowerEachTotal>(obj);
                    dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow()));
                    //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);
                }
            }


            //////PowerEachTotal obj = new PowerEachTotal();
            //////obj.SortID = count + 1;
            //////obj.ParentID = parentid;
            //////obj.PowerLineUID = lineuid;
            //////using (FrmPowerEachTotalDialog dlg = new FrmPowerEachTotalDialog())
            //////{
            //////    dlg.IsCreate = true;    //设置新建标志
            //////    dlg.Object = obj;
            //////    if (dlg.ShowDialog() != DialogResult.OK)
            //////    {
            //////        return;
            //////    }
            //////}
            //////dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow()));
        }