Esempio n. 1
0
        public List <Recess> getAllRecess()
        {
            List <Recess> recesss = new List <Recess>();

            OleDbCommand cmd = DBConnection.getInstance.getDbCommand();

            cmd.CommandText = "SELECT * FROM RECESS";
            OleDbDataReader result = cmd.ExecuteReader();

            if (result.HasRows)
            {
                while (result.Read())
                {
                    Recess recess = new Recess();
                    recess.idRecess    = result.GetInt32(0);
                    recess.company     = companyControl.getCompany(result.GetInt32(1));
                    recess.description = result.GetString(2);
                    recess.recessDate  = result.GetDateTime(3);
                    recess.department  = departmentControl.getDepartment(result.GetInt32(4));

                    recesss.Add(recess);
                }
            }

            result.Close();

            return(recesss);
        }
Esempio n. 2
0
        public Employee getEmployee(int idEmployee)
        {
            Employee employee = new Employee();

            OleDbCommand cmd = DBConnection.getInstance.getDbCommand();

            cmd.CommandText = "SELECT * FROM EMPLOYEE WHERE ID_EMPLOYEE=?";
            cmd.Parameters.Add("ID_EMPLOYEE", OleDbType.Integer).Value = idEmployee;
            OleDbDataReader result = cmd.ExecuteReader();

            if (result.HasRows)
            {
                if (result.Read())
                {
                    employee.idEmployee   = result.GetInt32(0);
                    employee.employeeName = result.GetString(1);
                    String fileName = Convert.ToString(result[2]);
                    employee.pisPasep = Formatter.getInstance.formatPisPasep(result.GetString(3), "");
                    employee.company  = companyControl.getCompany(result.GetInt32(4));
                    employee.schedule = scheduleControl.getSchedule(result.GetInt32(5));

                    employee.leefNumber        = Convert.ToString(result[6]);
                    employee.ctps              = result.GetString(7);
                    employee.department        = departmentControl.getDepartment(result.GetInt32(8));
                    employee.office            = officeControl.getOffice(result.GetInt32(9));
                    employee.admission         = result.GetDateTime(10);
                    employee.resignation       = result.GetDateTime(11);
                    employee.resignationReason = resignationReasonControl.getResignationReason(result.GetInt32(12));

                    employee.phone           = result.GetString(13);
                    employee.email           = result.GetString(14);
                    employee.generalRegistry = result.GetString(15);
                    employee.registryEntity  = result.GetString(16);
                    employee.father          = result.GetString(17);
                    employee.mother          = result.GetString(18);
                    employee.birth           = result.GetDateTime(19);
                    employee.gender          = result.GetString(20);
                    employee.civilStatus     = result.GetString(21);
                    employee.nationality     = result.GetString(22);
                    employee.naturalness     = result.GetString(23);
                    employee.address         = result.GetString(24);
                    employee.neighborhood    = result.GetString(25);
                    employee.city            = result.GetString(26);
                    employee.state           = result.GetString(27);
                    employee.zipCode         = result.GetString(28);

                    String imageFile = ConfigControl.Instance.getImageDirectory() + "/" + fileName;

                    if (File.Exists(imageFile))
                    {
                        BitmapImage img = new BitmapImage();
                        img.BeginInit();
                        img.CacheOption = BitmapCacheOption.OnLoad;
                        img.UriSource   = new Uri(imageFile);
                        img.EndInit();

                        employee.employeeImage = img;
                    }
                    else
                    {
                        BitmapImage img = new BitmapImage();
                        img.BeginInit();
                        img.CacheOption = BitmapCacheOption.OnLoad;
                        img.UriSource   = new Uri(ConfigControl.Instance.getNoImageFile());
                        img.EndInit();

                        employee.employeeImage = img;
                    }
                }
            }

            result.Close();

            return(employee);
        }