Example #1
0
        private void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            //Verify The user
            if (goodID != "OK")
            {
                //Recheck
                goodID = _memberFuncs.CheckTheMember(memberIDTextbox.Text);
                validatedLabel.Content = goodID;
                if (goodID != "OK")
                {
                    memberIDTextbox.BorderBrush = System.Windows.Media.Brushes.Red;
                }
            }

            //Verify The Service
            goodService = _serviceCheck.CheckTheServiceCode(serviceCodeTextbox.Text);
            if (!goodService)
            {
                serviceCodeTextbox.BorderBrush = System.Windows.Media.Brushes.Red;
                return;
            }

            //Verify Date - make sure date not in future
            goodDate = (ServiceDatePicker.SelectedDate != null) && (ServiceDatePicker.SelectedDate.GetValueOrDefault().Date <= DateTime.Today.Date);
            if (!goodDate)
            {
                ServiceDatePicker.BorderBrush = System.Windows.Media.Brushes.Red;
            }

            if (goodService && goodDate && goodID == "OK")
            {
                //Create object

                var newBill = new bill_info();
                newBill.EntryDate    = DateTime.Now.Date;
                newBill.ServiceDate  = ServiceDatePicker.SelectedDate;
                newBill.MemberID     = Convert.ToInt32(memberIDTextbox.Text);
                newBill.ProviderID   = Convert.ToInt32(ProviderID);
                newBill.ServiceID    = Convert.ToInt32(serviceCodeTextbox.Text);
                newBill.ExpectedCost = (!string.IsNullOrEmpty(CostTextbox.Text)) ? Convert.ToDecimal(CostTextbox.Text) : 0;
                newBill.Notes        = CommentsTextBox.Text;

                //Insert into database
                if (_billingFuncs.InsertBilling(newBill))
                {
                    MessageBox.Show("Created Billing Entry");
                }
                else
                {
                    MessageBox.Show("Error Creating Billing Entry");
                }


                this.Close();
            }
        }
Example #2
0
 public bool InsertBilling(bill_info newBillInfo)
 {
     dbs.bill_info.Add(newBillInfo);
     return(dbs.SaveChanges() > 0);
 }