Example #1
0
        public MonthlyDetailReport(ReportViewer rv, string report, DateTime dateTime, int paytype, MonthlyReportType monthlyReportType) : base(rv, report)
        {
            List <LedgerItem> ledgerItems = new List <LedgerItem>();
            DataTable         fees;

            if (paytype == 1)
            {
                fees = new Fee().GetAllStandardFees();
            }
            else if (paytype == 2)
            {
                fees = new MonthlyDetail().GetAllNonStandardFees();
            }
            else
            {
                fees = new MonthlyDetail().GetAllOtherFees();
            }

            DataTable payments   = new MonthlyDetail().GetAllPaymentsInMonth(dateTime, paytype, monthlyReportType);
            DataTable payDetails = new DataTable();

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

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

                //check if item is present in pay type, this is good for fees that have categories transfered
                foreach (PaymentDetail pitem in paylist)
                {
                    bool present = false;
                    foreach (DataRow row in fees.Rows)
                    {
                        if (row["CODE"].ToString().Equals(pitem.Code))
                        {
                            present = true;
                            break;
                        }
                    }

                    if (!present)
                    {
                        DataRow   dr = fees.NewRow();
                        DataTable dt = new DataTable();
                        dt = new Fee().GetFeeByCode(pitem.Code);
                        foreach (DataRow drow in dt.Rows)
                        {
                            dr[0] = drow["feecode"].ToString();
                            dr[1] = drow["feename"].ToString();
                            dr[2] = drow["shortname"].ToString();
                            dr[3] = Convert.ToInt16(drow["feetype"]);
                        }

                        fees.Rows.Add(dr);
                    }
                }

                foreach (DataRow row in fees.Rows)
                {
                    LedgerItem ledgerItem = new LedgerItem();
                    ledgerItem.FeeCode     = row["CODE"].ToString();
                    ledgerItem.FeeName     = row["SHORT NAME"].ToString();
                    ledgerItem.OrNumber    = prow["OR"].ToString();
                    ledgerItem.PaymentDate = Convert.ToDateTime(prow["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);
                }
            }

            MonthlyReportTitle title;

            if (monthlyReportType == MonthlyReportType.HSStandard)
            {
                title = new MonthlyReportTitle("STANDARD SCHOOL FEES: JHS, Elem, Pre-school");
            }
            else if (monthlyReportType == MonthlyReportType.HSNonStandard)
            {
                title = new MonthlyReportTitle("NON-STANDARD SCHOOL FEES: JHS, Elem, Pre-school");
            }
            else if (monthlyReportType == MonthlyReportType.SHSStandard)
            {
                title = new MonthlyReportTitle("STANDARD SCHOOL FEES: Senior High School");
            }
            else if (monthlyReportType == MonthlyReportType.SHSNonStandard)
            {
                title = new MonthlyReportTitle("NON-STANDARD SCHOOL FEES: Senior High School");
            }
            else if (monthlyReportType == MonthlyReportType.AllStandard)
            {
                title = new MonthlyReportTitle("STANDARD SCHOOL FEES: All Department");
            }
            else if (monthlyReportType == MonthlyReportType.AllNonStandard)
            {
                title = new MonthlyReportTitle("NON-STANDARD SCHOOL FEES: All Department");
            }
            else if (monthlyReportType == MonthlyReportType.HSOtherType)
            {
                title = new MonthlyReportTitle("OTHER SCHOOL FEES: JHS, Elem, Pre-school");
            }
            else if (monthlyReportType == MonthlyReportType.SHSOtherType)
            {
                title = new MonthlyReportTitle("OTHER SCHOOL FEES: Senior High School");
            }
            else
            {
                title = new MonthlyReportTitle("OTHER SCHOOL FEES: All Department");
            }

            List <MonthlyReportTitle> titles = new List <MonthlyReportTitle>();

            titles.Add(title);

            ReportDataSource dsReport = new ReportDataSource();

            dsReport.Name  = "dsPayment";
            dsReport.Value = ledger;
            RViewer.LocalReport.DataSources.Add(dsReport);

            ReportDataSource dsTitle = new ReportDataSource();

            dsTitle.Name  = "dsTitle";
            dsTitle.Value = titles;
            RViewer.LocalReport.DataSources.Add(dsTitle);
        }
Example #2
0
        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);
        }