Ejemplo n.º 1
0
		private void btnLogin_Click(object sender, EventArgs e)
		{
			BPUsers bpUsers = new BPUsers();
			int memberID;
			string returnURL;

			returnURL = Request.QueryString["returnUrl"];

			if (returnURL == null)
			{
				returnURL = "Index.aspx";
			}
			memberID = bpUsers.Login(txtLoginID.Text, txtPassword.Text);

			if (memberID > 0)
			{
				FormsAuthenticationTicket ticket;
				string hash;
				HttpCookie cookie;

				ticket = new FormsAuthenticationTicket(1, txtLoginID.Text, DateTime.Now, DateTime.Now.AddMinutes(30), true, memberID + ";" + bpUsers.GetUserGroupPermissions(memberID), FormsAuthentication.FormsCookiePath);

				hash = FormsAuthentication.Encrypt(ticket);

				//new way
				cookie = System.Web.Security.FormsAuthentication.GetAuthCookie(txtLoginID.Text, false, FormsAuthentication.FormsCookiePath);
				cookie.Name = FormsAuthentication.FormsCookieName;
				//cookie.Domain = "." + Request.ServerVariables["HTTP_HOST"];
				cookie.Value = hash;
				Response.AppendCookie(cookie);
				Response.Redirect(returnURL);
			}
			else
			{
				lblErr.Visible = true;
			}
		}
Ejemplo n.º 2
0
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
			// Put user code to initialize the page here
			//this.AuthenticatePage(Globals.PermissionLevels.ManageAdministrators);
			//if (this.CimsUser.RolePermission(Globals.PermissionLevels.ManageAdministrators) < 2)
			//{
				
			//}

			if (IsNewSession)
			{
				AddToListIfAdmin();
				IsNewSession = false;
			}

			if (!Page.IsPostBack)
			{
				BPUsers bp = new BPUsers();
				DSUsers = bp.SelectByID(UserID);

				DataBind();
			}
		}
Ejemplo n.º 3
0
		private void BindDSUsers()
		{
			BPUsers bpUsers = new BPUsers();
			if (lstGroups.SelectedValue == "-1")
			{
				DSUsers = bpUsers.SelectAllAdministrators();
			}
			else
			{
				DSUsers = bpUsers.SelectByGroupID(Convert.ToInt32(lstGroups.SelectedValue));
			}

			DSUsers.tbl_Users.DefaultView.RowFilter = RowFilter("UserFullName", "UserActive");

			letters_Bind();
			dgUsers.DataBind();

			SetPagerButtons();
			if (DSUsers.tbl_Users.DefaultView.Count ==  0)
			{
				lblError.Visible = true;
				lblError.Text = "0 Records found.";
			}

			else
			{
				lblError.Visible = false;
				lblError.Text = "";
			}
		}
Ejemplo n.º 4
0
		protected void AddToListIfAdmin()
		{
			BPUsers bp = new BPUsers();
			DataTable dt = bp.GetAdminForOnlineList(CarrielUser.CarrielIdentity.MemberID);
			if(dt != null)
			{
				dt.Columns.Add(new DataColumn("Session", Type.GetType("System.String")));
				dt.Rows[0]["Session"] = this.Session.SessionID;
				if(Application["LoggedInAdmins"] is DataTable)
				{
					DataTable dt2 = ((DataTable)Application["LoggedInAdmins"]);
					bool b = true;
					foreach(DataRow dr in dt2.Rows)
					{
						if(Convert.ToInt32(dr["UserID"]) == Convert.ToInt32(dt.Rows[0]["UserID"]))
						{
							b = false;
						}
					}
					if(b)
					{
						DataRow dr = dt.Rows[0];
						dt2.ImportRow(dr);
					}
					Application["LoggedInAdmins"] = dt2;
				}
				else
				{
					Application["LoggedInAdmins"] = dt;
				}
			}
		}
Ejemplo n.º 5
0
		private void btnSearch_Click(object sender, EventArgs e)
		{		
			BPUsers users = new BPUsers();
			if(ddlSearchBy.SelectedValue == "firstNames")
			{
				DSUsers = users.SelectByFirstName(txtSearch.Text);
			}
			else //if (ddlSearchBy.SelectedValue == "lastNames")
			{
				DSUsers = users.SelectByLastName(txtSearch.Text);
			}

			FillSearchResults(DSUsers);
		}
Ejemplo n.º 6
0
		private void GetSelectedItems()
		{
			lstSelectedUserItems.Items.Clear();

			if (GroupID != 0)
			{
				MyListViewItem listItem;

				BPUsers bp = new BPUsers();
				BEUsers ds = new BEUsers();
				ds = bp.SelectByGroupID(GroupID);

				foreach (BEUsers.tbl_UsersRow user in ds.tbl_Users)
				{
					listItem = lstSelectedUserItems.Items.Add();
					listItem.CheckBox = true;
					listItem.ItemValue = user.UserID.ToString();
					listItem.Text = user.UserFullName;
				}
			}
		}
Ejemplo n.º 7
0
		private void ShowGroupUsers()
		{
			pnlUsers.Visible = true;

			if (_HasChangedUsers)
			{
				BPGroups groups = new BPGroups();
				BEGroups.tbl_GroupsRow group;
			
				DSGroups = groups.SelectByIDWithUserGroups(GroupID);
				group = DSGroups.tbl_Groups.FindByGroupID(GroupID);

				groups.Update(DSGroups);
				if (_HasChangedUsers)
				{
					groups.UpdateUsers(group.GroupID, UserGroupsList);
				}
			}
				
			BPUsers bp = new BPUsers();
			DSUsers = bp.SelectByGroupID(GroupID);
			dgUsers.DataBind();
		}
Ejemplo n.º 8
0
		private void btnSubmit_Click(object sender, System.EventArgs e)
		{
			BPUsers bp = new BPUsers();
			DSUsers = bp.SelectByID(UserID);

			BEUsers.tbl_UsersRow user = DSUsers.tbl_Users.FindByUserID(UserID);
			user.LoginID = txtLoginName.Text;
			user.Password = txtPassword.Text;

			int testUserID = bp.Login(txtLoginName.Text, txtPassword.Text);

			if (testUserID == 0 || testUserID == UserID)
			{
				bp.Update(DSUsers);
				lblErr.Text = "";
				Response.Redirect(HttpUtility.UrlDecode( Request.QueryString["ReturnUrl"]));
			}
			else
			{
				lblErr.Text = "Sorry username and password taken.";
			}
		}
Ejemplo n.º 9
0
		private void Page_Load(object sender, System.EventArgs e)
		{
			this.AuthenticatePage(new string[] {Globals.PermissionLevels.EditUsers, Globals.PermissionLevels.AddUsers, Globals.PermissionLevels.ViewUsers});
			if (UserID > 0)
			{
				if (this.CarrielUser.RolePermission(Globals.PermissionLevels.EditUsers) != 2)
				{
					btnSubmit.Visible = false;
					btnDelete.Visible = false;
					btnChangePass.Visible = false;
				}
			}
			else
			{
				if (this.CarrielUser.RolePermission(Globals.PermissionLevels.AddUsers) != 2)
				{
					btnSubmit.Visible = false;
					btnChangePass.Visible = false;
				}
			}

			if (IsNewSession)
			{
				AddToListIfAdmin();
				IsNewSession = false;
			}
			
			if (!Page.IsPostBack)
			{
				BPUsers bpUsers = new BPUsers();
				if (UserID != 0)
				{
					//edit administrator

					DSUsers = bpUsers.SelectByID(UserID);
					user = DSUsers.tbl_Users.FindByUserID(UserID);

					txtFirstName.Text = user.UserFirstName;
					txtLastName.Text = user.UserLastName;
					chkActive.Checked = user.UserActive;
					txtEmail.Text = user.UserEmail;
					//lblLoginID.Text = user.LoginID;

					lblTitle.Text = "Edit User";

				}
				else
				{
					//add administrator
					btnChangePass.Visible = false;

					lblTitle.Text = "Add User";
				}

				BindUserGroups();
			}
		}
Ejemplo n.º 10
0
		private void btnDelete_Click(object sender, System.EventArgs e)
		{
			BPUsers bp = new BPUsers();
			BEUsers.tbl_UsersRow User;
			
			DSUsers = bp.SelectByID(UserID);
			User = DSUsers.tbl_Users.FindByUserID(UserID);

			User.Delete();
			bp.Update(DSUsers);

			Response.Redirect("BrowseUsers.aspx");
		}
Ejemplo n.º 11
0
		private void btnSubmit_Click(object sender, System.EventArgs e)
		{
			BPUsers bpUsers = new BPUsers();
			BEUsers.tbl_UsersRow user;
			if (UserID == 0)
			{
				// Add a user
				user = DSUsers.tbl_Users.Newtbl_UsersRow();
			}
			else
			{
				// Edit a user
				DSUsers = bpUsers.SelectByID(UserID);
				user = DSUsers.tbl_Users.FindByUserID(UserID);				
			}

			this.Save(user);

			DSUsers.EnforceConstraints = false;
			user.UserActive = chkActive.Checked;
			
			if (UserID == 0)
			{
				user.DateCreated = DateTime.Now;
				user.DateModified = DateTime.Now;
				user.ModifiedByAdminID = Convert.ToInt32(CarrielUser.CarrielIdentity.MemberID);
				
				DSUsers.tbl_Users.Addtbl_UsersRow(user);
			}
			else
			{
				user.DateModified = DateTime.Now;
				user.ModifiedByAdminID = Convert.ToInt32(CarrielUser.CarrielIdentity.MemberID);
			}

			bpUsers.Update(DSUsers);
		
			Response.Redirect("BrowseUsers.aspx");
		}