コード例 #1
0
ファイル: StudentModel.cs プロジェクト: jackzorror/msdwpf
        internal MSDStudent AddStudentInformation(MSDStudent student)
        {
            String query = " INSERT INTO student (last_name, first_name, gender, dob, home_phone, cell_phone, email_address, home_address) VALUES (" +
                           " '" + student.LastName + "'" +
                           ",  '" + student.FirstName + "'" +
                           ",  '" + student.Gender + "'" +
                           ", " + (student.Dob != null ? "'" + ((DateTime)student.Dob).ToString("yyyy-MM-dd HH:mm:ss") + "'" : "null") +
                           ", '" + student.HomePhone + "'" +
                           ", '" + student.CellPhone + "'" +
                           ", '" + student.EmailAddress + "'" +
                           ", '" + student.HomeAddress + "'" +
                           "); ";
            try
            {
                SQLiteCommand command = new SQLiteCommand(query, lconn);
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return FindStudentByFirstNameLastName(student.FirstName, student.LastName);
        }
コード例 #2
0
ファイル: StudentModel.cs プロジェクト: jackzorror/msdwpf
 internal void SaveStudentInformation(MSDStudent student)
 {
     String query = " UPDATE student  SET " +
                    " last_name = '" + student.LastName + "'" +
                    ", first_name = '" + student.FirstName + "'" +
                    ", gender = '" + student.Gender + "'" +
                    ", dob = " + (student.Dob != null ? "'" + ((DateTime)student.Dob).ToString("yyyy-MM-dd HH:mm:ss") + "'": "null") +
                    ", home_phone = '" + student.HomePhone + "'" +
                    ", cell_phone = '" + student.CellPhone + "'" +
                    ", email_address = '" + student.EmailAddress + "'" +
                    ", home_address = '" + student.HomeAddress + "'" +
                    " WHERE id = " + student.Id;
     try
     {
         SQLiteCommand command = new SQLiteCommand(query, lconn);
         command.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
コード例 #3
0
ファイル: StudentModel.cs プロジェクト: jackzorror/msdwpf
        internal MSDStudent FindStudentById(int id)
        {
            String query = "SELECT * FROM student WHERE id = " + id + ";";
            try
            {
                SQLiteCommand command = new SQLiteCommand(query, lconn);
                SQLiteDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    MSDStudent student = new MSDStudent();
                    student.Id = System.DBNull.Value != reader["id"] ? Convert.ToInt32(reader["id"]) : 0;
                    student.LastName = System.DBNull.Value != reader["last_name"] ? (String)reader["last_name"] : null;
                    student.FirstName = System.DBNull.Value != reader["first_name"] ? (String)reader["first_name"] : null;
                    student.Gender = System.DBNull.Value != reader["gender"] ? (String)reader["gender"] : null;
                    student.Dob = System.DBNull.Value != reader["dob"] ? (DateTime?)reader["dob"] : (DateTime?)null;
                    student.HomePhone = System.DBNull.Value != reader["home_phone"] ? (String)reader["home_phone"] : null;
                    student.CellPhone = System.DBNull.Value != reader["cell_phone"] ? (String)reader["cell_phone"] : null;
                    student.EmailAddress = System.DBNull.Value != reader["email_address"] ? (String)reader["email_address"] : null;
                    student.HomeAddress = System.DBNull.Value != reader["home_address"] ? (String)reader["home_address"] : null;
                    student.IsActive = System.DBNull.Value != reader["is_active"] ? Convert.ToInt32(reader["is_active"]) == 1 : false;

                    return student;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return null;
        }
コード例 #4
0
ファイル: StudentViewModel.cs プロジェクト: jackzorror/msdwpf
        internal void SetCurrentStudent(MSDStudent student)
        {
            CurrentMSDStudent = student;

            StudentMedicalEditButtonLabel = "Edit";
            CanEditStudentMedical = false;
            CanClickStudentMedicalSave = false;
            NotifyPropertyChanged("");
        }
コード例 #5
0
ファイル: StudentViewModel.cs プロジェクト: jackzorror/msdwpf
        internal void FoundSearchStudent(MSDStudent student)
        {
            CurrentMSDStudent = student;

            StudentInformationEditButtonLabel = "Edit";
            CanEditStudentInformation = false;
            CanClickStudentInformationSave = false;

            StudentMedicalEditButtonLabel = "Edit";
            CanEditStudentMedical = false;
            CanClickStudentMedicalSave = false;

            NotifyPropertyChanged("");
        }
コード例 #6
0
ファイル: StudentViewModel.cs プロジェクト: jackzorror/msdwpf
        internal void AddNewStudent()
        {
            CurrentMSDStudent = new MSDStudent();

            ShowStudentTabControl = "Visible";
            StudentSearchErrorMesage = "";
            SearchFirstName = "";
            SearchLastName = "";

            StudentInformationEditButtonLabel = "Cancel";
            CanEditStudentInformation = true;
            CanClickStudentInformationSave = true;

            StudentMedicalEditButtonLabel = "Cancel";
            CanEditStudentMedical = true;
            CanClickStudentMedicalSave = true;

            _msdStudentMedical = new MSDStudentMedical();
            _msdStudentParents = new List<MSDStudentParent>();
            _msdStudentParents.Add(new MSDStudentParent());
            _msdStudentParents.Add(new MSDStudentParent());
            NotifyPropertyChanged("");
        }