Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="facultyDto"></param>
        /// <returns></returns>
        public int UpdateFaculty(FacultyDto facultyDto)
        {
            int returnedValue = 0;

            try
            {
                PersonData personData = new PersonData();
                returnedValue = personData.UpdatePerson(facultyDto.Person);
                if (returnedValue > -1)
                {
                    query         = UpdateFacultyQuery(facultyDto);
                    returnedValue = dbConnect.ExecuteQueries(query, false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(-1);
            }
            finally
            {
                dbConnect.CloseConnection();
            }

            return(returnedValue);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="facultyId"></param>
        /// <returns></returns>
        public FacultyDto SelectFacultyById(int facultyId)
        {
            FacultyDto facultyDto;

            try
            {
                facultyDto = new FacultyDto();
                query      = SelectFacultyByCodeQuery(facultyId);
                OleDbDataReader reader = dbConnect.SelectDataReader(query);

                if (reader.Read() && reader.GetValue(0) != DBNull.Value)
                {
                    facultyDto.FacultyId = reader.GetInt32(0);
                    facultyDto.Office    = reader.GetString(1);
                    facultyDto.Salary    = reader.GetInt32(2);
                    facultyDto.ContactNo = reader.GetInt32(3);
                    //Person Info
                    PersonData personData = new PersonData();
                    PersonDto  personDto  = personData.SelectPersonById(facultyId);
                    facultyDto.Person = personDto;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(null);
            }
            finally
            {
                dbConnect.CloseConnection();
            }
            return(facultyDto);
        }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="facultyDto"></param>
 /// <returns></returns>
 private String UpdateFacultyQuery(FacultyDto facultyDto)
 {
     return(@"UPDATE faculty SET   salary = " + facultyDto.Salary + ", contactNo = " + facultyDto.ContactNo + "   WHERE facultyid = " + facultyDto.FacultyId);
 }
Ejemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="facultyDto"></param>
 /// <returns></returns>
 private String InsertFacultyQuery(FacultyDto facultyDto)
 {
     return(@"INSERT INTO faculty
              (facultyid, office, salary, contactNo) VALUES 
              (" + facultyDto.FacultyId + ",'" + facultyDto.Office + "'," + facultyDto.Salary + "," + facultyDto.ContactNo + ")");
 }