} //---------------------------- //this function returns the payment summary public CommonExchange.PaymentSummary GetPaymentSummary() { CommonExchange.PaymentSummary paySummary = new CommonExchange.PaymentSummary(); paySummary.AmountPayable = this.GetTotalAmountPayable(); paySummary.AmountPaid = 0; paySummary.Discount = 0; if (_paymentDetailsTable != null) { foreach (DataRow payRow in _paymentDetailsTable.Rows) { Decimal payAmount = 0; Decimal discount = 0; if (Decimal.TryParse(payRow["amount"].ToString(), out payAmount)) { paySummary.AmountPaid += payAmount; } if (Decimal.TryParse(payRow["discount"].ToString(), out discount)) { paySummary.Discount += discount; } } } paySummary.Balance = paySummary.AmountPayable - (paySummary.AmountPaid + paySummary.Discount); return(paySummary); } //---------------------------
//############################################CLASS PatientCharges EVENTS####################################################### //event is raised when the class is loaded protected virtual void ClassLoad(object sender, EventArgs e) { if (!DatabaseLib.ProcStatic.IsSystemAccessAdmin(_userInfo) && !DatabaseLib.ProcStatic.IsSystemAccessDentalUser(_userInfo)) { DentalLib.ProcStatic.ShowErrorDialog("You are not allowed to access this module.", "Payment Details"); _hasErrors = true; this.Close(); } else if (!DatabaseLib.ProcStatic.IsSystemAccessAdmin(_userInfo)) { this.lnkChange.Visible = false; } _paymentInfo = new CommonExchange.PaymentDetails(); _paymentInfo.DatePaid = _chargesManager.ServerDateTime; _paymentInfo.RegistrationSystemId = _regInfo.RegistrationSystemId; this.lblDate.Text = DateTime.Parse(_paymentInfo.DatePaid).ToLongDateString(); this.InitializePaymentTypeCombo(); _summary = _chargesManager.GetPaymentSummary(); this.lblBalancetoDate.Text = _summary.Balance.ToString("N"); this.lblShouldBeBalance.Text = _summary.Balance.ToString("N"); } //------------------------------------------------------------
} //--------------------------------- //##########################################END LINKBUTTON lnkPrescription EVENTS################################################### #endregion #region Programmer-Defined Void Procedures //this procedure sets the payment summary private void SetPaymentSummary() { _paymentSummary = _chargesManager.GetPaymentSummary(); this.lblAmountPayable.Text = _paymentSummary.AmountPayable.ToString("N"); this.lblAmountPaid.Text = _paymentSummary.AmountPaid.ToString("N"); this.lblDiscount.Text = _paymentSummary.Discount.ToString("N"); this.lblBalance.Text = _paymentSummary.Balance.ToString("N"); } //--------------------------
//this procedure prints the receipt public void PrintPatientChargesReceipt(CommonExchange.SysAccess userInfo, CommonExchange.Patient patientInfo, CommonExchange.Registration regInfo) { DataTable regTable = new DataTable("RegistrationTable"); regTable.Columns.Add("sysid_registration", System.Type.GetType("System.String")); DataRow regRow = regTable.NewRow(); regRow["sysid_registration"] = regInfo.RegistrationSystemId; regTable.Rows.Add(regRow); regTable.AcceptChanges(); DataTable procedureTable = new DataTable("ProceduresTakenTable"); procedureTable.Columns.Add("details_id", System.Type.GetType("System.String")); procedureTable.Columns.Add("sysid_registration", System.Type.GetType("System.String")); procedureTable.Columns.Add("date_administered", System.Type.GetType("System.String")); procedureTable.Columns.Add("procedure_name", System.Type.GetType("System.String")); procedureTable.Columns.Add("amount", System.Type.GetType("System.Decimal")); if (_registrationDetailsTable != null) { foreach (DataRow detailsRow in _registrationDetailsTable.Rows) { DataRow newRow = procedureTable.NewRow(); newRow["details_id"] = detailsRow["details_id"].ToString(); newRow["sysid_registration"] = regInfo.RegistrationSystemId; newRow["date_administered"] = "Date Administered: " + DateTime.Parse(detailsRow["date_administered"].ToString()).ToShortDateString() + ((!String.IsNullOrEmpty(DatabaseLib.ProcStatic.DataRowConvert(detailsRow, "tooth_no", ""))) ? " Tooth No: " + DatabaseLib.ProcStatic.DataRowConvert(detailsRow, "tooth_no", "").ToString() : ""); newRow["procedure_name"] = detailsRow["procedure_name"].ToString(); newRow["amount"] = Decimal.Parse(detailsRow["amount"].ToString()); procedureTable.Rows.Add(newRow); } procedureTable.AcceptChanges(); } DataTable paymentTable = new DataTable("PaymentTable"); paymentTable.Columns.Add("receipt_no", System.Type.GetType("System.String")); paymentTable.Columns.Add("sysid_registration", System.Type.GetType("System.String")); paymentTable.Columns.Add("receipt_details", System.Type.GetType("System.String")); paymentTable.Columns.Add("payment_details", System.Type.GetType("System.String")); paymentTable.Columns.Add("discount_details", System.Type.GetType("System.String")); paymentTable.Columns.Add("payment_amount", System.Type.GetType("System.Decimal")); paymentTable.Columns.Add("discount_amount", System.Type.GetType("System.Decimal")); if (_paymentDetailsTable != null) { foreach (DataRow payRow in _paymentDetailsTable.Rows) { DataRow newRow = paymentTable.NewRow(); newRow["receipt_no"] = payRow["receipt_no"].ToString(); newRow["sysid_registration"] = regInfo.RegistrationSystemId; newRow["receipt_details"] = "Date Posted: " + DateTime.Parse(payRow["date_paid"].ToString()).ToShortDateString() + " Receipt No: " + payRow["receipt_no"].ToString(); newRow["payment_details"] = "Amount Paid:" + " " + Decimal.Parse(payRow["amount"].ToString()).ToString("N") + " Discount: " + Decimal.Parse(payRow["discount"].ToString()).ToString("N"); newRow["discount_details"] = "Discount"; newRow["payment_amount"] = Decimal.Parse(payRow["amount"].ToString()) + Decimal.Parse(payRow["discount"].ToString()); paymentTable.Rows.Add(newRow); } paymentTable.AcceptChanges(); } using (DentalLib.ClassPatientRegistrationServices.CrystalReport.CrystalPaymentSummary rptReceipt = new DentalLib.ClassPatientRegistrationServices.CrystalReport.CrystalPaymentSummary()) { CommonExchange.ClinicInformation clinicInfo = new CommonExchange.ClinicInformation(); rptReceipt.Database.Tables["registration_table"].SetDataSource(regTable); rptReceipt.Database.Tables["procedures_table"].SetDataSource(procedureTable); rptReceipt.Database.Tables["payments_table"].SetDataSource(paymentTable); rptReceipt.SetParameterValue("@clinic_name", clinicInfo.ClinicName); rptReceipt.SetParameterValue("@address", clinicInfo.Address); rptReceipt.SetParameterValue("@contact_no", clinicInfo.PhoneNos); rptReceipt.SetParameterValue("@patient_name", patientInfo.LastName.ToUpper() + ", " + patientInfo.FirstName.ToUpper() + " " + patientInfo.MiddleName.ToUpper()); rptReceipt.SetParameterValue("@patient_address", patientInfo.HomeAddress); rptReceipt.SetParameterValue("@patient_age", patientInfo.Age); rptReceipt.SetParameterValue("@registration_no", regInfo.RegistrationSystemId); rptReceipt.SetParameterValue("@registration_date", regInfo.RegistrationDate.ToString()); CommonExchange.PaymentSummary summary = this.GetPaymentSummary(); rptReceipt.SetParameterValue("@total_notice", "Your current balance is >> "); rptReceipt.SetParameterValue("@total_amount", summary.Balance.ToString("N")); rptReceipt.SetParameterValue("@runtime_date", "as of " + DateTime.Parse(s_serverDateTime).ToShortDateString() + " " + DateTime.Parse(s_serverDateTime).ToShortTimeString()); rptReceipt.SetParameterValue("@printed_details", "Prepared by: " + userInfo.LastName + ", " + userInfo.FirstName + " " + userInfo.MiddleName); rptReceipt.SetParameterValue("@approved_details", "Approved by: " + clinicInfo.ApprovedBy); using (CrystalReportViewer frmViewer = new CrystalReportViewer(rptReceipt)) { frmViewer.ShowDialog(); } } } //-----------------------