private void btnLuuThongTin_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateLuu();

                if (HoaDonThuChiLogic.Insert(LoadHoaDonThuChi()))
                {
                    O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THEM_MOI_THANH_CONG);
                    frmthongbao.Show();
                    LoadDanhSachHoaDon();
                    LockAndUnlockPanelControl(false);
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CO_LOI_XAY_RA);
                frmthongbao.Show();
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
 private void repositoryItemButton_Print_Click(object sender, EventArgs e)
 {
     try
     {
         var          rowHandle       = gridViewDSHoaDonThuChi.FocusedRowHandle;
         int          _HoaDonThuChiId = O2S_Common.TypeConvert.Parse.ToInt32(gridViewDSHoaDonThuChi.GetRowCellValue(rowHandle, "HoaDonThuChiId").ToString());
         HOADONTHUCHI _hdThuChi       = HoaDonThuChiLogic.SelectSingle(_HoaDonThuChiId);
         // LoadPanelControl(_hdThuChi);
         //LockAndUnlockPanelControl(false);
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Error(ex);
     }
 }
        private void LoadDanhSachHoaDon()
        {
            try
            {
                HoaDonThuChiFilter _filter = new HoaDonThuChiFilter();
                _filter.LoaiChungTuId   = O2S_Common.TypeConvert.Parse.ToInt32(cboLoaiChungTu_TK.SelectedValue.ToString());
                _filter.ThoiGianLap_Tu  = date_TuNgay.DateTime;
                _filter.ThoiGianLap_Den = date_DenNgay.DateTime;
                this.lstHoaDonThuChi    = HoaDonThuChiLogic.Select(_filter);
                if (this.lstHoaDonThuChi != null && this.lstHoaDonThuChi.Count > 0)
                {
                    decimal _tongthu = 0;
                    decimal _tongchi = 0;

                    for (int i = 0; i < this.lstHoaDonThuChi.Count; i++)
                    {
                        this.lstHoaDonThuChi[i].Stt = i + 1;
                        if (this.lstHoaDonThuChi[i].LoaiChungTuId == KeySetting.LOAICHUNGTU_PhieuThu)
                        {
                            _tongthu += this.lstHoaDonThuChi[i].SoTien ?? 0;
                        }
                        else
                        {
                            _tongchi += this.lstHoaDonThuChi[i].SoTien ?? 0;
                            this.lstHoaDonThuChi[i].SoTien = 0 - this.lstHoaDonThuChi[i].SoTien;
                        }
                    }

                    gridControlDSHoaDonThuChi.DataSource = this.lstHoaDonThuChi;

                    lblTongThu.Text = O2S_Common.Number.Convert.NumberToString(_tongthu, 0) + " đ";
                    lblTongChi.Text = O2S_Common.Number.Convert.NumberToString(_tongchi, 0) + " đ";
                    lblTonQuy.Text  = O2S_Common.Number.Convert.NumberToString(_tongthu - _tongchi, 0) + " đ";
                }
                else
                {
                    gridControlDSHoaDonThuChi.DataSource = null;
                    lblTongThu.Text = "0 đ";
                    lblTongChi.Text = "0 đ";
                    lblTonQuy.Text  = "0 đ";
                }
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Warn(ex);
            }
        }
        //private void btnSua_Click(object sender, EventArgs e)
        //{
        //    LockAndUnlockPanelControl(true);
        //    //isInsert = false;
        //}

        private void btnXoa_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Bạn có muốn xóa?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (HoaDonThuChiLogic.Delete(this.HoaDonThuChiId_Select))
                    {
                        O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.XOA_THANH_CONG);
                        frmthongbao.Show();
                        LoadDanhSachHoaDon();
                        ResetPanelControl();
                    }
                }
            }
            catch (Exception ex)
            {
                O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CO_LOI_XAY_RA);
                frmthongbao.Show();
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }