void ThucThi_TaoHD() { try { string mahd = txtMaHD.EditValue.ToString(); string makh; string manv = txtMaNV_HD.EditValue.ToString(); DateTime ngaylap = dateNgayLap.Value; // kt xem textbox có bị bỏ trống không if (mahd != string.Empty && cboMaKH_HD.SelectedIndex != -1 && manv != string.Empty && txtMaNV_HD.EditValue.ToString() != string.Empty) { DialogResult result; result = MessageBox.Show("Bạn Có Muốn Tạo Hóa Đơn " + mahd + "?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { if (BatLoi_NgayLap_HD(ngaylap) == true) { // thêm nhân viên if (hd_bll.KiemTraTrung_HD(txtMaHD.EditValue.ToString()) == true) { makh = cboMaKH_HD.SelectedValue.ToString(); hd_bll.ThemHoaDon(mahd, makh, manv, ngaylap, 0); MessageBox.Show("Tạo Thành Công Hóa Dơn " + mahd, "Thông báo"); loadDataHD(); Clear_HD(); } else { MessageBox.Show("Hóa Đơn Đã Tồn Tại", "Thông báo"); } } else { dateNgayLap.ResetText(); dateNgayLap.Focus(); MessageBox.Show("Ngày Tạo Hóa Đơn Khác Với Ngày Hệ Thống", "Thông báo"); } } } else { MessageBox.Show("Có Thông Tin Chưa Được Nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { MessageBox.Show("Có Lỗi", "Thông báo"); } }
private void ThemHD() { try { string mahd = "HD"; string makh; txtMaNV.Text = nv.MANV; DateTime ngaylap = dtpNgayLap.Value; double chietkhau = 0; if (txtChietKhau.Text != string.Empty) { chietkhau = double.Parse(txtChietKhau.Text); } else { chietkhau = 0; } string tenkh = txtTenKH.Text; string diachi = txtDiaChi.Text; string sdt = txtSDT.Text; string trangthai = ""; // kt xem textbox có bị bỏ trống không if (txtTenKH.Text != string.Empty && txtDiaChi.Text != string.Empty && txtSDT.Text != string.Empty && cboTrangThai.SelectedIndex != -1) { DialogResult result; result = MessageBox.Show("Bạn Có Muốn Tạo Hóa Đơn " + mahd + "?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { if (BatLoi_NgayLap_HD(ngaylap) == true) { // thêm nhân viên if (hd_bll.KiemTraTrung_HD(txtMaHD.Text) == true) { trangthai = cboTrangThai.Text; makh = cboMaKH.SelectedValue.ToString(); hd_bll.ThemHoaDon(mahd, nv.MANV, ngaylap, chietkhau, 0, makh, tenkh, diachi, sdt, trangthai); MessageBox.Show("Tạo Thành Công Hóa Dơn " + mahd, "Thông báo"); loadDataHD(); lammoi_HD(); loadCboHD(); } else { MessageBox.Show("Hóa Đơn Đã Tồn Tại", "Thông báo"); } } else { dtpNgayLap.ResetText(); dtpNgayLap.Focus(); MessageBox.Show("Ngày Tạo Hóa Đơn Khác Với Ngày Hệ Thống", "Thông báo"); } } } else { MessageBox.Show("Có Thông Tin Chưa Được Nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { MessageBox.Show("Có Lỗi", "Thông báo"); } }