示例#1
0
        public IActionResult NhaXe(string id, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Server error. Please try again or request technical support");
                if (String.IsNullOrEmpty(returnUrl))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(Redirect(returnUrl));
                }
            }
            NhaXe res = context.NhaXe.Find(id);

            if (res == null)
            {
                ModelState.AddModelError("", "Không tìm thấy nhà xe với mã " + id);
                if (String.IsNullOrEmpty(returnUrl))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(Redirect(returnUrl));
                }
            }
            return(View("NhaXe", res));
        }
示例#2
0
        public IActionResult UpdateCoBan(NhaXe nhaxe)
        {
            //flag = 0: create
            //flag = 1: update
            //flag = 2: delete
            if (!ModelState.IsValid)
            {
                return(View(nhaXe));
            }
            NhaXe _nhaXe = null;

            try
            {
                _nhaXe = _context.NhaXe.Find(nhaxe.MaNhaXe);
                if (_nhaXe == null)
                {
                    throw new Exception("Không tìm thấy nhà xe");
                }
                _nhaXe = nhaXe;
                _context.NhaXe.Update(_nhaXe);
                _context.SaveChanges();
            }
            catch (Exception err)
            {
                ModelState.AddModelError("", err.Message);
            }
            return(View(_nhaXe));
        }
示例#3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string url = String.IsNullOrEmpty(Request["url"]) ? "Home" : Request["url"].ToString();

        this.url = url;
        nurl     = Request.QueryString["nUrl"];
        if (string.IsNullOrEmpty(nurl))
        {
            lst.Visible    = true;
            detail.Visible = false;
        }
        else
        {
            detail.Visible = true;
            lst.Visible    = false;
            nx             = new NhaxeRepository().Find(int.Parse(nurl));
        }
        if (!IsPostBack)
        {
            foreach (var item in getTinhHaveNhaxe())
            {
                ddlTinh.Items.Add(new ListItem(item.TenTinh, item.MaTinh.ToString()));
            }
            ddlTinh.DataBind();
        }
    }
示例#4
0
        public IActionResult UpdateCoBan(NhaXe nhaXe)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception("Thông tin không hợp lệ");
                }
                nhaXe = getAssociatedNhaXe(uManager).Result;
                ViewData["TenNhaXe"] = nhaXe.TenNhaXe;
                NhaXe _nhaXe = _context.NhaXe.Find(nhaXe.MaNhaXe);
                if (_nhaXe == null)
                {
                    throw new Exception("Không tìm thấy nhà xe");
                }
                _nhaXe.TenNhaXe     = nhaXe.TenNhaXe;
                _nhaXe.SoLuongXe    = nhaXe.SoLuongXe;
                _nhaXe.Sdt          = nhaXe.Sdt;
                _nhaXe.MauBieuTuong = nhaXe.MauBieuTuong;
                _nhaXe.DiaChi       = nhaXe.DiaChi;

                _context.NhaXe.Update(_nhaXe);
                _context.SaveChanges();
            }
            catch (Exception err) { ModelState.AddModelError("", err.Message); }
            return(View("CoBan", nhaXe));
        }
示例#5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ID = Request.QueryString["id"] != ""? int.Parse(Request.QueryString["id"]):0;
        string sql = "SELECT matinh as id, tentinh as text from TinhThanh";

        Value.BindToDropdown(Tinh, UpdateData.UpdateBySql(sql).Tables[0]);
        nx = new NhaxeRepository().Find(ID);
        if (!IsPostBack)
        {
            Tennhaxe.Text         = nx.Tennhaxe;
            Sodienthoai.Text      = nx.Sodienthoai;
            Soluongxe.Text        = nx.Soluongxe.ToString();
            Trusochinh.Text       = nx.Trusochinh;
            Gioithieuchitiet.Text = nx.Gioithieuchitiet;
            Gioithieungan.Text    = nx.Gioithieungan;
            Nguoidaidien.Text     = nx.Nguoidaidien;
            txtImg.Text           = nx.Anh;
            catimg.Src            = nx.Anh;
            for (int i = 0; i < Tinh.Items.Count; i++)
            {
                if (Tinh.Items[i].Value == nx.Tinh.ToString())
                {
                    Tinh.Items[i].Selected = true;
                }
            }
        }
    }
示例#6
0
        public IActionResult XeKhach()
        {
            nhaXe = getAssociatedNhaXe(uManager);
            ViewData["TenNhaXe"] = nhaXe.TenNhaXe;
            var xkList = from xk in _context.XeKhach where xk.MaNhaXe == nhaXe.MaNhaXe select xk;

            return(View("XeKhach", xkList.ToArray()));
        }
示例#7
0
 /// <summary>
 /// Updates the NhaXe
 /// </summary>
 /// <param name="NhaXe">NhaXe</param>
 public virtual void UpdateNhaXe(NhaXe _item)
 {
     if (_item == null)
     {
         throw new ArgumentNullException("NhaXe");
     }
     _item.LastUpdate = DateTime.Now;
     _nhaxeRepository.Update(_item);
 }
示例#8
0
        public virtual void DeleteNhaXe(NhaXe _item)
        {
            if (_item == null)
            {
                throw new ArgumentNullException("NhaXe");
            }

            _item.isDelete = true;
            UpdateNhaXe(_item);
        }
示例#9
0
        public IActionResult TtDangNhap()
        {
            nhaXe = getAssociatedNhaXe(uManager).Result;
            ViewData["TenNhaXe"] = nhaXe.TenNhaXe;
            string _role = uManager.GetRolesAsync(_user).Result.FirstOrDefault();
            TtDangNhapViewModel model = new TtDangNhapViewModel()
            {
                Qtv  = _user,
                Role = _role
            };

            return(View(model));
        }
示例#10
0
 /// <summary>
 /// Inserts NhaXe
 /// </summary>
 /// <param name="NhaXe">NhaXe</param>
 public virtual void InsertNhaXe(NhaXe _item)
 {
     if (_item == null)
     {
         throw new ArgumentNullException("NhaXe");
     }
     _item.CreatedOn        = DateTime.Now;
     _item.LastUpdate       = DateTime.Now;
     _item.DieuKhoanGuiHang = "";
     _nhaxeRepository.Insert(_item);
     _item.MaNhaXe = string.Format("NX{0}", _item.Id.ToString().PadLeft(10, '0'));
     _nhaxeRepository.Update(_item);
 }
示例#11
0
        public IActionResult TaiXe()
        {
            nhaXe = getAssociatedNhaXe(uManager);
            ViewData["TenNhaXe"] = nhaXe.TenNhaXe;
            var          xkList    = from xk in _context.XeKhach where xk.MaNhaXe == nhaXe.MaNhaXe select xk;
            List <TaiXe> taiXeList = new List <TaiXe>();

            foreach (XeKhach xk in xkList)
            {
                taiXeList.Add(_context.TaiXe.Find(xk.MaTaiXe));
            }
            return(View("TaiXe", taiXeList.ToArray()));
        }
示例#12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        BindData();
        string CompanyId  = Request.QueryString["CompanyId"];
        string createvote = Request.QueryString["Create"];

        if (!string.IsNullOrEmpty(CompanyId))
        {
            NhaXe NhaXe = new NhaXe();
            NhaXe          = new NhaxeRepository().Find(Convert.ToInt32(CompanyId));
            namenhaxe.Text = NhaXe.Tennhaxe;

            StringBuilder str   = new StringBuilder();
            string        addva = "";
            addva      += "<input type=\"hidden\" name=\"CompanyId\" id=\"CompanyId\" value=\"" + CompanyId + "\"/>";
            ltriph.Text = addva;
        }
        if (!string.IsNullOrEmpty(createvote))
        {
            string name    = Request["firstName"];
            string email   = Request["email"];
            string comment = Request["comment"];
            string CompId  = Request["CompanyId"];

            string OverallRating        = Request["OverallRating"];
            string VehicleQualityRating = Request["VehicleQualityRating"];
            string OnTimeRating         = Request["OnTimeRating"];
            string ServiceRating        = Request["ServiceRating"];

            int RatingAve = (Convert.ToInt32(OverallRating) + Convert.ToInt32(VehicleQualityRating) + Convert.ToInt32(OnTimeRating) + Convert.ToInt32(ServiceRating)) / 4;

            Hashtable tbIn = new Hashtable();

            tbIn.Add("CompanyId", CompId);
            tbIn.Add("OverallRating", OverallRating);
            tbIn.Add("QualityRating", VehicleQualityRating);
            tbIn.Add("OnTimeRating", OnTimeRating);
            tbIn.Add("ServiceRating", ServiceRating);
            tbIn.Add("RatingAverage", Convert.ToString(RatingAve));

            tbIn.Add("Comment_Content", comment);
            tbIn.Add("Comment_FullName", name);
            tbIn.Add("Comment_Email", email);

            bool _insert = UpdateData.Insert("tbl_Comment", tbIn);
            if (_insert)
            {
                Response.Redirect("/");
            }
        }
    }
示例#13
0
        public IActionResult NhaXe(string id)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Mã nhà xe không hợp lệ");
                return(RedirectToAction("Index"));
            }
            NhaXe res = context.NhaXe.Find(id);

            if (res == null)
            {
                ModelState.AddModelError("", "Không tìm thấy nhà xe với mã " + id);
                return(RedirectToAction("Index"));
            }
            return(View("NhaXe", res));
        }
        public IActionResult NhaXe()
        {
            NhaXe  nhaXeCuoi   = _context.NhaXe.LastOrDefault();
            string lastNhaXeId = null;

            if (nhaXeCuoi != null)
            {
                lastNhaXeId = nhaXeCuoi.MaNhaXe;
            }
            else
            {
                lastNhaXeId = "NX00000000";
            }

            ViewBag.NextNhaXeId = String.Concat("NX", IncrementString(lastNhaXeId.Substring(2)));
            NhaXe[] model = _context.NhaXe.ToArray();
            return(View(model));
        }
示例#15
0
        public IActionResult XeKhach()
        {
            nhaXe = getAssociatedNhaXe(uManager).Result;
            ViewData["TenNhaXe"] = nhaXe.TenNhaXe;
            var xkList = from xk in _context.XeKhach
                         where xk.MaNhaXe == nhaXe.MaNhaXe
                         select xk;
            XeKhach xeKhachCuoi   = _context.XeKhach.LastOrDefault();
            string  lastXeKhachId = null;

            if (xeKhachCuoi != null)
            {
                lastXeKhachId = xeKhachCuoi.MaXeKhach;
            }
            else
            {
                lastXeKhachId = "XK00000000";
            }
            ViewBag.NextXeKhachId = String.Concat("XK", Utils.IncrementString(lastXeKhachId.Substring(2)));
            return(View("XeKhach", xkList.ToArray()));
        }
示例#16
0
        public ActionResult Login(string Email, string Password)
        {
            //BienSoXe = BienSoXe + "@chonve.vn";
            var loginresult = _customerRegistrationService.ValidateCustomer(Email, Password);

            if (loginresult != CustomerLoginResults.Successful)
            {
                return(ErrorOccured("Tài khoản hoặc mật khẩu không đúng !"));
            }
            _customer = _customerService.GetCustomerByEmail(Email);

            //kiem tra co quyen ko
            if (!isRightAccess())
            {
                return(ErrorOccured("Bạn không có quyền vào chức năng này !"));
            }
            //kiem tra cac thong tin nha xe
            NhaXe currentNhaXe = _nhaxeService.GetNhaXeByCustommerId(currentCustomer.Id);

            if (currentNhaXe == null)
            {
                return(ErrorOccured("Không xác định nhà xe !"));
            }
            //luu nhat ky
            _customerActivityService.InsertActivity("PublicStore.Login", "Tài khoản nhà xe đăng nhập", currentCustomer);
            //lay thong tin van phong
            _nhanvien = _nhanvienService.GetByCustomerId(currentCustomer.Id);
            //OK, lay thong tin va truyen xuong client
            var loginInfo = new
            {
                Id         = currentCustomer.Id,
                NhaXeId    = currentNhaXe.Id,
                GuidId     = _settings.ApiToken,
                FullName   = currentCustomer.GetFullName(),
                TenNhaXe   = currentNhaXe.TenNhaXe,
                VanPhongId = _nhanvien.VanPhongID.GetValueOrDefault(0)
            };

            return(Successful(loginInfo));
        }
