/**
         * This method should set the data from any SQL reader
         */
        private void setObject(SqlDataReader r)
        {
            this.id         = int.Parse(r["employee_id"].ToString());
            this.SSN        = r["employee_SSN"].ToString();
            this.firstName  = r["employee_firstName"].ToString();
            this.lastName   = r["Employee_lastName"].ToString();
            this.dob        = DateTime.Parse(r["employee_dob"].ToString());
            this.created_at = DateTime.Parse(r["employee_created_at"].ToString());
            this.phone      = r["employee_phone"].ToString();


            // Converting the object to char -- Middle Initial
            string m = r["employee_middleInital"].ToString();

            this.middleInitial = m[0];



            // converting the object ot char (gender)
            string g = r["employee_gender"].ToString();

            this.gender = g;

            // The approved status is data of type bool.
            string approvedStatus = r["employee_approved"].ToString();

            this.approved = (approvedStatus == "True");



            // Preparing the variables for the Job constructor
            bool workingStatus = true;

            string workingStatusAsString = r["employee_working_status"].ToString();

            if (workingStatusAsString == "0")
            {
                workingStatus = false;
            }

            string   contract    = r["employee_contract"].ToString();
            int      hoursPerDay = int.Parse(r["employee_hoursPerDay"].ToString());
            DateTime firstDay    = DateTime.Parse(r["employee_firstDay"].ToString());
            int      position_id = int.Parse(r["employee_position"].ToString());

            // Setting the job object
            this.job = new Job(workingStatus, contract, hoursPerDay, firstDay, position_id);


            // Preparing the varirables for the address constructor
            string address1 = r["employee_address1"].ToString();
            string address2 = r["employee_address2"].ToString();
            string city     = r["employee_city"].ToString();
            string state    = r["employee_state"].ToString();
            int    zipCode  = int.Parse(r["employee_zip_code"].ToString());

            this.address = new Address(address1, address2, city, state, zipCode);

            // Get the records
            records = new EmployeesRecords(this.id);

            // Get the time off
            timeOff = new EmployeesTimeOff(this.id);

            // Get the documents
            documents = new EmployeesDocuments(this.id);

            // Get the income
            income = new EmployeesIncome(this.id);


            DatabaseHandler handler = new DatabaseHandler();

            handler.setSQL("SELECT position_department FROM [Position] WHERE position_id = @id");
            handler.addParameter("@id", position_id.ToString());
            handler.queryExecute();
            while (handler.reader.Read())
            {
                int dept_id = int.Parse(handler.reader["position_department"].ToString());
                this.department = new Department(dept_id);
            }
        }
Beispiel #2
0
        /**
         * This method should set the data from any SQL reader
         */
        private void setObject(SqlDataReader r)
        {
            this.id = int.Parse(r["employee_id"].ToString());
            this.SSN = r["employee_SSN"].ToString();
            this.firstName = r["employee_firstName"].ToString();
            this.lastName = r["Employee_lastName"].ToString();
            this.dob = DateTime.Parse(r["employee_dob"].ToString());
            this.created_at = DateTime.Parse(r["employee_created_at"].ToString());
            this.phone = r["employee_phone"].ToString();

            // Converting the object to char -- Middle Initial
            string m = r["employee_middleInital"].ToString();
            this.middleInitial = m[0];

            // converting the object ot char (gender)
            string g = r["employee_gender"].ToString();
            this.gender = g[0];

            // The approved status is data of type bool.
            string approvedStatus = r["employee_approved"].ToString();
            this.approved = (approvedStatus == "True");

            // Preparing the variables for the Job constructor
            bool workingStatus = true;

            string workingStatusAsString = r["employee_working_status"].ToString();
            if (workingStatusAsString == "0")
                workingStatus = false;

            string contract = r["employee_contract"].ToString();
            int hoursPerDay = int.Parse(r["employee_hoursPerDay"].ToString());
            DateTime firstDay = DateTime.Parse(r["employee_firstDay"].ToString());
            int position_id = int.Parse(r["employee_position"].ToString());
            // Setting the job object
            this.job = new Job(workingStatus,contract,hoursPerDay,firstDay,position_id);

            // Preparing the varirables for the address constructor
            string address1 = r["employee_address1"].ToString();
            string address2 = r["employee_address2"].ToString();
            string city = r["employee_city"].ToString();
            string state = r["employee_state"].ToString();
            int zipCode = int.Parse(r["employee_zip_code"].ToString());
            this.address = new Address(address1, address2, city, state, zipCode);

            // Get the records
            records = new EmployeesRecords(this.id);

            // Get the time off
            timeOff = new EmployeesTimeOff(this.id);

            // Get the documents
            documents = new EmployeesDocuments(this.id);

            // Get the income
            income = new EmployeesIncome(this.id);
        }