private void Del() { tblphieunhapkhoBL ctr = new tblphieunhapkhoBL(); string kq = ""; string sidhd = ""; try { sidhd = txtID.Text.Trim(); } catch { } string stientttemp = "N/A"; try { stientttemp = ctr.GetByID(sidhd).tienthanhtoan.ToString(); } catch { } if (MessageBox.Show("Xác nhận xóa dữ liệu?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { UpdateSoLuongMatHang(sidhd); kq = ctr.Delete(sidhd); if (kq.Trim().Equals("") == true) { _ctrlog.Append(Data.use, "Xóa phiếu nhập hàng của nhà cung cấp: " + cbNhaCC.Text.Trim() + " xuất ngày: " + dpkNgayNhap.Value.ToString("dd/MM/yyyy").Trim() + "; id: " + txtID.Text.Trim() + ";\nChi tiết: Tổng tiền hàng: " + txtTongTien.Text + " - Nợ cũ: " + txtNoToaTruoc.Text + " - Tiền thanh toán: " + stientttemp + " - Tổng nợ mới: " + txtConNo.Text); Add(); HienThiDSMatHang(); } else { MessageBox.Show("Xóa phiếu nhập hàng không thành công.\nChi tiết lỗi: " + kq, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } }
private List <tienthanhtoanphieunhap> GetListTienThanhToan() { tblphieunhapkhoBL ctrphieunhap = new tblphieunhapkhoBL(); tblphieunhapkho objphieunhap = new tblphieunhapkho(); objphieunhap = ctrphieunhap.GetByID(sidpn); try { List <tienthanhtoanphieunhap> lst = new List <tienthanhtoanphieunhap>(); for (int i = 1; i < c1FlexGrid1.Rows.Count; i++) { tienthanhtoanphieunhap obj = new tienthanhtoanphieunhap(); if (c1FlexGrid1[i, "tt"].ToString().Trim().Equals("0") == false) { if (c1FlexGrid1[i, "tt"].ToString().Trim().Equals("1") == true) { obj.id = Guid.NewGuid().ToString(); } else if (c1FlexGrid1[i, "tt"].ToString().Trim().Equals("2") == true) { obj.id = c1FlexGrid1[i, "id"].ToString().Trim(); } if (sidpn.Trim().Equals("") == true) { MessageBox.Show("Không lấy được thông tin hóa đơn.\nVui lòng tắt chương trình và khởi động lại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); c1FlexGrid1.Select(i, c1FlexGrid1.Cols["tientt"].Index); return(null); } try { obj.tientt = Convert.ToDouble(c1FlexGrid1[i, "tientt"].ToString().Trim()); } catch { MessageBox.Show("Tiền thanh toán nhập không đúng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); c1FlexGrid1.Select(i, c1FlexGrid1.Cols["tientt"].Index); return(null); } if (obj.tientt == 0) { MessageBox.Show("Tiền thanh toán phải lớn hơn 0", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); c1FlexGrid1.Select(i, c1FlexGrid1.Cols["tientt"].Index); return(null); } obj.idpn = sidpn; obj.ngaytt = Convert.ToDateTime(c1FlexGrid1[i, "ngaytt"].ToString().Trim()); if (objphieunhap.ngaytao == obj.ngaytt) { MessageBox.Show("Bản ghi này đã tồn tại.\nVui lòng nhập lại ngày thanh toán", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); c1FlexGrid1.Select(i, c1FlexGrid1.Cols["ngaytt"].Index); return(null); } obj.ghichu = c1FlexGrid1[i, "ghichu"].ToString().Trim(); lst.Add(obj); } } return(lst); } catch { return(null); } }
private void HienThiTT() { try { tblphieunhapkho obj = new tblphieunhapkho(); tblphieunhapkhoBL ctr = new tblphieunhapkhoBL(); obj = ctr.GetByID(txtID.Text.Trim()); dpkNgayNhap.Value = obj.ngaytao; cbNhaCC.SelectedValue = obj.id_nguoicap; txtChietKhau.Text = obj.chietkhau.ToString("N0", CultureInfo.InvariantCulture); txtTienThanhToan.Text = obj.tienthanhtoan.ToString("N0", CultureInfo.InvariantCulture); dpkNgayNhap.Value = obj.ngaytao; txtNoToaTruoc.Text = ctr.GetTienConNo(obj.id_nguoicap, obj.ngaytao).ToString("N0", CultureInfo.InvariantCulture); txtGhiChu.Text = obj.ghichu.Trim(); txtNoiNhap.Text = obj.noinhap.Trim(); } catch { HienThiDSMatHang(); } }
private void HienThiTTPhieuNhap() { tblphieunhapkho objpn = new tblphieunhapkho(); tblphieunhapkhoBL ctrpn = new tblphieunhapkhoBL(); objpn = ctrpn.GetByID(sidpn); try{ nhacungcap objnhacc = new nhacungcap(); nhacungcapBL ctrnhacc = new nhacungcapBL(); objnhacc = ctrnhacc.GetByID(objpn.id_nguoicap.Trim()); lbDiaChi.Text = objnhacc.diachi; lbDienThoai.Text = objnhacc.dienthoai; lbNgayXuat.Text = objpn.ngaytao.ToString("dd/MM/yyyy HH:mm:ss"); lbTenKH.Text = objnhacc.ten; } catch { lbDiaChi.Text = "-/-"; lbDienThoai.Text = "-/-"; lbNgayXuat.Text = "-/-"; lbTenKH.Text = "-/-"; } }