Example #1
0
        //public static string UserName = "";
        private void btLogin_Click(object sender, EventArgs e)
        {
            SqlCommand command = new SqlCommand();

            command.Connection  = con;
            command.CommandType = CommandType.Text;
            command.CommandText = @"Select * From tblAccount
                                            Where (fldUsername = @User)
                                            And (fldPassword = @Pass)";
            command.Parameters.Add("@User", SqlDbType.NVarChar, 50).Value = txtUsername.Text;
            command.Parameters.Add("@Pass", SqlDbType.NVarChar, 50).Value = txtPassword.Text;
            da.SelectCommand = command;
            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                frmMain1 main = new frmMain1(applicationConfiguration);
                main.Show();
                Hide();
            }
            else
            {
                if (MessageBox.Show(languagePackage.getAskRetryLoginMessage(), languagePackage.getAskRetryLoginTitle(), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    txtUsername.Focus();
                }
                else
                {
                    Close();
                    Dispose();
                    disconnect();
                    System.Windows.Forms.Application.Exit();
                }
            }
        }