日期:2014-05-18 浏览次数:21087 次
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[&