private void btnSua_Click(object sender, EventArgs e) { string sql1; sql1 = "SELECT * FROM HOA_DON_BAN"; HOA_DON_BAN = DAO.GetDataToTable(sql1); string sql; if (HOA_DON_BAN.Rows.Count == 0) { MessageBox.Show("Không còn dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { if (txtsoHDB.Text == "") { MessageBox.Show("Bạn chưa chọn bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtNgayban.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập ngày bán", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtNgayban.Focus(); return; } if (txtMaNV.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã nhân viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMaNV.Focus(); return; } if (txtMakhach.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã khách", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMakhach.Focus(); return; } if (txtTongtien.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập tổng tiền", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTongtien.Focus(); return; } } sql = "UPDATE HOA_DON_BAN SET NGAYBAN=N'" + txtNgayban.Text.ToString() + "',MANV=N'" + txtMaNV.Text.ToString() + "',MAKHACH=N'" + txtMakhach.Text.ToString() + "',TONGTIEN=N'" + txtTongtien.Text.ToString() + "' WHERE SOHDB=N'" + txtsoHDB.Text + "'"; DAO.RunSQL(sql); hienthi(); ResetValues(); btnBoqua.Enabled = false; }
private void txtDongia_TextChanged(object sender, EventArgs e) { double dg = Convert.ToDouble(DAO.Docbang("SELECT DONGIANHAP FROM DM_HANG_HOA WHERE MAVACH = N'" + txtMavach.Text + "'").Rows[0][0].ToString()); double gnmoi = dg + Convert.ToDouble(txtDongia.Text); string sql; sql = "UPDATE DM_HANG_HOA SET DONGIANHAP=" + gnmoi + "WHERE MAVACH = N'" + txtMavach.Text + "'"; DAO.RunSQL(sql); }
private void btnLuu_Click(object sender, EventArgs e) { string sql; if (txtMakhach.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã khách", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMakhach.Focus(); return; } if (txtTenkhach.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập tên khách", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTenkhach.Focus(); return; } if (txtDiachi.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTenkhach.Focus(); return; } if (mtbDienthoai.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTenkhach.Focus(); return; } sql = "SELECT MAKHACH FROM KHACH_HANG WHERE MAKHACH =N'" + txtMakhach.Text.Trim() + "'"; if (DAO.CheckKey(sql)) { MessageBox.Show("Mã khách này đã có, bạn phải nhập mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMakhach.Focus(); txtMakhach.Text = ""; return; } sql = "INSERT INTO KHACH_HANG(MAKHACH,TENKHACH,DIACHI,DIENTHOAI) VALUES(N'" + txtMakhach.Text + "',N'" + txtTenkhach.Text + "',N'" + txtDiachi.Text + "',N'" + mtbDienthoai.Text + "')"; DAO.RunSQL(sql); hienthi(); ResetValues(); btnXoa.Enabled = true; btnThem.Enabled = true; btnSua.Enabled = true; btnBoqua.Enabled = false; btnLuu.Enabled = false; txtMakhach.Enabled = false; }
private void btnLuu_Click(object sender, EventArgs e) { string sql; if (txtMaNCC.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã nhà cung cấp ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMaNCC.Focus(); return; } if (txtTenNCC.Text.Trim().Length == 0) { 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.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTenNCC.Focus(); return; } if (txtDienThoai.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTenNCC.Focus(); return; } sql = "SELECT MANCC FROM NHA_CUNG_CAP WHERE MANCC =N'" + txtMaNCC.Text.Trim() + "'"; if (DAO.CheckKey(sql)) { MessageBox.Show("Mã nhà cung cấp này đã có, bạn phải nhập mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMaNCC.Focus(); txtMaNCC.Text = ""; return; } sql = "INSERT INTO NHA_CUNG_CAP(MANCC,TENNCC,DIACHI,DIENTHOAI) VALUES(N'" + txtMaNCC.Text + "',N'" + txtTenNCC.Text + "',N'" + txtDiachi.Text + "',N'" + txtDienThoai.Text + "')"; DAO.RunSQL(sql); hienthi(); ResetValues(); btnXoa.Enabled = true; btnThem.Enabled = true; btnSua.Enabled = true; btnTimkiem.Enabled = false; btnLuu.Enabled = false; txtMaNCC.Enabled = false; }
private void btnSua_Click(object sender, EventArgs e) { string sql1; sql1 = "SELECT * FROM NHAN_VIEN"; NHAN_VIEN = DAO.GetDataToTable(sql1); string sql; if (NHAN_VIEN.Rows.Count == 0) { MessageBox.Show("Không còn dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { if (txtManhanvien.Text == "") { MessageBox.Show("Bạn chưa chọn bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtTennhanvien.Text.Trim().Length == 0) { 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 (txtDiachi.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTennhanvien.Focus(); return; } if (mtbDienthoai.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTennhanvien.Focus(); return; } } sql = "UPDATE NHANVIEN SET TENNHANVIEN=N'" + txtTennhanvien.Text.ToString() + "',DIACHI=N'" + txtDiachi.Text.ToString() + "',DIENTHOAI=N'" + mtbDienthoai.Text.ToString() + "',MANHOM=N'" + txtManhom.Text.ToString() + "' WHERE MANV=N'" + txtManhanvien.Text + "'"; DAO.RunSQL(sql); hienthi(); ResetValues(); btnBoqua.Enabled = false; }
private void btnSua_Click(object sender, EventArgs e) { string sql1; sql1 = "SELECT * FROM NHA_CUNG_CAP"; NHA_CUNG_CAP = DAO.GetDataToTable(sql1); string sql; if (NHA_CUNG_CAP.Rows.Count == 0) { MessageBox.Show("Không còn dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { if (txtMaNCC.Text == "") { MessageBox.Show("Bạn chưa chọn bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtTenNCC.Text.Trim().Length == 0) { 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.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTenNCC.Focus(); return; } if (txtDienThoai.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTenNCC.Focus(); return; } } sql = "UPDATE NHA_CUNG_CAP SET TENNCC=N'" + txtTenNCC.Text.ToString() + "',DIACHI=N'" + txtDiachi.Text.ToString() + "',DIENTHOAI=N'" + txtDienThoai.Text.ToString() + "' WHERE MANCC=N'" + txtMaNCC.Text + "'"; DAO.RunSQL(sql); hienthi(); ResetValues(); btnTimkiem.Enabled = false; }
private void btnLuu_Click(object sender, EventArgs e) { string sql; if (txtManhom.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã nhóm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtManhom.Focus(); return; } if (txtTennhom.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập tên nhóm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTennhom.Focus(); return; } sql = "SELECT MANHOM FROM NHOM_HANG WHERE MANHOM =N'" + txtManhom.Text.Trim() + "'"; if (DAO.CheckKey(sql)) { MessageBox.Show("Mã nhóm này đã có, bạn phải nhập mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtManhom.Focus(); txtManhom.Text = ""; return; } sql = "INSERT INTO NHOM_HANG(MANHOM,TENNHOM) VALUES(N'" + txtManhom.Text + "',N'" + txtTennhom.Text + "')"; DAO.RunSQL(sql); hienthi(); ResetValue(); btnXoa.Enabled = true; btnThem.Enabled = true; btnSua.Enabled = true; btnBoqua.Enabled = false; btnLuu.Enabled = false; txtManhom.Enabled = false; }
private void btnLuu_Click(object sender, EventArgs e) { string sql; if (txtMacongdung.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã công dụng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMacongdung.Focus(); return; } if (txtTencongdung.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập tên công dụng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTencongdung.Focus(); return; } sql = "SELECT MACONGDUNG FROM CONG_DUNG WHERE MACONGDUNG =N'" + txtMacongdung.Text.Trim() + "'"; if (DAO.CheckKey(sql)) { MessageBox.Show("Mã chất liệu này đã có, bạn phải nhập mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMacongdung.Focus(); txtMacongdung.Text = ""; return; } sql = "INSERT INTO CONG_DUNG(MACONGDUNG,TENCONGDUNG) VALUES(N'" + txtMacongdung.Text + "',N'" + txtTencongdung.Text + "')"; DAO.RunSQL(sql); hienthi(); ResetValue(); btnXoa.Enabled = true; btnThem.Enabled = true; btnSua.Enabled = true; btnBoqua.Enabled = false; btnLuu.Enabled = false; txtMacongdung.Enabled = false; }
private void btnSua_Click(object sender, EventArgs e) { string sql1; sql1 = "SELECT * FROM NHOM_HANG"; NHOM_HANG = DAO.GetDataToTable(sql1); string sql; if (NHOM_HANG.Rows.Count == 0) { MessageBox.Show("Không còn dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { if (txtManhom.Text == "") { MessageBox.Show("Bạn chưa chọn bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtTennhom.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập tên nhóm", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTennhom.Focus(); return; } } sql = "UPDATE NHOM_HANG SET TENNHOM=N'" + txtTennhom.Text.ToString() + "' WHERE MANHOM=N'" + txtManhom.Text + "'"; DAO.RunSQL(sql); hienthi(); ResetValue(); btnBoqua.Enabled = false; }
private void btnLuu_Click(object sender, EventArgs e) { string sql; if (txtsoHDB.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập số HDN", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtsoHDB.Focus(); return; } if (txtNgayban.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập ngày bán", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtNgayban.Focus(); return; } if (txtMaNV.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã nhân viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMaNV.Focus(); return; } if (txtMakhach.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã khách", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMakhach.Focus(); return; } if (txtTongtien.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập tổng tiền", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTongtien.Focus(); return; } sql = "SELECT SOHDB FROM HOA_DON_BAN WHERE SOHDB =N'" + txtsoHDB.Text.Trim() + "'"; if (DAO.CheckKey(sql)) { MessageBox.Show("số HDN này đã có, bạn phải nhập số HDB khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtsoHDB.Focus(); txtsoHDB.Text = ""; return; } sql = "INSERT INTO HOA_DON_BAN(SOHDB,NGAYBAN,MANV,MAKHACH,TONGTIEN) VALUES(N'" + txtsoHDB.Text + "',N'" + txtNgayban.Text + "',N'" + txtMaNV.Text + "',N'" + txtMakhach.Text + "',N'" + txtTongtien.Text + "')"; DAO.RunSQL(sql); hienthi(); ResetValues(); btnXoa.Enabled = true; btnThem.Enabled = true; btnSua.Enabled = true; btnBoqua.Enabled = false; btnLuu.Enabled = false; txtsoHDB.Enabled = false; }
private void btnLuu_Click(object sender, EventArgs e) { string sql; if (txtManhanvien.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã nhân viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtManhanvien.Focus(); return; } if (txtTennhanvien.Text.Trim().Length == 0) { 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 (txtDiachi.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập địa chỉ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTennhanvien.Focus(); return; } if (mtbDienthoai.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập điện thoại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTennhanvien.Focus(); return; } if (mskNgaysinh.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập ngày sinh", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTennhanvien.Focus(); return; } sql = "SELECT MANV FROM NHAN_VIEN WHERE MANV =N'" + txtManhanvien.Text.Trim() + "'"; if (DAO.CheckKey(sql)) { MessageBox.Show("Mã nhân viên này đã có, bạn phải nhập mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtManhanvien.Focus(); txtManhanvien.Text = ""; return; } sql = "INSERT INTO NHAN_VIEN(MANV,TENNHANVIEN,GIOITINH,NGAYSINH,DIENTHOAI,DIACHI,MANHOM) VALUES(N'" + txtManhanvien.Text + "',N'" + txtTennhanvien.Text + "',N'" + txtGioitinh.Text + "',N'" + mskNgaysinh.Text + "',N'" + mtbDienthoai.Text + "',N'" + txtDiachi.Text + "',N'" + txtManhom.Text + "')"; DAO.RunSQL(sql); hienthi(); ResetValues(); btnXoa.Enabled = true; btnThem.Enabled = true; btnSua.Enabled = true; btnBoqua.Enabled = false; btnLuu.Enabled = false; txtManhanvien.Enabled = false; }
private void btnLuu_Click(object sender, EventArgs e) { string sql; if (txtsoHDB.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập số HDB", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtsoHDB.Focus(); return; } if (txtMavach.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã vạch", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMavach.Focus(); return; } if (txtSoluong.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập số lượng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSoluong.Focus(); return; } if (txtDongia.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập đơn giá", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtDongia.Focus(); return; } if (txtGiamgia.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập giảm giá", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtGiamgia.Focus(); return; } if (txtThanhtien.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập thành tiền", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtThanhtien.Focus(); return; } sql = "SELECT SOHDB FROM CHI_TIET_HD_BAN WHERE SOHDB =N'" + txtsoHDB.Text.Trim() + "'"; if (DAO.CheckKey(sql)) { MessageBox.Show("số HDB này đã có, bạn phải nhập số HDN khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtsoHDB.Focus(); txtsoHDB.Text = ""; return; } sql = "INSERT INTO CHI_TIET_HD_BAN(SOHDB,MAVACH,SOLUONGBAN,DONGIA,GIAMGIA,THANHTIEN) VALUES(N'" + txtsoHDB.Text + "',N'" + txtMavach.Text + "',N'" + txtSoluong.Text + "',N'" + txtDongia.Text + "',N'" + txtGiamgia.Text + "',N'" + txtThanhtien.Text + "')"; DAO.RunSQL(sql); hienthi(); ResetValues(); btnXoa.Enabled = true; btnThem.Enabled = true; btnSua.Enabled = true; btnBoqua.Enabled = false; btnLuu.Enabled = false; txtsoHDB.Enabled = false; }
private void btnSua_Click(object sender, EventArgs e) { string sql1; sql1 = "SELECT * FROM CHI_TIET_HD_NHAP"; CHI_TIET_HD_BAN = DAO.GetDataToTable(sql1); string sql; if (CHI_TIET_HD_BAN.Rows.Count == 0) { MessageBox.Show("Không còn dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { if (txtsoHDB.Text == "") { MessageBox.Show("Bạn chưa chọn bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtMavach.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã vạch", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMavach.Focus(); return; } if (txtSoluong.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập số lượng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSoluong.Focus(); return; } if (txtDongia.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập đơn giá", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtDongia.Focus(); return; } if (txtGiamgia.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập giảm giá", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtGiamgia.Focus(); return; } if (txtThanhtien.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập thành tiền", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtThanhtien.Focus(); return; } sql = "UPDATE CHI_TIET_HD_BAN SET MAVACH=N'" + txtMavach.Text.ToString() + "',SOLUONGBAN=N'" + txtSoluong.Text.ToString() + "',DONGIA=N'" + txtDongia.Text.ToString() + "',GIAMGIA=N'" + txtGiamgia.Text.ToString() + "',THANHTIEN=N'" + txtThanhtien.Text.ToString() + "' WHERE SOHDB=N'" + txtsoHDB.Text + "'"; DAO.RunSQL(sql); hienthi(); ResetValues(); btnBoqua.Enabled = false; } }
private void btnLuu_Click(object sender, EventArgs e) { string sql; if (txtMavach.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã vạch", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMavach.Focus(); return; } if (txtTenhang.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập tên hàng hóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTenhang.Focus(); return; } if (txtMachatlieu.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã chất liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMachatlieu.Focus(); return; } if (txtSoluong.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập số lượng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSoluong.Focus(); return; } if (txtDongianhap.Text.Trim().Length == 0) { 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.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập đơn giá bán", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtDongiaban.Focus(); return; } sql = "SELECT MAVACH FROM DM_HANG_HOA WHERE MAVACH =N'" + txtMavach.Text.Trim() + "'"; if (DAO.CheckKey(sql)) { MessageBox.Show("Mã hàng hóa này đã có, bạn phải nhập mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMavach.Focus(); txtMavach.Text = ""; return; } sql = "INSERT INTO DM_HANG_HOA(MAVACH,TENHANGHOA,MANHOM,MACHATLIEU,MACONGDUNG,SOLUONG,DONGIANHAP,DONGIABAN,ANH,GHICHU) VALUES(N'" + txtMavach.Text + "',N'" + txtTenhang.Text + "',N'" + txtManhom.Text + "',N'" + txtMachatlieu.Text + "',N'" + txtMacongdung.Text + "',N'" + txtSoluong.Text + "',N'" + txtDongianhap.Text + "',N'" + txtDongiaban.Text + "',N'" + txtAnh.Text + "',N'" + txtGhichu.Text + "')"; DAO.RunSQL(sql); hienthi(); ResetValues(); btnXoa.Enabled = true; btnThem.Enabled = true; btnSua.Enabled = true; btnBoqua.Enabled = false; btnLuu.Enabled = false; txtMavach.Enabled = false; txtMachatlieu.Enabled = false; }
private void btnSua_Click(object sender, EventArgs e) { string sql1; sql1 = "SELECT * FROM DM_HANG_HOA"; DM_HANG_HOA = DAO.GetDataToTable(sql1); string sql; if (DM_HANG_HOA.Rows.Count == 0) { MessageBox.Show("Không còn dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { if (txtMavach.Text == "") { MessageBox.Show("Bạn chưa chọn bản ghi nào", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (txtTenhang.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập tên hàng hóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtTenhang.Focus(); return; } if (txtMachatlieu.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã chất liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMachatlieu.Focus(); return; } if (txtSoluong.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập số lượng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSoluong.Focus(); return; } if (txtDongianhap.Text.Trim().Length == 0) { 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.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập đơn giá bán", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtDongiaban.Focus(); return; } } sql = "UPDATE DM_HANG_HOA SET TENHANG=N'" + txtTenhang.Text.ToString() + "' WHERE MAVACH=N'" + txtMavach.Text + "'"; DAO.RunSQL(sql); hienthi(); ResetValues(); btnBoqua.Enabled = false; }
private void btnLuu_Click(object sender, EventArgs e) { string sql; double sl, SLcon; sql = "SELECT SOHDN FROM HOA_DON_NHAP WHERE SOHDN=N'" + txtsoHDN.Text + "'"; if (DAO.CheckKey(sql)) { if (txtsoHDN.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập số HDN", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtsoHDN.Focus(); return; } if (txtMavach.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập mã vạch", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMavach.Focus(); return; } if (txtSoluong.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập số lượng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSoluong.Focus(); return; } if (txtDongia.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập đơn giá", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtDongia.Focus(); return; } if (txtGiamgia.Text.Trim().Length == 0) { MessageBox.Show("Bạn phải nhập giảm giá", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtGiamgia.Focus(); return; } sql = "SELECT SOHDN FROM CHI_TIET_HD_NHAP WHERE SOHDN =N'" + txtsoHDN.Text.Trim() + "'"; if (DAO.CheckKey(sql)) { MessageBox.Show("số HDN này đã có, bạn phải nhập số HDN khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtsoHDN.Focus(); txtsoHDN.Text = ""; return; } sql = "INSERT INTO CHI_TIET_HD_NHAP(SOHDN,MAVACH,SOLUONG,DONGIA,GIAMGIA,THANHTIEN) VALUES(N'" + txtsoHDN.Text + "',N'" + txtMavach.Text + "',N'" + txtSoluong.Text + "',N'" + txtDongia.Text + "',N'" + txtGiamgia.Text + "',N'" + txtThanhtien.Text + "')"; DAO.RunSQL(sql); } // Câu 1: Cập nhật lại số lượng của mặt hàng vào bảng DM_HANG_HOA sl = Convert.ToDouble(DAO.GetFieldValues("SELECT SOLUONG FROM DM_HANG_HOA WHERE MAVACH = N'" + txtMavach.Text + "'")); SLcon = sl + Convert.ToDouble(txtSoluong.Text); sql = "UPDATE DM_HANG_HOA SET SOLUONG =" + SLcon + " WHERE MAVACH= N'" + txtMavach.Text + "'"; DAO.RunSQL(sql); ResetValues(); btnXoa.Enabled = true; btnSua.Enabled = true; btnBoqua.Enabled = false; btnLuu.Enabled = false; txtsoHDN.Enabled = false; }