private void btncongno_Click(object sender, EventArgs e) { string message = ""; foreach (ListViewItem item in lvhoadon.Items) { if (item.Selected) { DialogResult kq = MessageBox.Show("Bạn Muôn Thêm Mã Hóa Đơn : " + item.SubItems[1].Text + " Vào Công Nợ Khách Hàng !", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (kq == DialogResult.Yes) { if (txtmakhachhang.Text.Trim() == "") { message += "Chưa Nhập Mã Khách Hàng "; } if (cbmahopdong.Text.Trim() == "") { message += string.IsNullOrEmpty(message) ? "" : "-"; message += " Chưa Chọn Mã Hợp Đồng"; } DTO_HoaDon hd = new DTO_HoaDon(); hd.ma_hoa_don = item.SubItems[1].Text; hd.ma_khach_hang = txtmakhachhang.Text.Trim(); if (new BLL_CongNo()._check_ma_hoa_don_cong_no(hd) == 1) { message += string.IsNullOrEmpty(message) ? "" : "-"; message += " Mã Hóa Đơn Đã Lưu Vào Công Nợ Khách Hàng "; } if (message != "") { MessageBox.Show(" " + message + "!", "Thống Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (message == "") { DTO_HoaDon hoadon = new DTO_HoaDon(); hoadon.ma_khach_hang = txtmakhachhang.Text.Trim(); hoadon.ma_hop_dong = cbmahopdong.Text.Trim(); hoadon.ma_hoa_don = item.SubItems[1].Text; DTO_CongNo congno = new DTO_CongNo(); congno.ma_cong_no = new BLL_CongNo()._Ma_Cong_No(); int i = new BLL_CongNo()._Them_Cong_No_Khach_Hang(hoadon, congno); if (i == 0) { MessageBox.Show("Thêm Công Nợ Thành Công! ", "Thống Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm Công Nợ Thất Bại! ", "Thống Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } } }
private void btnluucongno_Click(object sender, EventArgs e) { string message = ""; if (txtmakhachhang.Text.Trim() == "") { message += "Chưa Nhập Mã Khách Hàng "; } if (cbmahopdong.Text.Trim() == "") { message += string.IsNullOrEmpty(message) ? "" : "-"; message += " Chưa Chọn Mã Hợp Đồng"; } if (txtmacongno.Text.Trim() == "") { message += string.IsNullOrEmpty(message) ? "" : "-"; message += " Chưa Nhập Mã Công Nơ"; } if (cbhoadon.Text.Trim() == "") { message += string.IsNullOrEmpty(message) ? "" : "-"; message += " Chưa Chọn Mã Hóa Đơn "; } if (message != "") { MessageBox.Show("Bạn " + message + "!", "Thống Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (message == "") { DTO_HoaDon hoadon = new DTO_HoaDon(); hoadon.ma_khach_hang = txtmakhachhang.Text.Trim(); hoadon.ma_hop_dong = cbmahopdong.Text.Trim(); hoadon.ma_hoa_don = cbhoadon.Text.Trim(); DTO_CongNo congno = new DTO_CongNo(); congno.ma_cong_no = txtmacongno.Text.Trim(); int i = new BLL_CongNo()._Them_Cong_No_Khach_Hang(hoadon, congno); if (i == 0) { MessageBox.Show("Thêm Công Nợ Thành Công! ", "Thống Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); _Ma_Cong_No(); _Load_List_View_Thanh_Toan(); _Load_List_View_Cong_No(); } else { MessageBox.Show("Thêm Công Nợ Thất Bại! ", "Thống Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void mnxoa_Click(object sender, EventArgs e) { foreach (ListViewItem item in lvcongno.Items) { if (item.Selected && item.SubItems[0].Text.Trim() != "") { DialogResult kq = MessageBox.Show("Bạn Chắc Chắc Muốn Xóa Mã Hóa Đơn :" + item.SubItems[2].Text.Trim() + " Và Số Tiền : " + item.SubItems[3].Text.Trim() + "VNĐ!", "Thống Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (kq == DialogResult.Yes) { DTO_CongNo congno = new DTO_CongNo(); congno.ma_hoa_don = item.SubItems[2].Text.Trim(); int i = new BLL_CongNo()._Xoa_Cong_No(congno); if (i == 0) { _Load_List_View_Thanh_Toan(); _Load_List_View_Cong_No(); } else { MessageBox.Show("Xóa Thất Bại. Vui Lòng Kiểm Tra Lại! ", "Thống Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } foreach (ListViewItem item in lvthanhtoan.Items) { if (item.Selected && item.SubItems[0].Text.Trim() != "") { DialogResult kq = MessageBox.Show("Bạn Chắc Chắc Muốn Xóa Số Tiền :" + item.SubItems[2].Text.Trim() + "VNĐ!", "Thống Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (kq == DialogResult.Yes) { DTO_ThanhToan tt = new DTO_ThanhToan(); tt.ma_thanh_toan = int.Parse(item.SubItems[4].Text.Trim()); int i = new BLL_CongNo()._Xoa_So_Tien_Thanh_Toan(tt); if (i == 0) { _Load_List_View_Thanh_Toan(); _Load_List_View_Cong_No(); } else { MessageBox.Show("Xóa Thất Bại. Vui Lòng Kiểm Tra Lại! ", "Thống Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } }
private void btnthemthanhtoan_Click(object sender, EventArgs e) { string message = ""; if (txtmakhachhang.Text.Trim() == "") { message += "Chưa Nhập Mã Khách Hàng "; } if (cbmahopdong.Text.Trim() == "") { message += string.IsNullOrEmpty(message) ? "" : "-"; message += " Chưa Chọn Mã Hợp Đồng"; } if (message != "") { MessageBox.Show("Bạn " + message + "!", "Thống Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (message == "") { DTO_ThanhToan tt = new DTO_ThanhToan(); tt.ma_hop_dong = cbmahopdong.Text.Trim(); tt.ma_khach_hang = txtmakhachhang.Text.Trim(); tt.ngay_thanh_toan = dtpngaythanhtoan.Value; tt.so_tien_thanh_toan = float.Parse(txtsotienthanhtoan.Text.Trim()); int i = new BLL_CongNo()._Them_Thanh_Toan_Cong_No(tt); if (i == 0) { MessageBox.Show("Thêm Thanh Toán Thành Công! ", "Thống Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); _Load_List_View_Thanh_Toan(); _Load_List_View_Cong_No(); } else { MessageBox.Show("Thêm Thanh Toán Thất Bại! ", "Thống Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }