/// <summary>
/// 登陆
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnLogin_Click(object sender, EventArgs e)
{
this.Login();
}
/// <summary>
/// 取消
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnCancel_Click(object sender, EventArgs e)
{
Application.Exit();
}
/// <summary>
/// 跟据分隔符来拆分字符串
/// </summary>
/// <param name="split">分隔符</param>
/// <param name="text">需要拆分的字符串</param>
/// <returns>拆分后的字符串数组</returns>
private string[] StrSplit(string split, string text)
{
char[] delim = split.ToCharArray();
string[] arr = null;
for (int i = 0; i <= text.Length; i++)
{
arr = text.Split(delim, i, StringSplitOptions.RemoveEmptyEntries);
}
return arr;
}
/// <summary>
/// 登陆系统
/// </summary>
private void Login()
{
DataBaseOperate dbo = new DataBaseOperate("bu2-db", "fiber10GDB");
string user = string.Empty;
DataSet ds = dbo.Search("Select * From UploadUser Where UName = '" + txtName.Text.Trim() + "' And UPassword = '" + txtPassword.Text.Trim() + "'", "User");
if (ds.Tables["User"].Rows.Count > 0)
{
//注释掉的部份是用来处理登陆者权限的
//user = ds.Tables["User"].Rows[0][3].ToString();
//ArrayList list = new ArrayList();
//string[] usr = this.StrSplit(",", user);
//for (int i = 0; i < usr.Length; i++)
//{
//
if (usr[i] == "10")
//
{
//
list.Add(UserPurview.Administrator);
//
}
//
else if (usr[i] == "9")
//
{
//
list.Add(UserPurview.PowerUser);
//
}
//
else if (usr[i] == "8")
//
{
//
list.Add(UserPurview.OC48);
//
}
//
else if (usr[i] == "7")
//
{
//
list.Add(UserPurview.XFP);
//
}
//
else if (usr[i] == "6")
//
{
//
list.Add(UserPurview.LR_LRM);
//
}
//
else if (usr[i] == "5")
//
{
//
list.Add(UserPurview.TenG);
//
}
//
else if (usr[i] == "4")
//
{
//
list.Add(UserPurview.Other);
//
}
//
else if (usr[i] == "3")
//
{
//
list.Add(UserPurview.MFG3);
//
}
//
else if (usr[i] == "2")
//
{
//
list.Add(UserPurview.MFG2);
//
}
//
else if (usr[i] == "1")
//
{
//
list.Add(UserPurview.MFG1);
//
}
//
else if (usr[i] == "0")
//
{
//
list.Add(UserPurview.User);
//
}
//}
//UserPurview[] view = new UserPurview[list.Count];
//for (int j = 0; j < list.Count; j++)
//{
//
view[j] = (UserPurview)list[j];
//}
frmMain frm = new frmMain(view);
//登陆成功,隐藏登陆窗体,显示主界面
this.Hide();
frm.Show();
}
else
{
MessageBox.Show("用户名或密码错误,请重新输入!", "Nonentity!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtPassword.Text = string.Empty;
txtName.Focus();
txtName.SelectAll();
}
}