Beispiel #1
0
        public ActionResult GetSectors(int?page, int?sortColumnIndex, int?sortDirection, string searchText)
        {
            ManageSectorModel SectorModel = new ManageSectorModel();
            SearchAttributes  searchParam = new SearchAttributes();

            searchParam.CurrentPageNumber = (page.HasValue && page.Value > 0) ? page.Value : 1;
            searchParam.RecordsPerPage    = AppSettingsUtility.GetInt(AppSettingsKeys.RecordsPerPage);
            searchParam.SortColumnIndex   = (sortColumnIndex.HasValue && sortColumnIndex.Value > 0) ? sortColumnIndex.Value : 1;
            searchParam.SortDirection     = (sortDirection.HasValue && sortDirection.Value == 1) ? Entity.SortDirection.Descending : Entity.SortDirection.Ascending;

            if (!string.IsNullOrEmpty(searchText))
            {
                searchParam.SearchText = searchText;
            }

            SectorModel.SearchParam = searchParam;
            SectorModel.GetAllSector(searchParam);

            //for Ajax Specific Request
            if (Request.IsAjaxRequest())
            {
                return(View("~/Views/Shared/PartialViews/Admin/Sector/_SectorList.cshtml", SectorModel));
            }
            else
            {
                return(View("~/Views/Admin/Sector/SectorList.cshtml", SectorModel));
            }
        }
Beispiel #2
0
        public JsonResult getCode(string value)
        {
            TSMSector         tsmSector = new TSMSector();
            ManageSectorModel mng       = new ManageSectorModel();

            Guid newGuid = new Guid();

            newGuid = Guid.Parse(value);
            try
            {
                tsmSector = mng.GetSector(newGuid);
            }
            catch { }
            return(this.Json(new { Code = tsmSector.Code }, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        public JsonResult GetParentByChild(string ChildCode)
        {
            string id = string.Empty;

            try
            {
                ManageSectorModel sectorModel = new ManageSectorModel();
                id = sectorModel.GetParentByChild(ChildCode);
            }
            catch (Exception ex)
            {
                ErrorLog.WriteLog("SectorController", "GetParentByChild", ex, ChildCode);
            }
            return(this.Json(new { id = id }, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public JsonResult GetChildID(string ParentCode)
        {
            List <TSMSector> lstTSMSector = new List <TSMSector>();

            try
            {
                ManageSectorModel sectorModel = new ManageSectorModel();
                lstTSMSector = sectorModel.GetChildID(ParentCode);
            }
            catch (Exception ex)
            {
                ErrorLog.WriteLog("SectorController", "GetChildID", ex, ParentCode);
            }
            return(this.Json(new { Child = lstTSMSector.Select(x => x.Name + "|" + x.ID).ToList() }, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        public ActionResult ManageSector(Guid?id)
        {
            ManageSectorModel SectorModel = new ManageSectorModel();

            if (id.HasValue && id.Value != Guid.Empty)
            {
                TSMSector tsmSector = SectorModel.GetSectorByID(id.Value);
                SectorModel.ChildNomenclature = new List <TSMSector>();
            }
            if (SectorModel.ParentNomenclature == null)
            {
                SectorModel.ParentNomenclature = new List <TSMSector>();
                SectorModel.ChildNomenclature  = new List <TSMSector>();
            }
            return(View("~/Views/Admin/Sector/manage-sector.cshtml", SectorModel));
        }
Beispiel #6
0
        public JsonResult DeleteSector(Guid id)
        {
            string message   = "Sucess! Deleted successfully";
            bool   isDeleted = true;

            try
            {
                ManageSectorModel model = new ManageSectorModel();
                model.Delete(id);
            }

            catch (Exception ex)
            {
                message   = "Failure! Unable to delete";
                isDeleted = false;
                ErrorLog.WriteLog("SectorController", "DeleteSector", ex, "");
            }
            return(this.Json(new { message = message, isDeleted = isDeleted }, JsonRequestBehavior.AllowGet));
        }
Beispiel #7
0
 public ActionResult ManageSector(ManageSectorModel TSMSectorModel)
 {
     try
     {
         bool exist = false;
         if (TSMSectorModel.ID == Guid.Empty)
         {
             exist = TSMSectorModel.CheckSector();
         }
         if (exist == false)
         {
             TSMSector tsmSector = TSMSectorModel.Save();
             if (TSMSectorModel.ID != Guid.Empty)
             {
                 TempData["Success"] = "true";
                 return(Redirect(Url.Action("manage-sector", "Admin") + "?id=" + tsmSector.ID));
             }
             else
             {
                 TempData["Success"] = "true";
                 return(Redirect(Url.Action("manage-sector", "Admin") + "?id=" + tsmSector.ID));
             }
         }
         else
         {
             TempData["Exist"]   = "true";
             TempData["Success"] = "false";
         }
     }
     catch (Exception ex)
     {
         TempData["Success"] = "false";
         ErrorLog.WriteLog("SectorController", "ManageSector", ex, "");
     }
     return(View("~/Views/Admin/Sector/manage-sector.cshtml", TSMSectorModel));
 }