private void Form1_Load(object sender, EventArgs e) { TfSQL con = new TfSQL(); string sql = "select distinct user_name from m_user order by user_name"; con.getComboBoxData(sql, ref cbmname); AcceptButton = btnlogin; }
private void btnlogin_Click(object sender, EventArgs e) { if (cbmname.Text != "") { TfSQL con = new TfSQL(); string sqlpass = "******" + cbmname.Text + "'"; // select user_pass from m_user where user_name = 'dang' if (con.sqlExecuteScalarString(sqlpass) == txtpass.Text) { Form lt = new MainForm(); this.Hide(); lt.ShowDialog(); this.Close(); } else { MessageBox.Show("Pass is not correct", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("User name is null.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }