这是我登录页面的代码。但是在用户登录后没有编码的“导航”。需要一些帮助来编码。(导航代码导航到下一个表格)
namespace WindowsFormsApplication2
{
public partial class Form5 : Form
{
public Form5()
{
InitializeComponent();
}
private void Form5_Load(object sender, EventArgs e)
{
using(SqlConnection myconnection = new SqlConnection("Data Source=chariths-bently\\charith;Initial Catalog=emp_mgt;Integrated Security=True"))
{
}
}
private void login_Click(object sender, EventArgs e)
{
if (ok(username.Text, password.Text) > 0)
MessageBox.Show("Access granted");
else
MessageBox.Show("access denied");
}
private int ok( string username, string password)
{
username.Trim();
password.Trim();
SqlDataReader dr = null;
using(SqlConnection myconnection = new SqlConnection("Data Source=chariths-bently\\charith;Initial Catalog=emp_mgt;Integrated Security=True"))
{
myconnection.Open();
string query = "select * from emp_info ";
SqlCommand cmd = new SqlCommand(query,myconnection);
if(cmd.ExecuteScalar () != null)
return 1;
else
return 0;
}
}
}
}
答案 0 :(得分:0)
private void login_Click(object sender, EventArgs e)
{
if (ok(username.Text, password.Text) > 0)
{
MessageBox.Show("Access granted");
Form6 f6 = new Form6(); // create your next form instance,(form6, for example)
f6.Open();
this.Close();
}
....
}