private void button1_Click(object sender, EventArgs e) { if(textBox1.Text == "" || tbNewPassword.Text =="" || tbConfirmPassword.Text =="" || tbNewPassword.Text != tbConfirmPassword.Text) { MessageBox.Show("Please input field! Verify New Password and Confirm Password is the same!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { try { Entities1 mdl = new Entities1(); mdl.Connection.Open(); user user = new user(); user.user_name = textBox1.Text; user.user_password = tbNewPassword.Text; user.created_by = Global.GlobalVar; user.created_date = DateTime.Now; user.updated_by = Global.GlobalVar; user.updated_date = DateTime.Now; user.user_address = ""; user.user_birth_date = DateTime.Now; user.user_birth_place = ""; user.user_email = ""; user.user_first_name = ""; user.user_last_name = ""; user.user_last_login = DateTime.Parse("01/01/1970"); user.user_phone_number = ""; user.user_photo_file = ""; user.user_social_number = ""; user.user_marital_status = ""; user.user_gender = ""; user.user_group_id = 1; mdl.AddTousers(user); mdl.SaveChanges(); mdl.Connection.Close(); MessageBox.Show("Success Add New User", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Loading(); } catch (Exception ex) { MessageBox.Show(ex.Message + " " + ex.InnerException + " " + ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
/// <summary> /// Create a new user object. /// </summary> /// <param name="user_id">Initial value of the user_id property.</param> /// <param name="user_name">Initial value of the user_name property.</param> /// <param name="user_email">Initial value of the user_email property.</param> /// <param name="user_password">Initial value of the user_password property.</param> /// <param name="user_first_name">Initial value of the user_first_name property.</param> /// <param name="user_last_name">Initial value of the user_last_name property.</param> /// <param name="user_last_login">Initial value of the user_last_login property.</param> /// <param name="user_group_id">Initial value of the user_group_id property.</param> /// <param name="user_birth_place">Initial value of the user_birth_place property.</param> /// <param name="user_birth_date">Initial value of the user_birth_date property.</param> /// <param name="user_address">Initial value of the user_address property.</param> /// <param name="user_social_number">Initial value of the user_social_number property.</param> /// <param name="user_photo_file">Initial value of the user_photo_file property.</param> /// <param name="user_gender">Initial value of the user_gender property.</param> /// <param name="user_marital_status">Initial value of the user_marital_status property.</param> /// <param name="created_by">Initial value of the created_by property.</param> /// <param name="created_date">Initial value of the created_date property.</param> /// <param name="updated_by">Initial value of the updated_by property.</param> /// <param name="updated_date">Initial value of the updated_date property.</param> public static user Createuser(global::System.Int32 user_id, global::System.String user_name, global::System.String user_email, global::System.String user_password, global::System.String user_first_name, global::System.String user_last_name, global::System.DateTime user_last_login, global::System.Int32 user_group_id, global::System.String user_birth_place, global::System.DateTime user_birth_date, global::System.String user_address, global::System.String user_social_number, global::System.String user_photo_file, global::System.String user_gender, global::System.String user_marital_status, global::System.String created_by, global::System.DateTime created_date, global::System.String updated_by, global::System.DateTime updated_date) { user user = new user(); user.user_id = user_id; user.user_name = user_name; user.user_email = user_email; user.user_password = user_password; user.user_first_name = user_first_name; user.user_last_name = user_last_name; user.user_last_login = user_last_login; user.user_group_id = user_group_id; user.user_birth_place = user_birth_place; user.user_birth_date = user_birth_date; user.user_address = user_address; user.user_social_number = user_social_number; user.user_photo_file = user_photo_file; user.user_gender = user_gender; user.user_marital_status = user_marital_status; user.created_by = created_by; user.created_date = created_date; user.updated_by = updated_by; user.updated_date = updated_date; return user; }
/// <summary> /// Deprecated Method for adding a new object to the users EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTousers(user user) { base.AddObject("users", user); }