Ejemplo n.º 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (nameTb.Text == "" || idTb.Text == "" || pwPb.Password == "")
            {
                MessageBox.Show("칸을 모두 채워주세요.", "알림", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var MyRead = MysqlConn.ExecuteQuery("select id from user where id='" + idTb.Text + "'");

            if (MyRead.Read())
            {
                MessageBox.Show("이미 존재하는 아이디입니다.", "알림", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            int a = MysqlConn.ExecuteNonQuery("insert into user value('" + nameTb.Text + "', '" + idTb.Text + "', '" + MainWindow.Sha512Hash(pwPb.Password) + "')");

            if (a == 1)
            {
                MessageBox.Show("회원가입 성공", "알림", MessageBoxButton.OK);
                this.Visibility = Visibility.Collapsed;
            }
            else
            {
                MessageBox.Show("회원가입 실패", "알림", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 2
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            int mealIdx = 0;
            int a       = MysqlConn.ExecuteNonQuery("insert into meal(meal_date, meal_type) values('" + DateTime.Now.ToShortDateString() + "', " + mealType + ");");
            //mealIdx 찾아서 insert
            var myRead = MysqlConn.ExecuteQuery("select meal_idx from meal where meal_date ='" + DateTime.Now.ToShortDateString() + "' and meal_type = " + mealType + ";");

            if (myRead.Read())
            {
                mealIdx = Int32.Parse(myRead["meal_idx"].ToString());
            }

            if (mealIdx == 0)
            {
                //에러
                MessageBox.Show("알수없는 에러.", "알림", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            string[] temp = tempTb.Text.ToString().Split(',');
            for (int i = 0; i < temp.Length; i++)
            {
                int b = MysqlConn.ExecuteNonQuery("insert into food(food_info, meal_idx) values('" + temp[i] + "', " + mealIdx + ");");
            }
            MessageBox.Show("급식이 등록되었습니다.", "알림", MessageBoxButton.OK);
            tempTb.Text = "";
            UpdateMeal?.Invoke(mealType);
            this.Visibility = Visibility.Collapsed;
        }
Ejemplo n.º 3
0
        private void GetMenu(int mealType)
        {
            var    myRead     = MysqlConn.ExecuteQuery("select * from meal natural join food where meal_date = '" + DateTime.Now.ToShortDateString() + "' and meal_type=" + mealType + ";");
            string menuString = "";

            while (myRead.Read())
            {
                menuString += myRead["food_info"] + "\n";
            }

            if (menuString == "")
            {
                return;
            }

            switch (mealType)
            {
            case 1:
                type1Tb.Text = menuString;
                break;

            case 2:
                type2Tb.Text = menuString;
                break;

            case 3:
                type3Tb.Text = menuString;
                break;
            }
            return;
        }
Ejemplo n.º 4
0
        private void LoginBtn_Click(object sender, RoutedEventArgs e)
        {
            if (idTb.Text == "" || pwPb.Password == "")
            {
                MessageBox.Show("아이디 또는 비밀번호를 입력하세요.", "알림", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            var MyRead = MysqlConn.ExecuteQuery("select name from user where id='" + idTb.Text + "' and pw='" + Sha512Hash(pwPb.Password.ToString()) + "'");

            if (MyRead.Read())
            {
                userName = MyRead["name"].ToString();
                MessageBox.Show(userName + "님 환영합니다!", "알림", MessageBoxButton.OK);
                MyRead.Close();

                ShowMealCtrl.Visibility = Visibility.Visible;
                //로그인 성공 이후 로직 구현.
                InitData();
            }
            else
            {
                MessageBox.Show("로그인에 실패하였습니다.", "알림", MessageBoxButton.OK, MessageBoxImage.Error);
                MyRead.Close();
                return;
            }
        }