public ActionResult Search(TankHistoryModel postModel)
        {
            if (string.IsNullOrEmpty(postModel.TextSearch))
            {
                return(RedirectToAction("Index"));
            }

            TankHistoryModel tankHistoryModel = new TankHistoryModel();

            string equipment = postModel.TextSearch;

            TempData["Equipment"] = equipment;

            return(RedirectToAction("Index", "TankHistory"));
        }
        // GET: /TankHistory/
        public ActionResult Index(string tankNumber)
        {
            PopulateSecurityExtended();
            int securityProfileId = SecurityExtended.SecurityProfileId;
            var permissionList    = _sharedFunctions.GetSecuritySettings(securityProfileId, (int)SecurityCatEnum.TankHistory, null);

            ViewBag.AllowDispatch          = true;
            ViewBag.AllowPrep              = true;
            ViewBag.AllowEditDispatch      = true;
            ViewBag.AllowViewOnHireHistory = true;
            ViewBag.AllowEditOnHireHistory = true;
            ViewBag.AllowEditTankInfo      = true;
            //foreach (var permission in permissionList)
            //{
            //    if (permission.PrivilegeDS == "Dispatch")
            //    {
            //        ViewBag.AllowDispatch = (permission.GrantedFL == 1);
            //    }
            //    else if (permission.PrivilegeDS == "Prep")
            //    {
            //        ViewBag.AllowPrep = (permission.GrantedFL == 1);
            //    }
            //    else if (permission.PrivilegeDS == "Edit Dispatch")
            //    {
            //        ViewBag.AllowEditDispatch = (permission.GrantedFL == 1);
            //    }
            //    else if (permission.PrivilegeDS == "View On Hire History")
            //    {
            //        ViewBag.AllowViewOnHireHistory = (permission.GrantedFL == 1);
            //    }
            //    else if (permission.PrivilegeDS == "Edit On Hire History")
            //    {
            //        ViewBag.AllowEditOnHireHistory = (permission.GrantedFL == 1);
            //    }
            //    else if (permission.PrivilegeDS == "Edit Tank Info")
            //    {
            //        ViewBag.AllowEditTankInfo = (permission.GrantedFL == 1);
            //    }
            //}

            TankHistoryModel tankHistoryModel = new TankHistoryModel();

            string equipment = string.Empty;

            if (!string.IsNullOrEmpty(tankNumber))
            {
                equipment = tankNumber.TrimEnd();
            }
            if (TempData["Equipment"] != null)
            {
                equipment = TempData["Equipment"].ToString();
            }

            int locationId      = SecurityExtended.LocationId.Value;
            int majorLocationID = SecurityExtended.LocationId.Value;

            tankHistoryModel.DataTableActivityHistory = GetTankActivityHistory(false, locationId, equipment, "");
            tankHistoryModel.DataTableActivityHistory.Columns["DispatchID"].SetOrdinal(15);
            tankHistoryModel.DataTableEquipmentInfo = GetEquipmentInfo(false, majorLocationID, equipment);
            tankHistoryModel.DataTableEquipmentInfo.Columns["EquipmentID"].SetOrdinal(44);
            tankHistoryModel.DataTableEquipmentProduct = GetEquipmentProduct(false, equipment);
            tankHistoryModel.DataTableOnHireHistory    = GetOnHireHistory(false, locationId, equipment);

            tankHistoryModel.HfShowResult = !string.IsNullOrEmpty(equipment) ? "true" : "false";
            tankHistoryModel.TextSearch   = equipment;
            return(View(tankHistoryModel));
        }
        public ActionResult Filter(TankHistoryModel postModel)
        {
            PopulateSecurityExtended();
            int securityProfileId = SecurityExtended.SecurityProfileId;
            var permissionList    = _sharedFunctions.GetSecuritySettings(securityProfileId, (int)SecurityCatEnum.TankHistory, null);

            ViewBag.AllowDispatch          = true;
            ViewBag.AllowPrep              = true;
            ViewBag.AllowEditDispatch      = true;
            ViewBag.AllowViewOnHireHistory = true;
            ViewBag.AllowEditOnHireHistory = true;
            ViewBag.AllowEditTankInfo      = true;
            //foreach (var permission in permissionList)
            //{
            //    if (permission.PrivilegeDS == "Dispatch")
            //    {
            //        ViewBag.AllowDispatch = (permission.GrantedFL == 1);
            //    }
            //    else if (permission.PrivilegeDS == "Prep")
            //    {
            //        ViewBag.AllowPrep = (permission.GrantedFL == 1);
            //    }
            //    else if (permission.PrivilegeDS == "Edit Dispatch")
            //    {
            //        ViewBag.AllowEditDispatch = (permission.GrantedFL == 1);
            //    }
            //    else if (permission.PrivilegeDS == "View On Hire History")
            //    {
            //        ViewBag.AllowViewOnHireHistory = (permission.GrantedFL == 1);
            //    }
            //    else if (permission.PrivilegeDS == "Edit On Hire History")
            //    {
            //        ViewBag.AllowEditOnHireHistory = (permission.GrantedFL == 1);
            //    }
            //    else if (permission.PrivilegeDS == "Edit Tank Info")
            //    {
            //        ViewBag.AllowEditTankInfo = (permission.GrantedFL == 1);
            //    }
            //}


            TankHistoryModel tankHistoryModel = new TankHistoryModel();

            int    locationId       = SecurityExtended.LocationId.Value;
            int    majorLocationID  = SecurityExtended.LocationId.Value;
            string equipment        = TempData["Equipment"].ToString();
            string filter           = postModel.TextFilter;
            string filterColumn     = postModel.SelectedColumn;
            string filterExpression = "";

            if (!string.IsNullOrEmpty(filter.Trim()))
            {
                filterExpression = filterColumn + " like '" + filter + "%'";
            }

            tankHistoryModel.DataTableActivityHistory  = GetTankActivityHistory(false, locationId, equipment, filterExpression);
            tankHistoryModel.DataTableEquipmentInfo    = GetEquipmentInfo(false, majorLocationID, equipment);
            tankHistoryModel.DataTableEquipmentProduct = GetEquipmentProduct(false, equipment);
            tankHistoryModel.DataTableOnHireHistory    = GetOnHireHistory(false, locationId, equipment);

            tankHistoryModel.HfShowResult = "true";
            tankHistoryModel.TextSearch   = equipment;
            return(View("Index", tankHistoryModel));;
        }