public frmBaoCaoTongHopThuChi() { InitializeComponent(); try { datesv = DateServer.Date(); int thang = datesv.Month; int nam = datesv.Year; int soNgayTrongThang = DateTime.DaysInMonth(nam, thang); batDau = new DateTime(nam, thang, 1); ketThuc = new DateTime(nam, thang, soNgayTrongThang); label1.Text = "Báo Cáo Tổng Hợp Thu Chi Từ Ngày " + new Common.Utilities().XuLy(2, batDau.ToShortDateString()) + " Đến Ngày " + new Common.Utilities().XuLy(2, ketThuc.ToShortDateString()); SelectSoQuy(); HienThiTongThe(); Entities.SoQuy sq = new Entities.SoQuy(); double dudauky = 0; double ducuoiky = 0; if (soquy != null) { if (!string.IsNullOrEmpty(soquy.DuDauKy)) dudauky = double.Parse(soquy.DuDauKy); if (!string.IsNullOrEmpty(soquy.DuCuoiKy)) ducuoiky = double.Parse(soquy.DuCuoiKy); txtducuoiky.Text = ducuoiky.ToString(); try { dudauky = double.Parse(sodu[0].SoDuDauKy); } catch { } txtdudauky.Text = dudauky.ToString(); } if (hienthi != null && hienthi.Count() > 0 && hienthi[0] != null) { if (Thu() == 0 && Chi() == 0) sq = new Entities.SoQuy("0", "0", "Tổng Cộng"); else if (Thu() == 0 && Chi() != 0) sq = new Entities.SoQuy("0", Format(Chi()), "Tổng Cộng"); else if (Thu() != 0 && Chi() == 0) sq = new Entities.SoQuy(Format(Thu()), "0", "Tổng Cộng"); else if (Thu() != 0 && Chi() != 0) sq = new Entities.SoQuy(Format(Thu()), Format(Chi()), "Tổng Cộng"); } List<Entities.SoQuy> dataSource = new List<Entities.SoQuy>(); foreach (Entities.SoQuy item in hienthi) { dataSource.Add(item); } dataSource.Add(sq); dtgvhienthi.DataSource = dataSource; Ton(); fix(); } catch { } }
/// <summary> /// xử lý hiển thị /// </summary> public void HienThiTongThe() { try { phatsinhno = phatsinhco = sdck = sddk = 0; try { hienthi = new Entities.SoQuy[pt.Length + pc.Length + bl.Length + bb.Length + hdn.Length + kh.Length + tl.Length + pttkh.Length + pttncc.Length + 1]; } catch { } if (kt == false) { for (int i = 0; i < sodu.Length; i++) { string monthsodu = sodu[i].NgayKetChuyen.Month.ToString(); string yearsodu = sodu[i].NgayKetChuyen.Year.ToString(); if (month == monthsodu && year == yearsodu) { sddk = Convert.ToDouble(sodu[i].SoDuDauKy); break; } } } int soluong = 0; // Phiếu Thu for (int i = 0; i < pt.Length; i++) { string month1 = pt[i].NgayLap.Month.ToString(); string year1 = pt[i].NgayLap.Year.ToString(); if (month == month1 && year == year1) { phatsinhno = Convert.ToDouble(pt[i].TongTienThanhToan); string ngaylap = new Common.Utilities().XuLy(2, pt[i].NgayLap.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, pt[i].MaPhieuThu, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), pt[i].GhiChu, "PhieuThu"); soluong++; } } phatsinhno = phatsinhco = 0; // Phiếu Chi for (int i = 0; i < pc.Length; i++) { string month1 = pc[i].NgayLap.Month.ToString(); string year1 = pc[i].NgayLap.Year.ToString(); if (month == month1 && year == year1) { phatsinhco = Convert.ToDouble(pc[i].TongTienThanhToan); string ngaylap = new Common.Utilities().XuLy(2, pc[i].NgayLap.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, pc[i].MaPhieuThu, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), pc[i].GhiChu, "PhieuChi"); soluong++; } } phatsinhno = phatsinhco = 0; // Bán Lẻ for (int i = 0; i < bl.Length; i++) { string month1 = bl[i].NgayBan.Month.ToString(); string year1 = bl[i].NgayBan.Year.ToString(); if (month == month1 && year == year1) { List <double> bientam = TienIch.TinhDoanhThu(Convert.ToDouble(bl[i].TongTienThanhToan), Convert.ToDouble(bl[i].GiaTriThe), Convert.ToDouble(bl[i].GiaTriTheGiaTri)); phatsinhno = bientam[3]; //bl[i].ThanhToanNgay string ngaylap = new Common.Utilities().XuLy(2, bl[i].NgayBan.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, bl[i].MaHDBanHang, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), bl[i].GhiChu, "BanLe"); soluong++; } } phatsinhno = phatsinhco = 0; // Bán Buôn for (int i = 0; i < bb.Length; i++) { string month1 = bb[i].NgayBan.Month.ToString(); string year1 = bb[i].NgayBan.Year.ToString(); if (month == month1 && year == year1) { double a = Convert.ToDouble(bb[i].TongTienThanhToan); double b = Convert.ToDouble(bb[i].ThanhToanKhiLapPhieu); if (b > a) { b = a; } phatsinhno = b; string ngaylap = new Common.Utilities().XuLy(2, bb[i].NgayBan.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, bb[i].MaHDBanHang, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), bb[i].GhiChu, "BanBuon"); soluong++; } } phatsinhno = phatsinhco = 0; // Hóa Đơn Nhập for (int i = 0; i < hdn.Length; i++) { string month1 = hdn[i].NgayNhap.Month.ToString(); string year1 = hdn[i].NgayNhap.Year.ToString(); if (month == month1 && year == year1) { double a = Convert.ToDouble(hdn[i].TongTien); double b = Convert.ToDouble(hdn[i].ThanhToanNgay); if (b > a) { b = a; } phatsinhco = b; string ngaylap = new Common.Utilities().XuLy(2, hdn[i].NgayNhap.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, hdn[i].MaHoaDonNhap, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), hdn[i].GhiChu, "HoaDonNhap"); soluong++; } } phatsinhno = phatsinhco = 0; // Khách Hàng Trả Lại for (int i = 0; i < kh.Length; i++) { string month1 = kh[i].NgayNhap.Month.ToString(); string year1 = kh[i].NgayNhap.Year.ToString(); double a = Convert.ToDouble(kh[i].TienBoiThuong); double b = double.Parse(kh[i].ThanhToanNgay); if (b > a) { b = a; } double a1 = b; if (month == month1 && year == year1) { phatsinhco = a1; string ngaylap = new Common.Utilities().XuLy(2, kh[i].NgayNhap.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, kh[i].MaKhachHangTraLai, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), kh[i].GhiChu, "KHTL"); soluong++; } } phatsinhno = phatsinhco = 0; // Trả Lại Nhà Cung Cấp for (int i = 0; i < tl.Length; i++) { string month1 = tl[i].Ngaytra.Month.ToString(); string year1 = tl[i].Ngaytra.Year.ToString(); double a = Convert.ToDouble(tl[i].TienBoiThuong); double b = Convert.ToDouble(tl[i].ThanhToanNgay); if (b > a) { b = a; } double a1 = b; if (month == month1 && year == year1) { phatsinhno = a1; string ngaylap = new Common.Utilities().XuLy(2, tl[i].Ngaytra.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, tl[i].MaHDTraLaiNCC, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), tl[i].GhiChu, "TLNCC"); soluong++; } } phatsinhno = phatsinhco = 0; // Phiếu thanh toán nhà cung cấp for (int i = 0; i < pttncc.Length; i++) { string month1 = pttncc[i].NgayLap.Month.ToString(); string year1 = pttncc[i].NgayLap.Year.ToString(); //double a1 = double.Parse(pttncc[i].NoHienThoi); double a1 = TongThanhToanCuaPhieuThanhToan("NCC", pttncc[i].MaPhieuTTNCC); if (month == month1 && year == year1) { phatsinhco = a1; string ngaylap = new Common.Utilities().XuLy(2, pttncc[i].NgayLap.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, pttncc[i].MaPhieuTTNCC, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), pttncc[i].GhiChu, "PTTNCC"); soluong++; } } phatsinhno = phatsinhco = 0; // Phiếu thanh toán khách hàng for (int i = 0; i < pttkh.Length; i++) { string month1 = pttkh[i].NgayLap.Month.ToString(); string year1 = pttkh[i].NgayLap.Year.ToString(); //double a1 = double.Parse(pttkh[i].NoHienThoi); double a1 = TongThanhToanCuaPhieuThanhToan("KH", pttkh[i].MaPhieuTTCuaKH); if (month == month1 && year == year1) { phatsinhno = a1; string ngaylap = new Common.Utilities().XuLy(2, pttkh[i].NgayLap.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, pttkh[i].MaPhieuTTCuaKH, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), pttkh[i].GhiChu, "PTTKH"); soluong++; } } phatsinhno = phatsinhco = 0; List <Entities.SoQuy> l = new List <Entities.SoQuy>(); foreach (Entities.SoQuy item in hienthi) { if (item != null) { l.Add(item); } } hienthi = l.ToArray(); //Tính toán if (hienthi.Length == 0) {//Chỉ có số dư đầu kỳ if (sddk == 0 && sdck == 0) { soquy = new Entities.SoQuy[0]; } else { soquy = new Entities.SoQuy[1]; soquy[0] = new Entities.SoQuy("0", "0", "Tổng Cộng", Format(sddk), Format(sdck)); } } else { soquy = new Entities.SoQuy[2]; for (int i = 0; i < hienthi.Length; i++) { phatsinhco += Convert.ToDouble(hienthi[i].PhatSinhCo); phatsinhno += Convert.ToDouble(hienthi[i].PhatSinhNo); sdck = sddk + phatsinhno - phatsinhco; soquy[0] = new Entities.SoQuy("1111", "Tiền mặt việt nam", Format(sddk), Format(phatsinhno), Format(phatsinhco), Format(sdck), "TongHop"); } if (phatsinhno == 0 && phatsinhco == 0) { sdck = sddk + phatsinhno - phatsinhco; soquy[1] = new Entities.SoQuy("0", "0", "Tổng Cộng", Format(sddk), Format(sdck)); } else if (phatsinhno == 0 && phatsinhco != 0) { soquy[1] = new Entities.SoQuy("0", Format(phatsinhco), "Tổng Cộng", Format(sddk), Format(sdck)); } else if (phatsinhno != 0 && phatsinhco == 0) { soquy[1] = new Entities.SoQuy(Format(phatsinhno), "0", "Tổng Cộng", Format(sddk), Format(sdck)); } else if (phatsinhno != 0 && phatsinhco != 0) { soquy[1] = new Entities.SoQuy(Format(phatsinhno), Format(phatsinhco), "Tổng Cộng", Format(sddk), Format(sdck)); } a = soquy[1].DuCuoiKy; } dtgvsoquy.DataSource = soquy; } catch { dtgvsoquy.DataSource = new Entities.SoQuy[0]; } finally { fix(); } }
/// <summary> /// xử lý hiển thị /// </summary> public void HienThiTongThe() { try { phatsinhno = phatsinhco = sdck = sddk = 0; try { hienthi = new Entities.SoQuy[pt.Length + pc.Length + bl.Length + bb.Length + hdn.Length + kh.Length + tl.Length + pttkh.Length + pttncc.Length + 1]; } catch { } if (kt == false) { for (int i = 0; i < sodu.Length; i++) { string monthsodu = sodu[i].NgayKetChuyen.Month.ToString(); string yearsodu = sodu[i].NgayKetChuyen.Year.ToString(); if (month == monthsodu && year == yearsodu) { sddk = Convert.ToDouble(sodu[i].SoDuDauKy); break; } } } int soluong = 0; // Phiếu Thu for (int i = 0; i < pt.Length; i++) { string month1 = pt[i].NgayLap.Month.ToString(); string year1 = pt[i].NgayLap.Year.ToString(); if (month == month1 && year == year1) { phatsinhno = Convert.ToDouble(pt[i].TongTienThanhToan); string ngaylap = new Common.Utilities().XuLy(2, pt[i].NgayLap.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, pt[i].MaPhieuThu, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), pt[i].GhiChu, "PhieuThu"); soluong++; } } phatsinhno = phatsinhco = 0; // Phiếu Chi for (int i = 0; i < pc.Length; i++) { string month1 = pc[i].NgayLap.Month.ToString(); string year1 = pc[i].NgayLap.Year.ToString(); if (month == month1 && year == year1) { phatsinhco = Convert.ToDouble(pc[i].TongTienThanhToan); string ngaylap = new Common.Utilities().XuLy(2, pc[i].NgayLap.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, pc[i].MaPhieuThu, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), pc[i].GhiChu, "PhieuChi"); soluong++; } } phatsinhno = phatsinhco = 0; // Bán Lẻ for (int i = 0; i < bl.Length; i++) { string month1 = bl[i].NgayBan.Month.ToString(); string year1 = bl[i].NgayBan.Year.ToString(); if (month == month1 && year == year1) { List<double> bientam = TienIch.TinhDoanhThu(Convert.ToDouble(bl[i].TongTienThanhToan), Convert.ToDouble(bl[i].GiaTriThe), Convert.ToDouble(bl[i].GiaTriTheGiaTri)); phatsinhno = bientam[3]; //bl[i].ThanhToanNgay string ngaylap = new Common.Utilities().XuLy(2, bl[i].NgayBan.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, bl[i].MaHDBanHang, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), bl[i].GhiChu, "BanLe"); soluong++; } } phatsinhno = phatsinhco = 0; // Bán Buôn for (int i = 0; i < bb.Length; i++) { string month1 = bb[i].NgayBan.Month.ToString(); string year1 = bb[i].NgayBan.Year.ToString(); if (month == month1 && year == year1) { double a = Convert.ToDouble(bb[i].TongTienThanhToan); double b = Convert.ToDouble(bb[i].ThanhToanKhiLapPhieu); if (b > a) { b = a; } phatsinhno = b; string ngaylap = new Common.Utilities().XuLy(2, bb[i].NgayBan.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, bb[i].MaHDBanHang, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), bb[i].GhiChu, "BanBuon"); soluong++; } } phatsinhno = phatsinhco = 0; // Hóa Đơn Nhập for (int i = 0; i < hdn.Length; i++) { string month1 = hdn[i].NgayNhap.Month.ToString(); string year1 = hdn[i].NgayNhap.Year.ToString(); if (month == month1 && year == year1) { double a = Convert.ToDouble(hdn[i].TongTien); double b = Convert.ToDouble(hdn[i].ThanhToanNgay); if (b > a) { b = a; } phatsinhco = b; string ngaylap = new Common.Utilities().XuLy(2, hdn[i].NgayNhap.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, hdn[i].MaHoaDonNhap, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), hdn[i].GhiChu, "HoaDonNhap"); soluong++; } } phatsinhno = phatsinhco = 0; // Khách Hàng Trả Lại for (int i = 0; i < kh.Length; i++) { string month1 = kh[i].NgayNhap.Month.ToString(); string year1 = kh[i].NgayNhap.Year.ToString(); double a = Convert.ToDouble(kh[i].TienBoiThuong); double b = double.Parse(kh[i].ThanhToanNgay); if (b > a) { b = a; } double a1 = b; if (month == month1 && year == year1) { phatsinhco = a1; string ngaylap = new Common.Utilities().XuLy(2, kh[i].NgayNhap.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, kh[i].MaKhachHangTraLai, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), kh[i].GhiChu, "KHTL"); soluong++; } } phatsinhno = phatsinhco = 0; // Trả Lại Nhà Cung Cấp for (int i = 0; i < tl.Length; i++) { string month1 = tl[i].Ngaytra.Month.ToString(); string year1 = tl[i].Ngaytra.Year.ToString(); double a = Convert.ToDouble(tl[i].TienBoiThuong); double b = Convert.ToDouble(tl[i].ThanhToanNgay); if (b > a) { b = a; } double a1 = b; if (month == month1 && year == year1) { phatsinhno = a1; string ngaylap = new Common.Utilities().XuLy(2, tl[i].Ngaytra.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, tl[i].MaHDTraLaiNCC, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), tl[i].GhiChu, "TLNCC"); soluong++; } } phatsinhno = phatsinhco = 0; // Phiếu thanh toán nhà cung cấp for (int i = 0; i < pttncc.Length; i++) { string month1 = pttncc[i].NgayLap.Month.ToString(); string year1 = pttncc[i].NgayLap.Year.ToString(); //double a1 = double.Parse(pttncc[i].NoHienThoi); double a1 = TongThanhToanCuaPhieuThanhToan("NCC", pttncc[i].MaPhieuTTNCC); if (month == month1 && year == year1) { phatsinhco = a1; string ngaylap = new Common.Utilities().XuLy(2, pttncc[i].NgayLap.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, pttncc[i].MaPhieuTTNCC, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), pttncc[i].GhiChu, "PTTNCC"); soluong++; } } phatsinhno = phatsinhco = 0; // Phiếu thanh toán khách hàng for (int i = 0; i < pttkh.Length; i++) { string month1 = pttkh[i].NgayLap.Month.ToString(); string year1 = pttkh[i].NgayLap.Year.ToString(); //double a1 = double.Parse(pttkh[i].NoHienThoi); double a1 = TongThanhToanCuaPhieuThanhToan("KH", pttkh[i].MaPhieuTTCuaKH); if (month == month1 && year == year1) { phatsinhno = a1; string ngaylap = new Common.Utilities().XuLy(2, pttkh[i].NgayLap.ToShortDateString()); hienthi[soluong] = new Entities.SoQuy(ngaylap, pttkh[i].MaPhieuTTCuaKH, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), pttkh[i].GhiChu, "PTTKH"); soluong++; } } phatsinhno = phatsinhco = 0; List<Entities.SoQuy> l = new List<Entities.SoQuy>(); foreach (Entities.SoQuy item in hienthi) { if (item != null) { l.Add(item); } } hienthi = l.ToArray(); //Tính toán if (hienthi.Length == 0) {//Chỉ có số dư đầu kỳ if (sddk == 0 && sdck == 0) { soquy = new Entities.SoQuy[0]; } else { soquy = new Entities.SoQuy[1]; soquy[0] = new Entities.SoQuy("0", "0", "Tổng Cộng", Format(sddk), Format(sdck)); } } else { soquy = new Entities.SoQuy[2]; for (int i = 0; i < hienthi.Length; i++) { phatsinhco += Convert.ToDouble(hienthi[i].PhatSinhCo); phatsinhno += Convert.ToDouble(hienthi[i].PhatSinhNo); sdck = sddk + phatsinhno - phatsinhco; soquy[0] = new Entities.SoQuy("1111", "Tiền mặt việt nam", Format(sddk), Format(phatsinhno), Format(phatsinhco), Format(sdck), "TongHop"); } if (phatsinhno == 0 && phatsinhco == 0) { sdck = sddk + phatsinhno - phatsinhco; soquy[1] = new Entities.SoQuy("0", "0", "Tổng Cộng", Format(sddk), Format(sdck)); } else if (phatsinhno == 0 && phatsinhco != 0) soquy[1] = new Entities.SoQuy("0", Format(phatsinhco), "Tổng Cộng", Format(sddk), Format(sdck)); else if (phatsinhno != 0 && phatsinhco == 0) soquy[1] = new Entities.SoQuy(Format(phatsinhno), "0", "Tổng Cộng", Format(sddk), Format(sdck)); else if (phatsinhno != 0 && phatsinhco != 0) soquy[1] = new Entities.SoQuy(Format(phatsinhno), Format(phatsinhco), "Tổng Cộng", Format(sddk), Format(sdck)); a = soquy[1].DuCuoiKy; } dtgvsoquy.DataSource = soquy; } catch { dtgvsoquy.DataSource = new Entities.SoQuy[0]; } finally { fix(); } }
private void btnNapLai_Click(object sender, EventArgs e) { int thang = datesv.Month; int nam = datesv.Year; int soNgayTrongThang = DateTime.DaysInMonth(nam, thang); batDau = new DateTime(nam, thang, 1); ketThuc = new DateTime(nam, thang, soNgayTrongThang); label1.Text = "Báo Cáo Tổng Hợp Thu Chi Từ Ngày " + new Common.Utilities().XuLy(2, batDau.ToShortDateString()) + " Đến Ngày " + new Common.Utilities().XuLy(2, ketThuc.ToShortDateString()); SelectSoQuy(); HienThiTongThe(); Entities.SoQuy tongSQ = new Entities.SoQuy(); double dudauky = 0; double ducuoiky = 0; if (soquy != null) { if (!string.IsNullOrEmpty(soquy.DuDauKy)) dudauky = double.Parse(soquy.DuDauKy); if (!string.IsNullOrEmpty(soquy.DuCuoiKy)) ducuoiky = double.Parse(soquy.DuCuoiKy); txtducuoiky.Text = ducuoiky.ToString(); txtdudauky.Text = dudauky.ToString(); } if (hienthi != null && hienthi.Count() > 0 && hienthi[0] != null) { if (Thu() == 0 && Chi() == 0) tongSQ = new Entities.SoQuy("0", "0", "Tổng Cộng"); else if (Thu() == 0 && Chi() != 0) tongSQ = new Entities.SoQuy("0", Format(Chi()), "Tổng Cộng"); else if (Thu() != 0 && Chi() == 0) tongSQ = new Entities.SoQuy(Format(Thu()), "0", "Tổng Cộng"); else if (Thu() != 0 && Chi() != 0) tongSQ = new Entities.SoQuy(Format(Thu()), Format(Chi()), "Tổng Cộng"); } List<Entities.SoQuy> dataSource = new List<Entities.SoQuy>(); foreach (Entities.SoQuy item in hienthi) { dataSource.Add(item); } dataSource.Add(tongSQ); dtgvhienthi.DataSource = dataSource; Ton(); fix(); }
private void btnLoc_Click(object sender, EventArgs e) { try { frmLocDieuKien a = new frmLocDieuKien(); a.ShowDialog(); if (frmLocDieuKien.truoc != "" && frmLocDieuKien.sau != "") { string batdau = frmLocDieuKien.truoc; string ketthuc = frmLocDieuKien.sau; this.batDau = Convert.ToDateTime(batdau); this.ketThuc = Convert.ToDateTime(ketthuc); label1.Text = "Báo Cáo Tổng Hợp Thu Chi Từ Ngày " + new Common.Utilities().XuLy(2, batDau.ToShortDateString()) + " Đến Ngày " + new Common.Utilities().XuLy(2, ketThuc.ToShortDateString()); SelectSoQuy(); HienThiTongThe(); Entities.SoQuy tongSQ = new Entities.SoQuy(); double dudauky = 0; double ducuoiky = 0; if (soquy != null) { if (!string.IsNullOrEmpty(soquy.DuDauKy)) dudauky = double.Parse(soquy.DuDauKy); if (!string.IsNullOrEmpty(soquy.DuCuoiKy)) ducuoiky = double.Parse(soquy.DuCuoiKy); txtducuoiky.Text = ducuoiky.ToString(); txtdudauky.Text = dudauky.ToString(); } if (hienthi != null && hienthi.Count() > 0 && hienthi[0] != null) { if (Thu() == 0 && Chi() == 0) tongSQ = new Entities.SoQuy("0", "0", "Tổng Cộng"); else if (Thu() == 0 && Chi() != 0) tongSQ = new Entities.SoQuy("0", Format(Chi()), "Tổng Cộng"); else if (Thu() != 0 && Chi() == 0) tongSQ = new Entities.SoQuy(Format(Thu()), "0", "Tổng Cộng"); else if (Thu() != 0 && Chi() != 0) tongSQ = new Entities.SoQuy(Format(Thu()), Format(Chi()), "Tổng Cộng"); } List<Entities.SoQuy> dataSource = new List<Entities.SoQuy>(); foreach (Entities.SoQuy item in hienthi) { dataSource.Add(item); } dataSource.Add(tongSQ); dtgvhienthi.DataSource = dataSource; Ton(); fix(); frmLocDieuKien.truoc = frmLocDieuKien.sau = ""; } } catch { } }
/// <summary> /// xử lý hiển thị /// </summary> public void HienThiTongThe() { try { phatsinhno = phatsinhco = sdck = sddk = 0; hienthi = new List<Entities.SoQuy>(); if (kt == false) { for (int i = 0; i < sodu.Length; i++) { if (batDau <= sodu[i].NgayKetChuyen && sodu[i].NgayKetChuyen <= ketThuc) { sddk = Convert.ToDouble(sodu[i].SoDuDauKy); break; } } } int soluong = 0; // Phiếu Thu for (int i = 0; i < pt.Length; i++) { string month1 = pt[i].NgayLap.Month.ToString(); string year1 = pt[i].NgayLap.Year.ToString(); if (batDau <= pt[i].NgayLap && pt[i].NgayLap <= ketThuc) { phatsinhno = Convert.ToDouble(pt[i].TongTienThanhToan); string ngaylap = new Common.Utilities().XuLy(2, pt[i].NgayLap.ToShortDateString()); Entities.SoQuy soquy = new Entities.SoQuy(ngaylap, pt[i].MaPhieuThu, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), pt[i].GhiChu, "PhieuThu"); hienthi.Add(soquy); } } phatsinhno = phatsinhco = 0; // Phiếu Chi for (int i = 0; i < pc.Length; i++) { string month1 = pc[i].NgayLap.Month.ToString(); string year1 = pc[i].NgayLap.Year.ToString(); if (batDau <= pc[i].NgayLap && pc[i].NgayLap <= ketThuc) { phatsinhco = Convert.ToDouble(pc[i].TongTienThanhToan); string ngaylap = new Common.Utilities().XuLy(2, pc[i].NgayLap.ToShortDateString()); Entities.SoQuy soquy = new Entities.SoQuy(ngaylap, pc[i].MaPhieuThu, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), pc[i].GhiChu, "PhieuChi"); hienthi.Add(soquy); } } phatsinhno = phatsinhco = 0; // Bán Lẻ for (int i = 0; i < bl.Length; i++) { if (batDau <= bl[i].NgayBan && bl[i].NgayBan <= ketThuc) { List<double> bientam = TienIch.TinhDoanhThu(Convert.ToDouble(bl[i].TongTienThanhToan), Convert.ToDouble(bl[i].GiaTriThe), Convert.ToDouble(bl[i].GiaTriTheGiaTri)); phatsinhno = bientam[3]; string ngaylap = new Common.Utilities().XuLy(2, bl[i].NgayBan.ToShortDateString()); Entities.SoQuy soquy = new Entities.SoQuy(ngaylap, bl[i].MaHDBanHang, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), bl[i].GhiChu, "BanLe"); hienthi.Add(soquy); } } phatsinhno = phatsinhco = 0; // Bán Buôn for (int i = 0; i < bb.Length; i++) { if (batDau <= bb[i].NgayBan && bb[i].NgayBan <= ketThuc) { phatsinhno = Convert.ToDouble(bb[i].ThanhToanKhiLapPhieu); string ngaylap = new Common.Utilities().XuLy(2, bb[i].NgayBan.ToShortDateString()); Entities.SoQuy soquy = new Entities.SoQuy(ngaylap, bb[i].MaHDBanHang, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), bb[i].GhiChu, "BanBuon"); hienthi.Add(soquy); } } phatsinhno = phatsinhco = 0; // Hóa Đơn Nhập for (int i = 0; i < hdn.Length; i++) { if (batDau <= hdn[i].NgayNhap && hdn[i].NgayNhap <= ketThuc) { phatsinhco = Convert.ToDouble(hdn[i].ThanhToanNgay); string ngaylap = new Common.Utilities().XuLy(2, hdn[i].NgayNhap.ToShortDateString()); Entities.SoQuy soquy = new Entities.SoQuy(ngaylap, hdn[i].MaHoaDonNhap, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), hdn[i].GhiChu, "HoaDonNhap"); hienthi.Add(soquy); } } phatsinhno = phatsinhco = 0; // Phiếu thanh toán nhà cung cấp for (int i = 0; i < pttncc.Length; i++) { double a1 = TongThanhToanCuaPhieuThanhToan("NCC", pttncc[i].MaPhieuTTNCC); if (batDau <= pttncc[i].NgayLap && pttncc[i].NgayLap <= ketThuc) { phatsinhco = a1; string ngaylap = new Common.Utilities().XuLy(2, pttncc[i].NgayLap.ToShortDateString()); Entities.SoQuy soquy = new Entities.SoQuy(ngaylap, pttncc[i].MaPhieuTTNCC, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), pttncc[i].GhiChu, "PTTNCC"); hienthi.Add(soquy); } } phatsinhno = phatsinhco = 0; // Phiếu thanh toán khách hàng for (int i = 0; i < pttkh.Length; i++) { double a1 = TongThanhToanCuaPhieuThanhToan("KH", pttkh[i].MaPhieuTTCuaKH); if (batDau <= pttkh[i].NgayLap && pttkh[i].NgayLap <= ketThuc) { phatsinhno = a1; string ngaylap = new Common.Utilities().XuLy(2, pttkh[i].NgayLap.ToShortDateString()); Entities.SoQuy soquy = new Entities.SoQuy(ngaylap, pttkh[i].MaPhieuTTCuaKH, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), pttkh[i].GhiChu, "PTTKH"); hienthi.Add(soquy); } } phatsinhno = phatsinhco = 0; // Khách Hàng Trả Lại for (int i = 0; i < kh.Length; i++) { string month1 = kh[i].NgayNhap.Month.ToString(); string year1 = kh[i].NgayNhap.Year.ToString(); double a1 = double.Parse(kh[i].ThanhToanNgay); if (batDau <= kh[i].NgayNhap && kh[i].NgayNhap <= ketThuc) { phatsinhco = a1; string ngaylap = new Common.Utilities().XuLy(2, kh[i].NgayNhap.ToShortDateString()); Entities.SoQuy soquy = new Entities.SoQuy(ngaylap, kh[i].MaKhachHangTraLai, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), kh[i].GhiChu, "KHTL"); hienthi.Add(soquy); } } phatsinhno = phatsinhco = 0; // Trả Lại Nhà Cung Cấp for (int i = 0; i < tl.Length; i++) { double a1 = double.Parse(tl[i].ThanhToanNgay); if (batDau <= tl[i].Ngaytra && tl[i].Ngaytra <= ketThuc) { phatsinhno = a1; string ngaylap = new Common.Utilities().XuLy(2, tl[i].Ngaytra.ToShortDateString()); Entities.SoQuy soquy = new Entities.SoQuy(ngaylap, tl[i].MaHDTraLaiNCC, "1111", "Tiền mặt việt nam", Format(phatsinhno), Format(phatsinhco), tl[i].GhiChu, "TLNCC"); hienthi.Add(soquy); } } phatsinhno = phatsinhco = 0; //Tính toán Entities.SoQuy tongSQ = new Entities.SoQuy(); if (hienthi.ToArray().Length == 1) { tongSQ = new Entities.SoQuy("0", "0", "Tổng Cộng", Format(sddk), Format(sdck)); } else { for (int i = 0; i < hienthi.ToArray().Length; i++) { phatsinhco += Convert.ToDouble(hienthi[i].PhatSinhCo); phatsinhno += Convert.ToDouble(hienthi[i].PhatSinhNo); sdck = sddk + phatsinhno - phatsinhco; tongSQ = new Entities.SoQuy("1111", "Tiền mặt việt nam", Format(sddk), Format(phatsinhno), Format(phatsinhco), Format(sdck), "TongHop"); } } this.soquy = tongSQ; } catch { } finally { } }