⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adminlogin.cs

📁 这是个C#做成的图书管理系统,请大家参考,多提建议
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace BookMS
{
    public partial class AdminLogin : Form
    {
        public AdminLogin()
        {
            InitializeComponent();
        }

        DataSet ds = new DataSet("AdminDs");
        private void AdminLogin_Load(object sender, EventArgs e)
        {
            if (File.Exists("..\\..\\AdminDs.ds"))
            {
                ds.Clear();
                ds.ReadXml("..\\..\\AdminDs.ds");
                comboBox1.DisplayMember = "用户名";
                comboBox1.ValueMember = "用户名";
                comboBox1.DataSource = ds.Tables["AdminTab"];

            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "")
            {
                MessageBox.Show("请选择用户!");
            }
            else
            {
                if (textBox2.Text == "")
                {
                    MessageBox.Show("请输入密码!");
                }
                else
                {
                    if (File.Exists("..\\..\\AdminDs.ds"))
                    {
                        ds.Clear();
                        ds.ReadXml("..\\..\\AdminDs.ds");
                        try
                        {
                            ds.Tables["AdminTab"].PrimaryKey = new DataColumn[] { ds.Tables["AdminTab"].Columns["用户名"] };
                            DataRow dr = ds.Tables["AdminTab"].Rows.Find(comboBox1.SelectedValue.ToString());

                            if (dr["密码"].ToString() == textBox2.Text && dr["权限"].ToString() == "1")
                            {
                                BookMS bms = new BookMS();
                                bms.Show();
                                this.Visible=false;
                            }
                            else if (dr["密码"].ToString() == textBox2.Text && dr["权限"].ToString() == "0")
                            {
                                MessageBox.Show("你是普通用户,有些功能将受到限制!");
                                BookBorrowCenter ublc = new BookBorrowCenter();
                                ublc.Show();
                                this.Visible=false;
                            }
                            else
                            {
                                MessageBox.Show("登录失败!");
                            }
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("无此用户!");
                        }
                        
                    }
                    else
                    {
                        MessageBox.Show("请与管理员确认服务是否启动", "提示", MessageBoxButtons.RetryCancel);
                    }
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -