Example #1
0
        protected void ButUpdateUser_Click(object sender, EventArgs e)
        {
            // Gets people index from ViewState
            users = (DataLibrary.Users)ViewState["users"];

            // Set user

            users.Name     = boxName.Text;
            users.LastName = boxLastName.Text;
            users.RegionId = Convert.ToInt32(DdlRegion.SelectedValue);

            DateTime signDate = DateTime.ParseExact(boxSignUp.Text, "dd/MM/yyyy", null);

            users.SignUpDate = Convert.ToDateTime(signDate);
            DateTime renewDate = DateTime.ParseExact(boxRenewal.Text, "dd/MM/yyyy", null);

            users.RenewalDate = Convert.ToDateTime(renewDate);

            users.UserName = boxUserName.Text;
            users.Pass     = boxPass.Text;

            BUsers.update(users);

            Response.Redirect("~/Users/MainList.aspx");
        }
Example #2
0
        // End declaration

        protected void Page_Load(object sender, EventArgs e)
        {
            // It does this only the first time the page is loaded
            if (!IsPostBack)
            {
                // Get user index and usert object for that index
                userIndex = Convert.ToInt32(Request.QueryString["userId"]);
                users     = BUsers.getById(userIndex);

                // Save the user object in viewState
                ViewState["users"] = users;


                // Load the dropDownList
                DdlRegion.DataSource     = BRegions.getAll();
                DdlRegion.DataTextField  = "Name";
                DdlRegion.DataValueField = "RegionId";
                DdlRegion.DataBind();

                // DNI cannot be modified
                boxDNI.Enabled = false;
                boxDNI.Text    = users.Dni.ToString();

                // Set the value of the record
                DdlRegion.SelectedValue = users.RegionId.ToString();
                boxName.Text            = users.Name;
                boxLastName.Text        = users.LastName;

                boxSignUp.Text   = users.SignUpDate.ToString("dd/MM/yyyy");
                boxRenewal.Text  = users.RenewalDate.ToString("dd/MM/yyyy");
                boxUserName.Text = users.UserName;
                boxPass.Text     = users.Pass;
            }
        }
Example #3
0
        // End declaration

        protected void Page_Load(object sender, EventArgs e)
        {
            // It does this only the first time the page is loaded
            if (!IsPostBack)
            {
                // Get the record to update through the index in the url
                userIndex = Convert.ToInt32(Request.QueryString["userId"]);
                users     = BUsers.getById(userIndex);

                // Sets people id in viewState
                ViewState["users"] = users;

                // Load the dropDownList
                DdlRegion.DataSource     = BRegions.getAll();
                DdlRegion.DataTextField  = "Name";
                DdlRegion.DataValueField = "RegionId";
                DdlRegion.DataBind();

                // Set the value of the record
                DdlRegion.SelectedValue = users.RegionId.ToString();
                boxName.Text            = users.Name;
                boxLastName.Text        = users.LastName;
                boxDNI.Text             = users.Dni.ToString();
                boxSignUp.Text          = users.SignUpDate.ToShortDateString();
                boxRenewal.Text         = users.RenewalDate.ToShortDateString();
                boxUserName.Text        = users.UserName;
                boxPass.Text            = users.Pass;

                // Disable fields
                disableFields();
            }
        }
Example #4
0
        protected void ButtonDelete_Click(object sender, EventArgs e)
        {
            // Get the record
            users = (DataLibrary.Users)ViewState["users"];

            // Gets people and user index
            userIndex   = users.UserId;
            peopleIndex = users.PeopleId;

            try
            {
                // Delete Users
                BUsers.deleteById(userIndex, peopleIndex);
                Response.Redirect("~/Users/MainList.aspx");
            }
            catch (Exception generalException)
            {
                PanelDeleteUser.Visible = true;
                LiteralDeleteUser.Text  = generalException.Message;
            }
        }