示例#1
0
        private void btnSecondSet_Click(object sender, EventArgs e)
        {
            SecondSettingForm settingform = new SecondSettingForm(currentUserId, genderFlag, true);
            DialogResult      result      = settingform.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                MessageBox.Show("수정 완료!");
            }
        }
        private void btnNext_Click(object sender, EventArgs e)
        {
            Button[] attList1 = new Button[8];               //본인 성격 버튼 배열
            attList1[0] = button1;
            attList1[1] = button2;
            attList1[2] = button3;
            attList1[3] = button4;
            attList1[4] = button5;
            attList1[5] = button6;
            attList1[6] = button7;
            attList1[7] = button8;

            Button[] attList2 = new Button[8];              //본인 매력포인트 버튼 배열
            attList2[0] = button9;
            attList2[1] = button10;
            attList2[2] = button11;
            attList2[3] = button12;
            attList2[4] = button13;
            attList2[5] = button14;
            attList2[6] = button15;
            attList2[7] = button16;

            if (!IsAttractSelected(attList1, attList2))              //버튼이 3개씩 선택되지 않았을 경우 리턴
            {
                return;
            }

            // 이름, 성별, 학과, 본인어필, 이상형 전송
            string attList     = SelectedAttraction(attList1) + SelectedAttraction(attList2);
            string insertQuery = null;

            if (genderFlag == 0)
            {
                insertQuery = "UPDATE user_data_m SET name=@name, age=@age, gender=@gender, department=@department, attraction=@attList WHERE id=@curID;";
            }
            else if (genderFlag == 1)
            {
                insertQuery = "UPDATE user_data_f SET name=@name, age=@age, gender=@gender, department=@department, attraction=@attList WHERE id=@curID;";
            }

            connection.Open();
            MySqlCommand command = new MySqlCommand(insertQuery, connection);

            try
            {
                command.Parameters.AddWithValue("@curID", currentUserId);
                command.Parameters.AddWithValue("@name", txtName.Text);
                command.Parameters.AddWithValue("@age", cmbAge.SelectedItem);
                switch (genderFlag)
                {
                case 0:
                    command.Parameters.AddWithValue("@gender", "남자");
                    break;

                case 1:
                    command.Parameters.AddWithValue("@gender", "여자");
                    break;
                }
                command.Parameters.AddWithValue("@department", departmentList.SelectedItem.ToString());
                command.Parameters.AddWithValue("@attList", attList);

                if (command.ExecuteNonQuery() == 1)
                {
                    MessageBox.Show("정상 전송"); // 나중에 지움
                }
                else
                {
                    MessageBox.Show("비정상 전송");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            connection.Close();
            if (connectFlag == false)
            {
                this.Visible = false; // 첫번째 세팅창 닫기

                SecondSettingForm settingform = new SecondSettingForm(currentUserId, genderFlag, false);
                DialogResult      result      = settingform.ShowDialog();

                if (result == DialogResult.Cancel)
                {
                    this.Visible = true;
                }
                else if (result == DialogResult.No)
                {
                    this.Close();
                    this.DialogResult = DialogResult.No;
                }
            }
            else
            {
                this.DialogResult = DialogResult.Cancel;
            }
        }