private void btnUpdate_Click(object sender, System.EventArgs e)
 {
     try
     {
         Bip.Components.UserEnt entity = new Bip.Components.UserEnt();
         entity.Load((int)ViewState["id"]);
         entity.Login = txtLogin.Text;
         if (txtPassword.Text.Length > 0)
         {
             entity.Password = txtPassword.Text;
         }
         entity.FirstName = txtFirstName.Text;
         entity.LastName  = txtLastName.Text;
         entity.Email     = txtEmail.Text;
         entity.Role      = ddlRoles.SelectedItem.Value;
         entity.Groups    = GetUserGroups();
         entity.Update();
         entity.Dispose();
         Response.Redirect((String)ViewState["UrlReferrer"]);
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }
 private void btnConfDelete_Click(object sender, System.EventArgs e)
 {
     try
     {
         Bip.Components.UserEnt entity = new Bip.Components.UserEnt();
         entity.Load((int)ViewState["id"]);
         entity.Delete();
         entity.Dispose();
         Response.Redirect((String)ViewState["UrlReferrer"]);
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
            try
            {
                if (Page.IsPostBack == false)
                {
                    Bip.Components.UserEnt entity = new Bip.Components.UserEnt();
                    if (Request.Params["Id"] != null)
                    {
                        int id = Int32.Parse(Request.Params["Id"]);
                        entity.Load(id);
                        ViewState["id"]               = id;
                        PanCreateNew.Visible          = false;
                        valReqPassword.Enabled        = false;
                        valReqConfirmPassword.Enabled = false;
                    }
                    else
                    {
                        PanEditExisting.Visible = false;
                        entity.New();
                        valReqPassword.Enabled        = true;
                        valReqConfirmPassword.Enabled = true;
                    }

                    txtLogin.Text           = entity.Login;
                    txtFirstName.Text       = entity.FirstName;
                    txtLastName.Text        = entity.LastName;
                    txtEmail.Text           = entity.Email;
                    ddlRoles.DataSource     = Bip.Components.UserRoles.GetRoleTable();
                    ddlRoles.DataValueField = "Id";
                    ddlRoles.DataTextField  = "Name";
                    ddlRoles.DataBind();
                    foreach (ListItem itm in ddlRoles.Items)
                    {
                        if (itm.Value == entity.Role)
                        {
                            itm.Selected = true;
                        }
                        else
                        {
                            itm.Selected = false;
                        }
                    }


                    dlGroups.DataSource = Bip.Components.GroupEnt.FindAll();
                    //dlGroups.DataValueField = "Id";
                    //dlGroups.DataTextField = "Name";
                    dlGroups.DataBind();
                    foreach (DataListItem itm in dlGroups.Items)
                    {
                        HtmlInputControl hfGroupId = (HtmlInputControl)itm.FindControl("hfGroupId");
                        CheckBox         cbSel     = (CheckBox)itm.FindControl("cbGroupSel");

                        string groupId = hfGroupId.Value;
                        cbSel.Checked = false;
                        foreach (int userGroupId in entity.Groups)
                        {
                            if (userGroupId.ToString() == groupId)
                            {
                                cbSel.Checked = true;
                            }
                        }
                    }



                    entity.Dispose();
                    if (Request.UrlReferrer != null)
                    {
                        ViewState["UrlReferrer"] = Request.UrlReferrer.ToString();
                    }
                    else
                    {
                        ViewState["UrlReferrer"] = "~/Security/UserList.aspx";
                    }
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
Exemplo n.º 4
0
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
			try
			{

				if(Page.IsPostBack==false)
				{
					Bip.Components.UserEnt entity = new Bip.Components.UserEnt();
					if (Request.Params["Id"] != null) 
					{
						int id = Int32.Parse(Request.Params["Id"]);
						entity.Load(id);
						ViewState["id"]=id;
						PanCreateNew.Visible = false;
						valReqPassword.Enabled = false;
						valReqConfirmPassword.Enabled = false;
					}
					else
					{
						PanEditExisting.Visible=false;
						entity.New();
						valReqPassword.Enabled = true;
						valReqConfirmPassword.Enabled = true;
					}

					txtLogin.Text = entity.Login;
					txtFirstName.Text= entity.FirstName;
					txtLastName.Text = entity.LastName;
					txtEmail.Text = entity.Email;
					ddlRoles.DataSource = Bip.Components.UserRoles.GetRoleTable();
					ddlRoles.DataValueField = "Id";
					ddlRoles.DataTextField = "Name";
					ddlRoles.DataBind();
					foreach(ListItem itm in ddlRoles.Items)
						if(itm.Value==entity.Role)
								itm.Selected = true;
						else	itm.Selected = false;


					dlGroups.DataSource = Bip.Components.GroupEnt.FindAll();
					//dlGroups.DataValueField = "Id";
					//dlGroups.DataTextField = "Name";
					dlGroups.DataBind();
					foreach(DataListItem itm in dlGroups.Items)
					{
						HtmlInputControl hfGroupId = (HtmlInputControl) itm.FindControl("hfGroupId");
						CheckBox cbSel = (CheckBox)itm.FindControl("cbGroupSel");

						string groupId = hfGroupId.Value;
						cbSel.Checked = false;
						foreach(int userGroupId in entity.Groups)
							if(userGroupId.ToString() == groupId)
								cbSel.Checked = true;
					}



					entity.Dispose();
					if(Request.UrlReferrer != null)
							ViewState["UrlReferrer"] = Request.UrlReferrer.ToString();
					else	ViewState["UrlReferrer"] = "~/Security/UserList.aspx";
				}
			}
			catch(Exception ex)
			{
				ProcessException(ex);
			}

		}
Exemplo n.º 5
0
		private void btnConfDelete_Click(object sender, System.EventArgs e)
		{
			try
			{
				Bip.Components.UserEnt entity = new Bip.Components.UserEnt();	
				entity.Load( (int)ViewState["id"] );
				entity.Delete();
				entity.Dispose();
				Response.Redirect((String) ViewState["UrlReferrer"]);
			}
			catch(Exception ex)
			{
				ProcessException(ex);
			}
		
		}
Exemplo n.º 6
0
		private void btnUpdate_Click(object sender, System.EventArgs e)
		{
			try
			{
				Bip.Components.UserEnt entity = new Bip.Components.UserEnt();	
				entity.Load( (int)ViewState["id"] );
				entity.Login = txtLogin.Text;
				if(txtPassword.Text.Length > 0)
					entity.Password = txtPassword.Text;
				entity.FirstName = txtFirstName.Text;
				entity.LastName = txtLastName.Text;
				entity.Email = txtEmail.Text;
				entity.Role = ddlRoles.SelectedItem.Value;
				entity.Groups = GetUserGroups();
				entity.Update();
				entity.Dispose();
				Response.Redirect((String) ViewState["UrlReferrer"]);
			}
			catch(Exception ex)
			{
				ProcessException(ex);
			}
		}