Esempio n. 1
0
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult tb = XtraMessageBox.Show("Bạn có chắc chắn muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (tb == DialogResult.Yes)
                {
                    if (validate())
                    {
                        string sql = "delete from NhapKho where sohd = '" + txtmahd.Text + "'";

                        if (ConnectDB.Query(sql) == -1)
                        {
                            XtraMessageBox.Show("Xóa hóa đơn không thành công (T_T) !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            XtraMessageBox.Show("Xóa hóa đơn thành công (^-^)!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            hien();
                            string sql2 = "insert into LichSu values('" + userthem + "',N'Xoá hoá đơn có: [Mã HĐ]:(" + txtmahd + ") ||[Mã hàng]:(" + txtmvt.Text + ") || [Barcode]:(" + txtbarcode.Text + ") || [Số lượng nhập]:(" + txtslnhap.Text + ") || [Đơn vị tính]:(" + txtdvtinh.Text + ") || [Ngày nhập]:(" + Convert.ToDateTime(date_nhap.Text).ToString("dd/MM/yyyy HH:mm:ss") + ") || [Người nhập]:(" + cb_user.EditValue.ToString() + ") || [Đơn vị giao nhận]:(" + txtdvgiaonhan.Text + ")','" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "')";
                            ConnectDB.Query(sql2);
                        }
                    }
                }
            }catch
            {
                XtraMessageBox.Show("Không thể kết nối tới CSDL", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 2
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            try
            {
                if (validate())
                {
                    string sql = "update NhapKho set mavt = '" + txtmvt.Text + "',barcodenhap ='" + txtbarcode.Text + "',slnhap ='" + txtslnhap.Text + "',dvt ='" + txtdvtinh.Text + "',ngaynhap ='" + Convert.ToDateTime(date_nhap.Text).ToString("MM/dd/yyyy HH:mm:ss") + "', manv = '" + cb_user.EditValue.ToString() + "',dvgiaonhan = N'" + txtdvgiaonhan.Text + "',ghichu = N'" + txtghichu.Text + "' where sohd ='" + txtmahd.Text + "'";

                    if (ConnectDB.Query(sql) == -1)
                    {
                        XtraMessageBox.Show("Update không thành công (T_T) !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        XtraMessageBox.Show("Update thành công (^-^)!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        hien();
                        string sql2 = "insert into LichSu values('" + userthem + "',N'Sửa thông tin nhập kho mặt hàng có: [Mã HĐ]:(" + txtmahd + ") thành ||[Mã hàng]:(" + txtmvt.Text + ") || [Barcode]:(" + txtbarcode.Text + ") || [Số lượng nhập]:(" + txtslnhap.Text + ") || [Đơn vị tính]:(" + txtdvtinh.Text + ") || [Ngày nhập]:(" + Convert.ToDateTime(date_nhap.Text).ToString("dd/MM/yyyy HH:mm:ss") + ") || [Người nhập]:(" + cb_user.EditValue.ToString() + ") || [Đơn vị giao nhận]:(" + txtdvgiaonhan.Text + ")','" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "')";
                        ConnectDB.Query(sql2);
                    }
                }
            }
            catch
            {
                XtraMessageBox.Show("Không thể kết nối tới CSDL", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 3
0
 private void simpleButton1_Click(object sender, EventArgs e)
 {
     try
     {
         string conn = "Data Source=192.168.1.53,1433;Initial Catalog=QLKhoBB;User ID=sa;Password=123456789";
         DapperPlusManager.Entity <Nhap>().Table("NhapKho");
         List <Nhap> nhaps = nhapBindingSource1.DataSource as List <Nhap>;
         if (nhaps != null)
         {
             using (IDbConnection db = new SqlConnection(conn))
             {
                 db.BulkInsert(nhaps);
             }
         }
         DialogResult tb = XtraMessageBox.Show("Import thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         if (tb == DialogResult.OK)
         {
             this.Close();
         }
         string sql2 = "insert into LichSu values('" + userthem + "',N'Import file Excel vào nhập kho','" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "')";
         ConnectDB.Query(sql2);
     }
     catch
     {
         XtraMessageBox.Show("Có lỗi xảy ra!. Không thể Import vào CSDL!. Lưu ý thoát file excel trước khi import và số hóa đơn không được trùng trong CSDL!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Esempio n. 4
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            int    tt  = 0;
            string bar = "";

            for (int i = 0; i < dataGridView1.RowCount - 1; i++)
            {
                tt = tt + Convert.ToInt32(dataGridView1.Rows[i].Cells[3].Value.ToString());
                labelControl3.Text = "" + tt.ToString() + "";
                bar = dataGridView1.Rows[i].Cells[2].Value.ToString();
            }
            string    sqln = @"select MaVT, TenVT, Barcode ,Sum(Nhap) as tongnhhap , SUM(Xuat) as tongxuat, (SUM(Nhap) - SUM(Xuat)) as Ton from (select mavt as MaVT, tenvt as TenVT, barcode as Barcode, 0 as Nhap, 0 as Xuat From VatTu union Select N.mavt as MaVT, H.tenvt as TenVT,  N.barcodenhap as Barcode, Sum(N.slnhap) as Nhap, 0 as Xuat  From NhapKho N, VatTu H Where N.mavt = H.mavt Group By N.mavt, H.tenvt, N.barcodenhap having SUM(N.slnhap) > 0 union Select X.mavt as MaVT, H.tenvt as TenVT, X.barcodexuat as Barcode, 0 as Nhap, Sum(X.slxuat) as Xuat   From XuatKho X, VatTu H Where X.mavt = H.mavt Group By X.mavt, H.tenvt, X.barcodexuat having SUM(X.slxuat) > 0) as hangton where Barcode = '" + bar + "' Group by MaVT, TenVT, Barcode";
            DataTable dat  = ConnectDB.getTable(sqln);

            if (dat.Rows.Count > 0 && Convert.ToInt32(dat.Rows[0]["Ton"].ToString()) >= Convert.ToInt32(labelControl3.Text))
            {
                try
                {
                    string conn = "Data Source=192.168.1.53,1433;Initial Catalog=QLKhoBB;User ID=sa;Password=123456789";
                    DapperPlusManager.Entity <Xuat>().Table("XuatKho");
                    List <Xuat> xuats = xuatBindingSource.DataSource as List <Xuat>;
                    if (xuats != null)
                    {
                        using (IDbConnection db = new SqlConnection(conn))
                        {
                            db.BulkInsert(xuats);
                        }
                    }
                    DialogResult tb = XtraMessageBox.Show("Import thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (tb == DialogResult.OK)
                    {
                        this.Close();
                    }
                    string sql2 = "insert into LichSu values('" + userthem + "',N'Import file Excel vào Xuất kho','" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "')";
                    ConnectDB.Query(sql2);
                }
                catch
                {
                    XtraMessageBox.Show("Có lỗi xảy ra!. Không thể Import vào CSDL!. Lưu ý thoát file excel trước khi import và số hóa đơn không được trùng trong CSDL!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                XtraMessageBox.Show("Số lượng xuất không được vượt quá lượng tồn trong kho!");
            }
        }
Esempio n. 5
0
 private void simpleButton2_Click(object sender, EventArgs e)
 {
     try
     {
         if (textEdit11.Text == string.Empty)
         {
             XtraMessageBox.Show("Vui lòng chọn đường dẫn lưu file backup", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             string sql = "BACKUP DATABASE [QLKhoBB] TO DISK ='" + textEdit11.Text + "\\" + "DATABASE" + "-" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".bak'";  //thực thi câu lệnh backup khi nhấn nút backup
             ConnectDB.Query(sql);
             XtraMessageBox.Show("Back up dữ liệu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             simpleButton2.Enabled = false;
         }
     }catch
     {
         XtraMessageBox.Show("Có lỗi xảy ra!. ", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Esempio n. 6
0
 private void simpleButton6_Click_1(object sender, EventArgs e)
 {
     try
     {
         string         sql3 = "SELECT sohd , NhapKho.mavt, tenvt, barcodenhap,slnhap,dvt,ngaynhap,username,dvgiaonhan,ghichu FROM NhapKho INNER JOIN VatTu ON VatTu.mavt = NhapKho.mavt INNER JOIN NhanVien ON NhanVien.manv = NhapKho.manv";
         SaveFileDialog saveFileDialogExcel = new SaveFileDialog();
         saveFileDialogExcel.Filter = "Excel files (*.xlsx)|*.xlsx";
         if (saveFileDialogExcel.ShowDialog() == DialogResult.OK)
         {
             string exportFilePath = saveFileDialogExcel.FileName;
             gridControl1.DataSource = ConnectDB.getTable(sql3);
             gridControl1.ExportToXlsx(exportFilePath);
             XtraMessageBox.Show("Xuất file Excel thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             string sql2 = "insert into LichSu values('" + userthem + "',N'Xuất file Excel của các mặt hàng đã nhập kho','" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "')";
             ConnectDB.Query(sql2);
         }
     }
     catch
     {
         XtraMessageBox.Show("Không thể Xuất file Excel", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Esempio n. 7
0
        public static string tk = ""; // tạo biến public để truyền tham số của biến username sang các form khác
        private void btn_dn_Click(object sender, EventArgs e)
        {
            try
            {
                if (validate())  //kiểm tra dữ liệu k rỗng thì :
                {
                    //khai báo chuỗi lệnh sql
                    string    sql  = @"select * from NhanVien where username = '******' and password = '******'";
                    DataTable data = ConnectDB.getTable(sql);

                    if (data.Rows.Count <= 0)  //gọi hàm getTable từ lớp DbHelper có giá trị truyền vào là chuỗi lênh select để lấy thông tin từ bảng nếu có số dòng <= 0 thì:
                    {
                        XtraMessageBox.Show("Sai tài khoản hoặc mật khẩu !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else  //nếu số dòng lấy được > 0 thì :
                    if (data.Rows[0]["trangthai"].ToString() == "Active")    // kiểm tra dữ liệu cột trạng thái trong sql nếu là Active thì mới được quyền truy cập
                    {
                        XtraMessageBox.Show("Đăng nhập thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Quyen.nhomnd = data.Rows[0]["nhomnd"].ToString();
                        ;
                        tk           = txtusername.Text;
                        this.Visible = false;                                                                                                                 //cho form này ẩn đi
                        new Form1().ShowDialog();                                                                                                             //hiện form chinh
                        string sql1 = "insert into LichSu values('" + txtusername.Text + "','Login','" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "')"; // thêm lich sử hoạt động là Login của username vào bảng lịch sử User
                        ConnectDB.Query(sql1);
                    }
                    else
                    {
                        XtraMessageBox.Show("Tài khoản này hiện đang bị khoá. Liên hệ admin để mở khoá tài khoản!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch
            {
                XtraMessageBox.Show("Không thể kết nối tới CSDL", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 8
0
 private void bnt_doimk_Click(object sender, EventArgs e)
 {
     try
     {
         string sql = @"select * from NhanVien where username = '******' and password = '******'";  // lọc Nhân viên có username và password nhập vào
         DataTable data = ConnectDB.getTable(sql);
         if (data.Rows.Count <= 0)
         {
             XtraMessageBox.Show("Mật khẩu hiện tại sai !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         if (txtpassmoi.Text != txtxacnhan.Text) // kiểm tra người dùng nhập mã mới có trùng với mã xác nhận không
         {
             MessageBox.Show("Xác nhận lại mật khẩu mới không đúng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             string sql1 = @"update NhanVien set password='******' where username= '******'"; // cập nhật mật khẩu mới
             if (ConnectDB.Query(sql1) == -1)
             {
                 XtraMessageBox.Show("Đổi mật khẩu không thành công (T_T) !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             else
             {
                 XtraMessageBox.Show("Đổi mật khẩu thành công (^-^)!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 string sql2 = "insert into LichSu values('" + user + "',N'Đổi mật khẩu thành ("+txtpassmoi.Text+ ")','" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "')"; // Ghi lại thao tác thay đổi mật khẩu vào bảng LichSu
                 ConnectDB.Query(sql2);
                 this.Close();
             }
         }
     }
     catch
     {
         XtraMessageBox.Show("Không thể kết nối tới CSDL", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Esempio n. 9
0
        private void simpleButton1_Click_1(object sender, EventArgs e)
        {
            DialogResult tb = XtraMessageBox.Show("Bạn có muốn in phiếu nhập mặt hàng này sau khi nhập kho không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (tb == DialogResult.Yes)
            {
                try
                {
                    if (validate())
                    {
                        string sql = "insert into NhapKho values('" + txtmahd.Text.Trim() + "','" + txtmvt.Text + "','" + txtbarcode.Text + "','" + txtslnhap.Text + "','" + txtdvtinh.Text + "','" + Convert.ToDateTime(date_nhap.Text).ToString("MM/dd/yyyy HH:mm:ss") + "',N'" + cb_user.EditValue.ToString() + "',N'" + txtdvgiaonhan.Text + "',N'" + txtghichu.Text + "')";

                        if (ConnectDB.Query(sql) == -1)
                        {
                            XtraMessageBox.Show("Nhập không thành công (T_T) !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            XtraMessageBox.Show("Nhập kho thành công (^-^)!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            hien();
                            string sql2 = "insert into LichSu values('" + userthem + "',N'Nhập kho mặt hàng có: [Mã HĐ]:(" + txtmahd + ") ||[Mã hàng]:(" + txtmvt.Text + ") || [Barcode]:(" + txtbarcode.Text + ") || [Số lượng nhập]:(" + txtslnhap.Text + ") || [Đơn vị tính]:(" + txtdvtinh.Text + ") || [Ngày nhập]:(" + Convert.ToDateTime(date_nhap.Text).ToString("dd/MM/yyyy HH:mm:ss") + ") || [Người nhập]:(" + cb_user.EditValue.ToString() + ") || [Đơn vị giao nhận]:(" + txtdvgiaonhan.Text + ")','" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "')";
                            ConnectDB.Query(sql2);
                        }
                    }
                }
                catch
                {
                    XtraMessageBox.Show("Không thể kết nối tới CSDL", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                SqlConnection con = new SqlConnection(@"Data Source=192.168.1.53,1433;Initial Catalog=QLKhoBB;User ID=sa;Password=123456789");
                con.Open();
                SqlCommand     cmd = new SqlCommand("select * from NhapKho where sohd  = '" + txtmahd.Text + "'", con);
                SqlDataAdapter da  = new SqlDataAdapter(cmd);
                DataTable      dt  = new DataTable();
                da.Fill(dt);
                con.Close();
                XtraReport1 rp = new XtraReport1();
                rp.DataSource = dt;
                rp.ShowPreviewDialog();
            }
            else
            {
                try
                {
                    if (validate())
                    {
                        string sql = "insert into NhapKho values('" + txtmahd.Text.Trim() + "','" + txtmvt.Text + "','" + txtbarcode.Text + "','" + txtslnhap.Text + "','" + txtdvtinh.Text + "','" + Convert.ToDateTime(date_nhap.Text).ToString("MM/dd/yyyy HH:mm:ss") + "',N'" + cb_user.EditValue.ToString() + "',N'" + txtdvgiaonhan.Text + "',N'" + txtghichu.Text + "')";

                        if (ConnectDB.Query(sql) == -1)
                        {
                            XtraMessageBox.Show("Nhập không thành công (T_T) !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            XtraMessageBox.Show("Nhập kho thành công (^-^)!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            string sql2 = "insert into LichSu values('" + userthem + "',N'Nhập kho mặt hàng có: [Mã HĐ]:(" + txtmahd + ") ||[Mã hàng]:(" + txtmvt.Text + ") || [Barcode]:(" + txtbarcode.Text + ") || [Số lượng nhập]:(" + txtslnhap.Text + ") || [Đơn vị tính]:(" + txtdvtinh.Text + ") || [Ngày nhập]:(" + Convert.ToDateTime(date_nhap.Text).ToString("dd/MM/yyyy HH:mm:ss") + ") || [Người nhập]:(" + cb_user.EditValue.ToString() + ") || [Đơn vị giao nhận]:(" + txtdvgiaonhan.Text + ")','" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "')";
                            ConnectDB.Query(sql2);
                            hien();
                        }
                    }
                }
                catch
                {
                    XtraMessageBox.Show("Không thể kết nối tới CSDL", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Esempio n. 10
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            string    sqln = @"select MaVT, TenVT, Barcode ,Sum(Nhap) as tongnhhap , SUM(Xuat) as tongxuat, (SUM(Nhap) - SUM(Xuat)) as Ton from (select mavt as MaVT, tenvt as TenVT, barcode as Barcode, 0 as Nhap, 0 as Xuat From VatTu union Select N.mavt as MaVT, H.tenvt as TenVT,  N.barcodenhap as Barcode, Sum(N.slnhap) as Nhap, 0 as Xuat  From NhapKho N, VatTu H Where N.mavt = H.mavt Group By N.mavt, H.tenvt, N.barcodenhap having SUM(N.slnhap) > 0 union Select X.mavt as MaVT, H.tenvt as TenVT, X.barcodexuat as Barcode, 0 as Nhap, Sum(X.slxuat) as Xuat   From XuatKho X, VatTu H Where X.mavt = H.mavt Group By X.mavt, H.tenvt, X.barcodexuat having SUM(X.slxuat) > 0) as hangton where Barcode = '" + txtbarcode.Text + "' Group by MaVT, TenVT, Barcode";
            DataTable dat  = ConnectDB.getTable(sqln);

            if (dat.Rows.Count > 0 && Convert.ToInt64(dat.Rows[0]["Ton"].ToString()) >= Convert.ToInt64(txtslnhap.Text))
            {
                try
                {
                    if (validate())
                    {
                        DialogResult tb = XtraMessageBox.Show("Bạn có muốn in phiếu xuất mặt hàng này sau khi xuất kho không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (tb == DialogResult.Yes)
                        {
                            string sql2 = "insert into XuatKho values('" + txtmahd.Text.Trim() + "','" + txtmvt.Text + "','" + txtbarcode.Text + "','" + txtslnhap.Text + "','" + txtdvtinh.Text + "','" + Convert.ToDateTime(date_nhap.Text).ToString("MM/dd/yyyy HH:mm:ss") + "',N'" + cb_user.EditValue.ToString() + "',N'" + txtdvgiaonhan.Text + "',N'" + txtghichu.Text + "')";
                            if (ConnectDB.Query(sql2) == -1)
                            {
                                XtraMessageBox.Show("Xuất không thành công (T_T) !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else
                            {
                                XtraMessageBox.Show("Xuất kho thành công (^-^)!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                string sqll = "insert into LichSu values('" + userxuat + "',N'Xuất kho mặt hàng có: [Mã HĐ]:(" + txtmahd + ") ||[Mã hàng]:(" + txtmvt.Text + ") || [Barcode]:(" + txtbarcode.Text + ") || [Số lượng xuất]:(" + txtslnhap.Text + ") || [Đơn vị tính]:(" + txtdvtinh.Text + ") || [Ngày xuất]:(" + Convert.ToDateTime(date_nhap.Text).ToString("dd/MM/yyyy HH:mm:ss") + ") || [Người xuất]:(" + cb_user.EditValue.ToString() + ") || [Đơn vị giao nhận]:(" + txtdvgiaonhan.Text + ")','" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "')";
                                ConnectDB.Query(sqll);
                                hien();
                            }
                            SqlConnection con = new SqlConnection(@"Data Source=192.168.1.53,1433;Initial Catalog=QLKhoBB;User ID=sa;Password=123456789");
                            con.Open();
                            SqlCommand     cmd = new SqlCommand("select * from XuatKho where sohd  = '" + txtmahd.Text + "'", con);
                            SqlDataAdapter da  = new SqlDataAdapter(cmd);
                            DataTable      dt  = new DataTable();
                            da.Fill(dt);
                            con.Close();
                            XtraReport2 rp = new XtraReport2();
                            rp.DataSource = dt;
                            rp.ShowPreviewDialog();
                        }
                        else
                        {
                            try
                            {
                                if (validate())
                                {
                                    string sql2 = "insert into XuatKho values('" + txtmahd.Text.Trim() + "','" + txtmvt.Text + "','" + txtbarcode.Text + "','" + txtslnhap.Text + "','" + txtdvtinh.Text + "','" + Convert.ToDateTime(date_nhap.Text).ToString("MM/dd/yyyy HH:mm:ss") + "',N'" + cb_user.EditValue.ToString() + "',N'" + txtdvgiaonhan.Text + "',N'" + txtghichu.Text + "')";

                                    if (ConnectDB.Query(sql2) == -1)
                                    {
                                        XtraMessageBox.Show("Xuất không thành công (T_T) !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    }
                                    else
                                    {
                                        XtraMessageBox.Show("Xuất kho thành công (^-^)!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        string sqll = "insert into LichSu values('" + userxuat + "',N'Xuất kho mặt hàng có: [Mã HĐ]:(" + txtmahd + ") ||[Mã hàng]:(" + txtmvt.Text + ") || [Barcode]:(" + txtbarcode.Text + ") || [Số lượng xuất]:(" + txtslnhap.Text + ") || [Đơn vị tính]:(" + txtdvtinh.Text + ") || [Ngày xuất]:(" + Convert.ToDateTime(date_nhap.Text).ToString("dd/MM/yyyy HH:mm:ss") + ") || [Người xuất]:(" + cb_user.EditValue.ToString() + ") || [Đơn vị giao nhận]:(" + txtdvgiaonhan.Text + ")','" + DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") + "')";
                                        ConnectDB.Query(sqll);
                                        hien();
                                    }
                                }
                            }
                            catch
                            {
                                XtraMessageBox.Show("Không thể kết nối tới CSDL", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                    }
                }
                catch
                {
                    XtraMessageBox.Show("Không thể kết nối tới CSDL", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                XtraMessageBox.Show("Mặt hàng này hiện trong kho còn ít hơn so với số lượng xuất!");
            }
        }