private void btnLuu_Click(object sender, EventArgs e)
        {
            btnXoa.Enabled = true;
            if (txtMaMT.Text == "")
            {
                MessageBox.Show("Bạn phải nhập mã máy tính", "Thông báo");
                txtMaMT.Focus();
                return;
            }

            String sql;

            sql = " SELECT Ma_mayVT FROM dboMay_vi_tinh WHERE Ma_mayVT=N'" + txtMaMT.Text + "'";
            DataTable dt = ThucthiSQL.DocBang(sql);

            if (dt.Rows.Count > 0)
            {
                MessageBox.Show("Mã này đã có, bạn phải nhập mã khác", "Thông báo");
                txtMaMT.Focus();
                txtMaMT.Text = "";
            }
            sql = "INSERT INTO dboMay_vi_tinh(Ma_mayVT,Ten_mayVT,Ma_hang_SX,Ma_loai_may,Ma_RAM,Ma_chip,Ma_MH,Ma_co_MH,Ma_o_cung,Ma_dungluong,Ma_chuot,Ma_ban_phim,Thoi_han_BH,So_luong,Gia_nhap,Gia_ban) VALUES (N'" +
                  txtMaMT.Text + "',N'" + txtTenmaytinh.Text + "',N'" + txtNSX.Text + "',N'" + cboLoaimay.Text + "',N'" + cboRAM.Text + "',N'" + txtChip.Text + "',N'" + cboManhinh.Text + "',N'" + cboKichthuoc.Text + "',N'" + cboLoaiocung.Text + "',N'" + cboOcung.Text + "',N'" + txtChuot.Text + "',N'" + txtBanphim.Text + "'," + txtBaoHanh.Text + "," + txtSoluong.Text + "," + txtGiaNhap.Text + "," + txtGiaBan.Text + ")";
            ThucthiSQL.CapNhatDuLieu(sql);
            Hienthi_Luoi();
        }
