private void FormTrojanCollect_Load(object sender, EventArgs e) { patCur = Patients.GetPat(PatNum); guarCur = Patients.GetPat(patCur.Guarantor); if (guarCur.EmployerNum == 0) { empCur = null; } else { empCur = Employers.GetEmployer(guarCur.EmployerNum); } if (guarCur.LName.Length == 0) { MessageBox.Show("Missing guarantor last name."); DialogResult = DialogResult.Cancel; return; } if (guarCur.FName.Length == 0) { MessageBox.Show("Missing guarantor first name."); DialogResult = DialogResult.Cancel; return; } if (!Regex.IsMatch(guarCur.SSN, @"^\d{9}$")) { MessageBox.Show("Guarantor SSN must be exactly 9 digits."); DialogResult = DialogResult.Cancel; return; } if (guarCur.Address.Length == 0) { MessageBox.Show("Missing guarantor address."); DialogResult = DialogResult.Cancel; return; } if (guarCur.City.Length == 0) { MessageBox.Show("Missing guarantor city."); DialogResult = DialogResult.Cancel; return; } if (guarCur.State.Length != 2) { MessageBox.Show("Guarantor state must be 2 characters."); DialogResult = DialogResult.Cancel; return; } if (guarCur.Zip.Length < 5) { MessageBox.Show("Invalid guarantor zip."); DialogResult = DialogResult.Cancel; return; } labelGuarantor.Text = guarCur.GetNameFL(); labelAddress.Text = guarCur.Address; if (guarCur.Address2 != "") { labelAddress.Text += ", " + guarCur.Address2; } labelCityStZip.Text = guarCur.City + ", " + guarCur.State + " " + guarCur.Zip; labelSSN.Text = guarCur.SSN.Substring(0, 3) + "-" + guarCur.SSN.Substring(3, 2) + "-" + guarCur.SSN.Substring(5, 4); if (guarCur.Birthdate.Year < 1880) { labelDOB.Text = ""; } else { labelDOB.Text = guarCur.Birthdate.ToString("MM/dd/yyyy"); } labelPhone.Text = Clip(guarCur.HmPhone, 13); if (empCur == null) { labelEmployer.Text = ""; labelEmpPhone.Text = ""; } else { labelEmployer.Text = empCur.EmpName; labelEmpPhone.Text = empCur.Phone; } labelPatient.Text = patCur.GetNameFL(); string command = @"SELECT MAX(ProcDate) FROM procedurelog,patient WHERE patient.PatNum=procedurelog.PatNum AND patient.Guarantor=" + POut.PInt(guarCur.PatNum); DataTable table = General.GetTable(command); DateTime lastProcDate; if (table.Rows.Count == 0) { lastProcDate = DateTime.MinValue; //this should never happen } else { lastProcDate = PIn.PDate(table.Rows[0][0].ToString()); } command = @"SELECT MAX(DatePay) FROM paysplit,patient WHERE patient.PatNum=paysplit.PatNum AND patient.Guarantor=" + POut.PInt(guarCur.PatNum); table = General.GetTable(command); DateTime lastPayDate; if (table.Rows.Count == 0) { lastPayDate = DateTime.MinValue; } else { lastPayDate = PIn.PDate(table.Rows[0][0].ToString()); } if (lastPayDate > lastProcDate) { textDate.Text = lastPayDate.ToString("MM/dd/yyyy"); } else { textDate.Text = lastProcDate.ToString("MM/dd/yyyy"); } textAmount.Text = guarCur.BalTotal.ToString("F2"); textPassword.Text = PrefB.GetString("TrojanExpressCollectPassword"); }
private void FormTrojanCollect_Load(object sender, EventArgs e) { if (_patCur == null) { MsgBox.Show(this, "Please select a patient first."); DialogResult = DialogResult.Cancel; return; } _guarCur = Patients.GetPat(_patCur.Guarantor); if (_guarCur.EmployerNum > 0) { _empCur = Employers.GetEmployer(_guarCur.EmployerNum); } if (_guarCur.LName.Length == 0) { MsgBox.Show(this, "Missing guarantor last name."); DialogResult = DialogResult.Cancel; return; } if (_guarCur.FName.Length == 0) { MsgBox.Show(this, "Missing guarantor first name."); DialogResult = DialogResult.Cancel; return; } if (!Regex.IsMatch(_guarCur.SSN, @"^\d{9}$")) { MsgBox.Show(this, "Guarantor SSN must be exactly 9 digits."); DialogResult = DialogResult.Cancel; return; } if (_guarCur.Address.Length == 0) { MsgBox.Show(this, "Missing guarantor address."); DialogResult = DialogResult.Cancel; return; } if (_guarCur.City.Length == 0) { MsgBox.Show(this, "Missing guarantor city."); DialogResult = DialogResult.Cancel; return; } if (_guarCur.State.Length != 2) { MsgBox.Show(this, "Guarantor state must be 2 characters."); DialogResult = DialogResult.Cancel; return; } if (_guarCur.Zip.Length < 5) { MsgBox.Show(this, "Invalid guarantor zip."); DialogResult = DialogResult.Cancel; return; } labelGuarantor.Text = _guarCur.GetNameFL(); labelAddress.Text = _guarCur.Address; if (!string.IsNullOrEmpty(_guarCur.Address2)) { labelAddress.Text += ", " + _guarCur.Address2; } labelCityStZip.Text = _guarCur.City + ", " + _guarCur.State + " " + _guarCur.Zip; labelSSN.Text = _guarCur.SSN.Substring(0, 3) + "-" + _guarCur.SSN.Substring(3, 2) + "-" + _guarCur.SSN.Substring(5, 4); labelDOB.Text = _guarCur.Birthdate.Year < 1880?"":_guarCur.Birthdate.ToShortDateString(); labelPhone.Text = Clip(_guarCur.HmPhone, 13); labelEmployer.Text = _empCur?.EmpName ?? ""; labelEmpPhone.Text = _empCur?.Phone ?? ""; labelPatient.Text = _patCur.GetNameFL(); DateTime lastProcDate = TrojanQueries.GetMaxProcedureDate(_guarCur.PatNum); DateTime lastPayDate = TrojanQueries.GetMaxPaymentDate(_guarCur.PatNum); textDate.Text = (lastPayDate > lastProcDate?lastPayDate:lastProcDate).ToShortDateString(); textAmount.Text = _guarCur.BalTotal.ToString("F2"); }