Example #1
0
        private void btnGoMainForm_Click(object sender, EventArgs e)
        {
            this.Hide();
            AdminMainForm adminMainForm = new AdminMainForm();

            adminMainForm.ShowDialog();
            this.Close();
        }
Example #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                int    number = int.Parse(TextBox_Id.Text);
                string pwd    = TextBox_Pwd.Text;

                //Sql연결
                string constr = "SERVER=127.0.0.1; DATABASE=gsmjukebox;UID=woung;PASSWORD='******'";
                using (SqlConnection sqlconn = new SqlConnection(constr))
                {
                    try
                    {
                        sqlconn.Open();
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show("Error:" + err);
                    }

                    string sql;

                    if (isAdmin)
                    {
                        string sndpwd = TextBox_SndPwd.Text;
                        sql = $"select number, pwd, sndpwd from dbo.Users where number={number} AND pwd='{pwd}' AND sndpwd='{sndpwd}'";
                    }
                    else
                    {
                        sql = $"select number, pwd from dbo.Users where number={number} and pwd='{pwd}'";
                    }


                    SqlCommand    command = new SqlCommand(sql, sqlconn);
                    SqlDataReader reader  = command.ExecuteReader();
                    if (reader.Read())
                    {
                        if (isAdmin)
                        {
                            this.Hide();
                            AdminMainForm adminMainForm = new AdminMainForm();
                            adminMainForm.ShowDialog();
                            this.Close();
                        }
                        else
                        {
                            this.Hide();
                            SongRegisterForm songRegisterForm = new SongRegisterForm();
                            songRegisterForm.loginnedNumber = number;
                            songRegisterForm.ShowDialog();
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("로그인 실패");
                    }
                }
            }
            catch (Exception err)
            {
                MessageBox.Show("아이디를 다시 입력해주세요");
            }
        }