private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtMaloai.Text == "")
            {
                MessageBox.Show("Bạn phải nhập Mã loại");
                return;
            }
            if (txtTenloai.Text == "")
            {
                MessageBox.Show("Bạn phải nhập Tên loại");
                txtTenloai.Focus();
                return;
            }
            sql = "SELECT * FROM tblLoai WHERE MaLoai ='" + txtMaloai.Text + "'";
            DataTable dt = ThucThiSQL.DocBang(sql);

            if (dt.Rows.Count > 0)
            {
                MessageBox.Show("Bạn đã nhập trùng MÃ CHẤT LIỆU");
                txtMaloai.Text = "";
                txtMaloai.Focus();
                return;
            }
            sql = "INSERT INTO tblLoai(MaLoai,TenLoai) " +
                  "VALUES (N'" + txtMaloai.Text + "',N'" + txtTenloai.Text + "')";
            ThucThiSQL.CapNhapDuLieu(sql);
            HienThi_Luoi();
            txtMaloai.Text     = "";
            txtTenloai.Text    = "";
            btnLuu.Enabled     = false;
            txtTenloai.Enabled = false;
        }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtMaKH.Text == "")
            {
                MessageBox.Show("Bạn phải nhập Mã KH");
                return;
            }
            if (txtTenKH.Text == "")
            {
                MessageBox.Show("Bạn phải nhập Tên KH");
                txtTenKH.Focus();
                return;
            }
            sql = "SELECT * FROM tblKH WHERE MaKH ='" + txtMaKH.Text + "'";
            DataTable dt = ThucThiSQL.DocBang(sql);

            if (dt.Rows.Count > 0)
            {
                MessageBox.Show("Bạn đã nhập trùng MÃ KH");
                txtMaKH.Text = "";
                txtMaKH.Focus();
                return;
            }
            sql = "INSERT INTO tblKH(MaKH,TenKH,GioiT,DiaChi,NgaySinh,SDT) " +
                  "VALUES (N'" + txtMaKH.Text + "',N'" + txtTenKH.Text + "',N'" + txtDiachi.Text + "',N'" + dtpNgaySinh.Value.ToShortDateString() + "',N'" + txtSDT.Text + "')";
            ThucThiSQL.CapNhapDuLieu(sql);
            HienThi_Luoi();
            Reset();
            btnLuu.Enabled   = false;
            txtTenKH.Enabled = false;
        }
        private void btnSua_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtTenKH.Text == "")
            {
                MessageBox.Show("Bạn phải nhập TÊN KH");
                txtTenKH.Focus();
                return;
            }
            if (txtDiachi.Text == "")
            {
                MessageBox.Show("Bạn phải nhập Địa chỉ");
                txtDiachi.Focus();
                return;
            }
            if (txtSDT.Text == "")
            {
                MessageBox.Show("Bạn phải nhập SDT");
                label.Focus();
                return;
            }
            sql = "UPDATE tblKH SET TenKH = N'" + txtTenKH.Text + "'," +
                  "DiaChi = N'" + txtDiachi.Text + "'," +
                  "NgaySinh = N'" + dtpNgaySinh.Value.ToString("yyyy/MM/dd") + "'," +
                  "SDT = N'" + txtSDT.Text + "' WHERE " +
                  "MaKH= N'" + txtMaKH.Text + "'";
            ThucThiSQL.CapNhapDuLieu(sql);
            HienThi_Luoi();
            Reset();
            Disable();
            SemiReset();
        }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtMaSP.Text == "")
            {
                MessageBox.Show("Bạn phải nhập Mã SP");
                return;
            }
            if (txtTenSP.Text == "")
            {
                MessageBox.Show("Bạn phải nhập Tên SP");
                txtTenSP.Focus();
                return;
            }
            sql = "SELECT * FROM tblSP WHERE MaSP ='" + txtMaSP.Text + "'";
            DataTable dt = ThucThiSQL.DocBang(sql);

            if (dt.Rows.Count > 0)
            {
                MessageBox.Show("Bạn đã nhập trùng MÃ SP");
                txtMaSP.Text = "";
                txtMaSP.Focus();
                return;
            }
            sql = "INSERT INTO tblSP (MaSP,TenSP,MaLoai,DonGiaNhap,DonGiaBan,SoLuong,Anh,GhiChu) " +
                  "VALUES (N'" + txtMaSP.Text + "',N'" + txtTenSP.Text + "',N'" + cboMaLoai.Text + "'," +
                  "" + txtDongiaNhap.Text + "," + txtDongiaBan.Text + "," + txtSoluong.Text + "," +
                  "N'" + txtLink.Text + "',N'" + txtGhichu.Text + "')";
            ThucThiSQL.CapNhapDuLieu(sql);
            HienThi_Luoi();
            Reset();
            btnLuu.Enabled   = false;
            txtTenSP.Enabled = false;
        }
