コード例 #1
0
 private void ReportPhieuThanhToan_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
 {
     xrTableCellTenDonVi.Text  = Settings.Default.TenDonVi;
     xrTableCellDiaChi.Text    = Settings.Default.DiaChi;
     xrTableCellSlogan.Text    = Settings.Default.Slogan;
     xrTableCellLienHe.Text    = "Liên hệ: " + Settings.Default.LienHe;
     xrTableCellViTri.Text     = "Vị trí: " + hoaDon.Ban.TenBan;
     xrTableCellCaLamViec.Text = "Ca làm việc: " + hoaDon.CaLamViec;
     xrTableCellThoiGian.Text  = "Giờ vào: " + hoaDon.NgayTao.ToString("dd-MM-yyy HH:mm");
     xrTableCellMaHoaDon.Text  = "Hoá đơn số: " + hoaDon.IdHoaDon;
     DataSource = listCT;
     xrTableCellTenMon.DataBindings.Add("Text", listCT, nameof(Mon.TenMon));
     xrTableCellDonGia.DataBindings.Add("Text", listCT, nameof(Mon.DonGia));
     xrTableCellDVT.DataBindings.Add("Text", listCT, nameof(Mon.DonViTinh.TenDVT));
     xrTableCellSoLuong.DataBindings.Add("Text", listCT, nameof(HoaDonChiTiet.SoLuong));
     xrTableCellTien.DataBindings.Add("Text", listCT, nameof(HoaDonChiTiet.Tien));
     xrTableCellGiamGia.Text       = hoaDon.TienChietKhau.ToString("n0") + "đ";
     xrTableCellTongTien.Text      = hoaDon.TongTien.ToString("n0") + "đ";
     xrTableCellThanhTien.Text     = hoaDon.ThanhTien.ToString("n0") + "đ";
     xrTableCellThanhTien_Chu.Text = "(" + VNCurrency.ToString(hoaDon.ThanhTien) + ")";
 }
コード例 #2
0
        private void NapDuLieu()
        {
            xrLabelTenDonVi.Text       = Settings.Default.TenDonVi;
            xrLabelDiaChiDonVi.Text    = "Địa chỉ: " + Settings.Default.DiaChi;
            xrLabelDienThoaiDonVi.Text = "Điện thoại: " + Settings.Default.LienHe;
            var temp = phieu.PhieuNhapKhoChiTiets.ToList();

            for (int i = 0; i < temp.Count; i++)
            {
                temp[i].STT = i + 1;
            }
            db = new ModelQuanLiCafeDbContext();
            db.DonViTinhs.Load();
            db.PhieuNhapKhoChiTiets.Where(s => s.SoHoaDon == phieu.SoHoaDon).Load();
            var tempPhieu = db.PhieuNhapKhoChiTiets.Local.ToBindingList();
            var myList    = from a in tempPhieu
                            join b in db.DonViTinhs.Local
                            on a.NguyenLieu.IdDVT equals b.IdDVT
                            select new { a.STT, a.NguyenLieu.TenNguyenLieu, a.SoLuong, a.DonGia, b.TenDVT, a.Tien };

            DataSource = myList.ToList();
            STT.DataBindings.Add("Text", DataSource, nameof(PhieuNhapKhoChiTiet.STT));
            Ten.DataBindings.Add("Text", DataSource, nameof(NguyenLieu.TenNguyenLieu));
            DonGia.DataBindings.Add("Text", DataSource, nameof(PhieuNhapKhoChiTiet.DonGia), "{0:n0}đ");
            SoLuong.DataBindings.Add("Text", DataSource, nameof(PhieuNhapKhoChiTiet.SoLuong));
            DVT.DataBindings.Add("Text", DataSource, nameof(DonViTinh.TenDVT));
            Tien.DataBindings.Add("Text", DataSource, nameof(PhieuNhapKhoChiTiet.Tien), "{0:n0}đ");

            xrLabelNgay.Text                = "Ngày lập phiếu: " + phieu.NgayLapPhieu.ToString("dd/MM/yyyy");
            xrLabelSoPhieu.Text             = "Số HĐ: " + phieu.SoHoaDon;
            xrLabelTenDoiTac.Text           = phieu.DoiTac.TenDoiTac;
            xrLabelSoDienThoaiDoiTac.Text   = phieu.DoiTac.SoDienThoai;
            xrLabelDiaChiDoiTac.Text        = phieu.DoiTac.DiaChi;
            xrTableCellTongTien.Text        = phieu.TongTien.ToString("n0") + "đ";
            xrLabelChietKhau.Text           = phieu.TienChietKhau.ToString("n0") + "đ";
            xrLabelThanhToan.Text           = phieu.ThanhTien.ToString("n0") + "đ";
            xrTableCellTongTienBangChu.Text = VNCurrency.ToString(phieu.TongTien);
        }
