private void journalReportViewForm_Load(object sender, EventArgs e)
        {
            var newDatePickerDialog = new dateIntervalDialog();
            var newConnection = new dbContextDataContext();

            newDatePickerDialog.ShowDialog();

            if (newDatePickerDialog.DialogResult == DialogResult.OK)
            {
                journalReportGridControl.DataSource = from p in newConnection.tblTransactions
                                                      join c in newConnection.tblClaimants
                                                      on p.ClaimantID equals c.ClaimantID
                                                      where p.TranDate >= newDatePickerDialog.startDate & p.TranDate <= newDatePickerDialog.endDate
                                                      select new
                                                      {
                                                          Date = p.TranDate,
                                                          Claimant = c.FirstNames + " " + c.LastName,
                                                          InvoiceNo = p.InvoiceNo,
                                                          Type = p.TranType,
                                                          Physio = p.PhysioID,
                                                          Narrative = p.Narrative,
                                                          Amount = p.TranAmount
                                                      };
                newDatePickerDialog.Dispose();
            }
            else
            {
                newDatePickerDialog.Dispose();
                this.Close();
            }
        }
        private void invoiceDetailsBtn_Click(object sender, EventArgs e)
        {
            if ((getClaimantInvoicesResult)claimantInvoicesView.GetFocusedRow() != null)
            {
                    var currentRow = (getClaimantInvoicesResult)claimantInvoicesView.GetFocusedRow();
                    var newConnection = new dbContextDataContext();
                    var currentInvoice = newConnection.tblInvoices.Where(i => i.InvoiceNo == currentRow.InvoiceNo).SingleOrDefault();

                    if (currentInvoice != null)
                    {
                        var viewInvoice = new Accounting.Invoice.newInvoiceForm(currentInvoice);
                        viewInvoice.ShowDialog();
                        if (viewInvoice.DialogResult == DialogResult.OK)
                        {
                            updateForm();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Data corrupt, can not retrieve invoice.");
                    }

            }
            else
                this.DialogResult = DialogResult.Retry;
        }
        private void patientLinqInstantFeedBackSource_GetQueryable(object sender, DevExpress.Data.Linq.GetQueryableEventArgs e)
        {
            var newConnection = new dbContextDataContext();
            e.QueryableSource = newConnection.tblPatients;

            e.Tag = newConnection;
        }
        public void ApplyChanges()
        {
            var newConnection = new dbContextDataContext();

            try
            {
                if (ClaimantPropertiesChanged())
                {
                    _sourceClaimant = (from p in newConnection.tblClaimants
                                       where p.ClaimantID == _sourceClaimant.ClaimantID
                                       select p).SingleOrDefault();
                    if (_sourceClaimant != null)
                    {
                        //_sourceClaimant.UpdateClaimant(EditCopyClaimant);
                        _sourceClaimant.setProperty(EditCopyClaimant);
                        newConnection.SubmitChanges();
                    }
                    else
                    {
                        _sourceClaimant = new tblClaimant();
                        //_sourceClaimant.UpdateClaimant(EditCopyClaimant);
                        _sourceClaimant.setProperty(EditCopyClaimant);
                        newConnection.tblClaimants.InsertOnSubmit(_sourceClaimant);
                        newConnection.SubmitChanges();
                    }
                }
            }

            catch(Exception)
            {
                MessageBox.Show(@"Database not responding. Please check your connection.");
            }
        }
        public void ApplyChanges()
        {
            if (DoctorPropertiesChanged())
            {
                var newConnection = new dbContextDataContext();
                try
                {
                    _sourceDoctor = (from p in newConnection.tblRefDoctors
                                     where p.RefDoctor == _sourceDoctor.RefDoctor
                                     select p).SingleOrDefault();

                    //Null = new doctor
                    if (_sourceDoctor != null)
                    {
                        _sourceDoctor.UpdateDoctor(EditCopyDoctor);
                        newConnection.SubmitChanges();
                    }
                    else
                    {
                        _sourceDoctor = new tblRefDoctor();
                        _sourceDoctor.UpdateDoctor(EditCopyDoctor);
                        newConnection.tblRefDoctors.InsertOnSubmit(_sourceDoctor);
                        newConnection.SubmitChanges();
                    }
                }
                    catch (Exception)
                {
                    MessageBox.Show(@"Database not responding. Please check your connection.");
                }
            }
        }
 private void patientInvoiceViewForm_Load(object sender, EventArgs e)
 {
     var newConnection = new dbContextDataContext();
     patientInvoiceGridControl.DataSource  = (from p in newConnection.tblTransactions
                                      join t in newConnection.tblPatients
                                      on p.PatientID equals t.PatientID
                                      where p.PatientID == 10834
                                      select p).Distinct();
 }
Exemple #7
0
 public addCreditViewForm(Db.Credit MyCredit)
 {
     InitializeComponent();
     myCredit = MyCredit;
     var claimant = new dbContextDataContext().tblClaimants.Where(c => c.ClaimantID == myCredit.ClaimantID).FirstOrDefault();
     if (claimant != null)
     {
         myClaimant = claimant;
     }
     updateDetails();
 }
Exemple #8
0
 private void claimantLinqInstantFeedbackSource_GetQueryable(object sender, DevExpress.Data.Linq.GetQueryableEventArgs e)
 {
     try
     {
         var newConnection = new dbContextDataContext();
         newConnection.ObjectTrackingEnabled = false;
         e.QueryableSource = newConnection.tblClaimants;
         e.Tag = newConnection;
     }
     catch (Exception)
     {
         MessageBox.Show("here");
     }
 }
        void updateAppointments(int ID)
        {
            Cursor.Current = Cursors.WaitCursor;
            var newConnection = new dbContextDataContext();

            if (futureDateCheckEdit.Checked == false)
            {
                this.appointmentsGridControl.DataSource = from a in newConnection.PatientAppointments
                                                          where (a.PatientID == ID)
                                                          from r in newConnection.tblRates
                                                          where r.RateID == a.RateID
                                                          from p in newConnection.tblPatients
                                                          where p.PatientID == a.PatientID
                                                          select new AnonAppointments
                                                          {
                                                              ID = p.PatientID,
                                                              AppointmentID = a.UniqueID,
                                                              Name = p.FirstNames + @" " + p.LastName,
                                                              DOB = p.BirthDate,
                                                              Physio = a.PhysioID,
                                                              Rate = r.RateDesc,
                                                              Date = a.StartDate.Value.Date,
                                                              Start = a.StartDate.Value.ToShortTimeString(),
                                                              End = a.EndDate.Value.ToShortTimeString()
                                                          };
            }
            else
            {
                this.appointmentsGridControl.DataSource = from a in newConnection.PatientAppointments
                                                          where (a.PatientID == ID) && (a.StartDate > System.DateTime.Today)
                                                          from r in newConnection.tblRates
                                                          where r.RateID == a.RateID
                                                          from p in newConnection.tblPatients
                                                          where p.PatientID == a.PatientID
                                                          select new AnonAppointments
                                                          {
                                                              ID = p.PatientID,
                                                              AppointmentID = a.UniqueID,
                                                              Name = p.FirstNames + @" " + p.LastName,
                                                              DOB = p.BirthDate,
                                                              Physio = a.PhysioID,
                                                              Rate = r.RateDesc,
                                                              Date = a.StartDate.Value.Date,
                                                              Start = a.StartDate.Value.ToShortTimeString(),
                                                              End = a.EndDate.Value.ToShortTimeString()
                                                          };
            }

            Cursor.Current = Cursors.Default;
        }
Exemple #10
0
        public invoicePrintReport(tblInvoice myInvoice, tblClaimant myClaimant, tblTransaction myTransaction)
        {
            InitializeComponent();

            Cursor.Current = Cursors.WaitCursor;
            invoiceDateLabel.Text = "Issued on: " + String.Format("{0:MM/dd/yyyy}", myTransaction.TranDate);
            InvoiceNoLabel.Text = "Invoice # : " + myInvoice.InvoiceNo.ToString();
            claimantNameLabel.Text = myClaimant.FirstNames + " " + myClaimant.LastName;
            streetLabel.Text = myClaimant.Address1;
            suburbLabel.Text = myClaimant.Address2;
            stateLabel.Text = myClaimant.Address3;
            postCodeLabel.Text = myClaimant.Postcode;
            if (myClaimant.Terms.GetValueOrDefault() > 0)
            {
                claimantTermsLabel.Text = myClaimant.Terms.ToString() + " " + "days";
            }
            else
            {
                claimantTermsLabel.Text = "ASAP";
            }

            var Lines = new dbContextDataContext().getInvoiceLines(myInvoice.InvoiceNo).ToList();
            tblPhysio myPhysio = new dbContextDataContext().tblPhysios.Where(p => p.PhysioID == myTransaction.PhysioID).SingleOrDefault();
            physioProviderNoLabel.Text = myPhysio.ProviderNo;
            physioNameLabel.Text = myPhysio.PhysioName;

            var receipts = new dbContextDataContext().getReceiptsOfSingleInvoice(myInvoice.InvoiceNo).ToList();
            this.DataSource = Lines;
            sessionDateTableCell.DataBindings.Add(new DevExpress.XtraReports.UI.XRBinding("Text", this.DataSource, "Date", "{0:MM/dd/yyyy}"));
            dobTableCell.DataBindings.Add(new DevExpress.XtraReports.UI.XRBinding("Text", this.DataSource, "DOB", "{0:MM/dd/yyyy}"));
            feeTableCell.DataBindings.Add("Text", this.DataSource, "Fee", "{0:c2}");
            gstTableCell.DataBindings.Add("Text", this.DataSource, "GST", "{0:c2}");
            totalTableCell.DataBindings.Add("Text", this.DataSource, "Total", "{0:c2}");

            decimal invoiceTotal = decimal.Add( (decimal)Lines.Sum(od => od.Fee), (decimal)Lines.Sum(od => od.GST));
            decimal alreadyPaid = (decimal)receipts.Sum(r => r.InvRecAmnt);
            decimal remaining = decimal.Subtract(invoiceTotal, alreadyPaid);

            invoiceTotalLabel.Text = string.Format("{0:c2}", invoiceTotal);
            paidTotalLabel.Text = string.Format("{0:c2}", alreadyPaid);
            amountToBePaidLabel.Text = string.Format("{0:c2}", remaining);

            decimal feeTotal = (decimal)Lines.Sum(od => od.Fee);
            decimal gstTotal = (decimal)Lines.Sum(od => od.GST);
            //feeTotalLabel.Text = feeTotalLabel.Text + feeTotal;
            //gstTotalLabel.Text = gstTotalLabel.Text + gstTotal;
            //totalLabel.Text = totalLabel.Text + decimal.Add(feeTotal, gstTotal);
            Cursor.Current = Cursors.Default;
        }
        private void patientInvoiceView_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            var newTransaction = (tblTransaction)this.patientInvoiceView.GetFocusedRow();
            var newConnection = new dbContextDataContext();
            var currentInvoice = newConnection.tblInvoices.SingleOrDefault(od => od.InvoiceNo == newTransaction.InvoiceNo);
            if (currentInvoice != null)
            {
                myInvoice = currentInvoice;
                this.DialogResult = DialogResult.OK;
            }

            else
            {
                MessageBox.Show("This invoice was not found.");
                this.DialogResult = DialogResult.Retry;
            }
        }
