Пример #1
0
 private void GetTafsiliGroupAccounts()
 {
     try
     {
         using (var controller = new Controllers.TafsiliGroupController())
         {
             var result = controller.GetTafsiliGroupAccounts(search: null);
             dtGroupAccount.ItemsSource = result.Body;
         }
     }
     catch (Exception c)
     {
         MessageBox.Show(c.Message);
     }
 }
        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();
                }
            }
        }
Пример #3
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();
             }
         }
     }
 }
        private void LoadInfo(string search = null)
        {
            try
            {
                switch (selectorType)
                {
                case Models.Common.SelectorType.GroupAccounts:
                    using (var controller = new Controllers.GroupController())
                    {
                        var result = controller.GetGroupAccounts(search: search);
                        dtSource.ItemsSource = result.Body;
                    }
                    break;

                case Models.Common.SelectorType.KolAccounts:
                    using (var controller = new Controllers.KolController())
                    {
                        var result = controller.GetKolAccounts(search: search);
                        dtSource.ItemsSource = result.Body;
                    }
                    break;

                case Models.Common.SelectorType.TafsiliGroup:
                    using (var controller = new Controllers.TafsiliGroupController())
                    {
                        var result = controller.GetTafsiliGroupAccounts(search: search);
                        dtSource.ItemsSource = result.Body;
                    }
                    break;

                case Models.Common.SelectorType.PeopleGroup:
                    using (var controller = new Controllers.PeopleGroupController())
                    {
                        var result = controller.GetPeopleGroup();
                        dtSource.ItemsSource = result.Body;
                    }
                    break;
                }
            }
            catch (Exception c)
            {
                MessageBox.Show(c.Message);
            }
        }
Пример #5
0
        private void removeButton_Click(object sender, MouseButtonEventArgs e)
        {
            var updateObject = (Models.TafsiliGroup)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.TafsiliGroupController())
                        {
                            result = controller.RemoveTafsiliGroupAccount(updateObject, true);
                        }
                    }
                }
            }
            catch (Exception c)
            {
                MessageBox.Show(c.Message);
                return;
            }
            finally
            {
                if (result != null)
                {
                    MessageBox.Show(result.Message);
                    if (result.Status == Models.ActionResult.Success)
                    {
                        GetTafsiliGroupAccounts();
                    }
                }
            }
        }