The interface is as above :
It's an initial login interface , There are registration and login functions , use mysql database :
Registration interface :
Login interface template :

using System; using System.Collections.Generic; using System.ComponentModel;
using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System.Threading.Tasks; using System.Windows.Forms; using
MySql.Data.MySqlClient; using System.Data.SqlClient; namespace
WinForms_Medicine_test { public partial class Form1 : Form { private int
error_time = 3; public Form1() { InitializeComponent(); } private void
textBox1_TextChanged(object sender, EventArgs e) { } private void
button1_Click(object sender, EventArgs e) { label4.Text = " Logging in ... please wait a moment "; Form2 f2
= new Form2(); f2.showuser = this.textBox1.Text.Trim();
//------------------ Connection database string ----------------------------------- String
serverinfo = "server=your_server;" + "port=your_port;" + "user=your_username;"
+ "password=your_passwd;" + "database=;";
//------------------ Connection database string ----------------------------------- // anomaly detection string
username = textBox1.Text.Trim(); string passwd = textBox2.Text.Trim(); if
(username.Equals("") || passwd.Equals("")) { MessageBox.Show(" The user name or password cannot be empty !"); }
else { MySqlConnection conn = new MySqlConnection(serverinfo); // Make a connection try {
conn.Open(); // open // establish sql sentence string sql = "select count(*) from
userINFO.loginINFO where name = '" + username + "' and passwd = '" + passwd +
"'"; MySqlCommand com = new MySqlCommand(sql, conn); int resp =
Convert.ToInt32(com.ExecuteScalar()); // Judge whether it exists if (resp > 0) { label4.Text =
""; MessageBox.Show(" Login successful !"); this.Hide(); f2.Show(); conn.Close();// Close the connection }
else { error_time = error_time - 1; // Wrong time MessageBox.Show(" Wrong user name or password !!");
label4.Text = ""; } } catch (Exception ex) {
MessageBox.Show(" An unknown error has occurred , Please contact the administrator ."); label4.Text = ""; } } } private void
textBox2_TextChanged(object sender, EventArgs e) { } private void
label1_Click(object sender, EventArgs e) { } private void Form1_Load(object
sender, EventArgs e) { } private void button2_Click(object sender, EventArgs e)
{ Form3 f3 = new Form3(); this.Hide(); f3.Show(); } } }
Registration interface :

using System; using System.Collections.Generic; using System.ComponentModel;
using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System.Threading.Tasks; using System.Windows.Forms; using
MySql.Data.MySqlClient; using System.Data.SqlClient; namespace
WinForms_Medicine_test { public partial class Form3 : Form { public Form3() {
InitializeComponent(); } private void label4_Click(object sender, EventArgs e)
{ } private void textBox1_TextChanged(object sender, EventArgs e) { } private
void button2_Click(object sender, EventArgs e) { Form1 f1 = new Form1();
this.Hide(); f1.Show(); } public string nickname = ""; public string username =
""; private void button1_Click(object sender, EventArgs e) { label5.Text =
" Registered ... please wait a moment "; //------------------ Connection database string -----------------------------------
String serverinfo = "server=your_server;" + "port=your_port;" +
"user=your_username;" + "password=your_passwd;" + "database=;";
//------------------ Connection database string ----------------------------------- string username
= textBox1.Text.Trim(); string passwd = textBox2.Text.Trim(); // Get the registered user name and password entered
string nickname = textBox3.Text.Trim(); MySqlConnection conn = new
MySqlConnection(serverinfo); // Make a connection try { conn.Open(); // open // establish sql sentence string
sql_1 = "select count(*) from userINFO.loginINFO where name = '"+ username+"'";
string sql_2 = "select count(*) from userINFO.loginINFO where name = '" +
nickname + "'"; MySqlCommand com_1 = new MySqlCommand(sql_1, conn);
MySqlCommand com_2 = new MySqlCommand(sql_2, conn); int resp_1 =
Convert.ToInt32(com_1.ExecuteScalar()); // Judge whether it exists or not int resp_2 =
Convert.ToInt32(com_2.ExecuteScalar()); if (resp_1 > 0) {
MessageBox.Show(" The user name already exists ! Please re-enter !"); label5.Text = ""; } else { if(resp_2 > 0) {
MessageBox.Show(" Nickname already exists , Please re-enter "); label5.Text = ""; } else { String sql_insert =
"insert into userINFO.loginINFO(name,passwd,nickname) VALUES('" + username +
"','" + passwd +"','"+nickname + "')"; MySqlCommand com_3 = new
MySqlCommand(sql_insert, conn); com_3.ExecuteNonQuery(); // implement MySqlCommand
com_4 = new MySqlCommand(sql_1, conn); // Check whether the registration data is added to the database
com_4.ExecuteNonQuery(); // implement int resp_4 =
Convert.ToInt32(com_4.ExecuteScalar()); com_3 = null; if (resp_4 > 0) {
MessageBox.Show(" congratulations ! " + nickname + ", login was successful , Go and land !"); label5.Text = ""; Form1 f1
= new Form1(); this.Hide(); f1.Show(); } else { MessageBox.Show(" login has failed ! Please try again !");
label5.Text = ""; } } } conn.Close();// Finally, close the connection } catch (Exception ex) {
MessageBox.Show(" An unknown error has occurred , Please contact the administrator ."); label5.Text = ""; } } private void
Form3_Load(object sender, EventArgs e) { } } }

Technology
©2019-2020 Toolsou All rights reserved,
Huawei 2021 session Hardware Engineer Logical post (FPGA) Super detailed surface !!!Vue-element-admin upgrade ui edition virtual machine VMware Download and install the most detailed tutorial !C++ Move constructor and copy constructor sound of dripping water java Backstage interview pygame Realize full screen mode and adjustable window size mysql Database setting character set configuration modification my.ini file (windows)30 What's the experience of being a junior programmer at the age of 20 C++ Multithreading programming ( Summary of common functions and parameters )python_ cherry tree