private DataTable approveContractordata(Contractor contractor)
 {
     DataTable dt = new DataTable();
     dt = Contractor.ApproveContractor(UserRole, UserLogin, contractor);
     return dt;
 }
        private void dgvListContractor_SelectionChanged(object sender, EventArgs e)
        {
            int IndexSelected = dgvListContractor.CurrentRow.Index;
            row = dgvListContractor.Rows[IndexSelected];
            BIT.frmEdit.TabPageSelected = "tabPageEditContractor";

            contractor = new Contractor();
            contractor.ContractorID = Convert.ToInt32(row.Cells[8].Value.ToString());
            contractor.ContractorPosition = row.Cells[0].Value.ToString();
            contractor.ContractorPhonePrimary = row.Cells[1].Value.ToString();
            contractor.ContractorPhoneMobile = row.Cells[2].Value.ToString();
            contractor.ContractorFirstName = row.Cells[3].Value.ToString();
            contractor.ContractorLastName = row.Cells[4].Value.ToString();
            contractor.ContractorEmailPrimary = row.Cells[5].Value.ToString();
            contractor.ContractorFax = row.Cells[6].Value.ToString();
            contractor.ContractorCompanyName = row.Cells[7].Value.ToString();
        }
        private Contractor populateContractorUIdata(Contractor contractor)
        {
            contractor.ContractorTitle = txtNewContractorTitle.Text;
            contractor.ContractorFirstName = txtNewContractorFirstName.Text;
            contractor.ContractorLastName = txtNewContractorLastName.Text;
            contractor.ContractorEmailPrimary = txtNewContractorEmailP.Text;
            contractor.ContractorEmailAlternate = txtNewContractorEmailA.Text;
            contractor.ContractorFax = txtNewContractorFax.Text;
            contractor.ContractorPhonePrimary = txtNewContractorPhoneP.Text;
            contractor.ContractorPhoneHome = txtNewContractorPhoneH.Text;
            contractor.ContractorPhoneMobile = txtNewContractorPhoneM.Text;
            contractor.ContractorPhoneWork = txtNewContractorPhoneW.Text;
            contractor.ContractorPhoneEmergency = txtNewContractorPhoneE.Text;
            contractor.ContractorCompanyName = txtNewContractorCompany.Text;
            contractor.ContractorPosition = txtNewContractorPosition.Text;
            contractor.ContractorDescription = txtNewContractorDescription.Text;

            return contractor;
        }
 private DataTable insertContractorData(Contractor contractor)
 {
     DataTable dt = new DataTable();
     dt = Contractor.InsertContractor(UserRole, UserLogin, contractor);
     return dt;
 }
        private void btnNewSave_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            string msg = "MESSAGE: ";

            switch (TabPageSelected)
            {
                case "tabPageNewClient":                    // Client* selected
                    client = new Client();
                    dt = insertClientData(populateClientUIdata(client));
                    msg = msg + "Client Created! ";
                    client.ClientID = Convert.ToInt32(dt.Rows[0][0]);
                    break;
                case "tabPageNewContractor":                // Contractor* selected
                    contractor = new Contractor();
                    dt = insertContractorData(populateContractorUIdata(contractor));
                    msg = msg + "Contractor Created! ";
                    contractor.ContractorID = Convert.ToInt32(dt.Rows[0][0]);
                    break;
                case "tabPageNewCoordinator":               // Coordinator* selected
                    coordinator = new Coordinator();
                    dt = insertCoordinatorData(populateCoordinatorUIdata(coordinator));
                    msg = msg + "Coordinator Created! ";
                    coordinator.CoordinatorID = Convert.ToInt32(dt.Rows[0][0]);
                    break;
                case "tabPageNewRequest":                   // Request* selected

                    break;
                case "tabPageNewJob":                       // Job* selected

                    break;
                case "tabPageNewContractorSkill":          // ContractorSkill* selected

                    break;
                case "tabPageNewSkill":                     // Skill* selected

                    break;
                case "tabPageNewLocation":                  // Location* selected

                    break;
                case "tabPageNewAvailability":              // Availability* selected

                    break;
                // ... unauthorized user...
                default:
                    break;
            }

            if (dt.Rows.Count > 0)
                msg = msg + "with ID: " + Convert.ToString(dt.Rows[0][0]);

            lblNewMessage.Text = msg;

            btnNewSave.Visible = false;
            btnNewApprove.Visible = true;
        }
 public PersonEntity Entity(Contractor contractor)
 {
     PersonEntity entity = new PersonEntity();
     entity.PersonID = contractor.ContractorID;
     entity.PersonType = 2;   // "Contractor"
     entity.PersonTitle = contractor.ContractorTitle;
     entity.PersonFirstName = contractor.ContractorFirstName;
     entity.PersonLastName = contractor.ContractorLastName;
     entity.PersonEmailPrimary = contractor.ContractorEmailPrimary;
     entity.PersonEmailAlternate = contractor.ContractorEmailAlternate;
     entity.PersonFax = contractor.ContractorFax;
     entity.PersonPhonePrimary = contractor.ContractorPhonePrimary;
     entity.PersonPhoneHome = contractor.ContractorPhoneHome;
     entity.PersonPhoneMobile = contractor.ContractorPhoneMobile;
     entity.PersonPhoneWork = contractor.ContractorPhoneWork;
     entity.PersonPhoneEmergency = contractor.ContractorPhoneEmergency;
     entity.PersonCompanyName = contractor.ContractorCompanyName;
     entity.PersonPosition = contractor.ContractorPosition;
     entity.PersonDescription = contractor.ContractorDescription;
     entity.PersonIsActive = contractor.ContractorIsActive;
     return entity;
 }
 public static DataTable UpdateContractor(string userRole, string userLogin, Contractor contractor)
 {
     IPersonData contractorData = new PersonData();
     contractor.ContractorIsActive = false;
     DataTable tb = contractorData.UpdatePerson(userRole, "Contractor", userLogin, contractor.Entity(contractor));
     return tb;
 }