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

📄 form_editpw.cs

📁 .net 2005 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.Data.SqlClient;
//using System.Data.OleDb;
using System.Data.Odbc;

namespace AttendManager
{
    public partial class Form_EditPW : Form
    {
        OdbcConnection m_connection;
        string m_sConn;
        int m_iCount = 0;
        private Form_Main m_FormMain;


        public Form_EditPW(Form_Main mFrm)
        {
            InitializeComponent();

            m_sConn = "Dsn=" + Properties.Settings.Default.DNS;
            m_FormMain = new Form_Main();
            m_FormMain = mFrm;


        }
        
        private void btn_Change_Click(object sender, EventArgs e)
        {
            try
            {
                if (CheckUser(m_FormMain.m_sUser , this.txt_OldPassWord.Text) == true)
                {
                    //更新用户口令
                    //首先判断添加的信息是否完整
                    if (this.txt_NewPassWord.Text != "" & this.txt_ReNewPassWord.Text != "" )
                    {
                        if (this.txt_NewPassWord.Text == this.txt_ReNewPassWord.Text)
                        {
    
                            //更新记录的SQL语句
                            string update = " UPDATE 用户 SET ";
                            update += " 口令='";
                            update += this.txt_ReNewPassWord.Text + "' WHERE 用户名='";
                            update += m_FormMain.m_sUser + "'";

                            //初始化OleDbCommand
                            OdbcCommand comm = new OdbcCommand();
                            comm.CommandText = update;
                            comm.Connection = m_FormMain.m_connection;
                            if (m_FormMain.m_connection.State == ConnectionState.Closed) { m_FormMain.m_connection.Open(); }

                            //执行添加记录的语句
                            comm.ExecuteNonQuery();

                            //成功提示
                            MessageBox.Show("修改口令成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }
                        else
                        {
                            //错误提示
                            MessageBox.Show("新口令输入不一致!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.txt_NewPassWord.Focus();
                        }

                    }
                    else
                    {
                        //错误提示
                        MessageBox.Show("口令不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.txt_NewPassWord.Focus();
                    }
                    
                }else{
                    MessageBox.Show("原口令不正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "IN button1_Click()", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {

            }
        }


        private bool CheckUser(string sUser, string sPW)
        {
            bool bpass = false;

            if (sPW.Equals("") == false && sUser.Equals("") == false)
            {
                // Execute the DataReader and access the data.
                string queryString = "Select * From 用户 where (用户名 = '" + sUser + "' and 口令 = '" + sPW + "')";
                OdbcCommand command = new OdbcCommand(queryString, m_FormMain.m_connection);
                OdbcDataReader reader = command.ExecuteReader();
                bpass = reader.HasRows;
                reader.Close();
            }
            return bpass;

        }

        private void btn_Cancal_Click(object sender, EventArgs e)
        {
            this.Close();
        }



    }
}

⌨️ 快捷键说明

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