public ActionResult Index(ValidateLogin login, FormCollection form)
        {
            ViewData["Result"] = "";
            if (ModelState.IsValid)
            {
                RepositoryOBTRS          mOBTRS  = new RepositoryOBTRS();
                List <tbl_Administrator> LogName = mOBTRS.Login(form.Get("email").Trim(), form.Get("password").Trim());
                if (LogName == null)
                {
                    //Khong the ket noi Database
                    ViewData["Result"] = "Can't connect to database server, please try again later!";
                    return(View(login));
                }
                else if (LogName.Count == 1)
                {
                    if (LogName[0].Admin_Active != false)
                    {
                        if (form.Get("Remember").ToString().ToLower() != "false")
                        {
                            //Luu vao Cookie
                            //HttpCookie cookie = HttpContext.Response.Cookies.Get("cmsOBTRS");
                            HttpCookie cookie = new HttpCookie("cmsOBTRS");
                            cookie.Values["Username"] = LogName[0].Admin_Name;
                            cookie.Values["ID"]       = LogName[0].Admin_ID.ToString();
                            cookie.Expires            = DateTime.Now.AddDays(+14);
                            HttpContext.Response.Cookies.Set(cookie);
                        }

                        //Luu vào Session
                        Session["LogedName"] = LogName[0].Admin_Name;
                        Session["Admin_ID"]  = LogName[0].Admin_ID;

                        //Lay Alias Role cua Admin dang nhap he thong
                        Session["Role"] = mOBTRS.CheckRole(LogName[0].Admin_RoleID);
                        string a = Session["Role"].ToString();

                        //Dang nhap thanh cong
                        if (!Response.IsRequestBeingRedirected)
                        {
                            Response.Redirect("/CMS/WelcomeAptech");
                        }
                    }
                    else
                    {
                        //Bi cam truy cap
                        ViewData["Result"] = "Access Denied!";
                        return(View(login));
                    }
                }
                else
                {
                    //Login sai mat khau va ten dang nhap
                    ViewData["Result"] = "Username or password invalid.Login failure!";
                    return(View(login));
                }
            }

            //Login unsuccessful
            return(View(login));
        }
 public ActionResult AboutUs(FormCollection form)
 {
     if (Session["Role"].ToString() == "N")
     {
         Response.Write("Access denied!");
         return(null);
     }
     else
     {
         RepositoryOBTRS db = new RepositoryOBTRS();
         ViewData["Data"] = db.GetAboutUs();
         if (form.Get("RichTextEditor") != null)
         {
             if (Session["Role"].ToString() == "R")
             {
                 ViewData["Result"] = "Your role is readonly";
             }
             else
             {
                 ViewData["Result"] = db.UpdateAboutUs(form.Get("RichTextEditor"));
                 ViewData["Data"]   = db.GetAboutUs();
             }
             return(View());
         }
         else
         {
             ViewData["Result"] = "";
         }
         return(View());
     }
 }
Beispiel #3
0
 /// <summary>
 /// Chi tiet dich vu
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult DetailService(Guid id)
 {
     try
     {
         if (id != null)
         {
             RepositoryOBTRS    db      = new RepositoryOBTRS();
             List <tbl_Service> service = db.GetServiceByID(id);
             ViewData["Title"]   = service[0].Services_Title;
             ViewData["Content"] = service[0].Services_Content;
         }
         else
         {
             ViewData["Title"]   = "";
             ViewData["Content"] = "";
         }
     }
     catch (Exception)
     {
         Response.Write("<strong style='font-size:12pt'>Have a error in during request to server!</strong>");
         Response.Write("<br>Sorry for this inconvenience! Please<a href='/Home'> click here</a> to HOME PAGE.");
         //throw;
         return(null);
     }
     return(View());
 }
        public ActionResult AddService(FormCollection form)
        {
            RepositoryOBTRS db     = new RepositoryOBTRS();
            Boolean         active = false;

            if (form.Get("Active") != "false")
            {
                active = true;
            }
            db.AddService(form.Get("Title"), form.Get("RichTextEditor"), active);
            return(Redirect("/CMS/ServicesManagement/"));
        }
        public ActionResult EditService(Guid id, FormCollection form)
        {
            RepositoryOBTRS db     = new RepositoryOBTRS();
            Boolean         active = false;

            if (form.Get("Active") != "false")
            {
                active = true;
            }
            db.UpdateService(id.ToString(), form.Get("Title"), form.Get("RichTextEditor"), active);
            return(Redirect("/CMS/EditService/" + id));
        }
        //Ham lay danh sach Role
        private List <SelectListItem> GetRoleForView()
        {
            List <SelectListItem> items = new List <SelectListItem>();
            RepositoryOBTRS       db    = new RepositoryOBTRS();
            List <tbl_Role>       role  = db.GetRole();

            for (int i = 0; i < role.Count; i++)
            {
                items.Add(new SelectListItem {
                    Text = role[i].Role_Name, Value = role[i].Role_ID.ToString()
                });
            }
            return(items);
        }
