private void btnPrintDailyCollection_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; frmReport frReport = new frmReport(ReportTypes.DailyCollection); frReport.MdiParent = MdiParent; frReport.DailyReportSummaryDate = dtpDaily.Value; frReport.Show(); Cursor.Current = Cursors.Default; } catch (MySqlException ex) { if (ex.Number == 1042) { MessageBox.Show("Database server is offline. Contact administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(ex.Number + ": " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void tsbPrintSoA_Click(object sender, EventArgs e) { try { if (txtSN.Text.Trim().Equals("") && txtName.Text.Trim().Equals("")) { throw new Exception("Nothing to print"); } if (dgvAssessDetails.SelectedRows.Count == 0) { throw new Exception("Please select fees below"); } //add fees in soa list List <PaymentDetail> SoAItems = new List <PaymentDetail>(); double totalsoa = 0; foreach (DataGridViewRow row in dgvAssessDetails.SelectedRows) { PaymentDetail pd = new PaymentDetail(); pd.Code = row.Cells["CODE"].Value.ToString(); pd.Name = row.Cells["FEE"].Value.ToString(); double amount = 0; bool isamount = Double.TryParse(Microsoft.VisualBasic.Interaction.InputBox("Enter amount for " + pd.Name + "\n\nTOTAL: " + totalsoa.ToString("N2"), pd.Name, "0"), out amount); if (isamount) { pd.Amount = amount; totalsoa += amount; SoAItems.Add(pd); } else { return; } } frmReport newMDIChild = new frmReport(ReportTypes.SOA); newMDIChild.SoAItems = SoAItems; newMDIChild.SoAStudent = student; newMDIChild.MdiParent = ParentForm; newMDIChild.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void tsbPrintLedger_Click(object sender, EventArgs e) { try { if (txtSN.Text.Trim().Equals("") && txtName.Text.Trim().Equals("")) { throw new Exception("Nothing to print"); } frmReport newMDIChild = new frmReport(ReportTypes.Ledger); newMDIChild.SoAStudent = student; newMDIChild.MdiParent = ParentForm; newMDIChild.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnPrintMonthlyDetails_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; frmReport frReport = new frmReport(ReportTypes.MonthlyCollectionDetail); frReport.MdiParent = MdiParent; frReport.MonthlyReportDate = dtpSummary.Value; if (cmbDepartment.SelectedIndex == 0 && cmbReportType.SelectedIndex == 0) { frReport.PayType = 1; //standard frReport.MonthReportType = MonthlyReportType.HSStandard; } else if (cmbDepartment.SelectedIndex == 0 && cmbReportType.SelectedIndex == 1) { frReport.PayType = 2; //non-standard frReport.MonthReportType = MonthlyReportType.HSNonStandard; } else if (cmbDepartment.SelectedIndex == 1 && cmbReportType.SelectedIndex == 0) { frReport.PayType = 1; //standard frReport.MonthReportType = MonthlyReportType.SHSStandard; } else if (cmbDepartment.SelectedIndex == 1 && cmbReportType.SelectedIndex == 1) { frReport.PayType = 2; //non-standard frReport.MonthReportType = MonthlyReportType.SHSNonStandard; } else if (cmbDepartment.SelectedIndex == 2 && cmbReportType.SelectedIndex == 0) { frReport.PayType = 1; //standard frReport.MonthReportType = MonthlyReportType.AllStandard; } else if (cmbDepartment.SelectedIndex == 2 && cmbReportType.SelectedIndex == 1) { frReport.PayType = 2; //non-standard frReport.MonthReportType = MonthlyReportType.AllNonStandard; } else if (cmbDepartment.SelectedIndex == 0 && cmbReportType.SelectedIndex == 2) { frReport.PayType = 3; //pta, alumni, other frReport.MonthReportType = MonthlyReportType.HSOtherType; } else if (cmbDepartment.SelectedIndex == 1 && cmbReportType.SelectedIndex == 2) { frReport.PayType = 3; //pta, alumni, other frReport.MonthReportType = MonthlyReportType.SHSOtherType; } else { frReport.PayType = 3; //pta, alumni, other frReport.MonthReportType = MonthlyReportType.AllOtherType; } frReport.Show(); Cursor.Current = Cursors.Default; } catch (MySqlException ex) { if (ex.Number == 1042) { MessageBox.Show("Database server is offline. Contact administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(ex.Number + ": " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void tsbSave_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; if (txtOR.Text.Trim().Equals("") || txtCash.Text.Trim().Equals("") || !Double.TryParse(txtCash.Text.Trim(), out double res) || txtName.Text.Trim().Equals("") || cmbDepartment.Text == string.Empty) { throw new Exception("Please fill important fields."); } List <PaymentDetail> paymentItems = new List <PaymentDetail>(); foreach (DataGridViewRow row in dgvItems.Rows) { string value = (string)row.Cells["txtPayment"].Value; if (!string.IsNullOrWhiteSpace(value)) { if (!Double.TryParse(value, out double val)) { dgvItems.CurrentCell = row.Cells["txtPayment"]; dgvItems.BeginEdit(true); throw new Exception("Invalid amount."); } if (Convert.ToDouble(row.Cells["txtPayment"].Value) > 0) { PaymentDetail feeObj = new PaymentDetail(); feeObj.Code = row.Cells["CODE"].Value.ToString(); feeObj.Amount = Convert.ToDouble(row.Cells["txtPayment"].Value); paymentItems.Add(feeObj); } } } double paymentTotal = 0; if (paymentItems.Count > 0 && Double.TryParse(lblTotal.Text.Trim(), out paymentTotal) && paymentTotal > 0) { int paymenttype = 5; Payment payment = new Payment(-1, txtOR.Text.Trim(), Convert.ToDouble(lblTotal.Text.Trim()), (MdiParent as frmMDI).LoginUser.Username, paymenttype); payment.PaymentDetail = paymentItems; payment.Payer = txtName.Text.Trim(); if (cmbDepartment.SelectedIndex == 0) { payment.Division = 1; } else if (cmbDepartment.SelectedIndex == 1) { payment.Division = 2; } if (payment.SavePaymentOther()) { DialogResult dlg = MessageBox.Show("Payment save successful.\nPlease insert Official Receipt(OR) for printing", "Payment", MessageBoxButtons.OK, MessageBoxIcon.Question); if (dlg == DialogResult.OK) { frmReport frReport; frReport = new frmReport(ReportTypes.OFOR); Student Payer = new Student(); Payer.LastName = txtName.Text.Trim(); frReport.Payer = Payer; frReport.ORNumber = txtOR.Text.Trim(); frReport.MdiParent = MdiParent; frReport.Show(); } tsbClear.PerformClick(); } else { throw new Exception("Error in saving this payment."); } } Cursor.Current = Cursors.Default; } catch (MySqlException ex) { if (ex.Number == 1042) { MessageBox.Show("Database server is offline. Contact administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(ex.Number + ": " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }