예제 #1
0
        // GET: Assets/Edit/5
        public ActionResult Edit(int?id)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                rs_assets rs_assets = db.rs_assets.Find(id);
                if (rs_assets == null)
                {
                    return(HttpNotFound());
                }
                SystemModel model = new SystemModel();

                model.System         = rs_assets;
                ViewBag.OriginLocId  = new SelectList(db.rs_locations, "LocationId", "LocationName", rs_assets.OriginLocId);
                ViewBag.CurrentLocId = new SelectList(db.rs_locations, "LocationId", "LocationName", rs_assets.CurrentLocId);
                ViewBag.OwnerId      = new SelectList(db.rs_user, "UserId", "Username", rs_assets.OwnedBy);
                ViewBag.DivId        = new SelectList(db.rs_division, "DivId", "DivisionNo", rs_assets.DivId);
                ViewBag.OwnerShipId  = new SelectList(db.rs_ownership, "OwnerShipId", "OwnerType", rs_assets.OwnerShipId);
                ViewBag.Availability = new SelectList(db.rs_assetstatus, "StatusId", "Status", rs_assets.Availability);
                return(View(model));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #2
0
        public ActionResult Index(string search)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                ViewBag.search = search;

                if (search != null && search.Length > 0)
                {
                    List <rs_user_group> rs_user_group = new List <rs_user_group>();

                    foreach (var item in search.Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        rs_user_group.AddRange(db.rs_user_group.Where(s => s.Name.Contains(item) ||
                                                                      s.Description.Contains(item)
                                                                      ));
                    }

                    return(View(rs_user_group.Distinct()));
                }

                return(View(db.rs_user_group.ToList()));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #3
0
        // GET: Assets/Create
        public ActionResult Create()
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                ViewBag.OriginLocId  = new SelectList(db.rs_locations, "LocationId", "LocationName");
                ViewBag.CurrentLocId = new SelectList(db.rs_locations, "LocationId", "LocationName");
                ViewBag.OwnerId      = new SelectList(db.rs_user, "UserId", "Username");
                ViewBag.DivId        = new SelectList(db.rs_division, "DivId", "DivisionNo");
                ViewBag.OwnerShipId  = new SelectList(db.rs_ownership, "OwnerShipId", "OwnerType");
                ViewBag.Availability = new SelectList(db.rs_assetstatus, "StatusId", "Status");

                if (AclHelper.IsAdmin(User.Identity.Name))
                {
                    ViewBag.SubAssetId = new SelectList(db.rs_assets.Where(x => x.IsSystem == false), "AssetId", "Model");
                }
                else
                {
                    ViewBag.SubAssetId = new SelectList(db.rs_assets.Where(x => x.IsSystem == false && x.OwnedBy == AclHelper.GetUserId(User.Identity.Name)), "AssetId", "Model");
                }
                SystemModel model = new SystemModel();

                model.Step = 1;
                return(View("Assets", model));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #4
0
        public ActionResult Index(string search)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                ViewBag.search = search;

                if (search != null && search.Length > 0)
                {
                    List <rs_user> rs_user = new List <rs_user>();

                    foreach (var item in search.Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        rs_user.AddRange(db.rs_user.Where(s => s.Username != "papaya" && s.UserType == UserType &&
                                                          (
                                                              s.Username.Contains(item) ||
                                                              s.FullName.Contains(item) ||
                                                              s.MobileNumber.Contains(item) ||
                                                              s.Email.Contains(item)
                                                          )
                                                          ));
                    }

                    return(View(rs_user.Distinct()));
                }

                var all_rs_user = db.rs_user.Include("rs_company").Where(e => e.Username != "papaya" && e.UserType == UserType);
                return(View(all_rs_user.ToList()));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #5