Exemple #12
0
        private void checkOutBtn_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                var currentRow = (AnonWaitingRoom)waitingRoomGridView.GetFocusedRow();
                var newConnection = new dbContextDataContext();
                var formOpen = false;

                if (currentRow != null)
                {
                    var thisApp = newConnection.PatientAppointments.Where(a => a.UniqueID == currentRow.AppointmentID).FirstOrDefault();

                    foreach (var f in Application.OpenForms)
                    {
                        if (f.GetType() == typeof(appointmentViewForm))
                        {
                            thisApp.CheckOut = true;
                            thisApp.Label = 2;
                            newConnection.SubmitChanges();

                            ((appointmentViewForm)f).RefreshAppointment(thisApp.UniqueID);
                            formOpen = true;
                        }
                    }

                    if (formOpen == false)
                    {
                        thisApp.CheckOut = true;
                        thisApp.Label = 2;
                        newConnection.SubmitChanges();
                    }
                    updateWaitingRoom();

                }
                else
                {
                    MessageBox.Show("Please Select a Patient first!");
                }
                Cursor.Current = Cursors.Default;
            }
            catch (Exception)
            {
                MessageBox.Show("Data changed. Waiting room will be reloaded. Please try again.");
            }
        }
Exemple #13
0
        private void referralDocBgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var newConnection = new dbContextDataContext();
            try
            {

                    _formIQueryable = (from p in newConnection.tblRefDoctors
                                       where (p.RefDFNames + " " + p.RefDName).Contains(searchFieldTextBox.Text)
                                       select p).Take(10).ToList();

                    searchTimer.Stop();
            }

            catch(Exception)
            {
                MessageBox.Show("Database not responding. Please check your connection.");
            }
        }
        private void receiptsByPhysioRateForm_Load(object sender, EventArgs e)
        {
            var newDatePickerDialog = new dateIntervalDialog();
            var newConnection = new dbContextDataContext();

            newDatePickerDialog.ShowDialog();

            if (newDatePickerDialog.DialogResult == DialogResult.OK)
            {
                receiptsPhysioPivotGrid.DataSource = newConnection.RatesAndItemsSummaryReportFunction(newDatePickerDialog.startDate, newDatePickerDialog.endDate);
                newDatePickerDialog.Dispose();
            }
            else
            {
                newDatePickerDialog.Dispose();
                this.Close();
            }
        }
        public void fillData()
        {
            Cursor.Current = Cursors.WaitCursor;
            var newConnection = new dbContextDataContext();
            var cid = new object();
            var pid = new object();

            if ((myClaimant.ClaimantID == 0) && (myPhysio.UniqueID != 0))
                this.agedTrailGridControl.DataSource = newConnection.getAgedTrailBalance(null, myPhysio.PhysioID, startDate, endDate);

            else if ((myClaimant.ClaimantID != 0) && (myPhysio.UniqueID == 0))
                this.agedTrailGridControl.DataSource = newConnection.getAgedTrailBalance(myClaimant.ClaimantID, null, startDate, endDate);
            else if ((myClaimant.ClaimantID == 0) && (myPhysio.UniqueID == 0))
                this.agedTrailGridControl.DataSource = newConnection.getAgedTrailBalance(null, null, startDate, endDate);
            else
            this.agedTrailGridControl.DataSource = newConnection.getAgedTrailBalance(myClaimant.ClaimantID, myPhysio.PhysioID, startDate, endDate);

            Cursor.Current = Cursors.Default;
        }
        public override void okBtn_Click(object sender, EventArgs e)
        {
            base.okBtn_Click(sender, e);
            var newConnection = new dbContextDataContext();

            foreach(var c in myCreditList)
            {
                if(c.CreditCancelled == true)
                {
                    var currentCredit = newConnection.Credits.Where(cr => cr.CreditID == c.CreditID).FirstOrDefault();
                    if (currentCredit != null)
                    {
                        currentCredit.setProperty(c);
                    }
                }
            }

            newConnection.SubmitChanges();
        }
Exemple #17
0
 private void deleteUserBtn_Click(object sender, EventArgs e)
 {
     var newConnection = new dbContextDataContext();
     var currentUser = newConnection.tblUsers.Where(od => od.UniqueID == myUser.UniqueID).SingleOrDefault();
     if (currentUser != null)
     {
         newConnection.tblUsers.DeleteOnSubmit(currentUser);
         newConnection.SubmitChanges();
         userLookUp.Properties.DataSource = newConnection.tblUsers;
         myUser = new tblUser();
         updateForm();
         userLookUp.EditValue = null;
     }
     else
     {
         myUser = new tblUser();
         updateForm();
         userLookUp.EditValue = null;
     }
 }
        private void newPatientStatsViewForm_Load(object sender, EventArgs e)
        {
            var newDatePickerDialog = new dateIntervalDialog();
            var newConnection = new dbContextDataContext();

            newDatePickerDialog.ShowDialog();

            if (newDatePickerDialog.DialogResult == DialogResult.OK)
            {
                Start = newDatePickerDialog.startDate;
                End = newDatePickerDialog.endDate;

                newPatientPivotGridControl.DataSource = newConnection.getNewPatients(Start, End);
                newDatePickerDialog.Dispose();
            }
            else
            {
                newDatePickerDialog.Dispose();
                this.Close();
            }
        }
Exemple #19
0
 void saveToDb()
 {
     var newConnection = new dbContextDataContext();
     var currentUser = newConnection.tblUsers.Where(od => od.UniqueID == myUser.UniqueID).SingleOrDefault();
     if (currentUser == null)
     {
         myUser.UserID = userIDTextEdit.Text;
         myUser.Password = passwordTextEdit.Text;
         myUser.FirstNames = firstNameTextEdit.Text;
         myUser.LastName = lastNameTextEdit.Text;
         if (accessLevelComboBoxEdit.Text == "Adminstrator")
         {
             myUser.UserLevel = 1;
         }
         if (accessLevelComboBoxEdit.Text == "General User")
         {
             myUser.UserLevel = 3;
         }
         newConnection.tblUsers.InsertOnSubmit(myUser);
     }
     else
     {
         myUser = newConnection.tblUsers.Where(od => od.UniqueID == myUser.UniqueID).SingleOrDefault();
         myUser.UserID = userIDTextEdit.Text;
         myUser.Password = passwordTextEdit.Text;
         myUser.FirstNames = firstNameTextEdit.Text;
         myUser.LastName = lastNameTextEdit.Text;
         if (accessLevelComboBoxEdit.Text == "Adminstrator")
         {
             myUser.UserLevel = 1;
         }
         if (accessLevelComboBoxEdit.Text == "General User")
         {
             myUser.UserLevel = 3;
         }
     }
     newConnection.SubmitChanges();
 }
