Esempio n. 1
0
        private void BtnEdit_userManager_Click(object sender, EventArgs e)
        {
            Control      txtBoxFirstName = FindControl("txtBox" + textBoxesNames[1]);
            Control      txtBoxLastName  = FindControl("txtBox" + textBoxesNames[2]);
            Control      txtBoxEmail     = FindControl("txtBox" + textBoxesNames[0]);
            Control      txtBoxTickets   = FindControl("txtBox" + textBoxesNames[3]);
            Control      lblID           = FindControl("lblUserId");
            User_Service userService     = new User_Service();
            User         user            = userService.GetUserByID(int.Parse(lblID.Tag.ToString()));
            BsonDocument replacement     = new BsonDocument
            {
                { "_id", lblID.Tag.ToString() },
                { "firstName", txtBoxFirstName.Text },
                { "lastName", txtBoxLastName.Text },
                { "email", txtBoxEmail.Text },
                { "userName", txtBoxFirstName.Text },
                { "password", user.Password },
                { "type", user.Type },
                { "ticket", txtBoxTickets.Text }
            };

            userService = new User_Service();
            foreach (var item in replacement)
            {
                userService.UpdateUserById(replacement, lblID.Tag.ToString(), item.Name, item.Value.ToString());
            }
            MessageBox.Show("chenged successfully");
            this.Close();
        }