コード例 #3
0
        public ActionResult In(int?id)
        {
            if (!id.HasValue)
            {
                ViewBag.Message = "Đường dẫn không đúng";
                return(View("Error"));
            }

            var nhathuoc   = this.GetNhaThuoc();
            var maNhaThuoc = nhathuoc.MaNhaThuoc;
            var item       = unitOfWork.PhieuThuChiRepository.GetMany(e => e.NhaThuoc.MaNhaThuoc == maNhaThuoc && e.MaPhieu == id).FirstOrDefault();

            if (item == null)
            {
                ViewBag.Message = "Phiếu thu/chi không tồn tại";
                return(View("Error"));
            }

            decimal nocu                     = 0M;
            string  khachhang                = "";
            string  diachikhachhang          = "";
            string  reportPath               = "~/Reports/RptPhieuThuChiKhac.rdlc";
            List <ReportParameter> listParam = new List <ReportParameter>();

            if (item.LoaiPhieu == 1)
            {
                reportPath = "~/Reports/RptPhieuThu.rdlc";
                nocu       = GetNoKhachHang(item.KhachHang.MaKhachHang, item.NgayTao);
                if (item.KhachHang != null)
                {
                    khachhang       = item.KhachHang.TenKhachHang;
                    diachikhachhang = item.KhachHang.DiaChi;
                }

                listParam = new List <ReportParameter>()
                {
                    new ReportParameter("pNhaThuoc", nhathuoc.TenNhaThuoc),
                    new ReportParameter("pDiaChiNhaThuoc", nhathuoc.DiaChi),
                    new ReportParameter("pSDTNhaThuoc", nhathuoc.DienThoai),
                    new ReportParameter("pPhieuXuat", item.SoPhieu.ToString()),
                    new ReportParameter("pNgayXuat", item.NgayTao.ToString("dd/MM/yyyy")),
                    new ReportParameter("pKhachHang", khachhang),
                    new ReportParameter("pDiaChiKhachHang", diachikhachhang),
                    new ReportParameter("pNhanVien", item.CreatedBy.TenDayDu),
                    new ReportParameter("pDienGiai", item.DienGiai),
                    new ReportParameter("pSoTien", item.Amount.ToString("#,##0")),
                    new ReportParameter("pSoTienBangChu", VNCurrency.ToString(item.Amount)),
                    new ReportParameter("pNoCu", nocu.ToString("#,##0")),
                    new ReportParameter("pConNo", (nocu - item.Amount).ToString("#,##0"))
                };
            }
            else if (item.LoaiPhieu == 2)
            {
                nocu       = GetNoNhaCungCap(item.NhaCungCap.MaNhaCungCap, item.NgayTao);
                reportPath = "~/Reports/RptPhieuChi.rdlc";
                if (item.NhaCungCap != null)
                {
                    khachhang       = item.NhaCungCap.TenNhaCungCap;
                    diachikhachhang = item.NhaCungCap.DiaChi;
                }

                listParam = new List <ReportParameter>()
                {
                    new ReportParameter("pNhaThuoc", nhathuoc.TenNhaThuoc),
                    new ReportParameter("pDiaChiNhaThuoc", nhathuoc.DiaChi),
                    new ReportParameter("pSDTNhaThuoc", nhathuoc.DienThoai),
                    new ReportParameter("pPhieuXuat", item.SoPhieu.ToString()),
                    new ReportParameter("pNgayXuat", item.NgayTao.ToString("dd/MM/yyyy")),
                    new ReportParameter("pKhachHang", khachhang),
                    new ReportParameter("pDiaChiKhachHang", diachikhachhang),
                    new ReportParameter("pNhanVien", item.CreatedBy.TenDayDu),
                    new ReportParameter("pDienGiai", item.DienGiai),
                    new ReportParameter("pSoTien", item.Amount.ToString("#,##0")),
                    new ReportParameter("pSoTienBangChu", VNCurrency.ToString(item.Amount)),
                    new ReportParameter("pNoCu", nocu.ToString("#,##0")),
                    new ReportParameter("pConNo", (nocu - item.Amount).ToString("#,##0"))
                };
            }
            else
            {
                string type    = "";
                string cusType = "";
                if (item.LoaiPhieu == Constants.LoaiPhieuThuChi.PhieuThuKhac)
                {
                    type    = "Thu khác";
                    cusType = "Người nộp";
                }
                else if (item.LoaiPhieu == Constants.LoaiPhieuThuChi.PhieuChiKhac)
                {
                    type    = "Chi khác";
                    cusType = "Người nhận";
                }
                else if (item.LoaiPhieu == Constants.LoaiPhieuThuChi.PhieuChiPhiKinhDoanh)
                {
                    type    = "Chi phí kinh doanh";
                    cusType = "Người nhận";
                }

                listParam = new List <ReportParameter>()
                {
                    new ReportParameter("pNhaThuoc", nhathuoc.TenNhaThuoc),
                    new ReportParameter("pDiaChiNhaThuoc", nhathuoc.DiaChi),
                    new ReportParameter("pSDTNhaThuoc", nhathuoc.DienThoai),
                    new ReportParameter("pPhieuXuat", item.SoPhieu.ToString()),
                    new ReportParameter("pNgayXuat", item.NgayTao.ToString("dd/MM/yyyy")),
                    new ReportParameter("pCusType", cusType),
                    new ReportParameter("pType", type),
                    new ReportParameter("pKhachHang", item.NguoiNhan),
                    new ReportParameter("pDiaChiKhachHang", item.DiaChi),
                    new ReportParameter("pNhanVien", item.CreatedBy.TenDayDu),
                    new ReportParameter("pDienGiai", item.DienGiai),
                    new ReportParameter("pSoTien", item.Amount.ToString("#,##0"))
                };
            }



            ReportViewer viewer = new ReportViewer();

            viewer.ProcessingMode         = ProcessingMode.Local;
            viewer.LocalReport.ReportPath = Server.MapPath(reportPath);
            viewer.LocalReport.DataSources.Add(new ReportDataSource());
            viewer.LocalReport.SetParameters(listParam);
            //var deviceInf = "<DeviceInfo><PageHeight>8.5in</PageHeight><PageWidth>11in</PageWidth></DeviceInfo>";
            byte[] bytes  = viewer.LocalReport.Render("PDF");
            Stream stream = new MemoryStream(bytes);

            return(File(stream, "application/pdf"));
        }
