Example #1
0
        // GET: /Report/
        public ActionResult PhieuGui(string mailerId)
        {
            var mailer = db.MAILER_GETINFO_BYLISTID(mailerId).Select(p => new MailerRpt()
            {
                SenderName           = p.SenderName,
                MailerID             = "*" + p.MailerID + "*",
                SenderID             = p.SenderID,
                SenderPhone          = p.SenderPhone,
                SenderAddress        = p.SenderAddress,
                RecieverName         = p.RecieverName,
                RecieverAddress      = p.RecieverAddress,
                RecieverPhone        = p.RecieverPhone,
                ReceiverDistrictName = p.ReceiDistrictName,
                ReceiverProvinceName = p.RecieProvinceName,
                SenderDistrictName   = p.SendDistrictName,
                SenderProvinceName   = p.SendProvinceName,
                PostOfficeName       = p.PostOfficeName,
                TL           = p.MerchandiseID == "T" ? "X" : ".",
                HH           = p.MerchandiseID == "H" ? "X" : ".",
                MH           = p.MerchandiseID == "M" ? "X" : ".",
                N            = p.MailerTypeID == "SN" ? "X" : ".",
                DB           = p.MerchandiseID == "ST" ? "X" : ".",
                TK           = p.MerchandiseID == "TK" ? "X" : ".",
                COD          = p.COD != null ? p.COD.Value.ToString("C", MNPOST.Utils.Cultures.VietNam) : "0",
                Weight       = p.Weight + "",
                Quantity     = p.Quantity + "",
                Amount       = p.Amount != null ? p.Amount.Value.ToString("C", MNPOST.Utils.Cultures.VietNam) : "0",
                Price        = p.Price != null ? p.Price.Value.ToString("C", MNPOST.Utils.Cultures.VietNam) : "0",
                ServicePrice = p.PriceService != null ? p.PriceService.Value.ToString("C", MNPOST.Utils.Cultures.VietNam): "0"
            }).ToList();

            Stream stream = REPORTUTILS.GetReportStream(ReportPath.RptPhieuGui, mailer);

            return(File(stream, "application/pdf"));
        }
        public ActionResult ShowReport(string docid)
        {
            // lam như phân lấy dữ liệu thư viện
            Dictionary <string, string> textValues = new Dictionary <string, string>();
            var listmaster = db.AC_CustomerDebitVoucher.Where(p => p.DocumentID == docid).FirstOrDefault();

            textValues.Add("txtDocumentID", docid);
            textValues.Add("txtDebtMonth", DateTime.Parse(listmaster.DebtMonth.ToString()).ToString("MM/yyyy"));
            textValues.Add("txtGhiChu", listmaster.Description);
            textValues.Add("txtCustomerID", listmaster.CustomerGroupID);
            textValues.Add("txttotal", string.Format("{0:n0}", listmaster.ToTalAmount)); //tong tien

            //txttenkh
            var query =
                (from a in db.AC_CustomerDebitVoucher
                 join b in db.BS_CustomerGroups on a.CustomerGroupID equals b.CustomerGroupCode
                 where a.DocumentID == docid
                 select b.CustomerGroupName).FirstOrDefault();

            textValues.Add("txttenkh", query);
            //
            decimal totalprice = (from a in db.AC_CustomerDebitVoucherDetail
                                  where a.DocumentID == docid
                                  select a.Price).Sum();

            textValues.Add("txttongcuoc", string.Format("{0:n0}", totalprice));

            decimal discount = (from a in db.AC_CustomerDebitVoucherDetail
                                where a.DocumentID == docid
                                select a.Discount).Sum();

            textValues.Add("txtgiamtru", string.Format("{0:n0}", discount));

            decimal vat = (from a in db.AC_CustomerDebitVoucherDetail
                           where a.DocumentID == docid
                           select a.VATamount).Sum();

            textValues.Add("txtgiamtru", string.Format("{0:n0}", discount));
            textValues.Add("txtvat", string.Format("{0:n0}", vat));

            Dictionary <string, Dictionary <string, string> > values = new Dictionary <string, Dictionary <string, string> >();

            values.Add("Section2", textValues); //

            //lay data
            var results = (from mm in db.MM_Mailers
                           join d in db.AC_CustomerDebitVoucherDetail
                           on mm.MailerID equals d.MailerID
                           join p in db.BS_Provinces
                           on mm.RecieverProvinceID equals p.ProvinceID
                           where d.DocumentID == docid
                           select new
            {
                SoPhieu = mm.MailerID,
                NgayGui = mm.AcceptDate,
                NoiDen = p.ProvinceCode,
                DichVu = mm.MailerTypeID,
                SoLuong = mm.Quantity,
                TrongLuong = mm.Weight,
                CuocPhi = d.Price,
                PhuPhi = d.PriceService,
                ThanhTien = d.BfVATamount
            }).ToList();



            Stream stream = REPORTUTILS.GetReportStream(ReportPath.RptAC_CustomerDebitDetails, results);

            return(File(stream, "application/pdf"));
        }