private void Button_Click(object sender, RoutedEventArgs e)
        {
            Models.ActionResultModelBinding result = null;
            try
            {
                if (_model != null)
                {
                    _model.Code  = txtCode.Text;
                    _model.Title = txtTitle.Text;

                    _model.Editable = chkIsDefault.IsChecked.Value;

                    var errors = _model.Validate(null);
                    if (errors.Count() > 0)
                    {
                        foreach (var item in errors)
                        {
                            MessageBox.Show(item.ErrorMessage);
                        }
                    }
                    else
                    {
                        using (var controller = new Controllers.TafsiliGroupController())
                        {
                            result = controller.UpdateTafsiliGroupAccount(_model);
                        }
                    }
                }
            }
            catch (Exception c)
            {
                MessageBox.Show(c.Message);
                return;
            }
            finally
            {
                if (result != null)
                {
                    MessageBox.Show(result.Message);

                    Close();
                }
            }
        }
예제 #2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     Models.ActionResultModelBinding result = null;
     try
     {
         Models.TafsiliGroup newTafsiliGroupAccountObject = new Models.TafsiliGroup
         {
             Code     = txtCode.Text,
             Title    = txtTitle.Text,
             Editable = chkEditable.IsChecked.Value
         };
         var errors = newTafsiliGroupAccountObject.Validate(null);
         if (errors.Count() > 0)
         {
             foreach (var item in errors)
             {
                 MessageBox.Show(item.ErrorMessage);
             }
         }
         else
         {
             using (var controller = new Controllers.TafsiliGroupController())
             {
                 result = controller.InsertTafsiliGroupAccount(newTafsiliGroupAccountObject);
             }
         }
     }
     catch (Exception c)
     {
         MessageBox.Show(c.Message);
         return;
     }
     finally
     {
         if (result != null)
         {
             MessageBox.Show(result.Message);
             if (result.Status == Models.ActionResult.Success)
             {
                 GetTafsiliGroupAccounts();
             }
         }
     }
 }