0
        public ActionResult Delete(int id)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                rs_assets rs_assets = db.rs_assets.Find(id);

                //Delete any attached accessories
                List <rs_accessories> acclist = db.rs_accessories.Where(x => x.AssetId == id).ToList();
                foreach (rs_accessories acc in acclist)
                {
                    db.rs_accessories.Remove(acc);
                    db.SaveChanges();
                }

                //Delete any related relationship
                List <rs_assets_rel> relist = db.rs_assets_rel.Where(x => x.AssetId == id || x.SysId == id).ToList();
                foreach (rs_assets_rel rel in relist)
                {
                    db.rs_assets_rel.Remove(rel);
                    db.SaveChanges();
                }

                db.rs_assets.Remove(rs_assets);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #6
0
        //public ActionResult Print(int id)
        //{
        //    if (AclHelper.hasAccess(User, currentAction, currentController))
        //    {
        //        try
        //        {
        //            ZebraPrinterProxy proxy = new ZebraPrinterProxy();
        //            proxy.Url = "http://localhost:9191";

        //            rs_user rs_user = db.rs_user.Single(s => s.UserId == id);
        //            sp_get_zebra_mapping_for_printing_result mapping = db.sp_get_zebra_mapping_for_printing("User Label").FirstOrDefault();

        //            XmlRpcStruct param = new XmlRpcStruct();
        //            param["darkness"] = mapping.Darkness.Value.ToString();
        //            param["username"] = rs_user.Username;
        //            param["name"] = rs_user.FullName;
        //            param["password"] = UtilitiesHelper.Decrypt(rs_user.Password);

        //            if (proxy.Print(mapping.IpAddress, mapping.Port.Value, mapping.TemplateCode, param))
        //            {
        //                TempData["Notification"] = NotificationHelper.Inform("Label is being printed.");
        //            }
        //            else
        //            {
        //                TempData["Notification"] = NotificationHelper.Inform("Failed to print label.");
        //            }
        //        }
        //        catch (Exception ex)
        //        {
        //            TempData["Notification"] = NotificationHelper.Error(ex.Message);
        //        }

        //        return RedirectToAction("Index");
        //    }
        //    else
        //    {
        //        return RedirectToAction("NotAuthenticated", "Home");
        //    }
        //}

        //
        // GET: /User/DownloadTemplate

        public ActionResult DownloadTemplate()
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                try
                {
                    ArrayList data      = new ArrayList();
                    ArrayList headerRow = new ArrayList();
                    headerRow.Add("Username");
                    headerRow.Add("Password");
                    headerRow.Add("Full Name");
                    data.Add(headerRow);

                    ExcelHelper helper = new ExcelHelper();
                    var         file   = helper.GetExcelBytes(data, 0, 0, new List <int>()
                    {
                        2
                    });

                    return(File(file, "application/vnd.ms-excel", "User upload file template.xls"));
                }
                catch (Exception ex)
                {
                    TempData["Notification"] = NotificationHelper.Error(ex.Message);
                }

                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #7
0
        public ActionResult Index(string search)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                ViewBag.search = search;

                if (search != null && search.Length > 0)
                {
                    List <rs_action> rs_action = new List <rs_action>();

                    foreach (var item in search.Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        rs_action.AddRange(db.rs_action.Where(s => s.Name.Contains(item) ||
                                                              s.rs_module.Name.Contains(item)
                                                              ));
                    }

                    return(View(rs_action.Distinct()));
                }

                var all_rs_action = db.rs_action.Include("rs_module").OrderBy(m => m.ModuleId);
                return(View(all_rs_action.ToList()));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #8
