public ActionResult ChiTietHopDong(int Id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.CVLeTanHopDong))
            {
                return(AccessDeniedView());
            }
            var model   = new XuLyHopDongModel();
            var hopdong = _chonveService.GetHopDongById(Id);

            if (hopdong == null)
            {
                throw new ArgumentException(" no result found with th specified id");
            }
            model.Id              = hopdong.Id;
            model.MaHopDong       = hopdong.MaHopDong;
            model.TenHopDong      = hopdong.TenHopDong;
            model.LoaiHopDongID   = hopdong.LoaiHopDongID;
            model.LoaiHopDongText = hopdong.LoaiHopDong.GetLocalizedEnum(_localizationService, _workContext);
            model.TrangThaiID     = hopdong.TrangThaiID;
            model.TrangThaiText   = hopdong.TrangThai.GetLocalizedEnum(_localizationService, _workContext);
            model.NhaXeID         = hopdong.NhaXeID;
            model.NhaXeText       = _nhaxeService.GetNhaXeById(model.NhaXeID).TenNhaXe;
            model.ThongTin        = hopdong.ThongTin;
            model.NgayKichHoat    = hopdong.NgayKichHoat;
            model.TrangThaiID     = hopdong.TrangThaiID;
            model.NguoiTaoID      = hopdong.NguoiTaoID;
            model.TenNguoiTao     = _customerService.GetCustomerById(model.NguoiTaoID).GetFullName();
            model.KhachHangID     = hopdong.KhachHangID;
            model.NguoiDuyetID    = hopdong.NguoiDuyetID;
            model.TenNguoiDuyet   = _customerService.GetCustomerById(model.NguoiDuyetID).GetFullName();
            prepareHopDongKhachHang(model);
            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult SuaNhaXe(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.QLNhaXe))
            {
                return(AccessDeniedView());
            }
            var nhaxe = _nhaxeService.GetNhaXeById(id);

            if (nhaxe == null || nhaxe.isDelete || nhaxe.NguoiTaoID != _workContext.CurrentCustomer.Id)
            {
                //No manufacturer found with the specified id
                return(RedirectToAction("ListNhaXe"));
            }
            var model = nhaxe.ToModel();

            //default values
            PrepareNhaXeModel(model);

            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult NhaXeInfoConnect(int nhaxeId)
        {
            var nhaxemodel = new NhaXeInfoModel();
            var nhaxe      = _nhaxeService.GetNhaXeById(nhaxeId);

            nhaxemodel.TenNhaXe   = GetLabel("nhaxe") + " " + nhaxe.TenNhaXe;
            nhaxemodel.HanhTrinhs = _hanhtrinhService.GetAllHanhTrinhByNhaXeId(nhaxeId).Select(c =>
            {
                var _hanhtrinh                = new NhaXeInfoModel.HanhTrinhInNhaXeModel();
                _hanhtrinh.Id                 = c.Id;
                _hanhtrinh.Mota               = c.MoTa;
                _hanhtrinh.HangXe             = GetLabel("vexe") + " " + nhaxe.TenNhaXe;
                var _lichtrinh                = _hanhtrinhService.GetAllLichTrinhByHanhTrinhId(c.Id).First();
                _hanhtrinh.LoaiXe             = _xeinfoService.GetById(_lichtrinh.LoaiXeId).TenLoaiXe;
                _hanhtrinh.GiaVeToanTuyenText = _priceFormatter.FormatPrice(_lichtrinh.GiaVeToanTuyen, true, false);
                _hanhtrinh.SoChuyenTrongNgay  = _hanhtrinhService.GetAllLichTrinhByHanhTrinhId(c.Id).Count() + GetLabel("Chuyen/ngay");
                return(_hanhtrinh);
            }).ToList();
            return(View(nhaxemodel));
        }
Ejemplo n.º 4
0
        public ActionResult ChiTietHopDong(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.QLHopDong))
            {
                return(AccessDeniedView());
            }
            var model = new XuLyHopDongModel();

            if (_permissionService.Authorize(StandardPermissionProvider.CVSaleManager))
            {
                model.isManager = true;
                PrepareListGiaHan(model);
            }
            model.IdCurrent = _workContext.CurrentCustomer.Id;
            var hopdong = _chonveService.GetHopDongById(id);

            if (hopdong == null)
            {
                throw new ArgumentException(" no result found with th specified id");
            }
            if (hopdong.NguoiTaoID == _workContext.CurrentCustomer.Id || model.isManager == true)
            {
                model.Id              = hopdong.Id;
                model.MaHopDong       = hopdong.MaHopDong;
                model.TenHopDong      = hopdong.TenHopDong;
                model.LoaiHopDongID   = hopdong.LoaiHopDongID;
                model.LoaiHopDongText = hopdong.LoaiHopDong.GetLocalizedEnum(_localizationService, _workContext);
                model.TrangThaiID     = hopdong.TrangThaiID;
                model.TrangThaiText   = hopdong.TrangThai.GetLocalizedEnum(_localizationService, _workContext);
                model.NhaXeID         = hopdong.NhaXeID;
                model.NhaXeText       = _nhaxeService.GetNhaXeById(model.NhaXeID).TenNhaXe;
                model.ThongTin        = hopdong.ThongTin;
                model.TrangThaiID     = hopdong.TrangThaiID;
                model.NguoiTaoID      = hopdong.NguoiTaoID;
            }

            return(View(model));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Thanh toan cac ve xe da chon, dua vao sesssion id de lay thong tin ve da chon mua
        /// </summary>
        /// <returns></returns>
        public ActionResult VeXeThanhToan()
        {
            if (Session["DAT_MUA_VE_XE_ID"] == null)
            {
                return(RedirectToRoute("HomePage"));
            }
            //kiem tra dang nhap hay chua
            if (!_workContext.CurrentCustomer.IsRegistered())
            {
                return(new HttpUnauthorizedResult());
            }
            //lay thong tin nguon ve xe, tu session id
            var model = new ThanhToanVeXeModel();

            model.MaXacThuc = "0";
            //thiet dat thong tin noi nhan
            var countries = new List <Nop.Core.Domain.Directory.Country>();

            countries.Add(_countryService.GetCountryById(NhaXesController.CountryID));

            var diachigiaohang = _workContext.CurrentCustomer.ShippingAddress;

            if (_workContext.CurrentCustomer.Addresses.Count > 0)
            {
                diachigiaohang = _workContext.CurrentCustomer.Addresses.First();
            }

            model.diachigiaohang.PrepareModel(
                address: diachigiaohang,
                excludeProperties: false,
                addressSettings: _addressSettings,
                localizationService: _localizationService,
                stateProvinceService: _stateProvinceService,
                diachiService: _diachiService,
                addressAttributeFormatter: _addressAttributeFormatter,
                loadCountries: () => countries);
            if (diachigiaohang == null)
            {
                model.diachigiaohang.FirstName   = _workContext.CurrentCustomer.GetAttribute <string>(SystemCustomerAttributeNames.FirstName);
                model.diachigiaohang.LastName    = _workContext.CurrentCustomer.GetAttribute <string>(SystemCustomerAttributeNames.LastName);
                model.diachigiaohang.FullName    = string.Format("{0} {1}", model.diachigiaohang.FirstName, model.diachigiaohang.LastName);
                model.diachigiaohang.Email       = _workContext.CurrentCustomer.Email;
                model.diachigiaohang.PhoneNumber = _workContext.CurrentCustomer.GetAttribute <string>(SystemCustomerAttributeNames.Phone);
            }
            //lay thong tin ve xe
            model.phoiveinfos = _phoiveService.GetPhoiVeGiuChoBySession(Session["DAT_MUA_VE_XE_ID"]);

            //cho thanh toan qua lau, nen het han giu cho ve
            if (model.phoiveinfos.Count == 0)
            {
                return(RedirectToRoute("HomePage"));
            }
            model.nguonvexeinfo = _vexeService.GetNguonVeXeById(model.phoiveinfos[0].NguonVeXeId.GetValueOrDefault(0));
            model.nhaxeinfo     = _nhaxeService.GetNhaXeById(model.nguonvexeinfo.NhaXeId);
            model.NgayDi        = model.phoiveinfos[0].NgayDi;
            model.NgayDi        = model.NgayDi.AddHours(model.nguonvexeinfo.ThoiGianDi.Hour).AddMinutes(model.nguonvexeinfo.ThoiGianDi.Minute);
            model.NgayVe        = model.NgayDi.AddHours(Convert.ToDouble(model.nguonvexeinfo.LichTrinhInfo.SoGioChay));
            model.TongTien      = decimal.Zero;
            model.KyHieuGhe     = "";
            foreach (var pv in model.phoiveinfos)
            {
                if (string.IsNullOrEmpty(model.KyHieuGhe))
                {
                    model.KyHieuGhe = pv.sodoghexequytac.Val;
                }
                else
                {
                    model.KyHieuGhe += "," + pv.sodoghexequytac.Val;
                }
                model.TongTien += pv.GiaVeHienTai;
            }

            return(View(model));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Print orders to PDF
        /// </summary>
        /// <param name="stream">Stream</param>
        /// <param name="orders">Orders</param>
        /// <param name="languageId">Language identifier; 0 to use a language used when placing an order</param>
        public virtual void PrintOrdersToPdf(Stream stream, PhoiVe _phoive, int languageId = 0)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            if (_phoive == null)
            {
                throw new ArgumentNullException("Không có vé");
            }
            //get thong tin nguon ve
            var order = _orderService.GetOrderById(_phoive.OrderId);

            if (order == null)
            {
                throw new ArgumentNullException("Không có đơn hàng");
            }
            var nguonvexe = _hanhtrinhService.GetNguonVeXeById(_phoive.NguonVeXeId);

            if (nguonvexe.ParentId > 0)
            {
                nguonvexe = _hanhtrinhService.GetNguonVeXeById(_phoive.NguonVeXeConId);
            }
            //get thong tin nha xe
            var nhaxe = _nhaxeService.GetNhaXeById(nguonvexe.NhaXeId);

            var diachi = _diachiService.GetById(nhaxe.DiaChiID);
            //get thong tin xe xuan ben
            var xexuatbenInfo = _nhaxeService.GetHistoryXeXuatBenByNguonVeId(nguonvexe.Id, _phoive.NgayDi);
            var TenXe         = "";
            var BienSo        = "";

            if (xexuatbenInfo != null)
            {
                var xeInfo = _xeinfoService.GetXeInfoById(xexuatbenInfo.XeVanChuyenId.GetValueOrDefault(0));
                TenXe  = xeInfo.TenXe;
                BienSo = xeInfo.BienSo;
            }


            //logo
            var logoPicture = _pictureService.GetPictureById(nhaxe.LogoID);
            var logoExists  = logoPicture != null;
            var doc         = new Document();
            var pdfWriter   = PdfWriter.GetInstance(doc, stream);

            doc.Open();
            //fonts
            var titleFont = GetFont();

            titleFont.Size = BaseFont.SUPERSCRIPT_SIZE;
            //font ten nha xe
            var TenNhaXe = GetFont();

            TenNhaXe.SetStyle("initial");

            //font thong tin
            var InfoFont = GetFont();

            InfoFont.Size = 14;
            var font = GetFont();

            font.Size = 13;

            var pdfSettingsByStore = _settingContext.LoadSetting <PdfSettings>(order.StoreId);
            var lang = _workContext.WorkingLanguage;

            //header
            float[] widths     = { 3, 7 };
            var     HeaderVeIn = new PdfPTable(widths);

            HeaderVeIn.DefaultCell.Border = Rectangle.NO_BORDER;

            if (logoExists)
            {
                var logoFilePath = _pictureService.GetThumbLocalPath(logoPicture, 0, false);
                var logo         = Image.GetInstance(logoFilePath);
                logo.ScaleToFit(200, 100);

                PdfPCell CellLeft = new PdfPCell(logo);
                CellLeft.Border      = Rectangle.NO_BORDER;
                CellLeft.FixedHeight = 80f;
                HeaderVeIn.AddCell(CellLeft);
            }
            PdfPCell CellRight = new PdfPCell();

            CellRight.Border = Rectangle.NO_BORDER;
            var ParaTenNhaXe = new Paragraph(string.Format(_localizationService.GetResource("PDFInvoice.TenNhaXe", lang.Id),
                                                           nhaxe.TenNhaXe), font);

            ParaTenNhaXe.Alignment = Element.ALIGN_RIGHT;
            CellRight.AddElement(ParaTenNhaXe);
            var ParaDiaChi = new Paragraph(string.Format(_localizationService.GetResource("PDFInvoice.DiaChiNhXe", lang.Id),
                                                         diachi.DiaChi1 + " " + diachi.DiaChi2), font);

            ParaDiaChi.Alignment = Element.ALIGN_RIGHT;
            CellRight.AddElement(ParaDiaChi);
            var ParaSdt = new Paragraph(string.Format(_localizationService.GetResource("PDFInvoice.SDTNhaXe", lang.Id),
                                                      nhaxe.DienThoai), font);

            ParaSdt.Alignment = Element.ALIGN_RIGHT;
            CellRight.AddElement(ParaSdt);
            HeaderVeIn.AddCell(CellRight);
            doc.Add(HeaderVeIn);
            doc.Add(new Paragraph(""));
            doc.Add(new Paragraph(""));
            //add line
            var line = new iTextSharp.text.pdf.draw.LineSeparator(0, 100, BaseColor.GRAY, Element.ALIGN_CENTER, 1);

            doc.Add(new Chunk(line));
            //content
            Paragraph vexekhach = new Paragraph(_localizationService.GetResource("PDFInvoice.VeXeKhach", lang.Id), titleFont);

            vexekhach.Alignment = Element.ALIGN_CENTER;
            doc.Add(vexekhach);
            doc.Add(new Paragraph(""));
            doc.Add(new Paragraph(""));
            var Table1 = new PdfPTable(2);

            float[] widthTable1 = new float[] { 1f, 2f };
            Table1.SetWidths(widthTable1);
            Table1.RunDirection       = GetDirection(lang);
            Table1.DefaultCell.Border = Rectangle.NO_BORDER;
            Table1.AddCell(new Paragraph(_localizationService.GetResource("PDFInvoice.Tuyen", lang.Id), font));
            Table1.AddCell(new Paragraph(nguonvexe.TenDiemDon + " -- " + nguonvexe.TenDiemDen, InfoFont));
            Table1.AddCell(new Paragraph(_localizationService.GetResource("PDFInvoice.GiaVe", lang.Id), font));
            Table1.AddCell(new Paragraph(nguonvexe.LichTrinhInfo.GiaVeToanTuyen.ToString() + " VNĐ", InfoFont));
            doc.Add(Table1);
            //add ghe,xe
            var Table2 = new PdfPTable(4);

            float[] widthTable2 = new float[] { 1f, 2f, 1f, 2f };
            Table2.SetWidths(widthTable2);
            Table2.RunDirection       = GetDirection(lang);
            Table2.DefaultCell.Border = Rectangle.NO_BORDER;
            Table2.AddCell(new Paragraph(_localizationService.GetResource("PDFInvoice.SoXe", lang.Id), font));
            Table2.AddCell(new Paragraph(TenXe + "/" + BienSo, InfoFont));
            Table2.AddCell(new Paragraph(_localizationService.GetResource("PDFInvoice.SoGhe", lang.Id), font));
            Table2.AddCell(new Paragraph(_phoive.sodoghexequytac.Val + " ( Tầng" + _phoive.sodoghexequytac.Tang + ")", InfoFont));
            doc.Add(Table2);
            //add thoi gian khoi hanh
            var Table3 = new PdfPTable(4);

            float[] widthTable3 = new float[] { 2f, 1f, 1f, 2f };
            Table3.SetWidths(widthTable3);
            Table3.RunDirection       = GetDirection(lang);
            Table3.DefaultCell.Border = Rectangle.NO_BORDER;
            Table3.AddCell(new Paragraph(_localizationService.GetResource("PDFInvoice.ThoiGianDi", lang.Id), font));
            Table3.AddCell(new Paragraph(nguonvexe.ThoiGianDi.ToString("HH:mm"), InfoFont));
            Table3.AddCell(new Paragraph(_localizationService.GetResource("PDFInvoice.NgayDi", lang.Id), font));
            Table3.AddCell(new Paragraph(_phoive.NgayDi.ToString("dd/MM/yyyy"), InfoFont));
            doc.Add(Table3);
            //add footer
            var FooterNgayBan = new Paragraph("Ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year, font);

            FooterNgayBan.Alignment = Element.ALIGN_RIGHT;
            var FooterNguoiBanTitle = new Paragraph("Người bán vé", font);

            FooterNguoiBanTitle.Alignment = Element.ALIGN_RIGHT;
            var firtname          = _workContext.CurrentCustomer.GetAttribute <string>(SystemCustomerAttributeNames.FirstName);
            var lastname          = _workContext.CurrentCustomer.GetAttribute <string>(SystemCustomerAttributeNames.LastName);
            var FooterTenNguoiBan = new Paragraph(firtname + " " + lastname, font);

            FooterTenNguoiBan.Alignment = Element.ALIGN_RIGHT;
            var Table4 = new PdfPTable(1);

            Table4.DefaultCell.Border = Rectangle.NO_BORDER;
            PdfPCell CellFooter = new PdfPCell();

            CellFooter.Border = Rectangle.NO_BORDER;
            CellFooter.AddElement(FooterNgayBan);
            CellFooter.AddElement(FooterNguoiBanTitle);
            CellFooter.AddElement(FooterTenNguoiBan);
            Table4.AddCell(CellFooter);
            doc.Add(Table4);
            doc.Add(new Paragraph(" "));
            doc.NewPage();
            doc.Close();
        }