Exemplo n.º 2
0
        private void dataGridView_DoubleClick(object sender, EventArgs e)
        {
            string mahangxoa, sql;
            Double thanhtienxoa, soluongxoa, sl, slcon, tong, tongmoi;

            if (dataGridView.Rows.Count == 0)
            {
                MessageBox.Show("Không có dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if ((MessageBox.Show("Bạn có chắc chắn muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
            {
                //Xóa hàng và cập nhật lại số lượng hàng
                mahangxoa    = dataGridView.CurrentRow.Cells["Mahang"].Value.ToString();
                soluongxoa   = Convert.ToDouble(dataGridView.CurrentRow.Cells["Soluong"].Value.ToString());
                thanhtienxoa = Convert.ToDouble(dataGridView.CurrentRow.Cells["Thanhtien"].Value.ToString());
                sql          = "DELETE tblChitietHDN WHERE MaHDN=N'" + txtMahoadon.Text + "' AND Mahang = N'" + mahangxoa + "'";
                ThucthiSQL.CapNhatDuLieu(sql);
                // Cập nhật lại số lượng cho các mặt hàng
                sl    = Convert.ToDouble(ThucthiSQL.DocBang("SELECT Soluongtonkho FROM tblHang WHERE Mahang = N'" + mahangxoa + "'").Rows[0][0].ToString());
                slcon = sl - soluongxoa;
                sql   = "UPDATE tblHang SET Soluongtonkho =" + slcon + " WHERE Mahang= N'" + mahangxoa + "'";
                ThucthiSQL.CapNhatDuLieu(sql);
                // Cập nhật lại tổng tiền cho hóa đơn bán
                tong    = Convert.ToDouble(ThucthiSQL.DocBang("SELECT Tongtien FROM tblHoadonnhap WHERE MaHDN = N'" + txtMahoadon.Text + "'").Rows[0][0].ToString());
                tongmoi = tong - thanhtienxoa;
                sql     = "UPDATE tblHoadonnhap SET Tongtien =" + tongmoi + " WHERE MaHDN = N'" + txtMahoadon.Text + "'";
                ThucthiSQL.CapNhatDuLieu(sql);
                txtTongtien.Text = tongmoi.ToString();
                lblBangchu.Text  = "Bằng chữ: " + ThucthiSQL.ChuyenSoSangChu(tongmoi.ToString());
                Hienthi_Luoi();
            }
        }
Exemplo n.º 3
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (dtpNgaynhap.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải chọn ngày nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                dtpNgaynhap.Focus();
                return;
            }
            if (cboManhanvien.Text == "")
            {
                MessageBox.Show("Bạn phải chọn mã nhân viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cboManhanvien.Focus();
                return;
            }
            if (cboMaNCC.Text == "")
            {
                MessageBox.Show("Bạn phải chọn mã nhà cung cấp", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cboMaNCC.Focus();
                return;
            }
            sql = "INSERT INTO tblHoadonnhap(MaHDN, Ngaynhap, MaNCC, MaNV, Tongtien) Values (N'" + txtMahoadon.Text +
                  "',N'" + dtpNgaynhap.Text + "',N'" + cboMaNCC.Text + "',N'" + cboManhanvien.Text + "'," + txtTongtien.Text + ")";
            ThucthiSQL.CapNhatDuLieu(sql);
            btnLuu.Enabled     = false;
            grbChitiet.Enabled = true;
        }
Exemplo n.º 4
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtMa_HDB.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập Mã Hóa Đơn nhập hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMa_HDB.Focus();
                return;
            }
            if (dtpNgayban.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập ngày nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                dtpNgayban.Focus();
                return;
            }
            if (cboMaKH.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập nhà cung cấp", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cboMaKH.Focus();
                return;
            }
            if (cboMaNV.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập Mã Nhân viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cboMaNV.Focus();
                return;
            }

            sql = "INSERT INTO tblHDB(Ma_HDB,Ngayban,MaNV,MaKH,Tong_tien) VALUES(N'" + txtMa_HDB.Text.Trim() + "'," +
                  "N'" + dtpNgayban.Value.ToShortDateString() + "',N'" + cboMaNV.Text.Trim() + "',N'" + cboMaKH.Text.Trim() + "',N'" + txtTong_tien.Text + "')";
            ThucthiSQL.CapNhatDuLieu(sql);
            btnLuu.Enabled     = false;
            grbChitiet.Enabled = true;
        }
Exemplo n.º 5
0
        private void DelUpdateHang(string mahang, double slxoa, double Giabanxoa)
        {
            double sl = Convert.ToDouble(ThucthiSQL.DocBang("select Soluongtonkho from tblHang where Mahang=N'" +
                                                            mahang + "'").Rows[0][0].ToString());
            double slmoi = sl + slxoa;
            string sql   = "update tblHang set Soluongtonkho=" + slmoi + "where Mahang=N'" + mahang + "'";

            ThucthiSQL.CapNhatDuLieu(sql);
        }
Exemplo n.º 6
0
        private void DelUpdateTongtien(string madonxoa, double thanhtienxoa)
        {
            double tong    = Convert.ToDouble(ThucthiSQL.DocBang("Select Tongtien from tblHoadonnhap where MaHDN=N'" + madonxoa + "'").Rows[0][0].ToString());
            double tongmoi = tong - thanhtienxoa;
            string sql     = "update tblHoadonnhap SET Tongtien=" + tongmoi + "where MaHDN=N'" + madonxoa + "'";

            ThucthiSQL.CapNhatDuLieu(sql);
            txtTongtien.Text = tongmoi.ToString();
            lblBangchu.Text  = "Bằng chữ: " + ThucthiSQL.ChuyenSoSangChu(tongmoi.ToString());
        }
Exemplo n.º 7
0
        private void DelUpdateSo_luongMVT(string ma_mayVTxoa, double slxoa, double giabanxoa)
        {
            //Cập nhập số lượng máy tính vào bảng máy vi tính  theo công thức
            //Slmoi= slg trong bảng máy vi tính - slg đã bị xóa
            double sl    = Convert.ToDouble(ThucthiSQL.DocBang("SELECT So_luong FROM dboMay_vi_tinh WHERE Ma_mayVT=N'" + ma_mayVTxoa + "'").Rows[0][0].ToString());
            double slmoi = sl - slxoa;
            string sql   = "UPDATE dboMay_vi_tinh SET So_luong=" + slmoi + "WHERE Ma_mayVT=N'" + ma_mayVTxoa + "'";

            ThucthiSQL.CapNhatDuLieu(sql);
        }
Exemplo n.º 8
0
        private void btnHuy_Click(object sender, EventArgs e)
        {
            string    sql = "SELECT Ma_mayVT,So_luong,Don_gia FROM tblChitietHDN WHERE Ma_mayVT = N'" + txtMahoadon.Text + "'";
            DataTable tbl = ThucthiSQL.DocBang(sql);

            sql = "DELETE tblHDN WHERE Ma_HDN= N'" + txtMahoadon.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
            ResetValues();
            Hienthi_Luoi();
        }
Exemplo n.º 9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (cboMamayvitinh.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã máy vi tính", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cboMamayvitinh.Focus();
                return;
            }
            if ((txtSo_luong.Text.Trim().Length == 0) || (txtSo_luong.Text == "0"))
            {
                MessageBox.Show("Bạn phải nhập số lượng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSo_luong.Text = "";
                txtSo_luong.Focus();
                return;
            }
            if (txtDon_gia.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập đơn giá", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDon_gia.Text = "";
                txtDon_gia.Focus();
                return;
            }
            string sql = "SELECT Ma_mayVT FROM tblChitietHDN WHERE Ma_mayVT=N'" + cboMamayvitinh.Text +
                         "' AND Ma_HDN = N'" + txtMahoadon.Text.Trim() + "'";

            if (ThucthiSQL.DocBang(sql).Rows.Count > 0)
            {
                MessageBox.Show("Mã hàng này đã có, bạn phải nhập mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ResetValuesMaytinh();
                cboMamayvitinh.Focus();
                return;
            }

            sql = "INSERT INTO tblChitietHDN(Ma_HDN,Ma_mayVT,So_luong,Don_gia,Thanh_tien) VALUES(N'" +
                  txtMahoadon.Text.Trim() + "','" + cboMamayvitinh.Text.ToString() + "'," + txtSo_luong.Text +
                  "," + txtDon_gia.Text + "," + txtThanh_tien.Text + ")";
            ThucthiSQL.CapNhatDuLieu(sql);
            Hienthi_Luoi();
            //
            double tong = Convert.ToDouble(ThucthiSQL.DocBang("SELECT Thanh_tien FROM tblHDN WHERE Ma_HDN=N'" +
                                                              txtMahoadon.Text + "'").Rows[0][0].ToString());
            double tongmoi = tong + Convert.ToDouble(txtThanh_tien.Text);

            sql = "UPDATE tblHDN SET Thanh_tien =" + tongmoi + "WHERE Ma_HDN=N'" + txtMahoadon.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
            //
            double sl = Convert.ToDouble(ThucthiSQL.DocBang("SELECT So_luong FROM dboMay_vi_tinh WHERE Ma_mayVT=N'" +
                                                            cboMamayvitinh.Text + "'").Rows[0][0].ToString());
            double slmoi = sl + Convert.ToDouble(txtSo_luong.Text);

            sql = "UPDATE dboMay_vi_tinh SET So_luong=" + slmoi + "WHERE Ma_mayVT=N'" + cboMamayvitinh.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
        }
Exemplo n.º 10
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtTenHH.Text == "")
            {
                MessageBox.Show("Bạn phải nhập tên hàng hóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenHH.Focus();
                return;
            }
            if (txtDongianhap.Text == "")
            {
                MessageBox.Show("Bạn phải nhập đơn giá nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDongianhap.Focus();
                return;
            }
            if (txtDongiaban.Text == "")
            {
                MessageBox.Show("Bạn phải nhập đơn giá bán", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDongiaban.Focus();
                return;
            }
            if (txtSoluong.Text == "")
            {
                MessageBox.Show("Bạn phải nhập số lượng tồn kho", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSoluong.Focus();
                return;
            }
            sql  = "select * from tblHang where Mahang = N'" + txtMaHH.Text + "'";
            tblH = ThucthiSQL.DocBang(sql);
            if (tblH.Rows.Count == 0)
            {
                sql = "INSERT INTO tblHang(Mahang, Tenhang, Dongiaban, Dongianhap, Soluongtonkho, Xuatxu, Anh, Ghichu) Values (N'" + txtMaHH.Text +
                      "',N'" + txtTenHH.Text + "',N'" + txtDongiaban.Text + "',N'" + txtDongianhap.Text + "',N'" + txtSoluong.Text + "',N'" + txtXuatxu.Text + "',N'" + txtAnh.Text + "',N'" + txtGhichu.Text + "')";
            }
            else
            {
                sql = "UPDATE tblHang SET Tenhang = N'" + txtTenHH.Text + "', Dongiaban = N'" + txtDongiaban.Text + "', Dongianhap = N'" + txtDongianhap.Text + "', Soluongtonkho = N'" + txtSoluong.Text + "', Xuatxu = N'" + txtXuatxu.Text + "', Anh = N'" + txtAnh.Text + "', Ghichu = N'" + txtGhichu.Text + "' where Mahang = N'" + txtMaHH.Text + "'";
            }

            ThucthiSQL.CapNhatDuLieu(sql);
            btnThem.Enabled = true;
            btnLuu.Enabled  = false;
            btnHuy.Enabled  = false;
            btnXoa.Enabled  = false;
            ResetValues();
            grbThongtinhang.Enabled = false;
            sql  = "SELECT * FROM tblHang";
            tblH = ThucthiSQL.DocBang(sql);
            dataGridView.DataSource = tblH;
            Hienthi_Luoi();
        }
Exemplo n.º 11
0
        private void btnThemhang_Click(object sender, EventArgs e)
        {
            if (cboMahang.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cboMahang.Focus();
                return;
            }
            if (txtSoluong.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập số lượng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSoluong.Text = "";
                txtSoluong.Focus();
                return;
            }
            if (txtGiamgia.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập giảm giá", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtGiamgia.Focus();
                return;
            }
            string sql = "SELECT * FROM tblChitietHDB WHERE Mahang=N'" + cboMahang.Text + "' AND MaHDB=N'" + txtMahoadon.Text + "'";

            if (ThucthiSQL.DocBang(sql).Rows.Count > 0)
            {
                MessageBox.Show("Mã sách này đã có, bạn phải nhập mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ResetValuesHang();
                cboMahang.Focus();
                return;
            }
            sql = "INSERT INTO tblChitietHDB(MaHDB, Mahang, Soluong, Giaban, Giamgia, Thanhtien) VALUES(N'" +
                  txtMahoadon.Text + "',N'" + cboMahang.Text + "', " + txtSoluong.Text +
                  "," + txtDongia.Text + "," + txtGiamgia.Text + "," + txtThanhtien.Text + ")";
            ThucthiSQL.CapNhatDuLieu(sql);
            Hienthi_Luoi();
            double tong = Convert.ToDouble(ThucthiSQL.DocBang("select Tongtien from tblHoadonban where MaHDB=N'" +
                                                              txtMahoadon.Text + "'").Rows[0][0].ToString());
            double tongmoi = tong + Convert.ToDouble(txtThanhtien.Text);

            sql = "update tblHoadonban set Tongtien=" + tongmoi + "where MaHDB=N'" + txtMahoadon.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
            txtTongtien.Text = tongmoi.ToString();
            lblBangchu.Text  = "Bằng chữ:" + ThucthiSQL.ChuyenSoSangChu(tongmoi.ToString());
            double sl    = Convert.ToDouble(ThucthiSQL.DocBang("select Soluongtonkho from tblHang where Mahang=N'" + cboMahang.Text + "'").Rows[0][0].ToString());
            double slmoi = sl - Convert.ToDouble(txtSoluong.Text);

            sql = "update tblHang set Soluongtonkho=" + slmoi + " where Mahang=N'" + cboMahang.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
            ResetValuesHang();
            btnHuy.Enabled = true;
        }
Exemplo n.º 12
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtTenKH.Text == "")
            {
                MessageBox.Show("Bạn phải nhập tên khách hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenKH.Focus();
                return;
            }
            if (txtDiachi.Text == "")
            {
                MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDiachi.Focus();
                return;
            }
            if (txtSDT.Text == "")
            {
                MessageBox.Show("Bạn phải nhập số điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSDT.Focus();
                return;
            }
            sql   = "select * from tblKhachhang where MaKH = N'" + txtMaKH.Text + "'";
            tblKH = ThucthiSQL.DocBang(sql);
            if (tblKH.Rows.Count == 0)
            {
                sql = "INSERT INTO tblKhachhang(MaKH, TenKH, Diachi, SDT) Values (N'" + txtMaKH.Text +
                      "',N'" + txtTenKH.Text + "',N'" + txtDiachi.Text + "',N'" + txtSDT.Text + "')";
            }
            else
            {
                sql = "UPDATE tblKhachhang SET TenKH = N'" + txtTenKH.Text + "', Diachi = N'" + txtDiachi.Text + "', SDT = N'" + txtSDT.Text + "' WHERE MaKH = N'" + txtMaKH.Text + "'";
            }

            ThucthiSQL.CapNhatDuLieu(sql);
            btnThem.Enabled = true;
            btnLuu.Enabled  = false;
            btnHuy.Enabled  = false;
            btnXoa.Enabled  = false;
            ResetValues();
            sql   = "SELECT * FROM tblKhachhang";
            tblKH = ThucthiSQL.DocBang(sql);
            dataGridView.DataSource = tblKH;
            Hienthi_Luoi();
            grbKhachhang.Enabled = false;
        }
Exemplo n.º 13
0
        private void DelUpdateHang(string mahang, double slxoa, double gianhapxoa)
        {
            double sl = Convert.ToDouble(ThucthiSQL.DocBang("select Soluongtonkho from tblHang where Mahang=N'" +
                                                            mahang + "'").Rows[0][0].ToString());
            double slmoi = sl - slxoa;
            string sql   = "update tblHang set Soluongtonkho=" + slmoi + "where Mahang=N'" + mahang + "'";

            ThucthiSQL.CapNhatDuLieu(sql);
            double dgn    = Convert.ToDouble(ThucthiSQL.DocBang("select Dongianhap from tblHang where Mahang=N'" + mahang + "'").Rows[0][0].ToString());
            double dgnmoi = (sl * dgn - slxoa * gianhapxoa) / slmoi;

            sql = "update tblHang set Dongianhap=" + dgnmoi + "where Mahang = N'" + cboMahang.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
            double dgbmoi = dgnmoi + dgnmoi * 0.2;

            sql = "update tblHang set Dongiaban=" + dgbmoi + "where Mahang = N'" + cboMahang.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
        }
Exemplo n.º 14
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            string sql;

            if (DataGridView.Rows.Count == 0)
            {
                MessageBox.Show("Không có dữ liệu để xóa", "Thông báo");
                return;
            }
            string ma = DataGridView.CurrentRow.Cells["Ma_mayVT"].Value.ToString();

            if (MessageBox.Show("Bạn có muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                sql = "DELETE dboMay_vi_tinh WHERE Ma_mayVT=N'" + ma + "'";
                ThucthiSQL.CapNhatDuLieu(sql);
                Hienthi_Luoi();
            }
        }
Exemplo n.º 15
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            string sql;

            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 tblKhachhang WHERE MaKH=N'" + txtMaKH.Text + "'";
                ThucthiSQL.CapNhatDuLieu(sql);
                sql   = "SELECT * FROM tblKhachhang";
                tblKH = ThucthiSQL.DocBang(sql);
                dataGridView.DataSource = tblKH;
                Hienthi_Luoi();
                ResetValues();
                grbKhachhang.Enabled = false;
                btnHuy.Enabled       = false;
                btnLuu.Enabled       = false;
            }
        }
Exemplo n.º 16
0
        private void chkThanhtoan_CheckedChanged(object sender, EventArgs e)
        {
            string sql, trangthai;

            if (chkThanhtoan.Checked == true)
            {
                trangthai = "Da thanh toan";
                sql       = "UPDATE tblHoadonnhap SET Trangthai = N'" + trangthai + "' where MaHDN = N'" + txtMahoadon.Text + "'";
                ThucthiSQL.CapNhatDuLieu(sql);
                btnIn.Enabled = true;
            }
            else
            {
                trangthai = "Chua thanh toan";
                sql       = "UPDATE tblHoadonnhap SET Trangthai = N'" + trangthai + "' where MaHDN = N'" + txtMahoadon.Text + "'";
                ThucthiSQL.CapNhatDuLieu(sql);
                btnIn.Enabled = false;
            }
        }
Exemplo n.º 17
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql = "SELECT * FROM tblNCC where MaNCC = N'" + txtMaNCC.Text + "'";

            if (txtTenNCC.Text == "")
            {
                MessageBox.Show("Bạn phải nhập tên nhà cung cấp", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenNCC.Focus();
                return;
            }
            if (txtDiachi.Text == "")
            {
                MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDiachi.Focus();
                return;
            }
            if (txtSDT.Text == "")
            {
                MessageBox.Show("Bạn phải nhập số điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSDT.Focus();
                return;
            }
            tblNCC = ThucthiSQL.DocBang(sql);
            if (tblNCC.Rows.Count == 0)
            {
                sql = "INSERT INTO tblNCC(MaNCC, TenNCC, Diachi, SDT) Values (N'" + txtMaNCC.Text +
                      "',N'" + txtTenNCC.Text + "',N'" + txtDiachi.Text + "',N'" + txtSDT.Text + "')";
            }
            else
            {
                sql = "UPDATE tblNCC SET TenNCC = N'" + txtTenNCC.Text + "', Diachi = N'" + txtDiachi.Text + "', SDT = N'" + txtSDT.Text + "' where MaNCC = N'" + txtMaNCC.Text + "'";
            }
            ThucthiSQL.CapNhatDuLieu(sql);
            btnThem.Enabled = true;
            btnLuu.Enabled  = false;
            btnHuy.Enabled  = false;
            btnXoa.Enabled  = false;
            ResetValues();
            sql    = "SELECT * FROM tblNCC";
            tblNCC = ThucthiSQL.DocBang(sql);
            dataGridView.DataSource = tblNCC;
            Hienthi_Luoi();
        }
Exemplo n.º 18
0
 private void btnHuy_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc muốn hủy hóa đơn không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         string    sql = "SELECT Ma_HDB, So_luong, Ma_mayVT FROM tblChitietHDB WHERE Ma_HDB = N'" + txtMa_HDB.Text + "'";
         DataTable tbl = ThucthiSQL.DocBang(sql);
         sql = "DELETE tblHDB WHERE Ma_HDB = N'" + txtMa_HDB.Text + "'";
         ThucthiSQL.CapNhatDuLieu(sql);
         ResetValues();
         Hienthi_Luoi();
         // cập nhật lại số lượng máy tính
         for (int i = 0; i < tbl.Rows.Count; i++)
         {
             DelUpdateSo_luongMVT(tbl.Rows[i][0].ToString(),
                                  Convert.ToDouble(tbl.Rows[0][1]),
                                  Convert.ToDouble(tbl.Rows[0][2]));
         }
         btnHuy.Enabled = false;
     }
 }
Exemplo n.º 19
0
 private void btnHuy_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc chắn muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         string    sql = "select Mahang, Soluong, Gianhap from tblchitietHDN where MaHDN=N'" + txtMahoadon.Text + "'";
         DataTable tbl = ThucthiSQL.DocBang(sql);
         sql = "delete tblHoadonnhap where MaHDN=N'" + txtMahoadon.Text + "'";
         ThucthiSQL.CapNhatDuLieu(sql);
         ResetValues();
         Hienthi_Luoi();
         for (int i = 0; i < tbl.Rows.Count; i++)
         {
             DelUpdateHang(tbl.Rows[0][0].ToString(), Convert.ToDouble(tbl.Rows[i][1].ToString()), Convert.ToDouble(tbl.Rows[i][2].ToString()));
         }
         btnHuy.Enabled           = false;
         btnIn.Enabled            = false;
         grbThongtinphieu.Enabled = false;
         grbChitiet.Enabled       = false;
     }
 }
