日期:2014-05-17 浏览次数:21007 次
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
namespace stserver
{
public partial class login : Form
{
public login()
{
InitializeComponent();
}
public bool islogin = false;
private void btn_submit_Click(object sender, EventArgs e)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(Application.StartupPath + "\\config.xml");
string connstr = doc.DocumentElement.SelectSingleNode("serverconnstr").InnerText;
string selectstr = "select top 1 id from admin where uid='" + txb_uid.Text + "' and pwd='" + txb_pwd.Text + "'";
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
SqlCommand cmd = new SqlCommand(selectstr, conn);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
islogin = true;
dr.Close();
conn.Close();
conn.Dispose();
MessageBox.Show("您好," + txb_pwd.Text + "!,欢迎使用\n\n祝您工作愉快!", "欢迎", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Close();
}
else
{
dr.Close();
conn.Close();
conn.Dispose();
MessageBox.Show("登录失败!\n请检查您的登录用户名和密码是否正确。\n\n如果您忘记了自己的密码请联系技术部");
txb_uid.Text = "";
txb_pwd.Text = "";
txb_uid.Focus();
}
dr.Close();
conn.Close();
conn.Dispose();
}
catch
{
MessageBox.Show("不能连接到服务器,请联系技术部","服务器故障",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
private void btn_cancel_Click(object sender, EventArgs e)
{
Application.ExitThread();
}
}
}
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace stserver
{