コード例 #1
0
ファイル: StudentMapper.cs プロジェクト: PAZ-MI4Ie/PAZ
 public void Save(Student student)
 {
     Boolean insert = true;
     if (student.Id != 0)
     {
         insert = false;
     }
     base.Save(student);
     this._db.OpenConnection();
     MySqlCommand command = this._db.CreateCommand();
     if (insert)
     {
         command.CommandText = "INSERT INTO student (user_id, studentnumber, study) VALUES " +
         "(?user_id, ?studentnumber, ?study)";
     }
     else
     {
         command.CommandText = "UPDATE student (studentnumber, study) VALUES " +
         "(?studentnumber, ?study) WHERE user_id = ?user_id";
     }
     command.Parameters.Add(new MySqlParameter("?user_id", MySqlDbType.Int32)).Value = student.Id;
     command.Parameters.Add(new MySqlParameter("?studentnumber", MySqlDbType.Int32)).Value = student.Studentnumber;
     command.Parameters.Add(new MySqlParameter("?study", MySqlDbType.String)).Value = student.Study;
     this._db.ExecuteCommand(command);
     this._db.CloseConnection();
     if (insert)
     {
         Pair pair = new Pair();
         pair.Student1 = student;
         pair.Student1_id = student.Id;
         PAZController.GetInstance().PairMapper.Save(pair);
     }
 }
コード例 #2
0
ファイル: KoppelWindow.xaml.cs プロジェクト: PAZ-MI4Ie/PAZ
        private void SelectCoupledUsers(Pair selectedPair, ComboBox firstBox, ComboBox secondBox)
        {
            bool userSelected = false;
            bool foundAllUsers = false;
            for (int i = 1; i < firstBox.Items.Count && !foundAllUsers; ++i)
            {
                User currentUser = (User)firstBox.Items[i];
                foreach (User user in selectedPair.Attachments)
                {
                    if (currentUser.Id == user.Id)
                    {
                        if (userSelected)
                        {
                            secondBox.SelectedIndex = i;
                            foundAllUsers = true;
                            break;
                        }
                        else
                        {
                            firstBox.SelectedIndex = i;
                            userSelected = true;
                        }
                    }
                }
            }

            if (!foundAllUsers)
                secondBox.SelectedIndex = 0;

            if (!userSelected)
                firstBox.SelectedIndex = 0;
        }