コード例 #1
0
        public ActionResult AddEdit(int id, Users usr, string LinkedLoc, string UnlinkedLoc)
        {
            if (base.IsAutoPostback() || !ModelState.IsValid)
            {
                doAddEditPopulate(id, usr);
                #region Use if using Users.Location -at present its aAJAXified
                /*if (locations != null)
                {
                    //HT:CAUTION: Using or assigning to User.UserLocations will create issues
                    locations = locations.Where(l => l != null && l.LocID > Defaults.Integer);
                    usr.UserLocations.Clear(); usr.UserLocations.AddRange(locations);//Pour in location data for View
                }*/
                #endregion
                //In case there's an invalid postback
                ViewData["LinkedLoc"] = LinkedLoc; ViewData["UnlinkedLoc"] = UnlinkedLoc;
                return View(usr);//Request.Form["chkDone"] must be present
            }
            if (usr.isSalesperson) usr.SalespersonCode = "";
            int result = new UserService().AddEdit(usr, LinkedLoc, UnlinkedLoc);
            //Log Activity
            new ActivityLogService((id > Defaults.Integer) ? ActivityLogService.Activity.UserEdit :
                ActivityLogService.Activity.UserAdd).Add();

            TempData["oprSuccess"] = true;
            return RedirectToAction("List");
        }
コード例 #2
0
ファイル: UserService.cs プロジェクト: HSG-PSG-1/CPM_Source
        public int Add(Users userObj, string LinkedLoc, string UnlinkedLoc)
        {
            //Set lastmodified fields
            userObj.LastModifiedBy = _SessionUsr.ID;
            userObj.LastModifiedDate = DateTime.Now;

            dbc.Users.InsertOnSubmit(userObj);
            dbc.SubmitChanges();

            //Process Locations
            BulkAddDelLocations(userObj.ID, LinkedLoc, UnlinkedLoc, true, userObj.OrgIdChanged);

            return userObj.ID; // Return the 'newly inserted id'
        }
コード例 #3
0
        public ActionResult DeleteTaco(int? UserId)
        {
            Users uObj = new Users() { ID = UserId.Value };
            bool proceed = false; string err = "";
            proceed = !(new UserService().IsReferred(uObj));//If user being deleted is referred abort
            if (!proceed)
                err = CPM.Models.Master.delRefChkMsg;
            else
            {
                proceed = !(uObj.ID == _SessionUsr.ID); // Self delete
                if (!proceed) err = "Cannot delete your own record!";
            }

            if (proceed)
            {//Delete & Log Activity
                new UserService().Delete(uObj);
                new ActivityLogService(ActivityLogService.Activity.UserDelete).Add();
            }
            //base.operationSuccess = proceed; HT: DON'T
            return this.Content(Defaults.getTaconite(proceed,
                Defaults.getOprResult(proceed, err), null, true), "text/xml");
        }
コード例 #4
0
ファイル: UserService.cs プロジェクト: HSG-PSG-1/CPM_Source
        public int AddEdit(Users userObj, string LinkedLoc, string UnlinkedLoc)
        {
            int userID = userObj.ID;

            if (userID <= Defaults.Integer) // Insert
                userID = Add(userObj, LinkedLoc, UnlinkedLoc);

            else
            {
                #region Update

                //Set lastmodified fields
                userObj.LastModifiedBy = _SessionUsr.ID;
                userObj.LastModifiedDate = DateTime.Now;

                dbc.Users.Attach(userObj);//attach the object as modified
                dbc.Refresh(System.Data.Linq.RefreshMode.KeepCurrentValues, userObj);

                //Process Locations
                BulkAddDelLocations(userID, LinkedLoc, UnlinkedLoc, false, userObj.OrgIdChanged);
                dbc.SubmitChanges();

                #endregion
            }

            #region If the user is current User's user then update the session for userAttributes

            if (_SessionUsr.ID == userObj.ID)
            {
                _SessionUsr.setUserSession(Login(userObj.Email, userObj.Password)); // HT: Probably no other way
                _Session.RoleRights = GetRoleRights(userObj.RoleID);
            }

            #endregion

            return userObj.ID;
            }
