private void btnAdd_Click(object sender, EventArgs e) { string Naam, Surname, userName; int passWord; bool isAdmin = false; if (rdbAdminYes.Checked) { isAdmin = true; } else if (rdbAdminNo.Checked) { isAdmin = false; } if (!Validation.EmployeeName(txtName.Text)) { lblNaam.ForeColor = Color.Red; } else { lblNaam.ForeColor = Color.Black; } if (!Validation.EmployeeSurname(txtSurname.Text)) { lblSurname.ForeColor = Color.Red; } else { lblSurname.ForeColor = Color.Black; } var oleDbConnection = new OleDbConnection(Global.connString); if (Validation.EmployeeName(txtName.Text) && Validation.EmployeeSurname(txtSurname.Text)) { Naam = txtName.Text; Surname = txtSurname.Text; userName = Naam.Substring(0, 1) + Surname.Substring(0, 3); passWord = passRandom.Next(1000, 9999); oleDbConnection.Open(); var myCommand = new OleDbCommand(); myCommand.Connection = oleDbConnection; myCommand.CommandText = "INSERT INTO Users (Employee_Name,Employee_Surname,Employee_Id,Admin_rights,Employee_Password) Values ('" + Naam + "','" + Surname + "','" + userName + "'," + isAdmin + "," + passWord + ")"; myCommand.ExecuteNonQuery(); MessageBox.Show("Data inserted successfully", "Inserted Data", MessageBoxButtons.OK, MessageBoxIcon.Information); oleDbConnection.Close(); Hide(); var form = new AddandRemoveUser(); form.Show(); } else { MessageBox.Show("Please enter values into all field", "Error in field", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public string GetCode() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(Merk.Substring(0, 3).ToUpper()); stringBuilder.Append(Naam.Substring(0, 3).ToUpper()); stringBuilder.Append(Volume.Replace(' ', '_')); return(stringBuilder.ToString()); }
public string GetCode() { string result = null; if (true) { result = Merk.Substring(1, 3) + Naam.Substring(1, 3); } return(result); }
private void button1_Click(object sender, EventArgs e) { string userName; string passWord; //int admin = 0; //if (rdbAdminYes.Checked) //{ // admin = -1 ; //} var oleDbConnection = new OleDbConnection(Global.connString); if (txtNaam.Text != "" && txtSurname.Text != "") { Naam = txtNaam.Text; Surname = txtSurname.Text; userName = Naam.Substring(0, 1) + Surname.Substring(0, 3); Random passRandom = new Random(); passWord = (passRandom.Next(1000, 9000)).ToString(); oleDbConnection.Open(); var myCommand = new OleDbCommand(); myCommand.Connection = oleDbConnection; myCommand.CommandText = "INSERT INTO Users (Employee_Name,Employee_Surname,Employee_Id,Admin_rights) values('" + Naam + "','" + Surname + "','" + userName + "'," + rdbAdminYes.Checked + ")"; myCommand.ExecuteNonQuery(); MessageBox.Show("Data inserted successfully"); oleDbConnection.Close(); Hide(); AddandRemoveUser form = new AddandRemoveUser(); form.Show(); } else { MessageBox.Show("Invalid fields", "Invalid Fields", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public string GetCode() { return $"{Merk.Substring(0, 3).ToUpper()}{Naam.Substring(0, 3).ToUpper()}{Volume.Replace(" ", "_")}"; }
public string GetCode() { return((Merk.Substring(0, 3) + Naam.Substring(0, 3) + Volume.Replace(' ', '_')).ToUpper()); }