This article shares the specific code of C# restaurant management system for your reference. The specific content is as follows
Part of the code:
fm_change_password.cs
using System; using ; using ; using ; using ; using ; using ; using ; using ; using ; namespace FoodManage { public partial class fm_change_password : Form { public fm_change_password() { InitializeComponent(); } public string useridname = ""; private void bt_ok_Click(object sender, EventArgs e) { SqlConnection conn=new SqlConnection(fm_public.strcon); (); SqlDataAdapter sda = new SqlDataAdapter("SELECT Password FROM TUser WHERE UserIDName='" + useridname + "'", conn); DataTable DT=new DataTable(); (DT); if([0]["Password"].ToString()!=tb_oldpass.Text) { ("Please re-enter the old password"); return; } if (tb_newpassw.Text != tb_newpass.Text) { ("Please re-enter the password when the two times are different"); return; } SqlCommand cmd = new SqlCommand("UPDATE TUser SET Password=@Password WHERE UserIDName='" + useridname + "'", conn); ("@Password",,128).Value=tb_newpassw.Text; (); ("Password modification was successful!(* ̄︶ ̄)y "); (); (); } private void bt_esc_Click(object sender, EventArgs e) { (); } } }
fm_login.cs
using System; using ; using ; using ; using ; using ; using ; using ; using ; namespace FoodManage { public partial class fm_login : Form { public fm_login() { InitializeComponent(); } private void bt_login_Click(object sender, EventArgs e) { //Discern whether the user name or password text box is empty if(tb_username.Text==""||tb_password.Text=="") { if(tb_username.Text=="") { ("Username is empty,Please re-enter!(* ̄︶ ̄)y "); return; } if (tb_password.Text == "") { ("Password is empty,Please re-enter!(* ̄︶ ̄)y "); return; } } //Connect the database SqlConnection conn = new SqlConnection(fm_public.strcon); (); string selectsql = "SELECT * FROM TUser WHERE UserIDName='" + tb_username.Text + "'"; SqlDataAdapter sda = new SqlDataAdapter(selectsql, conn); DataTable dt = new DataTable(); (dt); //Judge whether the user exists if ( == 0) { ("No user"); return; } //Discern whether the user name is locked if (([0]["LockIf"]) == true) { ("The user has been locked,Please contact the administrator!/(ㄒoㄒ)/~~ "); return; } //Preparation before updating the database SqlCommand cmd = new SqlCommand(); = conn; = ; //Judge whether the password is entered correctly. If the input is incorrect, the "Error Number" + 1. If the "Error Number" is cleared after the login is successfully logged in, the "Error Number" is cleared after the "Error Number" is cleared after the input is incorrect. if(tb_password.Text!=[0]["Password"].ToString()) { //Number of errors +1 = @"UPDATE TUser SET ErrorTime=ErrorTime+1 WHERE UserIDName=@UserName"; ("@UserName", , 8); ["@UserName"].Value = tb_username.(); (); ("密码错误Please re-enter!/(ㄒoㄒ)/~~ "); return; } // After the above verification, the user name and password are correct, the following code is executed without errors (set the error number is 0) = "update TUser set ErrorTime=0 where UserIDName=@UserName"; ("@UserName", , 8); ["@UserName"].Value = tb_username.(); (); (); fm_public.LoginSuccess = true; //Set user permissions and initialize the relevant parameters of the main interface if ([0]["Post"].ToString() == "administrator") { fm_public.userpower = "administrator"; } else { fm_public.userpower = "waiter"; } fm_public.useridname = [0]["UserIDName"].ToString(); fm_public.logintime = (); (); } private void bt_esc_Click(object sender, EventArgs e) { if (("Are you sure to exit the system?", "hint", , ) == ) { (); } } private void fm_login_Activated(object sender, EventArgs e) { tb_username.Focus(); } private void fm_login_Load(object sender, EventArgs e) { fm_start fm_starts = new fm_start(); fm_starts.ShowDialog(); } } }
Source code download:C# implements restaurant management system
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.