Example #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            // Getting the employee Information

                // Employee Information
                string SSN = SSNTextBox.Text;
                string firstName = FirstNameTextBox.Text;
                char middleInitial = MiddleInitialTextBox.Text.ToCharArray()[0];
                string lastName = LastNameTextBox.Text;
                DateTime dob = DateTime.Parse(DOBTextBox.Text.ToString());
                string phone = PhoneNumberTextBox.Text;
                char gender = GenderDropDown.SelectedItem.Text.ToCharArray()[0];

                // Address Parsing
                string address1 = Address1TextBox.Text;
                string address2 = Address2TextBox.Text;
                string city = CityTextBox.Text;
                string state = StateTextBox.Text;
                int zipCode = int.Parse(ZipCodeTextBox.Text);

                // JOB
                int position_id = int.Parse(PositionsDropDownList.SelectedItem.Value);
                string contract = ContractTypeDropDown.SelectedItem.Text;
                int workingHours = int.Parse(WorkingHoursDropDown.SelectedItem.Text);
                bool workingStatus = (WorkingStatusDropDown.SelectedItem.Text == "Working");
                DateTime firstDay = DateTime.Parse(FirstDayTextBox.Text.ToString());

                //Creating a new Job Instance
                Job j = new Job(workingStatus, contract, workingHours, firstDay, position_id);

                //Creating the Address instance
                Address a = new Address(address1, address2, city, state, zipCode);

                int check = Employee.create(SSN, firstName, middleInitial, lastName, dob, gender, phone, j, a);
                if (check == 1)
                {
                    header1.success("Employee Created!");
                }
                else {
                    header1.showAlert("Employee was not created because of en error!");
                }
        }
Example #2
0
 partial void DeleteJob(Job instance);
Example #3
0
 partial void UpdateJob(Job instance);
Example #4
0
 partial void InsertJob(Job instance);
Example #5
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);
        }
Example #6
0
        /**
         * create
         *
         * IS A static method that will return 0 if the creations has not compleated or the ID of the new Employee if the employee was created Successfully
         */
        public static int create(string SSN, string FirstName, char middleInitial, string lastName, DateTime dob, char gender, string phone, Job job, Address address)
        {
            DatabaseHandler handler = new DatabaseHandler();

            string insertSt = "INSERT INTO Employee (employee_SSN, employee_firstName, employee_middleInital, employee_lastName, employee_dob, employee_working_status, employee_contract, employee_hoursPerDay, employee_firstDay, employee_gender, employee_position, employee_approved, employee_created_at, employee_address1, employee_address2, employee_city, employee_state, employee_zip_code, employee_phone) VALUES        (@SSN,@firstName,@middleInitial,@lastName,@DOB,@workingStatus,@contract,@hoursPerDay,@firstDay,@gender,@position,@approved,@created_at,@address1,@address2,@city,@state,@zipCode,@phone)";
            handler.setSQL(insertSt);

            //Adding the employee information
            handler.addParameter("@SSN", SSN);
            handler.addParameter("@firstName", FirstName);
            handler.addParameter("@middleInitial", middleInitial.ToString());
            handler.addParameter("@lastName", lastName);
            handler.addParameter("@DOB", dob.Date.ToString());
            handler.addParameter("@gender", gender.ToString());
            handler.addParameter("@approved", "0");
            string created = DateTime.Now.ToString();
            handler.addParameter("@created_at", created);
            handler.addParameter("@phone", phone.ToString());

            bool workingStatus = job.WorkingStatus;
            string WorkingstatusToInt;

            if(workingStatus)
                WorkingstatusToInt = "1";
            else
                WorkingstatusToInt = "0";

            // JOB
            handler.addParameter("@workingStatus", WorkingstatusToInt);
            handler.addParameter("@contract", job.Contract);
            handler.addParameter("@hoursPerDay", job.HoursPerDay.ToString());
            handler.addParameter("@firstDay", job.FirstDayAtWork.Date.ToString());
            handler.addParameter("@position", job.Position.ID.ToString());

            // ADDRESS
            handler.addParameter("@address1", address.Address1);
            handler.addParameter("@address2", address.Address2);
            handler.addParameter("@city", address.City);
            handler.addParameter("@state", address.State);
            handler.addParameter("@zipCode", address.ZipCode.ToString());

            int rows = handler.ExecuteNonQuery();
            return rows;
        }