private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new MSPAccountingContext())
            {
                var appointment = new Appointment();

                appointment.Date = Convert.ToDateTime(dtpDate.Value);
                appointment.Location = txtbxLocation.Text;

                var errors = appointment.GetModelErrors();
                if (errors.Count > 0)
                {
                    new ErrorDisplay(errors).Show();
                }
                else
                {
                    db.Appointment.Add(appointment);
                    db.SaveChanges();

                    MessageBox.Show("Appointment Successfully Created!", "Success", MessageBoxButton.OK);

                    this.Close();
                }
            }
        }
Exemplo n.º 2
0
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new MSPAccountingContext())
            {
                var earning = new Earning()
                {
                    Date = dtDate.Value == null ? DateTime.Now : (DateTime)dtDate.Value,
                    Amount = Decimal.Parse(txtbxAmount.Text),
                    Client = db.Client.Single(x => x.ID == ((Client)cmbbxClient.SelectedItem).ID),
                    Comments = txtbxComments.Text
                };

                var errors = earning.GetModelErrors();

                if(errors.Count > 0)
                {
                    new ErrorDisplay(errors).ShowDialog();
                }
                else
                {
                    db.Earning.Add(earning);
                    db.SaveChanges();

                    MessageBox.Show("Earning Created!");
                    Close();
                }
            }
        }
Exemplo n.º 3
0
        private void btn_Create_Click(object sender, RoutedEventArgs e)
        {
            using(var db = new MSPAccountingContext())
            {
                var client = new Client();
                client.Name = txtbx_Name.Text;
                client.ContactInfo = new ContactInfo();
                client.ContactInfo.Phone = txtbx_Phone.Text;
                client.ContactInfo.Email = txtbx_Email.Text;
                client.ContactInfo.AddressLine1 = txtbx_Addr1.Text;
                client.ContactInfo.AddressLine2 = txtbx_Addr2.Text;
                client.ContactInfo.City = txtbx_City.Text;
                client.ContactInfo.State = db.State.Where(x => x.ID == ((State)cmbbx_State.SelectedItem).ID).FirstOrDefault();
                client.ContactInfo.Zip = txtbx_Zip.Text;

                var errors = client.GetModelErrors();
                if(errors.Count > 0)
                {
                    new ErrorDisplay(errors).Show();
                }
                else
                {
                    db.Client.Add(client);
                    db.SaveChanges();

                    MessageBox.Show("Client Successfully Created!", "Success", MessageBoxButton.OK);

                    this.Close();
                }
            }
        }
Exemplo n.º 4
0
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new MSPAccountingContext())
                {
                    var isClientSelected = cmbbxClient.SelectedItem != null;
                    var expense = new Expense()
                    {
                        Date = datetime_Date.Value == null ? DateTime.Now : (DateTime)datetime_Date.Value,
                        Amount = dcmlAmount.Value == null ? 0 : (decimal)dcmlAmount.Value,
                        Client = isClientSelected ? db.Client.SingleOrDefault(x => x.ID == ((Client)cmbbxClient.SelectedItem).ID) : null,
                        Comments = txtbxComments.Text
                    };

                    var errors = expense.GetModelErrors();

                    if (errors.Count > 0)
                    {
                        new ErrorDisplay(errors).Show();
                    }
                    else
                    {
                        db.Expense.Add(expense);
                        db.SaveChanges();
                    }
                }
            }

            catch (Exception ex)
            {

            }
        }
Exemplo n.º 5
0
        private void LoadStates()
        {
            using (var db = new MSPAccountingContext())
            {
                var statesList = db.State.ToList();
                cmbbx_State.ItemsSource = statesList;
                var displayName = utilities.GetPropertyName(() => statesList.First().Name);
                cmbbx_State.DisplayMemberPath = displayName;

                cmbbx_State.SelectedIndex = 0;
            }
        }
Exemplo n.º 6
0
        private void LoadClients()
        {
            var utilities = new Utilities();
            using (var db = new MSPAccountingContext())
            {
                var clients = db.Client.ToList();
                cmbbxClient.ItemsSource = clients;
                var displayName = utilities.GetPropertyName(() => clients.First().Name);
                cmbbxClient.DisplayMemberPath = displayName;

                cmbbxClient.SelectedIndex = 0;
            }
        }
Exemplo n.º 7
0
        private void Load()
        {
            var utilities = new Utilities();
            using (var db = new MSPAccounting.Models.MSPAccountingContext())
            {
                var earnings = db.Earning.ToList();

                if (earnings.Count == 0)
                {
                    dataGridEarnings.Visibility = Visibility.Collapsed;
                    txtblkNoEarnings.Visibility = Visibility.Visible;
                }
                else
                {
                    dataGridEarnings.Visibility = Visibility.Visible;
                    txtblkNoEarnings.Visibility = Visibility.Collapsed;

                    dataGridEarnings.ItemsSource = utilities.GetViewModelList<Earning, EarningView>(earnings);
                }
            }
        }
Exemplo n.º 8
0
        private void Load()
        {
            var utilities = new Utilities();
            using (var db = new MSPAccounting.Models.MSPAccountingContext())
            {
                var clients = db.Client.ToList();

                if (clients.Count == 0)
                {
                    dataGridClients.Visibility = Visibility.Collapsed;
                    txtblkNoClients.Visibility = Visibility.Visible;
                }
                else
                {
                    dataGridClients.Visibility = Visibility.Visible;
                    txtblkNoClients.Visibility = Visibility.Collapsed;

                    dataGridClients.ItemsSource = utilities.GetViewModelList<Client, ClientView>(clients);
                }
            }
        }
Exemplo n.º 9
0
        private void Load()
        {
            var utilities = new Utilities();

            using (var db = new MSPAccounting.Models.MSPAccountingContext())
            {
                var expenses = db.Expense.ToList();

                if (expenses.Count == 0)
                {
                    dataGridExpenses.Visibility = Visibility.Collapsed;
                    txtblkNoExpenses.Visibility = Visibility.Visible;
                }
                else
                {
                    dataGridExpenses.Visibility = Visibility.Visible;
                    txtblkNoExpenses.Visibility = Visibility.Collapsed;

                    dataGridExpenses.ItemsSource = utilities.GetViewModelList <Expense, ExpenseView>(expenses);
                }
            }
        }
Exemplo n.º 10
0
        private void Load()
        {
            var utilities = new Utilities();

            using (var db = new MSPAccounting.Models.MSPAccountingContext())
            {
                var clients = db.Client.ToList();

                if (clients.Count == 0)
                {
                    dataGridClients.Visibility = Visibility.Collapsed;
                    txtblkNoClients.Visibility = Visibility.Visible;
                }
                else
                {
                    dataGridClients.Visibility = Visibility.Visible;
                    txtblkNoClients.Visibility = Visibility.Collapsed;

                    dataGridClients.ItemsSource = utilities.GetViewModelList <Client, ClientView>(clients);
                }
            }
        }