コード例 #4
0
        public void sendmail(string mailkhach, string hoten, string xungho, string sdt, int phidichvu, string diachigiaohang, int tiengiam)
        {
            if (ModelState.IsValid)
            {
                double bien = Convert.ToDouble(MySession.TongTien);

                string tien_vnd  = VNCurrency.ToString(bien);
                var    db_config = connect_entity.Configs.FirstOrDefault();
                string html      = "";
                html += "<h3>Xác nhận Đơn Hàng Của Quý Khách Hàng </h3><br/><br/>";
                html += "Xin chào <b>" + xungho + " " + hoten + " </b><br/><br/>";
                html += "<b> Địa Chỉ Giao Hàng Quý Khách: </b>" + diachigiaohang + " <br/><br/>";
                html += "Cảm ơn quý khách đã mua hàng . Mã số xác nhận đơn hàng của quý khách là " + sdt + " <br/><br/>";
                html += "<table  cellpadding='1' cellspacing='1' padding='5' width='100%'   style='text-align:left; margin-bottom: 25px;border:1px solid #ccc;'>";
                html += "<tr height='30' style='background:#f0f0f0; height:30px;border-bottom:1px solid #ccc; '><th> Sản phẩm</th> <th>Mã sản phẩm</th><th> Đơn giá</th><th>Số lượng</th><th>Màu sắc</th><th> Thành tiền</th> </tr>";
                if (MySession.GioHang != null)
                {
                    foreach (var item in MySession.GioHang)
                    {
                        html += "<tr style='border-bottom:1px solid #ccc; text-align:left; height:30px; padding:5px;'>";
                        html += "<td>" + item.TenSanPham + "</td>";
                        html += "<td> Thoitrangdepxinh.vn-" + item.IDsanpham + "</td>";
                        html += "<td>" + item.Giaban + "</td>";
                        html += "<td>" + item.SoLuong + "</td>";
                        html += "<td>" + item.Mausac + "</td>";
                        html += "<td>" + string.Format("{0:#,##0}", item.TongTien) + " VND</td>";
                        html += "</tr>";
                    }

                    html += " <tr>  <th> Tổng tiền" + MySession.TongTien + " VND<td>";
                    html += "  </td></tr>    </table><br/>";
                    html += "Xin quý khách vui lòng thanh toán <b>" + string.Format("{0:0,00}", MySession.TongTien) + " VND</b>, <b>Đọc thành chữ:</b> " + tien_vnd + "<br/><br/>";
                    html += "Bạn có thể thanh toán qua ATM với số tài khoản vào một trong các tài khoản ngân hàng sau (" + db_config.PaymentTerms + ") Thuộc Chi Nhánh Ngân Hàng (" + db_config.GoogleId + ") Chủ Tài Khoản (" + db_config.PlaceBody + ") <br/><br/>";
                    html += " Chân thành cám ơn quý khách đã mua sắm, và chúng tôi hi vọng quý khách sẽ hài lòng với sản phẩm mình đã chọn.<br/>";
                }



                string smtpUserName = db_config.Mail_Noreply;
                string smtpPassword = db_config.Mail_Password;
                string smtpHost     = db_config.Mail_Smtp;                  //smtp.gmail.com
                int    smtpPort     = Convert.ToInt32(db_config.Mail_Port); //25

                string emailTo = mailkhach;                                 // Khi có liên hệ sẽ gửi về thư của mình
                string subject = db_config.PlaceHead;
                string body    = html;



                EmailService service = new EmailService();

                bool kq = service.Send(smtpUserName, smtpPassword, smtpHost, smtpPort,
                                       emailTo, subject, body);

                if (kq)
                {
                    ModelState.AddModelError("", "Cảm ơn bạn đã liên hệ với chúng tôi.");
                }
                else
                {
                    ModelState.AddModelError("", "Gửi tin nhắn thất bại, vui lòng thử lại.");
                }
            }
        }