public void Update(string Description,int OwnerID,int PreviousSectionID) { Functions F = new Functions(); bool KeepUser = true; int[] UO = F.GetUnassignedObjects(); //Check to see if this is NoBody User if(mvarOwnerID == UO[0]) { OCL.Section PrevSect = F.GetSection(PreviousSectionID); foreach(OCL.User U in PrevSect.CurrentUsers) { if(U.ID == mvarOwnerID) { if(U.NextOwnedSections.Count == 1) { KeepUser = false; //The Nobody User only has this one //section attached to this branch it //is ok to remove him after reassign } } } } string sSQL = "UPDATE tblSection SET Name = '" + Description + "' , OwnerID = " + OwnerID + " WHERE ID = " + mvarID; int results = F.ExecuteSqlCommand(sSQL); int OldOwner = mvarOwnerID; if(OwnerID != mvarOwnerID) { try { sSQL = "SELECT * FROM tblUserSectionRel WHERE UserId = " + OwnerID + " AND " + "SectionId = " + PreviousSectionID; // "SectionId = " + mvarID; DataSet DS = F.ReturnDataSet(sSQL); DataTable DT = DS.Tables[0]; if(DT.Rows.Count == 0) { F.AddUser(OwnerID,PreviousSectionID); } if(!KeepUser) F.RemoveUser(OldOwner,PreviousSectionID); mvarOwnerID = OwnerID; } catch(Exception Err) { throw new ApplicationException(Err.Message,Err.InnerException); } } }
public bool AddUser(OCL.User AccessingUser,OCL.User U,out string ErrorMessage) { try { Functions F = new Functions(); return F.AddUser(AccessingUser,U,this, out ErrorMessage,false); } catch(Exception Err) { throw new ApplicationException(Err.Message); } }
public void AddUser(int UserId) { Functions F = new Functions(); try { F.AddUser(UserId,mvarID); } catch(Exception Err) { throw new ApplicationException(Err.Message); } }