HomePage.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace HotelMS
{
    public partial class HomePage:Form
    {
        public HomePage()
        {
            InitializeComponent();
            AccountText.Focus();
        }

        private void Homepage_Load(object sender,EventArgs e)
        {
            this.CenterToScreen();
        }

        private void Login_Click(object sender,EventArgs e)
        {
            string account = AccountText.Text;
            string sqlconn = @"server=.;Initial Catalog=HotelMS;Integrated Security=True";
            SqlConnection sqlConnection=new SqlConnection(sqlconn);
            sqlConnection.Open();
            SqlCommand sqlCommand = new SqlCommand(
                "select * from UserInfo where Userid='"+AccountText.Text+"' and Userpsw='"+PasswordText.Text+"'"
                ,sqlConnection);
            SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
            if(!sqlDataReader.Read()) MessageBox.Show("用户名或密码错误!","提示");
            else
            {
                sqlDataReader.Close();
                sqlCommand=new SqlCommand(
                "select Usertype from UserInfo where Userid='"+AccountText.Text+"'"
                ,sqlConnection);
                if(sqlCommand.ExecuteScalar().ToString()=="管理员")
                {
                    AdminPage adminPage = new AdminPage(account);
                    adminPage.Show();
                }
                else
                {
                    UserPage userPage = new UserPage(account);
                    userPage.Show();
                }
                sqlConnection.Close();
                AccountText.Text="";
                PasswordText.Text="";
            }
        }

        private void timer1_Tick(object sender,EventArgs e)
        {
            lbltime.Text=DateTime.Now.ToString();
        }

        private void lbltime_Load(object sender,EventArgs e)
        {
            lbltime.Text=DateTime.Now.ToString();
后面还有 30 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。