Beispiel #7
0
        //Danh sach cac tinh thanh la diem den
        private List <SelectListItem> GetCityDestination(int StartID)
        {
            List <SelectListItem> items = new List <SelectListItem>();
            RepositoryOBTRS       db    = new RepositoryOBTRS();
            List <int>            city  = db.GetCityEnd(StartID);

            for (int i = 0; i < city.Count; i++)
            {
                items.Add(new SelectListItem {
                    Text = db.GetCityName(city[i]), Value = city[i].ToString()
                });
            }
            return(items);
        }
Beispiel #8
0
 /// <summary>
 /// Privacy Policy
 /// </summary>
 /// <returns></returns>
 public ActionResult PrivacyPolicy()
 {
     try
     {
         RepositoryOBTRS db = new RepositoryOBTRS();
         ViewData["Data"] = db.GetPrivacyPolicy();
     }
     catch (Exception)
     {
         Response.Write("<strong style='font-size:12pt'>Have a error in during request to server!</strong>");
         Response.Write("<br>Sorry for this inconvenience! Please<a href='/Home'> click here</a> to HOME PAGE.");
         //throw;
         return(null);
     }
     return(View());
 }
        public ActionResult BusDiagram_45(FormCollection form)
        {
            try
            {
                if (Session["Role"].ToString() == "N")
                {
                    Response.Write("Access denied!");
                    return(null);
                }
                else
                {
                    RepositoryOBTRS db = new RepositoryOBTRS();

                    //----------------- 45 Seats ------------------
                    //Lay du lieu diagram tu Database
                    ViewData["Data"] = db.GetBusDiagram(3);

                    //Cap nhat du lieu vao Database
                    if (form.Get("RichTextEditor") != null)
                    {
                        if (Session["Role"].ToString() == "R")
                        {
                            ViewData["Result"] = "Your role is readonly";
                        }
                        else
                        {
                            ViewData["Result"] = db.UpdateBusDiagram(form.Get("RichTextEditor"), 3);
                            //Lay du lieu diagram tu Database
                            ViewData["Data"] = db.GetBusDiagram(3);
                        }
                        return(View());
                    }
                    else
                    {
                        ViewData["Result"] = "";
                    }
                    //----------------------------------------------

                    return(View());
                }
            }
            catch (Exception)
            {
                //Chuyen ve trang dang nhap
                return(Redirect("/CMS/WelcomeAptech?logout=true"));
            }
        }
        //[HttpGet]
        public ActionResult EditAdmin(String adminID, ValidateAdmin vAdmin, FormCollection form)
        {
            try
            {
                ViewData["Role"] = GetRoleForView();

                if (ModelState.IsValid)
                {
                    RepositoryOBTRS db     = new RepositoryOBTRS();
                    Boolean         active = true;
                    if (form.Get("Active") == "false")
                    {
                        active = false;
                    }
                    String result = db.UpdateAdmin(
                        adminID,
                        form.Get("Role"),
                        form.Get("AdminName"),
                        DateTime.Parse(form.Get("DateOfBirth")),
                        form.Get("Password"),
                        form.Get("Address"),
                        form.Get("Phone"),
                        form.Get("Email"),
                        form.Get("Description"),
                        active
                        );
                    if (result == "")
                    {
                        //Neu cap nhat admin thanh cong
                        return(Redirect("/CMS/ManagerList"));
                    }
                    else
                    {
                        //Neu gap truc trac ko the cap nhat Admin
                        ViewData["Error"] = result;
                        return(View(vAdmin));
                    }
                }
            }
            catch (Exception)
            {
                return(Redirect("/CMS/"));
            }
            //Neu gia tri nhap vao ko dung
            return(View(vAdmin));
        }
 public ActionResult EditService(Guid id)
 {
     if (Session["Role"].ToString() == "N" || Session["Role"].ToString() == "R")
     {
         Response.Write("Access denied!");
         return(null);
     }
     else
     {
         RepositoryOBTRS repData = new RepositoryOBTRS();
         ViewData["NewsID"] = id;
         List <tbl_Service> service = repData.GetServiceByID(id);
         ViewData["Title"]  = service[0].Services_Title;
         ViewData["Data"]   = service[0].Services_Content;
         ViewData["Active"] = service[0].Services_Active;
         return(View());
     }
 }
