private void btnxoa_Click(object sender, EventArgs e) { if (txtmabangke.Text.Trim() != new BLL_BangKe()._Ma_Bang_Ke()) { DialogResult kq = MessageBox.Show("Bạn Muốn Xóa Mã Bảng Kê : " + txtmabangke.Text.Trim(), "Thông Báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (kq == DialogResult.OK) { DTO_BangKe dto = new DTO_BangKe(); dto.ma_bang_ke = txtmabangke.Text.Trim(); int delete = new BLL_BangKe()._Xoa_BangKe(dto); if (delete == 0) { MessageBox.Show("Xóa Thành Công !", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); _Load_ListView_DanhSachBangKe_KhachHang(); _Load_ComBobox_Dieu_xe(); } if (delete == 2) { MessageBox.Show("Mã Bảng Kê Không Tồn Tại Không Thể Xóa !", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (delete == 1) { MessageBox.Show("Bảng Kê Đã Xuất Hóa Đơn Không Thể Xóa !", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { MessageBox.Show("Mã Bảng Kê Không Tồn Tại Không Thể Xóa !", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void _combobox_ten_khach_hang() { DataTable dt = new BLL_BangKe()._List_Ten_Khach_Hang(); DataRow row = dt.NewRow(); row["ten_khach_hang"] = ""; row["ma_khach_hang"] = ""; dt.Rows.InsertAt(row, 0); cbkhachhang.DisplayMember = "ten_khach_hang"; cbkhachhang.ValueMember = "ma_khach_hang"; cbkhachhang.DataSource = dt; cbkhachhang.SelectedIndex = 0; }
private void mnxoa_Click(object sender, EventArgs e) { DialogResult kq = MessageBox.Show("Bạn Chắc Chắc Muốn Xóa", "Thông Báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (kq == DialogResult.OK) { foreach (ListViewItem item in lvthongtin.Items) { if (item.Selected) { DTO_BangKe dto = new DTO_BangKe(); dto.ma_bang_ke = item.SubItems[1].Text; int delete = new BLL_BangKe()._Xoa_BangKe(dto); if (delete == 0) { } } } _Load_ListView_DanhSachBangKe_KhachHang(); _Load_ComBobox_Dieu_xe(); } }
private void btncapnhat_Click(object sender, EventArgs e) { DialogResult kq = MessageBox.Show("Bạn Muốn Cập Nhật Mã Bảng Kê : " + txtmabangke.Text.Trim(), "Thông Báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (kq == DialogResult.OK) { string message = ""; if (txtmabangke.Text.Trim() == "") { message += " Chưa Nhập Mã Bảng Kê "; } if (txtmakhachhang.Text.Trim() == "") { message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Nhập Mã Khách Hàng "; } if (cbhopdong.Text.Trim() == "") { message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Tạo Hợp Đồng "; } if (txtmasoxe.Text.Trim() == "") { message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Nhập Mã Số Xe "; } if (txtkhoiluong.Text.Trim() == "") { message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Nhập Khối Lượng "; } if (txtnoinhan.Text.Trim() == "") { message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Nhập Nơi Nhận "; } if (txtnoigiao.Text.Trim() == "") { message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Nhập Nơi Giao "; } if (message == "") { DTO_BangKe dto = new DTO_BangKe(); dto.ma_bang_ke = txtmabangke.Text.Trim(); dto.ma_khach_hang = txtmakhachhang.Text.Trim(); dto.ngay_van_chuyen = dtpngayvanchuyen.Value; dto.ngay_tao = DateTime.Now; dto.ngay_cap_nhat = DateTime.Now; dto.so_xe = txtmasoxe.Text.Trim(); dto.noi_giao = txtnoigiao.Text.Trim(); dto.noi_nhan = txtnoinhan.Text.Trim(); dto.khoi_luong = int.Parse("0" + txtkhoiluong.Text.Trim()); dto.don_gia_tan = float.Parse("0" + txtdongiatan.Text.Trim()); dto.don_gia_chuyen = float.Parse("0" + txtdongiachuyen.Text.Trim()); dto.ghi_chu = rtbghichu.Text.Trim(); dto.ma_dieu_xe = cbmadieuxe.Text.Trim(); int update = new BLL_BangKe()._CapNhat_BangKe(dto); if (update == 1) { message = " Bảng Kê Này Đã Xuất Hóa Đơn Không Thể Cập Nhật "; MessageBox.Show(message + "!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { _Load_ListView_DanhSachBangKe_KhachHang(); _Load_ComBobox_Dieu_xe(); txtkhoiluong.Text = ""; txtnoigiao.Text = ""; rtbghichu.Text = ""; txtmasoxe.Text = ""; txtmabangke.Text = new BLL_BangKe()._Ma_Bang_Ke(); } } else { MessageBox.Show("Bạn" + message + "!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void btnluu_Click(object sender, EventArgs e) { if (txtmabangke.Text.Trim() == new BLL_BangKe()._Ma_Bang_Ke()) { string message = ""; if (txtmabangke.Text.Trim() == "") { message += " Chưa Nhập Mã Bảng Kê "; } if (txtmakhachhang.Text.Trim() == "") { message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Nhập Mã Khách Hàng "; } if (cbhopdong.Text.Trim() == "") { message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Tạo Hợp Đồng "; } if (txtmasoxe.Text.Trim() == "") { message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Nhập Mã Số Xe "; } if (txtkhoiluong.Text.Trim() == "") { message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Nhập Khối Lượng "; } if (txtnoinhan.Text.Trim() == "") { message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Nhập Nơi Nhận "; } if (txtnoigiao.Text.Trim() == "") { message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Nhập Nơi Giao "; } if (cbmadieuxe.Text.Trim() == "") { message += (string.IsNullOrEmpty(message) ? " " : " - ") + "Chưa Chọn Mã Điều Xe "; } if (message == "") { DTO_BangKe dto = new DTO_BangKe(); dto.ma_bang_ke = txtmabangke.Text.Trim(); dto.ma_khach_hang = txtmakhachhang.Text.Trim(); dto.ngay_van_chuyen = dtpngayvanchuyen.Value; dto.ngay_tao = DateTime.Now; dto.ngay_cap_nhat = DateTime.Now; dto.so_xe = txtmasoxe.Text.Trim(); dto.noi_giao = txtnoigiao.Text.Trim(); dto.noi_nhan = txtnoinhan.Text.Trim(); dto.khoi_luong = float.Parse("0" + txtkhoiluong.Text.Trim()); dto.don_gia_tan = float.Parse("0" + txtdongiatan.Text.Trim()); dto.don_gia_chuyen = float.Parse("0" + txtdongiachuyen.Text.Trim()); dto.ghi_chu = rtbghichu.Text.Trim(); dto.ma_dieu_xe = cbmadieuxe.Text.Trim(); int insert = new BLL_BangKe()._Them_BangKe(dto); if (insert == 1) { message = " Lưu Bản Kê Thất Bại "; MessageBox.Show(message + "!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { _Load_ListView_DanhSachBangKe_KhachHang(); _Load_ComBobox_Dieu_xe(); txtmabangke.Text = new BLL_BangKe()._Ma_Bang_Ke(); } } else { MessageBox.Show("Bạn" + message + "!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Không Thể Thêm Mới.Kiểm Tra Lại Mã Bảng Kê !", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }