Exemplo n.º 1
0
        public ActionResult CarFleet()
        {
            try
            {
                GetPagePermissionResult objPermission = Functions.CheckPagePermission(PageMaster.CarFleet);
                if (!objPermission.IsActive)
                {
                    return(this.RedirectToAction("Logout", "Home"));
                }

                ClsCarFleet objClsCarFleet = this.objiClsCarFleet as ClsCarFleet;
                long        lgCarFleetId   = 0;
                if (this.Request.QueryString.Count > 0)
                {
                    if (this.Request.QueryString["iFrame"] != null)
                    {
                        if (!objPermission.Add_Right)
                        {
                            return(this.RedirectToAction("PermissionRedirectPage", "Home"));
                        }

                        objClsCarFleet.hdniFrame = true;
                        this.ViewData["iFrame"]  = "iFrame";
                    }
                    else
                    {
                        if (!objPermission.Edit_Right || string.IsNullOrEmpty(this.Request.QueryString.ToString().Decode()))
                        {
                            return(this.RedirectToAction("PermissionRedirectPage", "Home"));
                        }

                        lgCarFleetId   = this.Request.QueryString.ToString().Decode().longSafe();
                        objClsCarFleet = this.objiClsCarFleet.GetCarFleetByCarFleetId(lgCarFleetId);
                    }
                }
                else
                {
                    if (!objPermission.Add_Right)
                    {
                        return(this.RedirectToAction("PermissionRedirectPage", "Home"));
                    }
                }

                #region Menu Access
                Controllers.BaseController baseController = new Controllers.BaseController();
                this.ViewData = baseController.MenuAccessPermissions(objPermission);
                #endregion Menu Access

                this.BindDropDownListForCarFleet(objClsCarFleet, true);

                return(this.View(objClsCarFleet));
            }
            catch (Exception ex)
            {
                Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.CarFleet, mySession.Current.UserId);
                return(this.View());
            }
        }
 public void BindDropDownListForCarFleet(ClsCarFleet objClsCarFleet, bool blBindDropDownFromDb)
 {
     try
     {
         if (blBindDropDownFromDb)
         {
             objClsCarFleet.lstFleetColors = _fleetService.GetAllFleetColorsForDropDown().ToList();
             objClsCarFleet.lstFleetMakes  = _fleetService.GetAllFleetMakesForDropDown().ToList();
             objClsCarFleet.lstFleetModels = _fleetService.GetAllFleetModelsForDropDown().ToList();
         }
         else
         {
             objClsCarFleet.lstFleetColors = new List <SelectListItem>();
             objClsCarFleet.lstFleetMakes  = new List <SelectListItem>();
             objClsCarFleet.lstFleetModels = new List <SelectListItem>();
         }
     }
     catch (Exception ex)
     {
         Logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.User);
     }
 }
        private string ValidateCarFleet(ClsCarFleet objCarFleet)
        {
            try
            {
                string strErrorMsg = string.Empty;
                if (string.IsNullOrEmpty(objCarFleet.strCode))
                {
                    strErrorMsg += _alertTextProvider.AlertMessage("Code", MessageType.InputRequired) + "<br/>";
                }
                else if (string.IsNullOrEmpty(objCarFleet.strReg))
                {
                    strErrorMsg += _alertTextProvider.AlertMessage("Registration", MessageType.InputRequired) + "<br/>";
                }
                else if (string.IsNullOrEmpty(objCarFleet.strFuel_Type.ToString()))
                {
                    strErrorMsg += _alertTextProvider.AlertMessage("Fuel Type", MessageType.InputRequired) + "<br/>";
                }
                else if (string.IsNullOrEmpty(objCarFleet.strLast_Trip.ToString()))
                {
                    strErrorMsg += _alertTextProvider.AlertMessage("Last Trip Date", MessageType.InputRequired) + "<br/>";
                }
                else if (string.IsNullOrEmpty(objCarFleet.inLast_Km.ToString()))
                {
                    strErrorMsg += _alertTextProvider.AlertMessage("Last Km", MessageType.InputRequired) + "<br/>";
                }
                else if (string.IsNullOrEmpty(objCarFleet.strLast_Location.ToString()))
                {
                    strErrorMsg += _alertTextProvider.AlertMessage("Last Location", MessageType.InputRequired) + "<br/>";
                }

                return(strErrorMsg);
            }
            catch (Exception ex)
            {
                Logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.CarFleet, _mySession.UserId);
                return(string.Empty);
            }
        }
        public ActionResult CarFleet(ClsCarFleet objCarFleet)
        {
            try
            {
                GetPagePermissionResult objPermission = _permissionChecker.CheckPagePermission(PageMaster.CarFleet);
                if (!objPermission.IsActive)
                {
                    return(RedirectToAction("Logout", "Home"));
                }

                if (objCarFleet.inId == 0)
                {
                    if (!objPermission.Add_Right)
                    {
                        return(RedirectToAction("PermissionRedirectPage", "Home"));
                    }
                }
                else
                {
                    if (!objPermission.Edit_Right)
                    {
                        return(RedirectToAction("PermissionRedirectPage", "Home"));
                    }
                }

                if (objCarFleet.hdniFrame)
                {
                    ViewData["iFrame"] = "iFrame";
                }

                string strErrorMsg = ValidateCarFleet(objCarFleet);

                if (ModelState.IsValid)
                {
                    if (!string.IsNullOrEmpty(strErrorMsg))
                    {
                        ViewData["Success"] = "0";
                        ViewData["Message"] = strErrorMsg;
                    }
                    else
                    {
                        objCarFleet.inId = _fleetService.SaveCarFleet(objCarFleet);
                        if (objCarFleet.inId > 0)
                        {
                            ViewData["Success"] = "1";
                            ViewData["Message"] = _alertTextProvider.AlertMessage("CarFleet", MessageType.Success);
                            BindDropDownListForCarFleet(objCarFleet, false);
                            return(View(objCarFleet));
                        }
                        else
                        {
                            ViewData["Success"] = "0";
                            ViewData["Message"] = _alertTextProvider.AlertMessage("CarFleet", MessageType.Fail);
                        }
                    }
                }

                BindDropDownListForCarFleet(objCarFleet, true);

                return(View(objCarFleet));
            }
            catch (Exception ex)
            {
                ViewData["Success"] = "0";
                ViewData["Message"] = _alertTextProvider.AlertMessage("CarFleet", MessageType.Fail);
                Logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.CarFleet, _mySession.UserId);
                return(View());
            }
        }
        public ActionResult CarFleet()
        {
            try
            {
                var objPermission = _permissionChecker.CheckPagePermission(PageMaster.CarFleet);
                if (!objPermission.IsActive)
                {
                    return(RedirectToAction("Logout", "Home"));
                }

                ClsCarFleet objClsCarFleet = _fleetService as ClsCarFleet;
                long        lgCarFleetId   = 0;
                if (Request.QueryString.Count > 0)
                {
                    if (Request.QueryString["iFrame"] != null)
                    {
                        if (!objPermission.Add_Right)
                        {
                            return(RedirectToAction("PermissionRedirectPage", "Home"));
                        }

                        objClsCarFleet.hdniFrame = true;
                        ViewData["iFrame"]       = "iFrame";
                    }
                    else
                    {
                        if (!objPermission.Edit_Right || string.IsNullOrEmpty(Request.QueryString.ToString().Decode()))
                        {
                            return(RedirectToAction("PermissionRedirectPage", "Home"));
                        }

                        lgCarFleetId   = Request.QueryString.ToString().Decode().LongSafe();
                        objClsCarFleet = _fleetService.GetCarFleetByCarFleetId(lgCarFleetId) as ClsCarFleet;
                    }
                }
                else
                {
                    if (!objPermission.Add_Right)
                    {
                        return(RedirectToAction("PermissionRedirectPage", "Home"));
                    }
                }

                #region Menu Access
                bool blUserAccess = true, blRoleAccess = true, blTrackerAccess = true, blCarFleetAccess = true, blFleetMakesAccess = true, blFleetModelsAccess = true, blFleetColorsAccess = true, blTripReasonAccess = true;
                objPermission = _permissionChecker.CheckPagePermission(PageMaster.User);
                if (!objPermission.Add_Right)
                {
                    blUserAccess = false;
                }

                objPermission = _permissionChecker.CheckPagePermission(PageMaster.Role);
                if (!objPermission.Add_Right)
                {
                    blRoleAccess = false;
                }

                objPermission = _permissionChecker.CheckPagePermission(PageMaster.Tracker);
                if (!objPermission.Add_Right)
                {
                    blCarFleetAccess = false;
                }

                objPermission = _permissionChecker.CheckPagePermission(PageMaster.CarFleet);
                if (!objPermission.Add_Right)
                {
                    blCarFleetAccess = false;
                }

                objPermission = _permissionChecker.CheckPagePermission(PageMaster.FleetMakes);
                if (!objPermission.Add_Right)
                {
                    blFleetMakesAccess = false;
                }

                objPermission = _permissionChecker.CheckPagePermission(PageMaster.FleetModels);
                if (!objPermission.Add_Right)
                {
                    blFleetModelsAccess = false;
                }

                objPermission = _permissionChecker.CheckPagePermission(PageMaster.FleetColors);
                if (!objPermission.Add_Right)
                {
                    blFleetColorsAccess = false;
                }

                objPermission = _permissionChecker.CheckPagePermission(PageMaster.TripReason);
                if (!objPermission.Add_Right)
                {
                    blTripReasonAccess = false;
                }

                ViewData["UserAccess"]    = blUserAccess;
                ViewData["RoleAccess"]    = blRoleAccess;
                ViewData["TrackerAccess"] = blTrackerAccess;

                ViewData["CarFleetAccess"]    = blCarFleetAccess;
                ViewData["FleetMakesAccess"]  = blFleetMakesAccess;
                ViewData["FleetModelsAccess"] = blFleetModelsAccess;
                ViewData["FleetColorsAccess"] = blFleetColorsAccess;
                ViewData["TripReasonAccess"]  = blTripReasonAccess;
                #endregion

                BindDropDownListForCarFleet(objClsCarFleet, true);

                return(View(objClsCarFleet));
            }
            catch (Exception ex)
            {
                Logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.CarFleet, _mySession.UserId);
                return(View());
            }
        }