Beispiel #12
0
        public ActionResult Payment(FormCollection form)
        {
            //Khai bao
            //thong tin tuyen xe
            List <String> RouteDetail = (List <String>)Session["RouteDetail"];
            //Thong in ghe dang dat
            ArrayList arrSeatNo = (ArrayList)Session["BookingSeats"];
            //Mang luu tru cac ket qua booking
            ArrayList       ResultList = new ArrayList();
            RepositoryOBTRS db         = new RepositoryOBTRS();

            try
            {
                if (form != null)
                {
                    //Luu tat ca cac ve cua khach hang vao Database
                    for (int i = 0; i < (form.Count / 2); i++)
                    {
                        db_OBTRSDataContext discount = new db_OBTRSDataContext();
                        var     dis          = discount.sp_CalculateDiscount(decimal.Parse(RouteDetail[5].ToString()), int.Parse(form["Age" + i]));
                        Decimal CostDiscount = new Decimal();
                        foreach (sp_CalculateDiscountResult item in dis)
                        {
                            CostDiscount = (Decimal)item.Result;
                        }
                        String result = db.InsertBookingTicket(int.Parse(RouteDetail[6]), int.Parse(RouteDetail[7]), int.Parse(RouteDetail[8]), int.Parse(RouteDetail[9]), Session["UserID"].ToString(), form["NameCustomer" + i].ToString(), int.Parse(form["Age" + i]), CostDiscount, int.Parse(arrSeatNo[i].ToString()), DateTime.Parse(Session["DateDeparture"].ToString()));
                        ResultList.Add(result);
                    }
                }
            }
            catch (Exception)
            {
                Response.Write("<strong style='font-size:12pt'>Have a error in during request to server!</strong>");
                Response.Write("<br>Sorry for this inconvenience! Please<a href='/Home'> click here</a> to HOME PAGE.");
                return(null);
            }
            return(View(ResultList));
        }
Beispiel #13
0
        private List <SelectListItem> GetCityDeparture(int CityDepartureID)
        {
            List <SelectListItem> items = new List <SelectListItem>();
            RepositoryOBTRS       db    = new RepositoryOBTRS();
            List <int>            city  = db.GetCityStart();

            for (int i = 0; i < city.Count; i++)
            {
                if (Convert.ToInt32(city[i]) == CityDepartureID)
                {
                    items.Add(new SelectListItem {
                        Text = db.GetCityName(city[i]), Value = city[i].ToString(), Selected = true
                    });
                }
                else
                {
                    items.Add(new SelectListItem {
                        Text = db.GetCityName(city[i]), Value = city[i].ToString()
                    });
                }
            }
            return(items);
        }
