Ejemplo n.º 1
0
        /// <summary>
        /// Connects to the database using the connected model approach
        /// and signs in
        /// </summary>
        private void btnSignin_Click(object sender, EventArgs e)
        {
            string user = tbUser.Text;

            userName = user;
            string password = tbPassword.Text;

            System.Diagnostics.Debug.WriteLine("The name and password " + user + password);
            SqlConnection conn       = new SqlConnection();
            string        connString = "Server=(local); Database=PackMyBag; User="******"; Password="******";";

            Form2 frm = new Form2();

            try
            {
                conn = new SqlConnection(connString);
                conn.Open();

                if (!(conn.State == ConnectionState.Closed))
                {
                    System.Diagnostics.Debug.WriteLine("the user from form 1 is " + user);
                    User.setUser(user);

                    this.Hide();
                    frm.Show();
                }
                else
                {
                    MessageBox.Show("Connection Failed", "Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in connection : " + ex.Message);
            }
            //this.Hide();
            //Form2 frm = new Form2();
            //frm.Show();
        }