Exemplo n.º 20
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (txtMaCV.Text == "")
            {
                MessageBox.Show("Bạn phải nhập mã chức vụ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaCV.Focus();
                return;
            }
            if (txtTenCV.Text == "")
            {
                MessageBox.Show("Bạn phải nhập tên chức vụ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenCV.Focus();
                return;
            }
            sql   = "select * from tblChucVu where MaCV = N'" + txtMaCV.Text + "'";
            tblCV = ThucthiSQL.DocBang(sql);
            if (tblCV.Rows.Count == 0)
            {
                sql = "INSERT INTO tblChucvu(MaCV, TenCV) Values (N'" + txtMaCV.Text + "',N'" + txtTenCV.Text + "')";
            }
            else
            {
                sql = "UPDATE tblChucvu set TenCV = N'" + txtTenCV.Text + "' where MaCV = N'" + txtMaCV.Text + "'";
            }
            ThucthiSQL.CapNhatDuLieu(sql);
            btnThem.Enabled = true;
            btnLuu.Enabled  = false;
            btnHuy.Enabled  = false;
            btnXoa.Enabled  = false;
            ResetValues();
            sql   = "SELECT * FROM tblChucvu";
            tblCV = ThucthiSQL.DocBang(sql);
            dataGridView.DataSource = tblCV;
            Hienthi_Luoi();
            grbChucvu.Enabled = false;
        }
Exemplo n.º 21
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;
            string gt = "Nam";

            if (cboMaCV.Text == "")
            {
                MessageBox.Show("Bạn phải chọn mã chức vụ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                cboMaCV.Focus();
                return;
            }
            if (txtTennhanvien.Text == "")
            {
                MessageBox.Show("Bạn phải nhập tên nhân viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTennhanvien.Focus();
                return;
            }
            if (txtSDT.Text == "")
            {
                MessageBox.Show("Bạn phải nhập số điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSDT.Focus();
                return;
            }
            if (txtDiachi.Text == "")
            {
                MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDiachi.Focus();
                return;
            }
            if (rdoNam.Checked == false && rdoNu.Checked == false)
            {
                MessageBox.Show("Bạn phải chọn giới tính", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (rdoNu.Checked == true)
            {
                gt = "Nữ";
            }
            sql   = "select * from tblNhanvien where MaNV = N'" + txtManhanvien.Text + "'";
            tblNV = ThucthiSQL.DocBang(sql);
            if (tblNV.Rows.Count == 0)
            {
                sql = "INSERT INTO tblNhanvien(MaNV, TenNV, Gioitinh, Ngaysinh, CMT, MaCV, Diachi, SDT) Values (N'" + txtManhanvien.Text +
                      "',N'" + txtTennhanvien.Text + "',N'" + gt + "',N'" + dtpNgaysinh.Text + "'," + txtCMT.Text + ",N'" + cboMaCV.Text + "',N'" + txtDiachi.Text + "',N'" + txtSDT.Text + "')";
            }
            else
            {
                sql = "UPDATE tblNhanvien SET TenNV = N'" + txtTennhanvien.Text + "', Gioitinh = N'" + gt + "', Ngaysinh = N'" + dtpNgaysinh.Text + "', CMT = " + txtCMT.Text + ", MaCV = N'" + cboMaCV.Text + "', Diachi = N'" + txtDiachi.Text + "', SDT = N'" + txtSDT.Text + "' WHERE MaNV = N'" + txtManhanvien.Text + "'";
            }

            ThucthiSQL.CapNhatDuLieu(sql);
            btnThem.Enabled = true;
            btnLuu.Enabled  = false;
            btnHuy.Enabled  = false;
            btnXoa.Enabled  = false;
            ResetValues();
            grbNhanvien.Enabled = false;
            sql   = "SELECT * FROM tblNhanvien";
            tblNV = ThucthiSQL.DocBang(sql);
            dataGridView.DataSource = tblNV;
            Hienthi_Luoi();
        }