using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
namespace TellCenter
{
public partial class Form1 : Form1
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string str = ConfigurationManager.ConnectionStrings["sqlstring"].ConnectionString;
using (SqlConnection sqlcnn = new SqlConnection(str))
{
SqlCommand sqlcmm = sqlcnn.CreateCommand();
sqlcmm.CommandText = "select * from Login where Name=@name and Password=@pass";
sqlcmm.Parameters.Add("@name", System.Data.SqlDbType.VarChar, 20).Value = txtname.Text;
sqlcmm.Parameters.Add("@pass", System.Data.SqlDbType.VarChar, 20).Value = txtpassword.Text;
object num = null;
try
{
sqlcnn.Open();
num = sqlcmm.ExecuteScalar();
sqlcnn.Close();
if (num != null)
{
MessageBox.Show("登陆成功!");
Form1 f11 = new Form1();
this.Hide();
Form1 f1 = new Form2();
f1.Show();
}
else
{
//this.Response.Write("用户名和密码错误!");
MessageBox.Show("用户名或密码错误!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click_1(object sender, EventArgs e)
{
}
}
}