Beispiel #14
0
        //Hien thi chi tiet viec dat ve
        public ActionResult BookingDetail()
        {
            //Kiem tra neu nguoi dung chua dang nhap thi hien thi thong bao yeu cau dang nhap
            if (Session["UserID"] == null)
            {
                Response.Write("You can only find book ticket detail if you login!<br />");
                Response.Write("Please <a href='/Home/SearchDetail'>back</a> home page to login or <a href='/Home/Register/'>register</a> is member of us");
                return(null);
            }
            //Ket thuc kiem tra

            try
            {
                int             beginID   = Convert.ToInt32(Request.Params["BeginID"]);
                int             endID     = Convert.ToInt32(Request.Params["EndID"]);
                int             bustypeID = Convert.ToInt32(Request.Params["BusTypeID"]);
                int             startTime = Convert.ToInt32(Request.Params["StartTime"]);
                RepositoryOBTRS db        = new RepositoryOBTRS();
                List <String>   list      = db.GetRouteDetail(beginID, endID, bustypeID, startTime);
                ViewData["RouteDetail"] = list;
                //Setup Session RouteDetail - danh sach chi tiet tuyen xe ma khach hang chon
                Session["RouteDetail"] = list;

                if (list[1].ToString() == "12")
                {
                    ViewData["BusDiagram"] = db.GetBusDiagram(1);
                }
                else if (list[1].ToString() == "24")
                {
                    ViewData["BusDiagram"] = db.GetBusDiagram(2);
                }
                else
                {
                    ViewData["BusDiagram"] = db.GetBusDiagram(3);
                }

                //Lay tong so ghe da dc dat
                db_OBTRSDataContext tbl  = new db_OBTRSDataContext();
                DateTime            date = DateTime.Parse(Request.Params["Date"]);
                var sumSeat = tbl.sp_GetSelectedSeat(beginID, endID, bustypeID, startTime, date);

                //Luu tru danh sach ghe ngoi
                ArrayList BookedSeatList = new ArrayList();
                foreach (sp_GetSelectedSeatResult name in sumSeat)
                {
                    BookedSeatList.Add(name.Seat);
                }

                //Lay danh sach cac ghe da dat cho
                //Session["BookedSeatList"] = BookedSeatList;
                //Tam thoi ko su dung--------

                ViewData["BookedSeat"] = BookedSeatList;
            }
            catch (Exception e)
            {
                Response.Write("<strong style='font-size:12pt'>Have a error in during request to server!</strong>");
                Response.Write("<br>Sorry for this inconvenience! Please<a href='/Home'> click here</a> to HOME PAGE.");
                //throw;
                return(null);
            }

            return(View());
        }
Beispiel #15
0
        public ActionResult SearchDetail(FormCollection form)
        {
            try
            {
                //Kiem tra va lay ID cua dia diem khoi hanh
                if (form["CityDeparture"] != null)
                {
                    //Lay thong tin dia diem di va den truyen cho Title
                    RepositoryOBTRS dbrep      = new RepositoryOBTRS();
                    int             cityDepart = Convert.ToInt16(form["CityDeparture"]);
                    ViewData["Title_Departure"] = dbrep.GetCityName(cityDepart);
                    int cityDesti = Convert.ToInt16(form["CityDestination"]);
                    ViewData["Title_Destination"] = dbrep.GetCityName(cityDesti);
                    //Ket thuc lay thong tin

                    int id = Convert.ToInt16(form["CityDeparture"]);
                    ViewData["CityStart"] = GetCityDeparture(id);
                    if (form["CityDestination"] != null)
                    {
                        int DestinationID = Convert.ToInt16(form["CityDestination"]);
                        ViewData["CityEnd"] = GetCityDestination(id, DestinationID);
                    }
                    else
                    {
                        ViewData["CityEnd"] = GetCityDestination(id);
                        //ViewData["CityDestination"] = "?";
                    }
                }
                else
                {
                    ViewData["CityStart"] = GetCityDeparture();
                    ViewData["CityEnd"]   = GetCityDestination(1);
                }

                if (form["CityDeparture"] != null && form["CityDestination"] != null)
                {
                    db_OBTRSDataContext db = new db_OBTRSDataContext();
                    int Departure          = Convert.ToInt32(form["CityDeparture"]);
                    int Destination        = Convert.ToInt32(form["CityDestination"]);

                    string Depart = "%%";
                    if (form["txtDepartureDate"] != null && form["txtDepartureDate"] != "")
                    {
                        DateTime dt = DateTime.Parse(form["txtDepartureDate"].ToString());
                        Depart = "%" + dt.DayOfWeek.ToString().Substring(0, 2).ToUpper() + "%";
                    }
                    var tblRoute = db.sp_GetRouteMatch(Departure, Destination, Depart);
                    ViewData["DataRoute"] = tblRoute;
                }
                else
                {
                    ViewData["DataRoute"] = null;
                }
                if (form["txtDepartureDate"] == null)
                {
                    String currentDate = DateTime.Now.ToShortDateString();
                    ViewData["DateDepart"] = currentDate;
                    //Setup session date ngay ma khach hang chon khoi hanh
                    Session["DateDeparture"] = currentDate;
                }
                else
                {
                    ViewData["DateDepart"]   = form["txtDepartureDate"];
                    Session["DateDeparture"] = form["txtDepartureDate"];
                }
            }catch (Exception)
            {
                Response.Write("<strong style='font-size:12pt'>Have a error in during request to server!</strong>");
                Response.Write("<br>Sorry for this inconvenience! Please<a href='/Home'> click here</a> to HOME PAGE.");
                //throw;
                return(null);
            }

            return(View());
        }