コード例 #1
0
        private void btn_cansel_Click(object sender, EventArgs e)
        {
            var form = new Runner_Menu(email);

            form.Show();
            Hide();
        }
コード例 #2
0
ファイル: Login.cs プロジェクト: PDA2304/Marathon_Skills_2016
        private void btn_login_Click(object sender, EventArgs e)
        {
            var conect = new SqlConnection(connection);

            try
            {
                conect.Open();

                string sql     = $"select [User].Email,[User].Password,[User].RoleId from [User] where ([User].Email = '{tb_email.Text}' )";
                var    adapter = new SqlDataAdapter(sql, conect);
                var    ds      = new DataSet();
                adapter.Fill(ds);
                var row = ds.Tables[0].Rows[0].ItemArray;

                if (tb_password.Text == row[1].ToString())
                {
                    if (row[2].ToString() == "R")
                    {
                        var form = new Runner_Menu(tb_email.Text);
                        form.Show();
                        this.Hide();
                    }
                    if (row[2].ToString() == "A")
                    {
                        var form = new Coordinator_Menu();
                        form.Show();
                        this.Hide();
                    }
                    if (row[2].ToString() == "C")
                    {
                        var form = new Administrator_Menu();
                        form.Show();
                        this.Hide();
                    }
                }
            }
            catch (Exception Error)
            {
                MessageBox.Show(Error.Message);
            }
            finally
            {
                conect.Close();
            }
        }
コード例 #3
0
        private void btn_registration_Click(object sender, EventArgs e)
        {
            if (tb_name.Text != "" && tb_last.Text != "" && Password() && Date())
            {
                byte[] byte_img = null;
                if (tb_path_img.Text == "")
                {
                    byte_img = bt;
                }
                else
                {
                    byte_img = File.ReadAllBytes(tb_path_img.Text);
                }

                var conect = new SqlConnection(Properties.Resources.connection);
                try
                {
                    string SQL  = $" update dbo.[User] set Password = N'{tb_password.Text}', FirstName = N'{tb_last.Text}', LastName = N'{tb_name.Text}', IMG = @img where  Email = N'{email}'";
                    string SQL1 = $"set language english update dbo.[Runner] set Gender = N'{cb_sex.SelectedItem}', DateOfBirth = CAST(N'{tb_date.Value.ToString("yyyy-MM-dd HH:mm:ss") + ".000"}' AS DateTime), CountryCode = N'{tb_country.SelectedValue}' where  Email = N'{email}'";

                    conect.Open();

                    var command = new SqlCommand(SQL, conect);
                    command.Parameters.Add(new SqlParameter("@img", byte_img));
                    command.ExecuteNonQuery();

                    command = new SqlCommand(SQL1, conect);
                    command.ExecuteNonQuery();

                    var form = new Runner_Menu(email);
                    Hide();
                    form.Show();
                }
                catch (Exception er)
                {
                    MessageBox.Show(er.Message);
                }
                finally
                {
                    conect.Close();
                }
            }
        }