Beispiel #5
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtMaNCC.Text == "")
            {
                MessageBox.Show("Bạn phải nhập Mã NCC");
                return;
            }
            if (txtTenNCC.Text == "")
            {
                MessageBox.Show("Bạn phải nhập Tên NCC");
                txtTenNCC.Focus();
                return;
            }
            sql = "SELECT * FROM tblNCC WHERE MaNCC ='" + txtMaNCC.Text + "'";
            DataTable dt = ThucThiSQL.DocBang(sql);

            if (dt.Rows.Count > 0)
            {
                MessageBox.Show("Bạn đã nhập trùng MÃ NCC");
                txtMaNCC.Text = "";
                txtMaNCC.Focus();
                return;
            }
            sql = "INSERT INTO tblNCC(MaNCC,TenNCC,DiaChi,SDT) " +
                  "VALUES (N'" + txtMaNCC.Text + "',N'" + txtTenNCC.Text + "',N'" + txtDiachi.Text + "',N'" + txtSDT.Text + "')";
            ThucThiSQL.CapNhapDuLieu(sql);
            HienThi_Luoi();
            Reset();
            btnLuu.Enabled    = false;
            txtTenNCC.Enabled = false;
        }
Beispiel #6
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtTenNCC.Text == "")
            {
                MessageBox.Show("Bạn phải nhập TÊN NCC");
                txtTenNCC.Focus();
                return;
            }
            if (txtDiachi.Text == "")
            {
                MessageBox.Show("Bạn phải nhập Địa chỉ");
                txtDiachi.Focus();
                return;
            }
            if (txtSDT.Text == "")
            {
                MessageBox.Show("Bạn phải nhập SDT");
                label.Focus();
                return;
            }
            sql = "UPDATE tblNCC SET TenNCC = N'" + txtTenNCC.Text + "'," +
                  "DiaChi = N'" + txtDiachi.Text + "',SDT = N'" + txtSDT.Text + "' WHERE " +
                  "MaNCC= N'" + txtMaNCC.Text + "'";
            ThucThiSQL.CapNhapDuLieu(sql);
            HienThi_Luoi();
            Reset();
            Disable();
            SemiReset();
        }
        private void btnSua_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtTenloai.Text == "")
            {
                MessageBox.Show("Bạn phải nhập TÊN Loại");
                txtTenloai.Focus();
                return;
            }
            sql = "UPDATE tblLoai SET TenLoai = N'" + txtTenloai.Text + "' WHERE " +
                  "MaLoai= N'" + txtMaloai.Text + "'";
            ThucThiSQL.CapNhapDuLieu(sql);
            HienThi_Luoi();
            txtMaloai.Text     = "";
            txtTenloai.Enabled = false;
            SemiReset();
        }
        private void btnSua_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtTenSP.Text == "")
            {
                MessageBox.Show("Bạn phải nhập TÊN NV");
                txtTenSP.Focus();
                return;
            }
            if (cboMaLoai.Text == "")
            {
                MessageBox.Show("Bạn phải nhập Địa chỉ");
                cboMaLoai.Focus();
                return;
            }
            if (txtDongiaNhap.Text == "")
            {
                MessageBox.Show("Bạn phải nhập SDT");
                txtDongiaNhap.Focus();
                return;
            }
            if (txtDongiaBan.Text == "")
            {
                MessageBox.Show("Bạn phải nhập SDT");
                txtDongiaBan.Focus();
                return;
            }
            if (txtSoluong.Text == "")
            {
                MessageBox.Show("Bạn phải nhập SDT");
                txtDongiaBan.Focus();
                return;
            }
            sql = "UPDATE tblNV SET TenSP=N'" + txtTenSP.Text + "',MaLoai=N'" + cboMaLoai.Text + "'," +
                  "DonGiaNhap=" + txtDongiaNhap.Text + ",DonGiaBan=" + txtDongiaBan.Text + ",SoLuong=" + txtSoluong.Text + "," +
                  "Anh=N'" + txtLink.Text + "',GhiChu=N'" + txtGhichu.Text + "' WHERE " +
                  "MaSP= N'" + txtMaSP.Text + "'";
            ThucThiSQL.CapNhapDuLieu(sql);
            HienThi_Luoi();
            Reset();
            Disable();
            SemiReset();
        }
        private void btnXoa_Click(object sender, EventArgs e)
        {
            string sql;

            if (dgvKH.Rows.Count == 0)
            {
                MessageBox.Show("KHÔNG CÓ DỮ LIỆU");
                return;
            }
            string ma = dgvKH.CurrentRow.Cells["MaKH"].Value.ToString();

            if (MessageBox.Show("Bạn có muốn xóa không? ", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                sql = "DELETE FROM tblKH WHERE MaKH =N'" + ma + "' ";
                ThucThiSQL.CapNhapDuLieu(sql);
                HienThi_Luoi();
                Reset();
                SemiReset();
                Disable();
            }
        }