示例#17
0
        public IActionResult TaiXe()
        {
            nhaXe = getAssociatedNhaXe(uManager).Result;
            ViewData["TenNhaXe"] = nhaXe.TenNhaXe;
            var s = from xk in _context.XeKhach
                    from tx in _context.TaiXe
                    where xk.MaNhaXe == nhaXe.MaNhaXe && xk.MaTaiXe == tx.MaTaiXe
                    select tx;
            TaiXe  taiXeCuoi   = _context.TaiXe.LastOrDefault();
            string lastTaiXeId = null;

            if (taiXeCuoi != null)
            {
                lastTaiXeId = taiXeCuoi.MaTaiXe;
            }
            else
            {
                lastTaiXeId = "TX00000000";
            }
            ViewBag.NextTaiXeId = String.Concat("TX", Utils.IncrementString(lastTaiXeId.Substring(2)));
            return(View("TaiXe", s.ToArray()));
        }
        public async Task <IActionResult> UpdateNhaXe(NhaXe NhaXe)
        {
            List <string> messages = new List <string>();

            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception("Thông tin không hợp lệ");
                }
                NhaXe _NhaXe = await _context.NhaXe.FindAsync(NhaXe.MaNhaXe);

                if (_NhaXe == null)
                {
                    throw new Exception("Không tìm thấy nhà xe");
                }
                _NhaXe.MaNhaXe = NhaXe.MaNhaXe;
                _context.NhaXe.Update(_NhaXe);
                _context.SaveChanges();
                messages.Add("redirect");
                messages.Add(Url.Action("NhaXe"));
            }
            catch (Exception err)
            {
                messages.Add(err.Message);
                foreach (var value in ModelState.Values)
                {
                    if (value.ValidationState == ModelValidationState.Invalid)
                    {
                        foreach (var modelErr in value.Errors)
                        {
                            messages.Add(modelErr.ErrorMessage);
                        }
                    }
                }
            }
            return(Json(messages.ToArray()));
        }
        public async Task <IActionResult> CreateNhaXe(NhaXe NhaXe)
        {
            List <string> messages = new List <string>();

            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception("Thông tin không hợp lệ");
                }
                string meta = NhaXe.MaNhaXe.Substring(0, 2);
                if (meta != "NX")
                {
                    throw new Exception("Mã nhà xe không hợp lệ");
                }
                await _context.NhaXe.AddAsync(NhaXe);

                _context.SaveChanges();
                messages.Add("redirect");
                messages.Add(Url.Action("NhaXe"));
            }
            catch (Exception err)
            {
                messages.Add(err.Message);
                foreach (var value in ModelState.Values)
                {
                    if (value.ValidationState == ModelValidationState.Invalid)
                    {
                        foreach (var modelErr in value.Errors)
                        {
                            messages.Add(modelErr.ErrorMessage);
                        }
                    }
                }
            }
            return(Json(messages.ToArray()));
        }
 public static NhaXeModel ToModel(this NhaXe entity)
 {
     return(entity.MapTo <NhaXe, NhaXeModel>());
 }
示例#21
0
 public IActionResult CoBan()
 {
     nhaXe = getAssociatedNhaXe(uManager).Result;
     ViewData["TenNhaXe"] = nhaXe.TenNhaXe;
     return(View("CoBan", nhaXe));
 }
示例#22
0
 public IActionResult Index()
 {
     nhaXe = getAssociatedNhaXe(uManager).Result;
     ViewData["TenNhaXe"] = nhaXe.TenNhaXe;
     return(View());
 }
示例#23
0
 public Qtv2Controller(BenXeDaNangContext context, UserManager <QuanTriVien> userManager)
 {
     _context = context;
     uManager = userManager;
     nhaXe    = null;
 }
 public static NhaXe ToEntity(this NhaXeModel model, NhaXe destination)
 {
     return(model.MapTo(destination));
 }