private void bbiLuu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gbList.FocusedRowHandle += 1;
            gbList.UpdateCurrentRow();

            if (!Kiem_Tra())
            {
                return;
            }

            Data_QLKDataContext database = new Data_QLKDataContext(SqlHelper.ConnectionString);
            try
            {
                database.Connection.Open();
                System.Data.Common.DbTransaction transaction = database.Connection.BeginTransaction();
                database.Transaction = transaction;

                if (tinh_trang == "them")
                {
                    CHUNG_TU chung_tu = new CHUNG_TU
                    {
                        Ma_Chung_Tu = txtMaChungTu.Text,
                        Ma_Hoa_Don = txtMaHoaDon.Text,
                        Ngay = txtNgay.DateTime,
                        Loai_Chung_Tu = 1, //1 la nhap kho 2 la xuat kho
                        Ma_Khach_Hang = string.IsNullOrEmpty(txtKhachHang.Text) ? "" : txtKhachHang.EditValue.ToString(),
                        Dia_Chi = txtDiaChi.Text,
                        Ly_Do = txtLyDo.Text,
                        VAT_Phan_Tram = txtVATPhanTram.Value,
                        VAT_Thanh_Tien = txtVATThanhTien.Value,
                        Chiet_Khau_Phan_Tram = txtChietKhauPhanTram.Value,
                        Chiet_Khau_Thanh_Tien = txtChietKhauThanhTien.Value,
                        Thanh_Tien = txtThanhTien.Value,
                        Hinh_Thuc_Cong_No = Convert.ToInt32(txtHinhThucCongNo.EditValue),
                        Hinh_Thuc_Thu_Chi = Convert.ToInt32(txtHinhThucThuChi.EditValue),
                        Thanh_Toan = txtThanhToan.Value,
                        Ghi_Chu = txtGhiChu.Text,
                        So_Thu_Tu = 0,
                        Nhan_Vien = string.IsNullOrEmpty(txtNhanVien.Text) ? "" : txtNhanVien.EditValue.ToString()
                    };
                    database.CHUNG_TUs.InsertOnSubmit(chung_tu);

                }
                else
                {
                    var chung_tu = (from ct in database.CHUNG_TUs
                                   where ct.Ma_Chung_Tu == txtMaChungTu.Text
                                   select ct).FirstOrDefault();

                    chung_tu.Ma_Chung_Tu = txtMaChungTu.Text;
                    chung_tu.Ma_Hoa_Don = txtMaHoaDon.Text;
                    chung_tu.Ngay = txtNgay.DateTime;
                    chung_tu.Loai_Chung_Tu = 1; //1 la nhap kho 2 la xuat kho
                    chung_tu.Ma_Khach_Hang = string.IsNullOrEmpty(txtKhachHang.Text) ? "" : txtKhachHang.EditValue.ToString();
                    chung_tu.Dia_Chi = txtDiaChi.Text;
                    chung_tu.Ly_Do = txtLyDo.Text;
                    chung_tu.VAT_Phan_Tram = txtVATPhanTram.Value;
                    chung_tu.VAT_Thanh_Tien = txtVATThanhTien.Value;
                    chung_tu.Chiet_Khau_Phan_Tram = txtChietKhauPhanTram.Value;
                    chung_tu.Chiet_Khau_Thanh_Tien = txtChietKhauThanhTien.Value;
                    chung_tu.Thanh_Tien = txtThanhTien.Value;
                    chung_tu.Hinh_Thuc_Cong_No = Convert.ToInt32(txtHinhThucCongNo.EditValue);
                    chung_tu.Hinh_Thuc_Thu_Chi = Convert.ToInt32(txtHinhThucThuChi.EditValue);
                    chung_tu.Thanh_Toan = txtThanhToan.Value;
                    chung_tu.Ghi_Chu = txtGhiChu.Text;
                    chung_tu.Nhan_Vien = string.IsNullOrEmpty(txtNhanVien.Text) ? "" : txtNhanVien.EditValue.ToString();
                    chung_tu.So_Thu_Tu = 0;

                }

                if (Luu_Chi_Tiet(database) == "OK")
                {
                    database.SubmitChanges();
                    database.Transaction.Commit();
                    RaiseReloadEventHander();
                    Close();
                }
                else
                {
                    database.Transaction.Rollback();
                }
            }
            catch (Exception ex)
            {
                database.Transaction.Rollback();
                MessageBox.Show(ex.ToString());
            }
        }
 partial void UpdateCHUNG_TU(CHUNG_TU instance);
 partial void DeleteCHUNG_TU(CHUNG_TU instance);
 partial void InsertCHUNG_TU(CHUNG_TU instance);