private void btnThem_Click(object sender, EventArgs e) { DialogResult dlr = MessageBox.Show("Bạn có chắc muốn thêm phiếu đặt hàng mới?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dlr == DialogResult.Yes) { txtMaPhieu.Text = PHIEUDATHANGDAO.KiemTraMaPDHTuDongTang(dsPDH, PHIEUDATHANGDAO.MaPDHTuDong(dsPDH)); dateNgayLap.Enabled = true; btnThem.Enabled = false; btnLuu.Enabled = true; btnXoa.Enabled = false; } }
private void btnLuu_Click(object sender, EventArgs e) { DialogResult dlr = MessageBox.Show("Bạn có chắc muốn lưu phiếu đặt hàng này?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dlr == DialogResult.Yes) { String sql = "set dateformat dmy insert into phieudathang values ('" + txtMaPhieu.Text.Trim() + "', '" + dateNgayLap.Text.Trim() + "', '" + DangNhap.MaNV + "', 0)"; cn.themxoasua(sql); PHIEUDATHANGDAO.ThemPDH(dsPDH, txtMaPhieu.Text.Trim(), dateNgayLap.Text.Trim(), DangNhap.MaNV); dgvPDH.Rows.Add(txtMaPhieu.Text.Trim(), dateNgayLap.Text.Trim(), DangNhap.MaNV); cbboxMaPhieu.Items.Add(txtMaPhieu.Text.Trim()); MessageBox.Show("Lưu phiếu đặt hàng thành công"); } }
private void btnXoa_Click(object sender, EventArgs e) { if (kttontaidulieu()) { DialogResult dlr = MessageBox.Show("Bạn có chắc muốn xóa phiếu đặt hàng này?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dlr == DialogResult.Yes) { String sql = "delete from phieudathang where sophieu = '" + txtMaPhieu.Text.Trim() + "'"; cn.themxoasua(sql); PHIEUDATHANGDAO.XoaPDH(dsPDH, txtMaPhieu.Text.Trim()); dgvPDH.Rows.RemoveAt(indexPDH); cbboxMaPhieu.Items.Remove(txtMaPhieu.Text.Trim()); MessageBox.Show("Xóa phiếu đặt hàng thành công"); } } }