0
        public ActionResult AddAccessories(SystemModel model)
        {
            rs_accessories acc = model.Accessories;

            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                if (ModelState.IsValid)
                {
                    rs_assets system = db.rs_assets.Find(model.System.AssetId);
                    if (system != null)
                    {
                        acc.AssetId = model.System.AssetId;
                        db.rs_accessories.Add(acc);
                        db.SaveChanges();

                        return(RedirectToAction("Details", new { id = model.System.AssetId }));
                    }
                    else
                    {
                        return(RedirectToAction("Details", new { id = model.System.AssetId }));
                    }
                }
                else
                {
                    return(RedirectToAction("NotAuthenticated", "Home"));
                }
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #9
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                try
                {
                    rs_user_group rs_user_group = db.rs_user_group.Single(s => s.GroupId == id);

                    Logger.Log("Delete", "Delete Group [ID:" + rs_user_group.GroupId + "]");
                    TempData["Notification"] = NotificationHelper.Inform("Delete Group [ID:" + rs_user_group.GroupId + "]");

                    db.rs_user_group.Remove(rs_user_group);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    TempData["Notification"] = NotificationHelper.Error(ex.Message);
                }

                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #10
0
        // GET: Assets/SystemDetails/5
        public ActionResult SystemDetails(int?id)
        {
            SystemModel model = null;

            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                rs_assets rs_assets = db.rs_assets.Find(id);
                if (rs_assets == null)
                {
                    return(HttpNotFound());
                }
                if (rs_assets.IsSystem)
                {
                    model = AssetHelper.GetSystemModel(rs_assets.AssetId);
                }
                else
                {
                    model.System = rs_assets;
                    model.Assets = null;
                }
                return(View(rs_assets));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #11
0
 public ActionResult Edit(SystemModel model)
 {
     if (AclHelper.hasAccess(User, currentAction, currentController))
     {
         if (ModelState.IsValid)
         {
             model.System.UpdatedDate     = DateTime.Now;
             model.System.CurrentLocId    = model.CurrentLocId;
             model.System.OriginLocId     = model.OriginLocId;
             model.System.OwnedBy         = model.OwnerId;
             model.System.DivId           = model.DivId;
             model.System.OwnerShipId     = model.OwnerShipId;
             model.System.Availability    = model.Availability;
             db.Entry(model.System).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         ViewBag.OriginLocId  = new SelectList(db.rs_locations, "LocationId", "LocationName", model.System.OriginLocId);
         ViewBag.CurrentLocId = new SelectList(db.rs_locations, "LocationId", "LocationName", model.System.CurrentLocId);
         ViewBag.OwnerId      = new SelectList(db.rs_user, "UserId", "Username", model.System.OwnedBy);
         ViewBag.DivId        = new SelectList(db.rs_division, "DivId", "DivisionNo", model.System.DivId);
         ViewBag.OwnerShipId  = new SelectList(db.rs_ownership, "OwnerShipId", "OwnerType", model.System.OwnerShipId);
         ViewBag.Availability = new SelectList(db.rs_assetstatus, "StatusId", "Status", model.System.Availability);
         return(View(model));
     }
     else
     {
         return(RedirectToAction("NotAuthenticated", "Home"));
     }
 }
예제 #12
0
        public ActionResult Edit(rs_module rs_module)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                if (ModelState.IsValid)
                {
                    rs_module current = db.rs_module.SingleOrDefault(m => m.Name == rs_module.Name &&
                                                                     m.Controller == rs_module.Controller &&
                                                                     m.ModuleId != rs_module.ModuleId);
                    if (current != null)
                    {
                        TempData["Notification"] = NotificationHelper.Error("Module already exist.");
                    }
                    else
                    {
                        try
                        {
                            rs_module.UserUpdate = User.Identity.Name;
                            rs_module.DateUpdate = DateTime.Now;

                            db.Entry(rs_module).State = EntityState.Modified;

                            //System.Data.Objects.ObjectStateEntry stateEntry = null;
                            //if (db.ObjectStateManager.TryGetObjectStateEntry(db.CreateEntityKey("rs_module", rs_module), out stateEntry))
                            //{
                            //    // object is attached
                            //    db.rs_module.ApplyCurrentValues(rs_module);
                            //}
                            //else
                            //{
                            //    db.rs_module.Attach(rs_module);
                            //    db.ObjectStateManager.ChangeObjectState(rs_module, EntityState.Modified);
                            //}

                            db.SaveChanges();

                            Logger.Log("Edit", "Edit Module [ID:" + rs_module.ModuleId + ", Name:" + rs_module.Name + "]");

                            TempData["Notification"] = NotificationHelper.Inform("Edit Module [ID:" + rs_module.ModuleId + ", Name:" + rs_module.Name + "]");
                            return(RedirectToAction("Index"));
                        }
                        catch (Exception ex)
                        {
                            TempData["Notification"] = NotificationHelper.Error(ex.Message);
                        }
                    }
                }

                ViewBag.ParentModuleId = new SelectList(db.rs_module.Where(m => m.FlagActive == true).OrderBy(m => m.Name), "ModuleId", "Name", rs_module.ParentModuleId);
                ViewBag.UserEntry      = new SelectList(db.rs_user, "UserId", "Username", rs_module.UserEntry);
                ViewBag.UserUpdate     = new SelectList(db.rs_user, "UserId", "Username", rs_module.UserUpdate);
                return(View(rs_module));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #13
0
        public ActionResult AddAsset(SystemModel model, HttpPostedFileBase file)
        {
            rs_assets    rs_assets = model.SubAsset;
            JSonResponse result    = new JSonResponse();

            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                if (ModelState.IsValid)
                {
                    rs_assets system = db.rs_assets.Find(model.System.AssetId);
                    if (system != null)
                    {
                        rs_assets.CreatedDate  = DateTime.Now;
                        rs_assets.UpdatedDate  = DateTime.Now;
                        rs_assets.CurrentLocId = model.CurrentLocId;
                        rs_assets.OriginLocId  = model.OriginLocId;
                        rs_assets.OwnedBy      = model.OwnerId;
                        rs_assets.DivId        = model.DivId;
                        rs_assets.OwnerShipId  = model.OwnerShipId;
                        rs_assets.Availability = model.Availability;
                        string ownerShip = db.rs_ownership.Find(model.OwnerShipId).OwnerType;
                        int    divNo     = db.rs_division.Find(model.DivId).DivisionNo;

                        rs_assets.TrackingNo = AssetHelper.GenerateTrackingNo(ownerShip, divNo,
                                                                              rs_assets.IsSystem, rs_assets.PurchaseDate);

                        if (AssetHelper.IsImage(file))
                        {
                            file.SaveAs(HttpContext.Server.MapPath("~/AssetsImg/")
                                        + file.FileName);
                            rs_assets.ImageLink = file.FileName;
                        }
                        db.rs_assets.Add(rs_assets);
                        db.SaveChanges();

                        rs_assets_rel rel = new rs_assets_rel();
                        rel.AssetId = rs_assets.AssetId;
                        rel.SysId   = model.System.AssetId;
                        db.rs_assets_rel.Add(rel);
                        db.SaveChanges();

                        return(RedirectToAction("Details", new { id = model.System.AssetId }));
                    }
                    else
                    {
                        return(RedirectToAction("Details", new { id = model.System.AssetId }));
                    }
                }
                else
                {
                    return(RedirectToAction("NotAuthenticated", "Home"));
                }
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #14
0
        public ActionResult Index(LoanFormSearchModel model, string search)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                List <rs_loan_form> loanForm = new List <rs_loan_form>();
                loanForm = db.rs_loan_form.ToList();

                ViewBag.search = search;

                if (model != null)
                {
                    if (model.From != null && model.To != null)
                    {
                        model.To = model.To.Date.Add(new TimeSpan(23, 59, 59));

                        loanForm = loanForm.Where(t => (t.StartDate >= model.From && t.EndDate < model.To)).ToList();
                    }
                    if (model.LoanId != 0)
                    {
                        loanForm = loanForm.Where(t => t.LoanId == model.LoanId).ToList();
                    }
                    if (model.BookedBy != 0)
                    {
                        loanForm = loanForm.Where(t => t.RequestorId == model.BookedBy).ToList();
                    }

                    if (search != null && search.Length > 0)
                    {
                        List <rs_loan_form> searched = new List <rs_loan_form>();

                        foreach (var item in search.Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            searched.AddRange(loanForm.Where(s => s.Address.Contains(item) || s.Company.Contains(item) ||
                                                             s.ContactPersion.Contains(item) || s.Email.Contains(item) ||
                                                             s.Purpose.Contains(item) || s.Telephone.Contains(item) ||
                                                             s.UploadedFile.Contains(item)));
                        }

                        model.Loans = searched.Distinct().ToList();
                        return(View("Index", model));
                    }

                    model.Loans = loanForm;
                }
                else
                {
                    model       = new LoanFormSearchModel();
                    model.Loans = loanForm;
                }

                return(View("Index", model));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #15
0
        //
        // GET: /UserGroup/

        public ActionResult Index()
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                return(View(db.rs_user_group.ToList()));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #16
0
        //
        // GET: /UserGroup/Create

        public ActionResult Create()
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                return(View());
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #17
0
        //
        // GET: /User/

        public ActionResult Index()
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                var rs_user = db.rs_user.Where(e => e.Username != "papaya" && e.UserType == UserType);
                return(View(rs_user.ToList()));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #18
0
        //
        // GET: /UserGroup/Delete/5

        public ActionResult Delete(int id)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                rs_user_group rs_user_group = db.rs_user_group.Single(s => s.GroupId == id);
                return(View(rs_user_group));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #19
0
        //
        // GET: /Action/Details/5

        public ActionResult Details(int id)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                rs_action rs_action = db.rs_action.Single(s => s.ActionId == id);
                return(View(rs_action));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #20
0
        //
        // GET: /Action/

        public ActionResult Index()
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                var rs_action = db.rs_action.Include("rs_module").OrderBy(m => m.ModuleId);
                return(View(rs_action.ToList()));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #21
0
        //[ValidateAntiForgeryToken]
        public ActionResult AttachSubAsset(FormCollection collection)
        {
            int SystemId   = 0;
            int SubAssetId = 0;

            Int32.TryParse(collection.Get("SubAssetId").ToString(), out SubAssetId);
            Int32.TryParse(collection.Get("SystemId").ToString(), out SystemId);

            JSonResponse result = new JSonResponse();

            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                if (SubAssetId != 0 && SystemId != 0)
                {
                    rs_assets rs_asset = db.rs_assets.Find(SubAssetId);
                    rs_assets system   = db.rs_assets.Find(SystemId);

                    if (system != null && rs_asset != null)
                    {
                        //check and only allow to attach if asset not attached before
                        rs_assets_rel exist = db.rs_assets_rel.FirstOrDefault(x => x.AssetId == SubAssetId && x.SysId == SystemId);
                        if (exist == null)
                        {
                            rs_assets_rel rel = new rs_assets_rel();
                            rel.AssetId = rs_asset.AssetId;
                            rel.SysId   = SystemId;
                            db.rs_assets_rel.Add(rel);
                            db.SaveChanges();
                        }
                        else
                        {
                            TempData["Notification"] = NotificationHelper.Inform("Selected Sub Asset already attached");
                        }

                        return(RedirectToAction("Details", new { id = SystemId }));
                    }
                    else
                    {
                        return(RedirectToAction("Details", new { id = SystemId }));
                    }
                }
                else
                {
                    return(RedirectToAction("NotAuthenticated", "Home"));
                }
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #22
0
        public ActionResult Create(SystemModel model, HttpPostedFileBase file)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                if (ModelState.IsValid)
                {
                    model.Step = 2;

                    model.System.CreatedDate  = DateTime.Now;
                    model.System.UpdatedDate  = DateTime.Now;
                    model.System.CurrentLocId = model.CurrentLocId;
                    model.System.OriginLocId  = model.OriginLocId;
                    model.System.OwnedBy      = model.OwnerId;
                    model.System.DivId        = model.DivId;
                    model.System.OwnerShipId  = model.OwnerShipId;
                    model.System.Availability = model.Availability;
                    ViewBag.Availability      = new SelectList(db.rs_assetstatus, "StatusId", "Status");

                    string ownerShip = db.rs_ownership.Find(model.OwnerShipId).OwnerType;
                    int    divNo     = db.rs_division.Find(model.DivId).DivisionNo;

                    model.System.TrackingNo = AssetHelper.GenerateTrackingNo(ownerShip,
                                                                             divNo, model.System.IsSystem, model.System.PurchaseDate);

                    if (AssetHelper.IsImage(file))
                    {
                        file.SaveAs(HttpContext.Server.MapPath("~/AssetsImg/")
                                    + file.FileName);
                        model.System.ImageLink = file.FileName;
                    }

                    db.rs_assets.Add(model.System);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.OriginLocId  = new SelectList(db.rs_locations, "LocationId", "LocationName", model.System.OriginLocId);
                ViewBag.CurrentLocId = new SelectList(db.rs_locations, "LocationId", "LocationName", model.System.CurrentLocId);
                ViewBag.OwnerId      = new SelectList(db.rs_user, "UserId", "Username");
                ViewBag.DivId        = new SelectList(db.rs_division, "DivId", "DivisionNo");
                ViewBag.OwnerShipId  = new SelectList(db.rs_ownership, "OwnerShipId", "OwnerType");
                ViewBag.Availability = new SelectList(db.rs_assetstatus, "StatusId", "Status");

                return(View("Assets", model));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #23
0
        //
        // GET: /Action/Create

        public ActionResult Create()
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                ViewBag.ModuleId = new SelectList(db.rs_module.Where(m => m.FlagActive == true).OrderBy(m => m.Name), "ModuleId", "Name");
                //ViewBag.UserEntry = new SelectList(db.rs_user, "UserId", "Username");
                //ViewBag.UserUpdate = new SelectList(db.rs_user, "UserId", "Username");
                return(View());
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #24
0
        //
        // GET: /Action/Edit/5

        public ActionResult Edit(int id)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                rs_action rs_action = db.rs_action.Single(s => s.ActionId == id);
                ViewBag.ModuleId = new SelectList(db.rs_module.Where(m => m.FlagActive == true).OrderBy(m => m.Name), "ModuleId", "Name", rs_action.ModuleId);
                //ViewBag.UserEntry = new SelectList(db.rs_user, "UserId", "Username", rs_action.UserEntry);
                //ViewBag.UserUpdate = new SelectList(db.rs_user, "UserId", "Username", rs_action.UserUpdate);
                return(View(rs_action));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #25
0
        //
        // GET: /User/Edit/5

        public ActionResult Edit(int id)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                rs_user rs_user = db.rs_user.Single(s => s.UserId == id);
                //ViewBag.CompanyId = new SelectList(db.rs_company.Where(c => c.FlagActive == true).OrderBy(c => c.Name), "CompanyId", "Name", rs_user.CompanyId);
                ViewBag.GroupId = new SelectList(db.rs_user_group.Where(g => g.FlagActive == true).OrderBy(g => g.Name), "GroupId", "Name", rs_user.GroupId);

                return(View(rs_user));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #26
0
        // POST: Assets/Delete/5 Delete Relationship
        //[HttpPost, ActionName("DeleteRel")]
        //[ValidateAntiForgeryToken]
        public ActionResult DeleteRel(int id, int parentId)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                rs_assets_rel rel = db.rs_assets_rel.FirstOrDefault(x => x.AssetId == id && x.SysId == parentId);
                db.rs_assets_rel.Remove(rel);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #27
0
        // POST: Assets/Delete/5 Delete Accessories
        //[HttpPost, ActionName("DeleteAcc")]
        //[ValidateAntiForgeryToken]
        public ActionResult DeleteAcc(int id)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                rs_accessories acc = db.rs_accessories.Find(id);
                db.rs_accessories.Remove(acc);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #28
0
        public ActionResult Edit(rs_action rs_action)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                if (ModelState.IsValid)
                {
                    rs_action current = db.rs_action.SingleOrDefault(m => m.ModuleId == rs_action.ModuleId &&
                                                                     m.Name.ToLower() == rs_action.Name.ToLower() &&
                                                                     m.ActionId != rs_action.ActionId
                                                                     );
                    if (current != null)
                    {
                        TempData["Notification"] = NotificationHelper.Error("Action already exist.");
                    }
                    else
                    {
                        try
                        {
                            rs_action.UserUpdate = User.Identity.Name;
                            rs_action.DateUpdate = DateTime.Now;

                            db.rs_action.Attach(rs_action);
                            db.Entry(rs_action).State = EntityState.Modified;
                            //db.ObjectStateManager.ChangeObjectState(rs_action, EntityState.Modified);
                            db.SaveChanges();

                            Logger.Log("Edit", "Edit Action - [ID:" + rs_action.ActionId + ", Name:" + rs_action.Name + "]");

                            TempData["Notification"] = NotificationHelper.Inform("Edit Action - [ID:" + rs_action.ActionId + ", Name:" + rs_action.Name + "]");
                            return(RedirectToAction("Index"));
                        }
                        catch (Exception ex)
                        {
                            TempData["Notification"] = NotificationHelper.Error(ex.Message);
                        }
                    }
                }

                ViewBag.ModuleId = new SelectList(db.rs_module.Where(m => m.FlagActive == true).OrderBy(m => m.Name), "ModuleId", "Name", rs_action.ModuleId);
                //ViewBag.UserEntry = new SelectList(db.rs_user, "UserId", "Username", rs_action.UserEntry);
                //ViewBag.UserUpdate = new SelectList(db.rs_user, "UserId", "Username", rs_action.UserUpdate);
                return(View(rs_action));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #29
0
        // GET: Assets/Details/5
        public ActionResult Details(int?id)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                ViewBag.OriginLocId  = new SelectList(db.rs_locations, "LocationId", "LocationName");
                ViewBag.CurrentLocId = new SelectList(db.rs_locations, "LocationId", "LocationName");
                ViewBag.OwnerId      = new SelectList(db.rs_user, "UserId", "Username");
                ViewBag.DivId        = new SelectList(db.rs_division, "DivId", "DivisionNo");
                ViewBag.OwnerShipId  = new SelectList(db.rs_ownership, "OwnerShipId", "OwnerType");
                ViewBag.Availability = new SelectList(db.rs_assetstatus, "StatusId", "Status");
                if (AclHelper.IsAdmin(User.Identity.Name))
                {
                    ViewBag.SubAssetId = new SelectList(db.rs_assets.Where(x => x.IsSystem == false), "AssetId", "Model");
                }
                else
                {
                    ViewBag.SubAssetId = new SelectList(db.rs_assets.Where(x => x.IsSystem == false && x.OwnedBy == AclHelper.GetUserId(User.Identity.Name)), "AssetId", "Model");
                }
                SystemModel system = new SystemModel();

                system = AssetHelper.GetSystemModel((int)id);

                if (system.System == null)
                {
                    return(HttpNotFound());
                }
                system.SystemId = system.System.AssetId;

                if (TempData["errorMessage"] != null)
                {
                    TempData["Notification"] = NotificationHelper.Inform(TempData["errorMessage"].ToString());

                    TempData.Remove("errorMessage");
                }
                system.Step = 3;
                return(View("Assets", system));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }
예제 #30
0
        public ActionResult Edit(rs_user_group rs_user_group)
        {
            if (AclHelper.hasAccess(User, currentAction, currentController))
            {
                if (ModelState.IsValid)
                {
                    rs_user_group current = db.rs_user_group.SingleOrDefault(s => s.Name == rs_user_group.Name && s.GroupId != rs_user_group.GroupId);
                    if (current != null)
                    {
                        TempData["Notification"] = NotificationHelper.Error("User group already exist.");
                    }
                    else
                    {
                        try
                        {
                            rs_user_group.UserUpdate = User.Identity.Name;
                            rs_user_group.DateUpdate = DateTime.Now;


                            db.Entry(rs_user_group).State = EntityState.Modified;
                            db.SaveChanges();

                            //db.rs_user_group.Attach(rs_user_group);
                            //db.ObjectStateManager.ChangeObjectState(rs_user_group, EntityState.Modified);
                            //db.SaveChanges();

                            Logger.Log("Edit", "Edit Group [ID:" + rs_user_group.GroupId + "]");

                            TempData["Notification"] = NotificationHelper.Inform("Edit Group [ID:" + rs_user_group.GroupId + "]");

                            return(RedirectToAction("Index"));
                        }
                        catch (Exception ex)
                        {
                            TempData["Notification"] = NotificationHelper.Error(ex.Message);
                        }
                    }
                }

                return(View(rs_user_group));
            }
            else
            {
                return(RedirectToAction("NotAuthenticated", "Home"));
            }
        }