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); } }
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; }