public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; User_Model usermodel = new User_Model(); usermodel.LoginPwd = context.Request.Form["txtpwd"]; usermodel.NickName = context.Request.Form["txtnick"]; usermodel.Sex = context.Request.Form["txtsex"]; usermodel.Age = Convert.ToInt32(context.Request.Form["txtage"]); usermodel.FaceId = Convert.ToInt32(context.Request.Form["txtface"]); usermodel.Friend = Convert.ToInt32(context.Request.Form["txtfriend"]); usermodel.Name = context.Request.Form["txtname"]; usermodel.StarId = Convert.ToInt32(context.Request.Form["txtstar"]); usermodel.BloodId = Convert.ToInt32(context.Request.Form["txtblood"]); User_Service userSer = new User_Service(); if (userSer.AddUser(usermodel)) { context.Response.Redirect("Index.ashx"); } else { context.Response.Redirect("Error.html"); } }
//Adds a new user. private void btnAddUser_Click(object sender, EventArgs e) { if (isUserValid()) { User newUser = new User { username = txtUsername.Text, password = txtPassword.Text, lastName = txtlastName.Text, firstName = txtName.Text, email = txtEmailAddress.Text, nrTickets = 0 }; try { service.AddUser(newUser); } catch { MessageBox.Show("Something went wrong", "Error", MessageBoxButtons.OK); } MessageBox.Show($"{newUser.firstName} {newUser.lastName} is added as a new user.", "Welcome aboard!!", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearFields(); } }
private void btn_user_management_add_Click(object sender, EventArgs e) { try { string email = txtbox_user_management_email.Text; string name = txtbox_user_management_name.Text; string password = txtbox_user_management_password.Text; string status = txtbox_user_management_status.Text; user_service.AddUser(email, name, password, status); MessageBox.Show("User has been added", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); //hide panel panel_add_edit_user.Hide(); //fill list again FillUsers(); //Send email notification if used is succesfully added Notifications_Service.Email_UserAddEdit(email, name, password, status, "Added"); } catch (Exception) { MessageBox.Show("Oops, something went wrong. please try again.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }