Пример #1
0
        public ActionResult TripReason()
        {
            try
            {
                GetPagePermissionResult objPermission = Functions.CheckPagePermission(PageMaster.TripReason);
                if (!objPermission.IsActive)
                {
                    return(this.RedirectToAction("Logout", "Home"));
                }

                ClsTripReason objClsTripReason = this.objiClsTripReason as ClsTripReason;
                long          lgTripReasonId   = 0;
                if (this.Request.QueryString.Count > 0)
                {
                    if (this.Request.QueryString["iFrame"] != null)
                    {
                        if (!objPermission.Add_Right)
                        {
                            return(this.RedirectToAction("PermissionRedirectPage", "Home"));
                        }

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

                        lgTripReasonId   = this.Request.QueryString.ToString().Decode().longSafe();
                        objClsTripReason = this.objiClsTripReason.GetTripReasonByTripReasonId(lgTripReasonId);
                    }
                }
                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

                return(this.View(objClsTripReason));
            }
            catch (Exception ex)
            {
                Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.TripReason, mySession.Current.UserId);
                return(this.View());
            }
        }
Пример #2
0
        private string ValidateTripReason(ClsTripReason objTripReason)
        {
            try
            {
                string strErrorMsg = string.Empty;
                if (string.IsNullOrEmpty(objTripReason.strTripReasonName))
                {
                    strErrorMsg += Functions.AlertMessage("Trip Reason Name", MessageType.InputRequired) + "<br/>";
                }

                return(strErrorMsg);
            }
            catch (Exception ex)
            {
                Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.TripReason, mySession.Current.UserId);
                return(string.Empty);
            }
        }
Пример #3
0
        public ActionResult TripReason()
        {
            try
            {
                var objPermission = _permissionChecker.CheckPagePermission(PageMaster.TripReason);
                if (!objPermission.IsActive)
                {
                    return(RedirectToAction("Logout", "Home"));
                }

                ClsTripReason objClsTripReason = DependencyResolver.Current.GetService <IClsTripReason>() as ClsTripReason;
                long          lgTripReasonId   = 0;
                if (Request.QueryString.Count > 0)
                {
                    if (Request.QueryString["iFrame"] != null)
                    {
                        if (!objPermission.Add_Right)
                        {
                            return(RedirectToAction("PermissionRedirectPage", "Home"));
                        }

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

                        lgTripReasonId   = Request.QueryString.ToString().Decode().LongSafe();
                        objClsTripReason = _trackerService.GetTripReasonByTripReasonId(lgTripReasonId) as ClsTripReason;
                    }
                }
                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)
                {
                    blTrackerAccess = 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

                return(View(objClsTripReason));
            }
            catch (Exception ex)
            {
                Logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.TripReason, _mySession.UserId);
                return(View());
            }
        }
Пример #4
0
        public ActionResult TripReason(ClsTripReason objTripReason)
        {
            try
            {
                GetPagePermissionResult objPermission = Functions.CheckPagePermission(PageMaster.TripReason);
                if (!objPermission.IsActive)
                {
                    return(this.RedirectToAction("Logout", "Home"));
                }

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

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

                bool blExists = this.objiClsTripReason.IsTripReasonExists(objTripReason.lgId, objTripReason.strTripReasonName);
                if (blExists)
                {
                    this.ViewData["Success"] = "0";
                    this.ViewData["Message"] = Functions.AlertMessage("Trip Reason", MessageType.AlreadyExist);
                }
                else
                {
                    string strErrorMsg = this.ValidateTripReason(objTripReason);
                    if (!string.IsNullOrEmpty(strErrorMsg))
                    {
                        this.ViewData["Success"] = "0";
                        this.ViewData["Message"] = strErrorMsg;
                    }
                    else
                    {
                        objTripReason.lgId = this.objiClsTripReason.SaveTripReason(objTripReason);
                        if (objTripReason.lgId > 0)
                        {
                            this.ViewData["Success"] = "1";
                            this.ViewData["Message"] = Functions.AlertMessage("Trip Reason", MessageType.Success);
                            return(this.View(objTripReason));
                        }
                        else
                        {
                            this.ViewData["Success"] = "0";
                            this.ViewData["Message"] = Functions.AlertMessage("Trip Reason", MessageType.Fail);
                        }
                    }
                }

                return(this.View(objTripReason));
            }
            catch (Exception ex)
            {
                this.ViewData["Success"] = "0";
                this.ViewData["Message"] = Functions.AlertMessage("Trip Reason", MessageType.Fail);
                Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.TripReason, mySession.Current.UserId);
                return(this.View(objTripReason));
            }
        }
Пример #5
0
        public ActionResult TripReason(ClsTripReason objTripReason)
        {
            try
            {
                var objPermission = _permissionChecker.CheckPagePermission(PageMaster.TripReason);
                if (!objPermission.IsActive)
                {
                    return(RedirectToAction("Logout", "Home"));
                }

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

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

                bool blExists = _trackerService.IsTripReasonExists(objTripReason.lgId, objTripReason.strTripReasonName);
                if (blExists)
                {
                    ViewData["Success"] = "0";
                    ViewData["Message"] = _alertTextProvider.AlertMessage("Trip Reason", MessageType.AlreadyExists);
                }
                else
                {
                    string strErrorMsg = ValidateTripReason(objTripReason);
                    if (!string.IsNullOrEmpty(strErrorMsg))
                    {
                        ViewData["Success"] = "0";
                        ViewData["Message"] = strErrorMsg;
                    }
                    else
                    {
                        objTripReason.lgId = _trackerService.SaveTripReason(objTripReason);
                        if (objTripReason.lgId > 0)
                        {
                            ViewData["Success"] = "1";
                            ViewData["Message"] = _alertTextProvider.AlertMessage("Trip Reason", MessageType.Success);
                            return(View(objTripReason));
                        }
                        else
                        {
                            ViewData["Success"] = "0";
                            ViewData["Message"] = _alertTextProvider.AlertMessage("Trip Reason", MessageType.Fail);
                        }
                    }
                }

                return(View(objTripReason));
            }
            catch (Exception ex)
            {
                ViewData["Success"] = "0";
                ViewData["Message"] = _alertTextProvider.AlertMessage("Trip Reason", MessageType.Fail);
                Logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.TripReason, _mySession.UserId);
                return(View(objTripReason));
            }
        }