Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Hide();
            Form menu = new MainMenuForm();

            menu.Show();
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Form menu = new MainMenuForm();

            Close();
        }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            AC.openConnection();

            if (string.IsNullOrEmpty(textBoxEID.Text.Trim()) || string.IsNullOrEmpty(textBoxEpass.Text.Trim()))
            {
                MessageBox.Show("社員IDとパスワードを入力してください", "データ入力エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);

                if (textBoxEID.CanSelect)
                {
                    textBoxEID.Select();
                }

                textBoxEID.SelectAll();
                textBoxEpass.Text = string.Empty;

                return;
            }

            AC.sql = "select 社員ID, パスワード, 社員名, ステータス from 社員マスタ where 社員ID = @id and パスワード = @pa;";
            AC.cmd.Parameters.Clear();
            AC.cmd.CommandType = CommandType.Text;
            AC.cmd.CommandText = AC.sql;

            AC.cmd.Parameters.AddWithValue("@id", textBoxEID.Text.Trim());
            AC.cmd.Parameters.AddWithValue("@pa", Sha256hash.ToHash(textBoxEpass.Text.Trim()));

            AC.rd = AC.cmd.ExecuteReader();

            if (AC.rd.HasRows)
            {
                while (AC.rd.Read())
                {
                    AC.currentFullName = AC.rd[2].ToString();
                    status             = int.Parse(AC.rd[3].ToString());
                    MessageBox.Show("ようこそ " + AC.currentFullName + "さん", "ログイン成功", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }

                AC.currentID = int.Parse(textBoxEID.Text);

                textBoxEID.Text   = string.Empty;
                textBoxEpass.Text = string.Empty;

                Hide();

                Form menuForm = new MainMenuForm();
                menuForm.Show();
            }
            else if (status != 0)
            {
                MessageBox.Show("社員IDかパスワードが違います。もう一度やり直してください。", "データ入力エラー", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                if (textBoxEID.CanSelect)
                {
                    textBoxEID.Select();
                }
            }
            else
            {
                MessageBox.Show("社員IDかパスワードが違います。もう一度やり直してください。", "データ入力エラー", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                if (textBoxEID.CanSelect)
                {
                    textBoxEID.Select();
                }
            }

            textBoxEID.SelectAll();
            textBoxEpass.Text = string.Empty;

            AC.rd.Close();
        }