RT  各位高手速度哈  急~~~~~~
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;namespace jinxiaocun
{
    public partial class frmWindows_login : Form
    {
        int nCount = 0;
        public static string strLogin = "";
        public static string strPwd = ""; 
        public static int nXuanzhong = 0;
        string strSQL;
        public static int nsystem;
        public static int ncustormer;
        public static int nsupplie;
        public static int nstockmanage;
        public static int nsellmanage;
        public static int nreservemanage;
        public frmWindows_login()
        {
            InitializeComponent();
        }        private void frmWindows_login_Load(object sender, EventArgs e)
        {        }        private void btnDenglu_Click(object sender, EventArgs e)
        {
            strLogin = txtLogin.Text;//获取用户名的文本信息
            strPwd = txtPwd.Text;            //用户名和密码不能为空
            if (strLogin == "" || strPwd == "") //||表示或者
            {
                MessageBox.Show("用户名和密码不能为空");
                return;//程序不再往后执行
            }
            if (strLogin.IndexOf("'") >= 0)
            {
                MessageBox.Show("密码中不能含有'");
                return;
            }
            
            if (rdbgly.Checked == true) { 
                string strCountsql = "select count(*) from logintable where login='" + strLogin + "'";
                int nCountresult = Convert.ToInt32(ConglyClass.returnStringSql(strCountsql));
                if (nCountresult != 1){MessageBox.Show("你不是管理员/员工,无法登录!"); return;}
                nXuanzhong=1;
            }
            else if (rdbkehu.Checked == true)
            {
                 string strCountsql = "select count(*) from custormer where Clogin='" + strLogin + "'";
                 int nCountresult = Convert.ToInt32(ConglyClass.returnStringSql(strCountsql));
                 if (nCountresult != 1){MessageBox.Show("你不是客户,无法登录!"); return;}
                 nXuanzhong=2;
            }
            else { MessageBox.Show("请选择身份,再登录!"); return;}
            if(nXuanzhong==1){
            strSQL = "select password from logintable where login='" + strLogin + "'";
            }else{
            strSQL = "select CPassword from custormer where CLogin='" + strLogin + "'";
            }
            string strPwd2 = ConglyClass.returnStringSql(strSQL);
            if (strPwd == strPwd2)//判断密码是对的
            {
                this.Hide();
               if (nXuanzhong == 1) {
                   string strsqlcount = "select COUNT(*) from limits_authority where [login]='" + strLogin + "'";
                   if (Convert.ToInt32(ConglyClass.returnStringSql(strsqlcount)) == 1)
                   {
                       string strsql = "SELECT system,custormer,supplie,stockmanage,sellmanage,reservemanage FROM limits_authority where [login]='"+strLogin+"'";
                       SqlDataReader sdrread = ConglyClass.getSqlDataReader(strsql);
                       sdrread.Read();
                       nsystem = Convert.ToInt32(sdrread["system"]);
                       ncustormer = Convert.ToInt32(sdrread["custormer"]);
                       nsupplie=Convert.ToInt32(sdrread["supplie"]);
                       nstockmanage=Convert.ToInt32(sdrread["stockmanage"]);
                       nsellmanage=Convert.ToInt32(sdrread["sellmanage"]);
                       nreservemanage=Convert.ToInt32(sdrread["reservemanage"]);
                   }
                   else {
                       nsystem = 0;
                       ncustormer = 0;
                       nsupplie = 0;
                       nstockmanage = 0;
                       nsellmanage = 0;
                       nreservemanage = 0;
                   }
                   frmSystem_interface frm = new frmSystem_interface();
                   frm.ShowDialog();
               }
              
              if (frmChange_Password.nUpdate == 2) { this.Show(); txtPwd.Text = ""; frmChange_Password.nUpdate = 1; }  else { this.Close(); } 
            }
            else
            {
                //增加第一个功能:错误超过三次,则系统关闭,提示使用变量nCount
                nCount++;//值自动加1
                MessageBox.Show("密码输入错误!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                if (nCount >= 3) this.Close();
            }     
        }        private void btnRegister_Click(object sender, EventArgs e)
        {
            frmWindows_register frm2 = new frmWindows_register();
            frm2.ShowDialog();
            if (frmWindows_register.nRegister_status == 1) { 
            txtLogin.Text = frmWindows_register.strLogin;
            txtPwd.Text = "";}
        }        private void rdbkehu_CheckedChanged(object sender, EventArgs e)
        {        }        private void rdbgly_CheckedChanged(object sender, EventArgs e)
        {        }
    }
}//员工基本信息维护和客户资料管理

解决方案 »

  1.   


    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;namespace jinxiaocun
    {
        public partial class frmWindows_login : Form
        {
            int nCount = 0;
            public static string strLogin = "";//存储用户登录名
            public static string strPwd = ""; //存储用户密码
            public static int nXuanzhong = 0;//选中标记
            string strSQL;
            public static int nsystem;
            public static int ncustormer;
            public static int nsupplie;
            public static int nstockmanage;
            public static int nsellmanage;
            public static int nreservemanage;
            public frmWindows_login()
            {
                InitializeComponent();
            }        private void frmWindows_login_Load(object sender, EventArgs e)
            {        }        private void btnDenglu_Click(object sender, EventArgs e)//登录按钮
            {
                strLogin = txtLogin.Text;//获取用户名的文本信息
                strPwd = txtPwd.Text;            //用户名和密码不能为空
                if (strLogin == "" || strPwd == "") //||表示或者
                {
                    MessageBox.Show("用户名和密码不能为空");
                    return;//程序不再往后执行
                }
                if (strLogin.IndexOf("'") >= 0)//strLogin用户名中是否存在逗号,存在直接return
                {
                    MessageBox.Show("密码中不能含有'");
                    return;
                }
                //选中Checkbox,管理员登陆的。估计是指定管理员用户类型的
                if (rdbgly.Checked == true) { 
                    string strCountsql = "select count(*) from logintable where login='" + strLogin + "'";//定义sql语句,数据库中查找存在用户名和密码的数据条数
                    int nCountresult = Convert.ToInt32(ConglyClass.returnStringSql(strCountsql));//返回数据库查找结果,条数赋给nCountresult 
                    if (nCountresult != 1){MessageBox.Show("你不是管理员/员工,无法登录!"); return;}
                    nXuanzhong=1;//管理员登陆标记设置为1
                }
                else if (rdbkehu.Checked == true)//选择客户登陆,指定客户类型的
                {
                     string strCountsql = "select count(*) from custormer where Clogin='" + strLogin + "'";
                     int nCountresult = Convert.ToInt32(ConglyClass.returnStringSql(strCountsql));
                     if (nCountresult != 1){MessageBox.Show("你不是客户,无法登录!"); return;}
                     nXuanzhong=2;//客户登陆标记设置为2
                }
                else { MessageBox.Show("请选择身份,再登录!"); return;}
                if(nXuanzhong==1){
                strSQL = "select password from logintable where login='" + strLogin + "'";//查询密码
                }else{
                strSQL = "select CPassword from custormer where CLogin='" + strLogin + "'";
                }
                string strPwd2 = ConglyClass.returnStringSql(strSQL);
                if (strPwd == strPwd2)//判断密码是对的
                {
                    this.Hide();//隐藏窗体,估计是登陆窗体吧
                   if (nXuanzhong == 1) {
                       string strsqlcount = "select COUNT(*) from limits_authority where [login]='" + strLogin + "'";
                       if (Convert.ToInt32(ConglyClass.returnStringSql(strsqlcount)) == 1)//如果从数据库找到一条数据
                       {
                           string strsql = "SELECT system,custormer,supplie,stockmanage,sellmanage,reservemanage FROM limits_authority where [login]='"+strLogin+"'";
                           SqlDataReader sdrread = ConglyClass.getSqlDataReader(strsql);
                           sdrread.Read();//读取数据,分别付给下面变量
                           nsystem = Convert.ToInt32(sdrread["system"]);
                           ncustormer = Convert.ToInt32(sdrread["custormer"]);
                           nsupplie=Convert.ToInt32(sdrread["supplie"]);
                           nstockmanage=Convert.ToInt32(sdrread["stockmanage"]);
                           nsellmanage=Convert.ToInt32(sdrread["sellmanage"]);
                           nreservemanage=Convert.ToInt32(sdrread["reservemanage"]);
                       }
                       else {//没找到设置默认值,都设置为0
                           nsystem = 0;
                           ncustormer = 0;
                           nsupplie = 0;
                           nstockmanage = 0;
                           nsellmanage = 0;
                           nreservemanage = 0;
                       }
                       frmSystem_interface frm = new frmSystem_interface();//显示frmSystem_interface窗体
                       frm.ShowDialog();
                   }
                  
                  if (frmChange_Password.nUpdate == 2) { this.Show(); txtPwd.Text = ""; frmChange_Password.nUpdate = 1; }  else { this.Close(); } 
                }
                else
                {
                    //增加第一个功能:错误超过三次,则系统关闭,提示使用变量nCount
                    nCount++;//值自动加1
                    MessageBox.Show("密码输入错误!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    if (nCount >= 3) this.Close();
                }     
            }
           //注册按钮事件
            private void btnRegister_Click(object sender, EventArgs e)
            {
                frmWindows_register frm2 = new frmWindows_register();
                frm2.ShowDialog();
                if (frmWindows_register.nRegister_status == 1) { 
                txtLogin.Text = frmWindows_register.strLogin;
                txtPwd.Text = "";}
            }        private void rdbkehu_CheckedChanged(object sender, EventArgs e)
            {        }        private void rdbgly_CheckedChanged(object sender, EventArgs e)
            {        }
        }
    }//员工基本信息维护和客户资料管理
      

  2.   

    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;namespace jinxiaocun
    {
        public partial class frmWindows_login : Form
        {
            int nCount = 0;
            public static string strLogin = "";
            public static string strPwd = ""; 
            public static int nXuanzhong = 0;
            string strSQL;
            public static int nsystem;
            public static int ncustormer;
            public static int nsupplie;
            public static int nstockmanage;
            public static int nsellmanage;
            public static int nreservemanage;        //------------这上面全是变量的声明        public frmWindows_login()
            {
                InitializeComponent();
            }        private void frmWindows_login_Load(object sender, EventArgs e)
            {        }        private void btnDenglu_Click(object sender, EventArgs e)  
            {
                strLogin = txtLogin.Text;//获取用户名的文本信息
                strPwd = txtPwd.Text;    //密码框的信息            //用户名和密码不能为空
                if (strLogin == "" || strPwd == "") //||表示或者
                {
                    MessageBox.Show("用户名和密码不能为空");
                    return;//程序不再往后执行
                }
                if (strLogin.IndexOf("'") >= 0)
                {
                    MessageBox.Show("密码中不能含有'");
                    return;
                }
                
                if (rdbgly.Checked == true) { 
                    string strCountsql = "select count(*) from logintable where login='" + strLogin + "'";
                    int nCountresult = Convert.ToInt32(ConglyClass.returnStringSql(strCountsql));
                    if (nCountresult != 1){MessageBox.Show("你不是管理员/员工,无法登录!"); return;} 
                    
                    nXuanzhong=1;
                    
                                    //如查XX选中,通过用声明到数据库里查一下,如果有,nXuanzhong变量赋1,否则return
                }
                else if (rdbkehu.Checked == true)
                {
                     string strCountsql = "select count(*) from custormer where Clogin='" + strLogin + "'";
                     int nCountresult = Convert.ToInt32(ConglyClass.returnStringSql(strCountsql));
                     if (nCountresult != 1){MessageBox.Show("你不是客户,无法登录!"); return;}
                     nXuanzhong=2;                //这是和上面一个意思
                }
                else { MessageBox.Show("请选择身份,再登录!"); return;}
                if(nXuanzhong==1){
                strSQL = "select password from logintable where login='" + strLogin + "'";
                }else{
                strSQL = "select CPassword from custormer where CLogin='" + strLogin + "'";
                }
                string strPwd2 = ConglyClass.returnStringSql(strSQL);            //上面是通过用户名查密码            if (strPwd == strPwd2)//判断密码是对的
                {
                    this.Hide();
                   if (nXuanzhong == 1) {
                       string strsqlcount = "select COUNT(*) from limits_authority where [login]='" + strLogin + "'";
                       if (Convert.ToInt32(ConglyClass.returnStringSql(strsqlcount)) == 1)
                       {
                           string strsql = "SELECT system,custormer,supplie,stockmanage,sellmanage,reservemanage FROM limits_authority where [login]='"+strLogin+"'";
                           SqlDataReader sdrread = ConglyClass.getSqlDataReader(strsql);
                           sdrread.Read();
                           nsystem = Convert.ToInt32(sdrread["system"]);
                           ncustormer = Convert.ToInt32(sdrread["custormer"]);
                           nsupplie=Convert.ToInt32(sdrread["supplie"]);
                           nstockmanage=Convert.ToInt32(sdrread["stockmanage"]);
                           nsellmanage=Convert.ToInt32(sdrread["sellmanage"]);
                           nreservemanage=Convert.ToInt32(sdrread["reservemanage"]);                       //
                       }
                       else {
                           nsystem = 0;
                           ncustormer = 0;
                           nsupplie = 0;
                           nstockmanage = 0;
                           nsellmanage = 0;
                           nreservemanage = 0;
                       }
                       frmSystem_interface frm = new frmSystem_interface();
                       frm.ShowDialog();
                   }
                  
                  if (frmChange_Password.nUpdate == 2) { this.Show(); txtPwd.Text = ""; frmChange_Password.nUpdate = 1; }  else { this.Close(); } 
                }
                else
                {
                    //增加第一个功能:错误超过三次,则系统关闭,提示使用变量nCount
                    nCount++;//值自动加1
                    MessageBox.Show("密码输入错误!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    if (nCount >= 3) this.Close();
                }     
            }        private void btnRegister_Click(object sender, EventArgs e)
            {
                frmWindows_register frm2 = new frmWindows_register();
                frm2.ShowDialog();
                if (frmWindows_register.nRegister_status == 1) { 
                txtLogin.Text = frmWindows_register.strLogin;
                txtPwd.Text = "";}
            }        private void rdbkehu_CheckedChanged(object sender, EventArgs e)
            {        }        private void rdbgly_CheckedChanged(object sender, EventArgs e)
            {        }
        }
    }//员工基本信息维护和客户资料管理后面的注释不下去了,真没觉得哪里有必要再注释一下,代码倒是可以整一下,写得有点乱了
      

  3.   

     if (strPwd == strPwd2)//判断密码是对的
                {
                    this.Hide();//隐藏窗体,估计是登陆窗体吧
                   if (nXuanzhong == 1) {
                       string strsqlcount = "select COUNT(*) from limits_authority where [login]='" + strLogin + "'";
                       if (Convert.ToInt32(ConglyClass.returnStringSql(strsqlcount)) == 1)//如果从数据库找到一条数据
                       {
                           string strsql = "SELECT system,custormer,supplie,stockmanage,sellmanage,reservemanage FROM limits_authority where [login]='"+strLogin+"'";
                           SqlDataReader sdrread = ConglyClass.getSqlDataReader(strsql);
                           sdrread.Read();//读取数据,分别付给下面变量
                           nsystem = Convert.ToInt32(sdrread["system"]);
                           ncustormer = Convert.ToInt32(sdrread["custormer"]);
                           nsupplie=Convert.ToInt32(sdrread["supplie"]);
                           nstockmanage=Convert.ToInt32(sdrread["stockmanage"]);
                           nsellmanage=Convert.ToInt32(sdrread["sellmanage"]);
                           nreservemanage=Convert.ToInt32(sdrread["reservemanage"]);
                       }
                       else {//没找到设置默认值,都设置为0
                           nsystem = 0;
                           ncustormer = 0;
                           nsupplie = 0;
                           nstockmanage = 0;
                           nsellmanage = 0;
                           nreservemanage = 0;
                       }
                       frmSystem_interface frm = new frmSystem_interface();//显示frmSystem_interface窗体
                       frm.ShowDialog();

                   }
    不知道frmSystem_interface是不是