Exemple #20
0
        private void paymentAuditTrail_Load(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            var newDatePickerDialog = new dateIntervalDialog();
            var newConnection = new dbContextDataContext();

            newDatePickerDialog.ShowDialog();

            if (newDatePickerDialog.DialogResult == DialogResult.OK)
            {
                Start = newDatePickerDialog.startDate;
                End = newDatePickerDialog.endDate;

                paymentAuditTrialPivotGridControl.DataSource = newConnection.getPaymentAuditTrial(newDatePickerDialog.startDate, newDatePickerDialog.endDate);
                newDatePickerDialog.Dispose();
            }
            else
            {
                newDatePickerDialog.Dispose();
                this.Close();
            }
            Cursor.Current = Cursors.Default;
        }
Exemple #21
0
 private void referralInstantFeedBack_GetQueryable(object sender, DevExpress.Data.Linq.GetQueryableEventArgs e)
 {
     var newConnection = new dbContextDataContext();
     e.QueryableSource = newConnection.tblRefDoctors;
     e.Tag = newConnection;
 }
        void applyReceipt()
        {
            var newConnection = new dbContextDataContext();

            myReceipt.ReceiptDate = System.DateTime.Today;
            myReceipt.ReceiptAmnt = myPayments.Sum(p => p.PayinAmnt);
            myReceipt.UserID = staticProperties.userName;
            myReceipt.IsMulti = true;

            newConnection.tblReceipts.InsertOnSubmit(myReceipt);
            newConnection.SubmitChanges();

            foreach (var p in myPayments)
            {
                p.ReceiptNo = myReceipt.ReceiptNo;
                if (p.PayinType == "7")
                {
                    var c = new tblReceiptCreditPatient();
                    c.ClaimantID = myClaimant.ClaimantID;
                    c.CreditAmnt = p.PayinAmnt;
                    c.ReceiptNo = myReceipt.ReceiptNo;
                    c.ReceiptDate = myReceipt.ReceiptDate;

                    newConnection.tblReceiptCreditPatients.InsertOnSubmit(c);
                }

                newConnection.tblPayins.InsertOnSubmit(p);
            }
            newConnection.SubmitChanges();
        }
