Exemplo n.º 1
0
        // ghi nhan lai su thay doi

        private void btn_ghinhan_Click(object sender, EventArgs e)
        {
            if (key == 1)
            {
                if (tbx_tenkho.Text == "" || tbx_ghichu.Text == "" || tbx_tongdmsp.Value == 0)
                {
                    MessageBox.Show("Hãy Nhập Đủ hết thông tin", "Lỗi Nhập!");
                    tbx_makho.Focus();
                }
                else
                {
                    DataTable dtkh = acc.CheckSql("SELECT *FROM KHOHANG WHERE MAKHO='" + tbx_makho.Text + "'");
                    if (dtkh.Rows.Count > 0)
                    {
                        MessageBox.Show("Mã Kho đã tồn tại!!", "Cảnh Báo");
                        tbx_makho.Clear();
                        tbx_makho.Focus();
                    }
                    else
                    {
                        acc.THEM_KHOHANG(tbx_makho.Text, tbx_tenkho.Text, Convert.ToInt32(tbx_tongdmsp.Value), tbx_ghichu.Text);
                        KhoHang_Load(sender, e);
                        clearText();
                    }
                }
            }
            if (key == 2)
            {
                if (tbx_makho.Text.Trim() == "")
                {
                    MessageBox.Show("Hãy Nhập Đầy Đủ THông Tin Hoặc Chọn Dòng Bạn Muốn sửa!", "Thông Báo");
                    tbx_makho.Focus();
                }
                else
                {
                    acc.SUA_KHOHANG(tbx_makho.Text, tbx_tenkho.Text, Convert.ToInt32(tbx_tongdmsp.Value), tbx_ghichu.Text);
                    KhoHang_Load(sender, e);
                    clearText();
                    //bt_them.Enabled = true; bt_xoa.Enabled = false;
                }
            }

            if (key == 3)
            {
                if (tbx_makho.Text == "" || dgvKHOHANG.SelectedRows == null)
                {
                    MessageBox.Show("Hãy Nhập mã Kho Hàng Bạn Muốn Xóa hoặc Chọn Tại Bảng!", "Thông Báo");
                    tbx_makho.Focus();
                }
                else
                {
                    if (MessageBox.Show("Bạn có Chắc Chắn Muốn xóa Kho này?", "xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        //acc.Custom_ByQuery("UPDATE DANHMUC SET MAKHO=NULL WHERE MAKHO='" + this.tbx_makho.Text + "'");
                        //acc.Custom_ByQuery("UPDATE PHIEUNHAPKHO SET MAKHO=NULL WHERE MAKHO='" + this.tbx_makho.Text + "'");
                        //acc.Custom_ByQuery("UPDATE PHIEUXUAT SET MAKHO=NULL WHERE MAKHO='" + this.tbx_makho.Text + "'");
                        //acc.Custom_ByQuery("UPDATE BOPHAN SET MAKHO=NULL WHERE MAKHO='" + this.tbx_makho.Text + "'");
                        //acc.Custom_ByQuery("UPDATE BAOCAOTHONGKE SET MAKHO=NULL WHERE MAKHO='" + this.tbx_makho.Text + "'");
                        acc.XOA_KHOHANG(tbx_makho.Text);
                        KhoHang_Load(sender, e);
                        clearText();
                    }
                }
            }
        }