Пример #1
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         //Verify
         if (string.IsNullOrEmpty(this.txtCode.Text.Trim()))
         {
             throw new ApplicationException("编码不能为空");
         }
         if (string.IsNullOrEmpty(this.txtName.Text.Trim()))
         {
             throw new ApplicationException("名称不能为空");
         }
         //save
         ModelService modelService = new ModelService();
         if (this.Model == null)//新建
         {
             BillsType model = new BillsType();
             model.Code    = this.txtCode.Text.Trim();
             model.Name    = this.txtName.Text.Trim();
             model.IsOut   = this.ckbIsOut.Checked;
             model.Actived = this.ckbActived.Checked;
             model.Remark  = this.txtRemark.Text.Trim();
             modelService.CreateBillsType(model, PermissionService.GetCurrentUser().Name);
         }
         else//修改
         {
             this.Model.Code    = this.txtCode.Text.Trim();
             this.Model.Name    = this.txtName.Text.Trim();
             this.Model.IsOut   = this.ckbIsOut.Checked;
             this.Model.Actived = this.ckbActived.Checked;
             this.Model.Remark  = this.txtRemark.Text.Trim();
             modelService.SaveBillsType(this.Model, PermissionService.GetCurrentUser().Name);
         }
         //close diaglog
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         ErrorHandler.OnError(ex);
     }
 }