Exemple #23
0
        private void ReferralDocBgWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            var newConnection = new dbContextDataContext();
            try
            {
                if (!string.IsNullOrEmpty(searchFieldTextBox.Text))
                {
                    _doctorList = (from p in newConnection.tblRefDoctors
                                   where (p.RefDFNames + @" " + p.RefDName + @" " + p.RefProviderNo).Contains(searchFieldTextBox.Text)
                                   select p).Take(30).ToList();
                }
                else
                {
                    searchResultProgressBar.Value = 0;
                    loadBarTimer.Stop();
                }
                searchTimer.Stop();
            }

            catch (Exception)
            {
                MessageBox.Show(@"Database not responding. Please check your connection.");
            }
        }
Exemple #24
0
 private void PostCodeBgWorkerDoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         var newConnection = new dbContextDataContext();
         _postCodeList = (from p in newConnection.tblPostcodes
                          where p.Location.Contains(_suburbSearchText)
                          select p
                         ).Take(10).ToList();
     }
     catch (Exception)
     {
         MessageBox.Show(@"Something is wrong with your server, Can not retrieve post code / Suburb Data!");
     }
     this.postCodeTimer.Stop();
 }
        void updateForm()
        {
            var newConnection = new dbContextDataContext();

            var unpaidlist =
                (from u in newConnection.getUnPaidInvoices(myClaimant.ClaimantID)
                 select new AnonUnPaidInvoice
                 {
                     Balance = u.Balance.GetValueOrDefault(u.InvoiceTotal.Value),
                     InvoiceDate = u.InvoiceDate.Value,
                     InvoiceTotal = u.InvoiceTotal.GetValueOrDefault(0.0M),
                     ReceiptTotal = u.ReceiptTotal.GetValueOrDefault(0.0M),
                     InvoiceNo = u.InvoiceNo,
                     ReceiptAmount = 0.0M
                 }).ToList();

            myUnPaidInvoices = new BindingList<AnonUnPaidInvoice>(unpaidlist);
        }
Exemple #26
0
 private void userViewForm_Load(object sender, EventArgs e)
 {
     var newConnection = new dbContextDataContext();
     userLookUp.Properties.DataSource = newConnection.tblUsers;
     userLookUp.Properties.DisplayMember = "UserID";
 }
        private void invoiceDetailsBtn_Click(object sender, EventArgs e)
        {
            if ((AnonUnPaidInvoice)multipleReceiptView.GetFocusedRow() != null)
            {
                var currentRow = (AnonUnPaidInvoice)multipleReceiptView.GetFocusedRow();

                Cursor.Current = Cursors.WaitCursor;
                var newConnection = new dbContextDataContext();

                var currentInvoice = newConnection.tblInvoices.Where(i => i.InvoiceNo == currentRow.InvoiceNo).SingleOrDefault();
                if (currentInvoice != null)
                {
                    var newInvoice = new Accounting.Invoice.newInvoiceForm(currentInvoice);
                    newInvoice.ShowDialog();

                    if (newInvoice.DialogResult == DialogResult.OK)
                        updateForm();
                    newInvoice.Dispose();
                }
                else
                {
                    MessageBox.Show("Data corrupt, can not retrieve invoice.");
                }

            }
            else
                this.DialogResult = DialogResult.Retry;
        }
Exemple #28
0
 private void addCreditViewForm_Load(object sender, EventArgs e)
 {
     var newConnection = new dbContextDataContext();
     creditTypeLookUpEdit.Properties.DataSource = newConnection.CreditTypes;
 }
        public override void okBtn_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            base.okBtn_Click(sender, e);

            if (this.myUnPaidInvoices.Any() != true)
            {
                MessageBox.Show("Can not process receipt. This claimant have no unpaid invoices.");
                this.DialogResult = DialogResult.Retry;
                return;
            }

            if (this.DialogResult == DialogResult.OK)
            {
                applyReceipt();

                var paidlist = new List<int> { };
                var newConnection = new dbContextDataContext();
                foreach (var i in myUnPaidInvoices)
                {
                    if(!object.Equals(i.ReceiptAmount, default(decimal)))
                    {
                        var ir = new tblInvoiceReceipt();
                        ir.InvRecAmnt = i.ReceiptAmount;
                        ir.InvoiceNo = i.InvoiceNo;
                        ir.ReceiptNo = myReceipt.ReceiptNo;
                        newConnection.tblInvoiceReceipts.InsertOnSubmit(ir);
                    }
                    if ((i.ReceiptAmount + i.ReceiptTotal) == i.InvoiceTotal)
                    {
                        paidlist.Add(i.InvoiceNo);
                    }
                }

                foreach (var p in paidlist)
                {
                    var inv = newConnection.tblInvoices.Where(i => i.InvoiceNo == p).SingleOrDefault();
                    if(inv !=null)
                    inv.InvoicePaid = true;
                }

                if (myPayments.Sum(p => p.PayinAmnt).Value > myUnPaidInvoices.Sum(u => u.ReceiptAmount))
                {
                    var result = MessageBox.Show("Fund remaining, do you want to save this as a credit?", "OVERPAYMENT",
                             MessageBoxButtons.YesNoCancel,
                             MessageBoxIcon.Question);

                    if (result == DialogResult.Yes)
                    {
                        var newCredit = new Db.Credit();
                        newCredit.CreditComment = "Overpayment on Receipt #: " + myReceipt.ReceiptNo.ToString();
                        newCredit.CreditDate = System.DateTime.Today;
                        newCredit.CreditType = 3;
                        newCredit.ClaimantID = myClaimant.ClaimantID;
                        newCredit.CreditCancelled = false;
                        newCredit.CreditAmount = decimal.Subtract(myPayments.Sum(p => p.PayinAmnt).Value, myUnPaidInvoices.Sum(u => u.ReceiptAmount));
                        newConnection.Credits.InsertOnSubmit(newCredit);
                    }

                    if (result == DialogResult.No)
                    {
                        //proceed as normal.
                    }

                    if (result == DialogResult.Cancel)
                    {
                        this.DialogResult = DialogResult.Retry;
                        return;
                    }
                }

                newConnection.SubmitChanges();
            }
            Cursor.Current = Cursors.Default;
        }
Exemple #30
0
        void applyCredit()
        {
            var newConnection = new dbContextDataContext();
            var currentCredit = newConnection.Credits.Where(c => c.CreditID == myCredit.CreditID).FirstOrDefault();
            if (currentCredit.IsNullOrDefault())
            {
                if (myCredit.CreditAmount <= 0)
                {
                    MessageBox.Show("Please enter the Credit Amount.");
                    this.DialogResult = DialogResult.Retry;
                    return;
                }
                if (myCredit.CreditType <= 0)
                {
                    MessageBox.Show("Please select the Credit Type.");
                    this.DialogResult = DialogResult.Retry;
                    return;
                }

                newConnection.Credits.InsertOnSubmit(myCredit);
            }
            else
            {
                currentCredit.setProperty(myCredit);
            }

            newConnection.SubmitChanges();
        }