コード例 #5
0
 public void doAddEditPopulate(int id, Users usr)
 {
     ViewData["IsEditMode"] = (id > Defaults.Integer);
     populateData(true);
 }
コード例 #6
0
ファイル: UserService.cs プロジェクト: HSG-PSG-1/CPM_Source
 public bool Delete(Users userObj)
 {
 dbc.Users.DeleteOnSubmit(dbc.Users.Single(c => c.ID == userObj.ID));
 dbc.SubmitChanges();
 // Following code is not working - they say 'optimistic concurrency' is not too gud in L2S
 //dbc.users.Attach(userObj);//attach the object to be deleted
 //dbc.users.DeleteOnSubmit(userObj);//delete the object
 //dbc.SubmitChanges();
 return true;
 }
コード例 #7
0
ファイル: UserService.cs プロジェクト: HSG-PSG-1/CPM_Source
        public Users GetUserById(int id, int OrgID)
        {
            #region Kept for Ref (Tried to load with Users.UserLocations)
            /*http://stackoverflow.com/questions/32433/select-from-multiple-table-using-linq
            DataLoadOptions dlo = new DataLoadOptions();
            //dlo.LoadWith<UserLocation>(v => v.CustomerLocation);
            //HT: SPECIAL CASE: Have added an association between vw_Users_Role_Org & UserLocation (also set PK in vw)
            //Ref: http://forums.asp.net/t/1514585.aspx
            dlo.LoadWith<vw_Users_Role_Org>(v => v.UserLocations);

            dbc.DeferredLoadingEnabled = false;
            dbc.LoadOptions = dlo; */
            #endregion

            using (dbc)
            {
                vw_Users_Role_Org vw_u = (from vw in dbc.vw_Users_Role_Orgs
                                          where vw.ID == id
                                          select vw).SingleOrDefault<vw_Users_Role_Org>();

                emptyUsr.UserLocations = new EntitySet<UserLocation>();//To make sure it DOESN'T come from cache
                Users usr = emptyUsr;
                if (vw_u != null)
                    usr = new Users
                     {
                         ID = vw_u.ID,
                         Name = vw_u.UserName,
                         RoleID = vw_u.RoleID,
                         OrgID = vw_u.OrgID,
                         OrgType = vw_u.OrgTypeId.Value,
                         Email = vw_u.Email,
                         LastModifiedBy = vw_u.LastModifiedBy,
                         Password = vw_u.Password,
                         LastModifiedDate = vw_u.LastModifiedDate,
                         /* Set other special properties */
                         EmailOLD = vw_u.Email,
                         LastModifiedByVal = vw_u.LastModifiedByName,
                         OrgName = vw_u.OrgName,
                         OrgTypeName = vw_u.OrgType,
                         SalespersonCode = vw_u.SalespersonCode
                     };

                usr.OriOrgId = usr.OrgID;//Required ahead
                return usr;
            }
        }
コード例 #8
0
ファイル: CPM.designer.cs プロジェクト: HSG-PSG-1/CPM_Source
 partial void UpdateUsers(Users instance);
コード例 #9
0
ファイル: CPM.designer.cs プロジェクト: HSG-PSG-1/CPM_Source
 partial void InsertUsers(Users instance);
コード例 #10
0
ファイル: CPM.designer.cs プロジェクト: HSG-PSG-1/CPM_Source
		private void detach_Users(Users entity)
		{
			this.SendPropertyChanging();
			entity.MasterRole = null;
		}
コード例 #11
0
ファイル: CPM.designer.cs プロジェクト: HSG-PSG-1/CPM_Source
		private void attach_Users(Users entity)
		{
			this.SendPropertyChanging();
			entity.MasterRole = this;
		}
コード例 #12
0
ファイル: CPM.designer.cs プロジェクト: HSG-PSG-1/CPM_Source
 partial void DeleteUsers(Users instance);