Ejemplo n.º 1
0
        /// <summary>
        /// 修改焦点对象
        /// </summary>
        public void UpdateObject()
        {
            //获取焦点对象
            Common_Type obj = FocusedObject;

            if (obj == null)
            {
                return;
            }

            //创建对象的一个副本
            Common_Type objCopy = new Common_Type();

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

            //执行修改操作
            using (FrmCommon_TypeDialog dlg = new FrmCommon_TypeDialog())
            {
                dlg.Object = objCopy;                   //绑定副本
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //用副本更新焦点对象
            DataConverter.CopyTo <Common_Type>(objCopy, obj);
            //刷新表格
            gridControl.RefreshDataSource();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加对象
        /// </summary>
        public void AddObject()
        {
            //检查对象链表是否已经加载
            if (ObjectList == null)
            {
                return;
            }
            //新建对象
            Common_Type obj = new Common_Type();

            obj.Type = type;
            obj.ID   = Guid.NewGuid().ToString();

            //执行添加操作
            using (FrmCommon_TypeDialog dlg = new FrmCommon_TypeDialog())
            {
                dlg.IsCreate = true;                    //设置新建标志
                dlg.Object   = obj;
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //将新对象加入到链表中
            ObjectList.Add(obj);

            //刷新表格,并将焦点行定位到新对象上。
            gridControl.RefreshDataSource();
            GridHelper.FocuseRow(this.gridView, obj);
        }
Ejemplo n.º 3
0
        void GridView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            object obj = this.ctrlCommon_Type1.GridView.GetRow(this.ctrlCommon_Type1.GridView.FocusedRowHandle);

            if (obj == null)
            {
                return;
            }

            Common_Type ct = (Common_Type)obj;

            type = ct.ID;

            InitData();
            InitVisuble();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 刷新表格中的数据
        /// </summary>
        /// <returns>ture:成功  false:失败</returns>
        public bool RefreshData()
        {
            try
            {
                Common_Type ct = new Common_Type();
                ct.Type = type;

                IList <Common_Type> list = Services.BaseService.GetList <Common_Type>("SelectCommon_TypeByType", ct);
                this.gridControl.DataSource = list;
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return(false);
            }

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

            if (obj == null)
            {
                return;
            }

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

            //执行删除操作
            try
            {
                Services.BaseService.Delete <Common_Type>(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();
        }