| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 | using DevExpress.Xpo.DB.Exceptions;using DevExpress.Xpo;using DevExpress.XtraEditors;using Ips.Library.DxpLib;using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace Ips.Sps.TskResults.Poses{    public partial class PosEditForm : DevExpress.XtraEditors.XtraForm    {        public PosEditForm()        {            InitializeComponent();        }        public PosEditForm(long? id) : this()        {            this.Id = id;        }        public long? Id { get; private set; }        protected UnitOfWork UnitOfWork { get; private set; }        public Pos EditModel { get => (Pos)bsPos.DataSource; }        private void PosEditForm_Load(object sender, EventArgs e)        {            UnitOfWork = new UnitOfWork();            if (Id.HasValue)                bsPos.DataSource = UnitOfWork.GetObjectByKey<Pos>(Id.Value);            else                bsPos.DataSource = new Pos(UnitOfWork);        }        private void btnSave_Click(object sender, EventArgs e)        {            try            {                UnitOfWork.CommitChanges();                var pos = (Pos)(bsPos.DataSource);                Id = pos.Id;                this.DialogResult = DialogResult.OK;                Close();            }            catch (LockingException)            {                MsgHelper.ShowError("对象已被修改,请关闭后重新打开进行编辑!");            }        }        private void btnCancel_Click(object sender, EventArgs e)        {            Close();        }    }}
 |