Ejemplo n.º 1
0
        /// <summary>
        /// 添加对象
        /// </summary>
        public void AddObject()
        {
            int    count    = 0;
            string parentid = "";

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

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

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

            PowerStuff obj = new PowerStuff();

            obj.SortID       = count + 1;
            obj.ParentID     = parentid;
            obj.PowerLineUID = lineuid;
            using (FrmPowerStuffDialog dlg = new FrmPowerStuffDialog())
            {
                dlg.IsCreate = true;    //设置新建标志
                dlg.Object   = obj;
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow()));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改焦点对象
        /// </summary>
        public void UpdateObject()
        {
            if (treeList1.FocusedNode == null)
            {
                return;
            }

            string     uid     = treeList1.FocusedNode["UID"].ToString();
            PowerStuff obj     = Services.BaseService.GetOneByKey <PowerStuff>(uid);
            PowerStuff objCopy = new PowerStuff();

            DataConverter.CopyTo <PowerStuff>(obj, objCopy);

            FrmPowerStuffDialog dlg = new FrmPowerStuffDialog();

            dlg.Object = objCopy;

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

            DataConverter.CopyTo <PowerStuff>(objCopy, obj);
            treeList1.FocusedNode.SetValue("StuffName", obj.StuffName);
            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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 刷新表格中的数据
        /// </summary>
        /// <returns>ture:成功  false:失败</returns>
        public bool RefreshData()
        {
            try
            {
                try
                {
                    ilist.Clear();
                    PowerStuff ps = new PowerStuff();
                    ps.PowerLineUID = lineuid;

                    ilist = Services.BaseService.GetList <PowerStuff>("SelectPowerStuffList", ps);
                }
                catch (Exception ex) { MsgBox.Show(ex.Message); }
                dataTable            = new DataTable();
                dataTable            = DataConverter.ToDataTable((IList)ilist, typeof(PowerStuff));
                treeList1.DataSource = dataTable;
                this.treeList1.ExpandAll();

                treeList1.MoveFirst();


                //this.treeList1.DataSource = dataTable;
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 删除焦点对象
        /// </summary>
        public void DeleteObject()
        {
            //获取焦点对象
            PowerStuffList obj = FocusedObject;

            if (obj == null)
            {
                return;
            }

            PowerStuff pp = new PowerStuff();

            pp.PowerLineUID = obj.UID;

            IList <PowerStuff> li = Services.BaseService.GetList <PowerStuff>("SelectPowerStuffList", pp);

            if (li.Count > 0)
            {
                MsgBox.Show("该分类下面有输变电设备表记录,无法删除");
                return;
            }



            //请求确认
            if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes)
            {
                return;
            }

            //执行删除操作
            try
            {
                Services.BaseService.Delete <PowerStuffList>(obj);
            }
            catch (Exception exc)
            {
                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();
        }
Ejemplo n.º 5
0
        public void InsertData()
        {
            int    count    = 0;
            string parentid = "";

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

            if (treeList1.FocusedNode != null)
            {
                parentid = treeList1.FocusedNode["ParentID"].ToString();
                count    = int.Parse(treeList1.FocusedNode["SortID"].ToString());
            }

            //object objs = Services.BaseService.GetObject("SelectPowerProjectBySortID", parentid);
            //if (objs != null)
            //    count = (int)objs;

            PowerStuff obj = new PowerStuff();

            obj.SortID       = count;
            obj.ParentID     = parentid;
            obj.PowerLineUID = lineuid;

            using (FrmPowerStuffDialog dlg = new FrmPowerStuffDialog())
            {
                dlg.IsCreate = true;    //设置新建标志
                dlg.Object   = obj;
                dlg.IsInsert = true;
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow()));

            treeList1.DataSource = dataTable;
        }