private void button1_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection("Data Source=DESKTOP-DELL-30;Initial Catalog=testdb;Integrated Security=True"); SqlDataAdapter sda = new SqlDataAdapter(@"select * from Stock.dbo.Login where username = '******' and password = '******'", conn); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows.Count == 1) { this.Hide(); StockMain main = new StockMain(); main.Show(); } else { MessageBox.Show("Invalid Username/Password..!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); button2_Click(sender, e); } }
private void button2_Click(object sender, EventArgs e) { //To-Do: Check Username and password SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\project\stock\stock\Database1.mdf;Integrated Security=True"); SqlDataAdapter sda = new SqlDataAdapter("select count(*) from Login where username='******' and password='******'", con); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows[0][0].ToString() == "1") { this.Hide(); StockMain main = new StockMain(); main.Show(); } else { MessageBox.Show("Please Enter The Correct Username and password", "alert", MessageBoxButtons.OK, MessageBoxIcon.Error); button1_Click(sender, e); } }
} // Login Button private void button2_click(object sender, EventArgs e) { //TO-DO: Check user name and password SqlConnection con = new SqlConnection("Data Source=ELITE2560P;Initial Catalog=stock;Integrated Security=True"); SqlDataAdapter sda = new SqlDataAdapter(@"SELECT * FROM [dbo].[Login] Where UserName='******' and Password='******'", con); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows.Count == 1) { this.Hide(); StockMain main = new StockMain(); main.Show(); } else { MessageBox.Show("Invalid Username and Password...!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); button1_click(sender, e); } }
private void button2_Click(object sender, EventArgs e) { //To-do check login and password String strSql = "Select* from[commondb].[dbo].StaffCode_ct where Stf_Code = '" + textBox1.Text + "' and password = '******'"; SqlConnection con = Connection.GetConnection(); SqlDataAdapter sda = new SqlDataAdapter("Select * from [commondb].[dbo].StaffCode_ct as aa where aa.[STF_CODE] = '" + textBox1.Text + "' ", con); DataSet dt = new DataSet(); sda.Fill(dt, "StaffCode"); if (dt.Tables[0].Rows.Count == 1) { String dpwd = dt.Tables[0].Rows[0]["password"].ToString(); String dpwd2 = dt.Tables["StaffCode"].Rows[0]["password"].ToString(); String tpwd = textBox2.Text; if (dpwd == tpwd) { this.Hide(); StockMain main = new StockMain(); main.Show(); } else { MessageBox.Show("로그인 아이디 또는 패스워드가 틀립니다. ", "에러 메세지 박스", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("로그인 아이디 또는 패스워드가 틀립니다. ", "에러 메세지 박스2", MessageBoxButtons.OK, MessageBoxIcon.Warning); button1_Click(sender, e); } }