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();
                }
            }
        }
        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();
                }
            }
        }
        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();
                }
            }
        }
        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)
            {

            }
        }