Exemple #1
0
        private void loadPhieuThu()
        {
            UnknownColumnViewTableAdapter unknownColumnViewTableAdapter = (UnknownColumnViewTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterUnknownColumnView);

            this.dateNgay.DateTime = this.PhieuThuRow.Ngay;
            this.txtSoTien.Value   = this.PhieuThuRow.SoTien;

            if (!this.PhieuThuRow.IsMaPhieuNull())
            {
                this.txtMaPhieu.Text = this.PhieuThuRow.MaPhieu;
            }

            if (!this.PhieuThuRow.IsGhiChuNull())
            {
                this.txtGhiChu.Text = this.PhieuThuRow.GhiChu;
            }

            if (!this.PhieuThuRow.IsHocSinhIdNull())
            {
                this.cmbHocSinh.EditValue = this.PhieuThuRow.HocSinhId;
                this.txtConLai.Text       = String.Format("{0:n0}", unknownColumnViewTableAdapter.GetSoTienTruyThuByHocSinhId(this.PhieuThuRow.HocSinhId));
            }

            if (!this.PhieuThuRow.IsPhanLoaiThuIdNull())
            {
                this.cmbPhanLoaiThu.EditValue = this.PhieuThuRow.PhanLoaiThuId;
            }
        }
Exemple #2
0
        public decimal GetSoTienTonDauKy(DateTime toDate)
        {
            UnknownColumnViewTableAdapter unknownColumnViewTableAdapter = (UnknownColumnViewTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterUnknownColumnView);
            DateTime lastDayOfPrevMonth = DateTimeUtil.DateEndOfMonth(toDate.AddMonths(-1));
            decimal  tongThu            = (decimal)unknownColumnViewTableAdapter.GetSumSoTienThuByDateRange(Settings.Default.AppLannchDate, lastDayOfPrevMonth, null);
            decimal  tongChi            = (decimal)unknownColumnViewTableAdapter.GetSumSoTienChiByDateRange(Settings.Default.AppLannchDate, lastDayOfPrevMonth, null);
            decimal  chenhLech          = tongThu - tongChi + Settings.Default.SoTienTonDauKy;

            return(chenhLech);
        }
Exemple #3
0
        private void btnXemBaoCao_Click(object sender, EventArgs e)
        {
            if (this.dateTuNgay.DateTime == null || this.dateDenNgay.DateTime == null)
            {
                MessageBox.Show("Xin vui lòng chọn ngày", "Chọn ngày", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            List <int> phanLoaiThuIds = new List <int>();

            int[] selectedThuRowHandlers = this.gvThu.GetSelectedRows();

            if (ArrayUtil.IsEmpty(selectedThuRowHandlers))
            {
                MessageBox.Show("Xin vui lòng chọn Phân loại thu", "Chọn Phân loại thu", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            foreach (int rowHandler in selectedThuRowHandlers)
            {
                int phanLoaiThuId = (int)this.gvThu.GetRowCellValue(rowHandler, "PhanLoaiThuId");
                phanLoaiThuIds.Add(phanLoaiThuId);
            }

            List <int> phanLoaiChiIds = new List <int>();

            int[] selectedRowHandlers = this.gvMain.GetSelectedRows();

            if (ArrayUtil.IsEmpty(selectedRowHandlers))
            {
                MessageBox.Show("Xin vui lòng chọn Mã loại chi", "Chọn Mã loại chi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (chkTon.Checked && StringUtil.IsEmpty(txtTon.Text))
            {
                MessageBox.Show("Xin vui lòng nhập số tiền tồn tháng trước", "Nhập số tiền tồn tháng trước", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            foreach (int rowHandler in selectedRowHandlers)
            {
                int phanLoaiChiId = (int)this.gvMain.GetRowCellValue(rowHandler, "PhanLoaiChiId");
                phanLoaiChiIds.Add(phanLoaiChiId);
            }

            DateTime fromDate = DateTimeUtil.StartOfDate(this.dateTuNgay.DateTime);
            DateTime toDate   = DateTimeUtil.EndOfDate(this.dateDenNgay.DateTime);

            UnknownColumnViewTableAdapter unknownColumnViewTableAdapter = (UnknownColumnViewTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterUnknownColumnView);
            RptTinhHinhThuChi             rpt = new RptTinhHinhThuChi();

            rpt.TuNgay.Value  = fromDate;
            rpt.DenNgay.Value = toDate;
            rpt.TongThu.Value = unknownColumnViewTableAdapter.GetSumSoTienThuByDateRange(fromDate, toDate, StringUtil.JoinWithCommas(phanLoaiThuIds));
            rpt.TongChi.Value = unknownColumnViewTableAdapter.GetSumSoTienChiByDateRange(fromDate, toDate, StringUtil.JoinWithCommas(phanLoaiChiIds));

            rpt.Ton.Value       = findSoTienTonDauKy(toDate);
            rpt.ChenhLech.Value = (decimal)rpt.Ton.Value + (decimal)rpt.TongThu.Value - (decimal)rpt.TongChi.Value;

            PhieuThuService phieuThuService = new PhieuThuService();

            rpt.thuDataSource.DataSource = phieuThuService.LoadPhieuThuByDateRangeWithGroupPhanLoaiThu(fromDate, toDate, phanLoaiThuIds);

            PhieuChiService phieuChiService = new PhieuChiService();

            rpt.chiDataSource.DataSource = phieuChiService.LoadPhieuChiByDateRangeWithGroupPhanLoaiChi(fromDate, toDate, phanLoaiChiIds);

            FormMainFacade.ShowReport(rpt);
        }