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."); } } }
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."); } }
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."); } }
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(); }
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; } }
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; }
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(); }
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(); }
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(); }
public void ApplyChanges() { var newConnection = new dbContextDataContext(); //If Patient Changed. if(PatientPropertiesChanged()) { try { _sourcePatient = (from p in newConnection.tblPatients where p.PatientID == _sourcePatient.PatientID select p).SingleOrDefault(); if(_sourcePatient != null) { _sourcePatient.UpdatePatient(EditCopyPatient); newConnection.SubmitChanges(); } else { _sourcePatient = new tblPatient(); _sourcePatient.UpdatePatient(EditCopyPatient); newConnection.tblPatients.InsertOnSubmit(_sourcePatient); newConnection.SubmitChanges(); } } catch (Exception) { MessageBox.Show(@"Database not responding. Please check your connection."); } } //If Patient Address Changed. if(PatientAddressPropertiesChanged()) { try { _sourceAddress = (from p in newConnection.tblPatientAddrs where p.PatientID == _sourcePatient.PatientID select p).FirstOrDefault(); if (_sourceAddress != null) { _sourceAddress.UpdatePatientAddress(EditCopyAddress); newConnection.SubmitChanges(); } else { _sourceAddress = new tblPatientAddr(); newConnection.tblPatientAddrs.InsertOnSubmit(_sourceAddress); newConnection.SubmitChanges(); } } catch (Exception) { MessageBox.Show(@"Database not responding. Please check your connection."); } } //Claimants of this patient changed. if(ClaimantsChanged() == false) { var added = this.EditCopyClaimantList.Except(this._sourceClaimantList); var deleted = this._sourceClaimantList.Except(this.EditCopyClaimantList); if (deleted.Any()) { using (newConnection) { foreach (var y in deleted.Select(x => (tblPatientClaimant)(from p in newConnection.tblPatientClaimants where p.PatientID == this._sourcePatient.PatientID && p.ClaimantID == x.ClaimantID select p).First())) { newConnection.tblPatientClaimants.DeleteOnSubmit(y); } newConnection.SubmitChanges(); } } if (added.Any()) { var newConnection1 = new dbContextDataContext(); using (newConnection1) { foreach (var y in added.Select(x => new tblPatientClaimant { ClaimantID = x.ClaimantID, PatientID = _sourcePatient.PatientID })) { newConnection1.tblPatientClaimants.InsertOnSubmit(y); } newConnection1.SubmitChanges(); } } } }
void applyPaid() { if (this.myReceiptAmounts.Sum(r => r.InvRecAmnt).GetValueOrDefault(0.0M) >= (this.myInvoiceLines.Sum(f => f.Fee) + this.myInvoiceLines.Sum(g => g.GST))) { var newConnection = new dbContextDataContext(); var thisInvoice = newConnection.tblInvoices.Where(inv => inv.InvoiceNo == myInvoice.InvoiceNo).SingleOrDefault(); if (thisInvoice != null) { thisInvoice.InvoicePaid = true; newConnection.SubmitChanges(); this.invoiceChanged = true; } } }
public void commitInvoice() { var newConnection = new dbContextDataContext(); myInvoice.InvoiceComments = myForm.invoiceCommentsMemoEdit.Text; myInvoice.InvoicePaid = false; myInvoice.InvoiceCancelled = false; myTransaction.TranType = "I"; myTransaction.TranDate = System.DateTime.Today; myTransaction.ClaimantID = myClaimant.ClaimantID; myTransaction.InvoiceNo = myInvoice.InvoiceNo; myTransaction.Narrative = "Normal Invoice"; myTransaction.TranAmount = decimal.Add(myInvoiceLines.Sum(line => line.Fee).GetValueOrDefault(0.0M), myInvoiceLines.Sum(gst => gst.GST).GetValueOrDefault(0.0M)); myTransaction.GST = myInvoiceLines.Sum(line => line.GST).GetValueOrDefault(0.0M); newConnection.tblTransactions.InsertOnSubmit(myTransaction); newConnection.tblInvoices.InsertOnSubmit(myInvoice); newConnection.SubmitChanges(); myTransaction.InvoiceNo = myInvoice.InvoiceNo; newConnection.SubmitChanges(); foreach (tblPatientStat line in myInvoiceLines) { line.InvoiceNo = myInvoice.InvoiceNo; newConnection.tblPatientStats.InsertOnSubmit(line); } newConnection.SubmitChanges(); this.updateInvoiceForm(); this.makeInvoiceOfficial(); }