Пример #1
0
        private void BtnOkAndContinue_Click(object sender, EventArgs e)
        {
            装修明细BindingSource.EndEdit();
            string check = entity.CheckRules();

            if (!string.IsNullOrEmpty(check))
            {
                KryptonMessageBox.Show(check, "数据校验失败");
                return;
            }
#if DEBUG
            System.Diagnostics.Debug.Assert(isNew);//只有新增状态才有此按钮
#endif
            context.装修明细.AddObject(entity);
            string msg;
            if (Helper.saveData(context, entity, out msg))
            {
                KryptonMessageBox.Show("成功新增装修明细,您可以继续添加。", "成功新增装修明细");
                if (this.Owner is 装修明细Form)
                {
                    (this.Owner as 装修明细Form).RefreshAndLocate装修明细(entity.ID);
                }

                装修明细 old = entity;
                entity = new 装修明细()
                {
                    日期   = old.日期,
                    源房ID = old.源房ID,
                    购买地点 = old.购买地点,
                    装修分类 = old.装修分类,
                    备注   = old.备注
                };
                装修明细BindingSource.DataSource = entity;
            }
            else
            {
                KryptonMessageBox.Show(msg, "失败");
                context.装修明细.DeleteObject(entity);
            }
        }
Пример #2
0
 public 装修Form(装修明细 entity) //编辑操作
 {
     InitializeComponent();
     this.entity = context.装修明细.FirstOrDefault(m => m.ID == entity.ID);
     isNew       = false;
 }
Пример #3
0
        private bool isNew; //是否新增操作

        public 装修Form()     //新增操作
        {
            InitializeComponent();
            entity = new 装修明细();
            isNew  = true;
        }