Пример #1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     Models.ActionResultModelBinding result = null;
     try
     {
         Models.Moin newMoinAccountObject = new Models.Moin
         {
             Id          = model.Id,
             Code        = txtCode.Text,
             Title       = txtTitle.Text,
             NatureId    = cmbNature.SelectedValue == null ? default(short) : (short)cmbNature.SelectedValue,
             IsDefault   = chkIsDefault.IsChecked.Value,
             IsPermanent = chkIsTemprory.IsChecked.Value ? false : true,
             KolId       = kolSelector.lblValue.Tag != null ? (int)((Tuple <long, string>)kolSelector.lblValue.Tag).Item1:0,
         };
         newMoinAccountObject.SetDataTable(tafsiliGroupSelector.lblValue.Tag != null ? (List <long>)tafsiliGroupSelector.lblValue.Tag : new List <long>());
         var errors = newMoinAccountObject.Validate(null);
         if (errors.Count() > 0)
         {
             foreach (var item in errors)
             {
                 MessageBox.Show(item.ErrorMessage);
             }
         }
         else
         {
             using (var controller = new Controllers.MoinController())
             {
                 result = controller.UpdateMoinAccount(newMoinAccountObject);
             }
         }
     }
     catch (Exception c)
     {
         MessageBox.Show(c.Message);
         return;
     }
     finally
     {
         if (result != null)
         {
             MessageBox.Show(result.Message);
             if (result.Status == Models.ActionResult.Success)
             {
                 Close();
             }
         }
     }
 }
Пример #2
0
 private void GetMoinAccounts()
 {
     try
     {
         using (var controller = new Controllers.MoinController())
         {
             var result = controller.GetMoinAccounts();
             dtGroupAccount.ItemsSource = result.Body;
         }
     }
     catch (Exception c)
     {
         MessageBox.Show(c.Message);
     }
 }
Пример #3
0
        private void removeButton_Click(object sender, MouseButtonEventArgs e)
        {
            var updateObject = (Models.Moin)dtGroupAccount.SelectedItem;

            Models.ActionResultModelBinding result = null;
            try
            {
                var question = MessageBox.Show(Application.Current.FindResource("removeAccountWarning") as string, Application.Current.FindResource("warningTitle") as string, MessageBoxButton.YesNo);
                if (question == MessageBoxResult.Yes)
                {
                    if (updateObject != null)
                    {
                        using (var controller = new Controllers.MoinController())
                        {
                            result = controller.RemoveMoinAccount(updateObject, true);
                        }
                    }
                }
            }
            catch (Exception c)
            {
                MessageBox.Show(c.Message);
                return;
            }
            finally
            {
                if (result != null)
                {
                    MessageBox.Show(result.Message);
                    if (result.Status == Models.ActionResult.Success)
                    {
                        GetMoinAccounts();
                    }
                }
            }
        }