Example #1
0
 private void btnTimKiem_Click(object sender, EventArgs e)
 {
     SplashScreenManager.ShowForm(typeof(O2S_Common.Utilities.ThongBao.WaitForm_Wait));
     try
     {
         PhieuThuFilter _filter = new PhieuThuFilter();
         _filter.CoSoId          = GlobalSettings.CoSoId;
         _filter.ThoiGianThu_Tu  = date_TuNgay.DateTime;
         _filter.ThoiGianThu_Den = date_DenNgay.DateTime;
         this.lstPhieuThu        = PhieuThuLogic.SelectBaoCaoThuTienChiTiet(_filter);
         if (this.lstPhieuThu != null && this.lstPhieuThu.Count > 0)
         {
             gridControlDSPhieuGhiDanh.DataSource = this.lstPhieuThu;
         }
         else
         {
             gridControlDSPhieuGhiDanh.DataSource = null;
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Error(ex);
     }
     SplashScreenManager.CloseForm();
 }
        private void repositoryItemButton_Huy_Click(object sender, EventArgs e)
        {
            try
            {
                var rowHandle = gridViewPhieuThu.FocusedRowHandle;
                if (gridViewPhieuThu.GetRowCellValue(rowHandle, "IsRemove").ToString() != "1")
                {
                    int _PhieuThuId = O2S_Common.TypeConvert.Parse.ToInt32(gridViewPhieuThu.GetRowCellValue(rowHandle, "PhieuThuId").ToString());
                    frmPopUpHuyPhieuThuTien _frm = new frmPopUpHuyPhieuThuTien(_PhieuThuId);
                    _frm.ShowDialog();
                    //
                    LoadDanhSachHocVien();
                    gridViewDSHocVien_Click(null, null);

                    PhieuThuFilter _filter = new PhieuThuFilter();
                    _filter.HocVienId      = this.HocVienId_Select;
                    _filter.PhieuGhiDanhId = this.PhieuGhiDanhId_Select;
                    LoadDanhSachPhieuThu(_filter);
                }
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
Example #3
0
        public static List <BaoCaoThuTien_TongHopDTO> SelectBaoCaoThuTienTongHop(PhieuThuFilter _filter)
        {
            try
            {
                var query = (from p in GlobalSettings.Database.PHIEUTHUs
                             where (p.ThoiGianThu >= _filter.ThoiGianThu_Tu && p.ThoiGianThu <= _filter.ThoiGianThu_Den) && p.HOCVIEN.CoSoId == _filter.CoSoId
                             group p by new
                {
                    p.ThoiGianThu,
                    p.CreatedBy,
                } into phieuthu
                             select new BaoCaoThuTien_TongHopDTO
                {
                    ThoiGianThu = phieuthu.Key.ThoiGianThu,
                    TenNguoiThu = (from tk in Database.TAIKHOANs
                                   join nv in Database.NHANVIENs on tk.TaiKhoanId equals nv.TaiKhoanId
                                   where tk.TenDangNhap == phieuthu.Key.CreatedBy
                                   select nv.TenNhanVien).FirstOrDefault(),
                    SoTien = phieuthu.Sum(o => o.SoTien),
                });
                return(query.ToList());
            }
            catch (System.Exception ex)
            {
                return(null);

                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
Example #4
0
        public static List <BaoCaoThuTien_ChiTietDTO> SelectBaoCaoThuTienChiTiet(PhieuThuFilter _filter)
        {
            try
            {
                var query = (from p in GlobalSettings.Database.PHIEUTHUs
                             where (p.ThoiGianThu >= _filter.ThoiGianThu_Tu && p.ThoiGianThu <= _filter.ThoiGianThu_Den) && p.CoSoId == _filter.CoSoId
                             select p).AsEnumerable().Select((obj, index) => new BaoCaoThuTien_ChiTietDTO
                {
                    Stt         = index + 1,
                    MaPhieuThu  = obj.MaPhieuThu,
                    ThoiGianThu = obj.ThoiGianThu,
                    SoTien      = obj.SoTien,
                    TenNguoiThu = (from tk in Database.TAIKHOANs
                                   join nv in Database.NHANVIENs on tk.TaiKhoanId equals nv.TaiKhoanId
                                   where tk.TenDangNhap == obj.CreatedBy
                                   select nv.TenNhanVien).FirstOrDefault(),
                    MaPhieuGhiDanh = obj.PHIEUGHIDANH.MaPhieuGhiDanh,
                    MaHocVien      = obj.HOCVIEN.MaHocVien,
                    TenHocVien     = obj.HOCVIEN.TenHocVien,
                    GioiTinh       = obj.HOCVIEN.GioiTinh,
                    NgaySinh       = obj.HOCVIEN.NgaySinh,
                    GhiChu         = obj.GhiChu
                });
                return(query.ToList());
            }
            catch (System.Exception ex)
            {
                return(null);

                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
 private void LoadDanhSachPhieuThu(PhieuThuFilter _filter)
 {
     try
     {
         gridControlPhieuThu.DataSource = PhieuThuLogic.Select(_filter);
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Error(ex);
     }
 }
Example #6
0
        public static List <PhieuThu_PlusDTO> Select(PhieuThuFilter _filter)
        {
            try
            {
                var query = (from p in GlobalSettings.Database.PHIEUTHUs
                             //where p.HocVienId==_filter.HocVienId
                             select p).AsEnumerable().Select((obj, index) => new PhieuThu_PlusDTO
                {
                    Stt            = index + 1,
                    PhieuThuId     = obj.PhieuThuId,
                    MaPhieuThu     = obj.MaPhieuThu,
                    SoThuId        = obj.SoThuId,
                    PhieuGhiDanhId = obj.PhieuGhiDanhId,
                    HocVienId      = obj.HocVienId,
                    TenHocVien     = obj.HOCVIEN.TenHocVien,
                    LoaiPhieuThuId = obj.LoaiPhieuThuId,
                    SoTien         = obj.SoTien,
                    ThoiGianThu    = obj.ThoiGianThu,
                    NoiDung        = obj.NoiDung,
                    GhiChu         = obj.GhiChu,
                    IsRemove       = obj.IsRemove ?? 0,
                    LyDoHuy        = obj.LyDoHuy,
                    NguoiHuy       = obj.NguoiHuy,
                    ThoiGianHuy    = obj.ThoiGianHuy,
                    CreatedDate    = obj.CreatedDate,
                    CreatedBy      = obj.CreatedBy,
                    CreatedLog     = obj.CreatedLog,
                    ModifiedDate   = obj.ModifiedDate,
                    ModifiedBy     = obj.ModifiedBy,
                    ModifiedLog    = obj.ModifiedLog,
                });
                if (_filter.PhieuThuId != null && _filter.PhieuThuId != 0)
                {
                    query = query.Where(o => o.PhieuThuId == _filter.PhieuThuId).ToList();
                }
                if (_filter.HocVienId != null && _filter.HocVienId != 0)
                {
                    query = query.Where(o => o.HocVienId == _filter.HocVienId).ToList();
                }
                if (_filter.PhieuGhiDanhId != null && _filter.PhieuGhiDanhId != 0)
                {
                    query = query.Where(o => o.PhieuGhiDanhId == _filter.PhieuGhiDanhId).ToList();
                }
                return(query.ToList());
            }
            catch (System.Exception ex)
            {
                return(null);

                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
        private void gridViewDSHocVien_Click(object sender, EventArgs e)
        {
            try
            {
                var rowHandle = gridViewDSHocVien.FocusedRowHandle;
                this.HocVienId_Select      = O2S_Common.TypeConvert.Parse.ToInt32(gridViewDSHocVien.GetRowCellValue(rowHandle, "HocVienId").ToString());
                this.PhieuGhiDanhId_Select = O2S_Common.TypeConvert.Parse.ToInt32(gridViewDSHocVien.GetRowCellValue(rowHandle, "PhieuGhiDanhId").ToString());

                PHIEUGHIDANH _phieugd = PhieuGhiDanhLogic.SelectSingle(this.PhieuGhiDanhId_Select);

                lblMaHocVien.Text     = _phieugd.HOCVIEN.MaHocVien;
                lblTenHocVien.Text    = _phieugd.HOCVIEN.TenHocVien;
                lblHocPhi.Text        = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.TongTien.ToString()), 0);
                lblDaDong.Text        = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.DaDong.ToString()), 0);
                lblConNo.Text         = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.ConNo.ToString()), 0);
                lblMienGiam_Tien.Text = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.MienGiam_Tien.ToString()), 0);
                numDaDong.Text        = _phieugd.ConNo.ToString();
                //Load danh sach phieu thu
                PhieuThuFilter _filter = new PhieuThuFilter();
                _filter.HocVienId      = this.HocVienId_Select;
                _filter.PhieuGhiDanhId = this.PhieuGhiDanhId_Select;
                LoadDanhSachPhieuThu(_filter);
                //Load dot hoc theo lop hoc
                if (_phieugd.LopHocId != null && _phieugd.LopHocId != 0)
                {
                    cboDotHoc.DataSource    = DotHocLogic.SelectDotHocChucDongTien(_phieugd.LopHocId ?? 0, this.PhieuGhiDanhId_Select);
                    cboDotHoc.DisplayMember = "TenDotHoc";
                    cboDotHoc.ValueMember   = "DotHocId";
                }
                else
                {
                    cboDotHoc.DataSource    = null;
                    cboDotHoc.DisplayMember = "TenDotHoc";
                    cboDotHoc.ValueMember   = "DotHocId";
                }
                btnInBienLai.Enabled = false;
                //if (_phieugd.ConNo == 0)
                //{
                //    btnLuuLai.Enabled = false;
                //    numDaDong.ReadOnly = true;
                //}
                //else
                //{
                //    btnLuuLai.Enabled = true;
                //    numDaDong.ReadOnly = false;
                //}
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
        private void btnLuuLai_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateLuu();
                //Update PHIEUGHIDANH
                PHIEUGHIDANH _phieughidanh = PhieuGhiDanhLogic.SelectSingle(this.PhieuGhiDanhId_Select);
                _phieughidanh.DaDong = _phieughidanh.DaDong + O2S_Common.TypeConvert.Parse.ToDecimal(numNopThem.Text);

                decimal _mienggiam = _phieughidanh.MienGiam_Tien ?? 0;
                _phieughidanh.ConNo = _phieughidanh.TongTien - _phieughidanh.DaDong - _mienggiam;
                //Insert Phieu Thu
                var      rowHandle = gridViewDSHocVien.FocusedRowHandle;
                PHIEUTHU _phieuthu = new PHIEUTHU();
                _phieuthu.CoSoId         = GlobalSettings.CoSoId;
                _phieuthu.PhieuGhiDanhId = this.PhieuGhiDanhId_Select;
                _phieuthu.HocVienId      = this.HocVienId_Select;
                _phieuthu.ThoiGianThu    = DateTime.Now;
                _phieuthu.SoTien         = O2S_Common.TypeConvert.Parse.ToDecimal(numNopThem.Text);
                _phieuthu.GhiChu         = "";//gridViewDSHocVien.GetRowCellValue(rowHandle, "TenKhoaHoc").ToString();
                if (PhieuGhiDanhLogic.InsertQLHocPhi(_phieughidanh, _phieuthu, ref this.PhieuThu_Insert))
                {
                    O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.LUU_THANH_CONG);
                    frmthongbao.Show();
                    //
                    LoadDanhSachHocVien();
                    gridViewDSHocVien_Click(null, null);

                    PhieuThuFilter _filter = new PhieuThuFilter();
                    _filter.HocVienId      = this.HocVienId_Select;
                    _filter.PhieuGhiDanhId = this.PhieuGhiDanhId_Select;
                    LoadDanhSachPhieuThu(_filter);

                    btnInBienLai.Enabled = true;
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
        private void gridViewDSHocVien_Click(object sender, EventArgs e)
        {
            try
            {
                var rowHandle = gridViewDSHocVien.FocusedRowHandle;
                this.HocVienId_Select      = O2S_Common.TypeConvert.Parse.ToInt32(gridViewDSHocVien.GetRowCellValue(rowHandle, "HocVienId").ToString());
                this.PhieuGhiDanhId_Select = O2S_Common.TypeConvert.Parse.ToInt32(gridViewDSHocVien.GetRowCellValue(rowHandle, "PhieuGhiDanhId").ToString());

                PHIEUGHIDANH _phieugd = PhieuGhiDanhLogic.SelectSingle(this.PhieuGhiDanhId_Select);

                lblMaHocVien.Text     = _phieugd.HOCVIEN.MaHocVien;
                lblTenHocVien.Text    = _phieugd.HOCVIEN.TenHocVien;
                lblHocPhi.Text        = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.TongTien.ToString()), 0);
                lblDaDong.Text        = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.DaDong.ToString()), 0);
                lblConNo.Text         = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.ConNo.ToString()), 0);
                lblMienGiam_Tien.Text = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.MienGiam_Tien.ToString()), 0);
                numNopThem.Text       = _phieugd.ConNo.ToString();
                //Load danh sach phieu thu
                PhieuThuFilter _filter = new PhieuThuFilter();
                _filter.HocVienId      = this.HocVienId_Select;
                _filter.PhieuGhiDanhId = this.PhieuGhiDanhId_Select;
                LoadDanhSachPhieuThu(_filter);
                btnInBienLai.Enabled = false;
                if (_phieugd.ConNo == 0)
                {
                    btnLuuLai.Enabled   = false;
                    numNopThem.ReadOnly = true;
                }
                else
                {
                    btnLuuLai.Enabled   = true;
                    numNopThem.ReadOnly = false;
                }
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
        private void btnLuuLai_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateLuu();
                //Update PHIEUGHIDANH: dadong
                PHIEUGHIDANH _phieughidanh = PhieuGhiDanhLogic.SelectSingle(this.PhieuGhiDanhId_Select);
                _phieughidanh.DaDong = _phieughidanh.DaDong + O2S_Common.TypeConvert.Parse.ToDecimal(numDaDong.Text);
                //
                _phieughidanh.SoTietKH        = _phieughidanh.SoTietKH + O2S_Common.TypeConvert.Parse.ToDecimal(numSoTietHoc.Text);//so tiet tren dot hoc da chon
                _phieughidanh.HocPhiKH        = _phieughidanh.HocPhiKH + O2S_Common.TypeConvert.Parse.ToDecimal(numHocPhi.Text);
                _phieughidanh.HocPhiHocVienKH = _phieughidanh.HocPhiHocVienKH + O2S_Common.TypeConvert.Parse.ToDecimal(numTongTien.Text);
                _phieughidanh.SoTietHocVienKH = _phieughidanh.SoTietHocVienKH + O2S_Common.TypeConvert.Parse.ToDecimal(numSoBuoiHVDangKy.Text);

                decimal _mienggiam = _phieughidanh.MienGiam_Tien ?? 0;
                _phieughidanh.ConNo = _phieughidanh.TongTien - _phieughidanh.DaDong - _mienggiam;


                //Insert Phieu Thu
                var      rowHandle = gridViewDSHocVien.FocusedRowHandle;
                PHIEUTHU _phieuthu = new PHIEUTHU();
                _phieuthu.CoSoId         = GlobalSettings.CoSoId;
                _phieuthu.PhieuGhiDanhId = this.PhieuGhiDanhId_Select;
                _phieuthu.HocVienId      = this.HocVienId_Select;
                _phieuthu.ThoiGianThu    = DateTime.Now;
                _phieuthu.SoTien         = O2S_Common.TypeConvert.Parse.ToDecimal(numDaDong.Text);
                _phieuthu.NoiDung        = cboDotHoc.Text;
                _phieuthu.GhiChu         = "Thu tiền đợt học: " + cboDotHoc.Text;
                //Hoc phi hoc vien
                DOTHOC _dothoc = DotHocLogic.SelectSingle(O2S_Common.TypeConvert.Parse.ToInt32(cboDotHoc.SelectedValue.ToString()));

                decimal _donGia = _dothoc.HocPhi ?? 0;
                if (_dothoc.SoBuoiHoc != null && _dothoc.SoBuoiHoc != 0)
                {
                    _donGia = _dothoc.HocPhi / _dothoc.SoBuoiHoc ?? 1;
                }

                HOCPHIHOCVIEN _hocphiHV = new HOCPHIHOCVIEN()
                {
                    PhieuGhiDanhId = this.PhieuGhiDanhId_Select,
                    HocVienId      = this.HocVienId_Select,
                    Stt            = 1,
                    DmDichVuId     = _dothoc.DotHocId,
                    TenDichVu      = cboDotHoc.Text,
                    SoTien         = O2S_Common.TypeConvert.Parse.ToDecimal(numTongTien.Text),
                    SoLuong        = O2S_Common.TypeConvert.Parse.ToDecimal(numSoBuoiHVDangKy.Text),
                    DonGia         = _donGia,
                    PhieuThuId     = 0,
                    GhiChu         = "",
                };
                if (PhieuGhiDanhLogic.InsertQLHocPhi_Option1(_phieughidanh, _phieuthu, _hocphiHV, ref this.PhieuThu_Insert))
                {
                    O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.LUU_THANH_CONG);
                    frmthongbao.Show();
                    //
                    LoadDanhSachHocVien();
                    gridViewDSHocVien_Click(null, null);

                    PhieuThuFilter _filter = new PhieuThuFilter();
                    _filter.HocVienId      = this.HocVienId_Select;
                    _filter.PhieuGhiDanhId = this.PhieuGhiDanhId_Select;
                    LoadDanhSachPhieuThu(_filter);

                    btnInBienLai.Enabled = true;
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }