コード例 #1
0
ファイル: frmAssessment.cs プロジェクト: darkholds/mcs_pams
        private void dgvStudent_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                if (dgvStudent.SelectedRows.Count > 0)
                {
                    txtSN.Text   = dgvStudent.SelectedRows[0].Cells["STUDENT NUMBER"].Value.ToString();
                    txtName.Text = dgvStudent.SelectedRows[0].Cells["LAST NAME"].Value.ToString() + ", " + dgvStudent.SelectedRows[0].Cells["FIRST NAME"].Value.ToString() + " " + dgvStudent.SelectedRows[0].Cells["MIDDLE NAME"].Value.ToString();

                    Registration reg = new Registration().GetRegistration(txtSN.Text.Trim());
                    if (reg == null)
                    {
                        throw new Exception("Student/Pupil has no active registration");
                    }
                    lblRegId.Text      = reg.Id.ToString();
                    lblSchoolYear.Text = reg.SchoolYear;
                    lblSem.Text        = reg.Semester;
                    lblGradeLevel.Text = reg.GradeLevel;
                    lblSection.Text    = reg.Section;
                    lblStatus.Text     = reg.Status;
                    lblDateReg.Text    = reg.DateRegistered;

                    Assessment asses = new Assessment().GetAssessment(reg.Id);
                    if (asses == null)
                    {
                        asses = new Assessment();
                        asses.CreateBlankAssessmentFromRegistration(reg.Id);
                        asses.GetAssessment(reg.Id);
                        MessageBox.Show("Student is registered but has no initial assessment. Select fees to add assessment details", "No Assessment", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //throw new Exception("Student/Pupil has no active assessment");
                    }

                    ttDiscount.SetToolTip(lblTuition, "SCHOLARSHIP INFORMATION\nDiscount: " + asses.Discount.ToString("N2") + "\nSubsidy: " + asses.Subsidy.ToString("N2"));
                    lblRegId.Tag = asses.Id;
                    dgvAssessDetail.DataSource         = asses.AssessmentDetail;
                    dgvAssessDetail.Columns[0].Width   = 75;
                    dgvAssessDetail.Columns[1].Width   = 300;
                    dgvAssessDetail.Columns[2].Width   = 75;
                    dgvAssessDetail.Columns[3].Visible = false; //feetype
                    dgvAssessDetail.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                    dgvAssessDetail.Columns[2].DefaultCellStyle.Format    = string.Format("N2");

                    RefreshDetails();

                    scAssessment.Panel1Collapsed = true;
                    txtSN.ReadOnly     = true;
                    txtName.ReadOnly   = true;
                    gbDiscount.Enabled = true;
                }
                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)
            {
                tsbClear.PerformClick();
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
ファイル: frmAssessment.cs プロジェクト: darkholds/mcs_pams
        private void btnSubtract_Click(object sender, EventArgs e)
        {
            try
            {
                if (lblRegId.Text.Trim().Equals("") || txtDiscount.Text.Trim().Equals(""))
                {
                    throw new Exception("Nothing to update");
                }

                double discount = 0;
                if (!Double.TryParse(txtDiscount.Text.Trim(), out discount))
                {
                    throw new Exception("Invalid discount or subsidy value.");
                }

                int discounttype = 0;
                if (rbSubsidy.Checked)
                {
                    discounttype = 1;
                }

                long   id      = new Assessment().GetAssessment(Convert.ToInt64(lblRegId.Text.Trim())).Id;
                double tuition = 0;
                bool   tbool   = Double.TryParse(lblTuition.Text.Trim(), out tuition);
                if (!tbool || tuition == 0)
                {
                    throw new Exception("Invalid tuition amount");
                }

                bool success = new AssessmentDetail().UpdateTuition(id, tuition - discount, discount, discounttype);
                if (success)
                {
                    Assessment asses = new Assessment().GetAssessment(Convert.ToInt64(lblRegId.Text.Trim()));
                    dgvAssessDetail.DataSource         = asses.AssessmentDetail;
                    dgvAssessDetail.Columns[0].Width   = 75;
                    dgvAssessDetail.Columns[1].Width   = 300;
                    dgvAssessDetail.Columns[2].Width   = 75;
                    dgvAssessDetail.Columns[3].Visible = false; //feetype
                    dgvAssessDetail.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                    dgvAssessDetail.Columns[2].DefaultCellStyle.Format    = string.Format("N2");

                    RefreshDetails();

                    MessageBox.Show("Assessment update successful!");
                }
                else
                {
                    throw new Exception("Updating this assessment failed, server might be offline or nothing to update.");
                }
            }
            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)
            {
                txtDiscount.Text = string.Empty;
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
ファイル: Report.cs プロジェクト: darkholds/mcs_pams
        public SoaReport(ReportViewer rv, string report, Student student, User user, List <PaymentDetail> soadetail) : base(rv, report)
        {
            Registration Reg    = new Registration().GetRegistration(student.Id);
            Assessment   Assess = new Assessment().GetAssessment(Reg.Id);

            DataTable table = new DataTable();

            table = new Payment().GetAllPaymentPerAssessment(student.Id, Assess.Id);

            List <Payment> Payments = new List <Payment>();

            if (table.Rows.Count > 0)
            {
                foreach (DataRow row in table.Rows)
                {
                    Payment payment = new Payment();
                    payment.ORNumber    = row["OR NUMBER"].ToString();
                    payment.Amount      = Convert.ToDouble(row["AMOUNT"].ToString());
                    payment.PaymentDate = Convert.ToDateTime(row["PAYMENT DATE"]).ToShortDateString();

                    Payments.Add(payment);
                }
            }
            else
            {
                Payments.Add(new Payment());
            }

            List <Student> studList = new List <Student>();

            studList.Add(student);

            List <Assessment> assList = new List <Assessment>();

            assList.Add(Assess);

            List <Registration> regList = new List <Registration>();

            regList.Add(Reg);

            List <User> userList = new List <User>();

            userList.Add(user);

            ReportDataSource dsStud = new ReportDataSource();

            dsStud.Name  = "dsStudent";
            dsStud.Value = studList;
            RViewer.LocalReport.DataSources.Add(dsStud);

            ReportDataSource dsAssess = new ReportDataSource();

            dsAssess.Name  = "dsAssess";
            dsAssess.Value = assList;
            RViewer.LocalReport.DataSources.Add(dsAssess);

            ReportDataSource dsReg = new ReportDataSource();

            dsReg.Name  = "dsRegistration";
            dsReg.Value = regList;
            RViewer.LocalReport.DataSources.Add(dsReg);

            ReportDataSource dsPay = new ReportDataSource();

            dsPay.Name  = "dsPayment";
            dsPay.Value = Payments;
            RViewer.LocalReport.DataSources.Add(dsPay);

            ReportDataSource dsUser = new ReportDataSource();

            dsUser.Name  = "dsUser";
            dsUser.Value = userList;
            RViewer.LocalReport.DataSources.Add(dsUser);

            ReportDataSource dsPayDet = new ReportDataSource();

            dsPayDet.Name  = "dsPayDetail";
            dsPayDet.Value = soadetail;
            RViewer.LocalReport.DataSources.Add(dsPayDet);
        }
コード例 #4
0
ファイル: Report.cs プロジェクト: darkholds/mcs_pams
        public LedgerReport(ReportViewer rv, string report, Student student) : base(rv, report)
        {
            Registration Reg    = new Registration().GetRegistration(student.Id);
            Assessment   Assess = new Assessment().GetAssessment(Reg.Id);

            DataTable payments  = new Ledger().GetAllPaymentPerAccount(Assess.Id);
            DataTable payDetail = new DataTable();

            List <LedgerItem> ledger = new List <LedgerItem>();

            foreach (DataRow prow in payments.Rows)
            {
                long id = Convert.ToInt64(prow["ID"]);
                payDetail = new Ledger().GetPaymentDetailById(id);
                List <PaymentDetail> paylist = new List <PaymentDetail>();
                foreach (DataRow plist in payDetail.Rows)
                {
                    PaymentDetail pd = new PaymentDetail();
                    pd.Code   = plist["CODE"].ToString();
                    pd.Amount = Convert.ToDouble(plist["AMOUNT"]);
                    paylist.Add(pd);
                }

                foreach (DataRow row in Assess.AssessmentDetail.Rows)
                {
                    LedgerItem ledgerItem = new LedgerItem();
                    ledgerItem.FeeCode          = row["CODE"].ToString();
                    ledgerItem.FeeName          = row["FEE"].ToString();
                    ledgerItem.OrNumber         = prow["OR"].ToString();
                    ledgerItem.PaymentDate      = Convert.ToDateTime(prow["PAYMENT DATE"]);
                    ledgerItem.AssessmentAmount = Convert.ToDouble(row["AMOUNT"]);
                    ledgerItem.AssessmentTotal  = Assess.Total;

                    foreach (PaymentDetail det in paylist)
                    {
                        if (ledgerItem.FeeCode.Equals(det.Code))
                        {
                            ledgerItem.PaidAmount = det.Amount;
                            break;
                        }
                        else
                        {
                            ledgerItem.PaidAmount = 0;
                        }
                    }
                    ledger.Add(ledgerItem);
                }
            }


            List <PaymentDetail> assList = new List <PaymentDetail>();

            foreach (DataRow row in Assess.AssessmentDetail.Rows)
            {
                PaymentDetail pd = new PaymentDetail();
                pd.Code   = row["CODE"].ToString();
                pd.Name   = row["FEE"].ToString();
                pd.Amount = Convert.ToDouble(row["AMOUNT"]);
                assList.Add(pd);
            }

            List <Student> studList = new List <Student>();

            studList.Add(student);
            ReportDataSource dsStud = new ReportDataSource();

            dsStud.Name  = "dsStudent";
            dsStud.Value = studList;
            RViewer.LocalReport.DataSources.Add(dsStud);

            ReportDataSource dsLedger = new ReportDataSource();

            dsLedger.Name  = "dsPayment";
            dsLedger.Value = ledger;
            RViewer.LocalReport.DataSources.Add(dsLedger);
        }
コード例 #5
0
ファイル: Account.cs プロジェクト: darkholds/mcs_pams
 public void GetAccountByRegistrationId(long regid)
 {
     StudentRegistration = new Registration().GetRegistration(regid);
     StudentAssessment   = new Assessment().GetAssessment(regid);
     StudentPayment      = new Payment().GetAllPaymentPerAssessment(StudentRegistration.StudentInfo.Id, StudentAssessment.Id);
 }