private void LoadGeneralData()
        {
            // ... for geographical location
            hdfCountryId.DataBind();
            if (hdfCountryId.Value != "")
            {
                CountryGateway countryGateway = new CountryGateway();
                countryGateway.LoadByCountryId(Int64.Parse(hdfCountryId.Value));
                tbxCountry.Text = countryGateway.GetName(Int64.Parse(hdfCountryId.Value));
            }
            else
            {
                tbxCountry.Text = "";
            }

            hdfProvinceStateId.DataBind();
            if (hdfProvinceStateId.Value != "")
            {
                ProvinceGateway provinceGateway = new ProvinceGateway();
                provinceGateway.LoadByProvinceId(Int64.Parse(hdfProvinceStateId.Value));
                tbxProvinceState.Text = provinceGateway.GetName(Int64.Parse(hdfProvinceStateId.Value));
            }
            else
            {
                tbxProvinceState.Text = "";
            }

            hdfCountyId.DataBind();
            if (hdfCountyId.Value != "")
            {
                CountyGateway countyGateway = new CountyGateway();
                countyGateway.LoadByCountyId(Int64.Parse(hdfCountyId.Value));
                tbxCounty.Text = countyGateway.GetName(Int64.Parse(hdfCountyId.Value));
            }
            else
            {
                tbxCounty.Text = "";
            }

            hdfCityId.DataBind();
            if (hdfCityId.Value != "")
            {
                CityGateway cityGateway = new CityGateway();
                cityGateway.LoadByCityId(Int64.Parse(hdfCityId.Value));
                tbxCity.Text = cityGateway.GetName(Int64.Parse(hdfCityId.Value));
            }
            else
            {
                tbxCity.Text = "";
            }

            // ... for project
            ProjectGateway projectGateway = new ProjectGateway(projectTDS);
            int currentCompanyId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString()));
            hdfClientId.Value = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value)).ToString();

            // ... for client
            int companyId = Int32.Parse(hdfCompanyId.Value);
            CompaniesGateway companiesGateway = new CompaniesGateway();
            companiesGateway.LoadAllByCompaniesId(currentCompanyId, companyId);

            if (projectTDS.LFS_PROJECT.Rows.Count > 0)
            {
                tkrdpStartDate.DataBind();
                tkrdpEndDate.DataBind();
                tkrdpProposalDate.DataBind();
                tbxProjectNumber.DataBind();
                tbxName.DataBind();
                tbxDescription.DataBind();
                tbxClientName.Text = companiesGateway.GetName(projectGateway.GetClientID(int.Parse(hdfProjectId.Value)));
                tbxClientProjectNumber.DataBind();

                // ... ... for primary contact
                ContactsList contactList = new ContactsList();
                contactList.LoadAllAndAddItemByCompaniesId(-1, " ", projectGateway.GetClientID(int.Parse(hdfProjectId.Value)), companyId);
                ddlClientPrimaryContactId.DataSource = contactList.Table;
                ddlClientPrimaryContactId.DataValueField = "CONTACTS_ID";
                ddlClientPrimaryContactId.DataTextField = "Name";

                if (projectGateway.GetClientPrimaryContactID(int.Parse(hdfProjectId.Value)).HasValue)
                {
                    ddlClientPrimaryContactId.SelectedValue = projectGateway.GetClientPrimaryContactID(int.Parse(hdfProjectId.Value)).ToString();
                }
                else
                {
                    ddlClientPrimaryContactId.SelectedValue = "-1";
                }

                ddlClientPrimaryContactId.DataBind();

                // ... ... for secondary contact
                ddlClientSecondaryContactId.DataSource = contactList.Table;
                ddlClientSecondaryContactId.DataValueField = "CONTACTS_ID";
                ddlClientSecondaryContactId.DataTextField = "Name";

                if (projectGateway.GetClientSecondaryContactID(int.Parse(hdfProjectId.Value)).HasValue)
                {
                    ddlClientSecondaryContactId.SelectedValue = projectGateway.GetClientSecondaryContactID(int.Parse(hdfProjectId.Value)).ToString();
                }
                else
                {
                    ddlClientSecondaryContactId.SelectedValue = "-1";
                }

                ddlClientSecondaryContactId.DataBind();

                // ... for resources
                // ...  ... for project lead
                EmployeeList employeeList = new EmployeeList();
                employeeList.LoadAndAddItem(-1, " ");
                ddlProjectLeadId.DataSource = employeeList.Table;
                ddlProjectLeadId.DataValueField = "EmployeeID";
                ddlProjectLeadId.DataTextField = "FullName";
                ddlProjectLeadId.SelectedValue = (projectGateway.GetProjectLeadID(int.Parse(hdfProjectId.Value)).HasValue) ? ((int)projectGateway.GetProjectLeadID(int.Parse(hdfProjectId.Value))).ToString() : "-1";
                ddlProjectLeadId.DataBind();

                // ... ... for salesman
                SalesmanListGateway salesmanListGateway = new SalesmanListGateway(new DataSet());
                salesmanListGateway.Load();
                ddlSalesmanId.DataSource = salesmanListGateway.Table;
                ddlSalesmanId.DataValueField = "SalesmanID";
                ddlSalesmanId.DataTextField = "FullName";
                ddlSalesmanId.SelectedValue = ((int)projectGateway.GetSalesmanID(int.Parse(hdfProjectId.Value))).ToString();
                ddlSalesmanId.DataBind();

                // ... ... for Pricing
                if (projectGateway.GetProjectType(int.Parse(hdfProjectId.Value)) == "Ballpark")
                {
                    ProjectSaleBillingPricingGateway projectSaleBillingPricingGateway = new ProjectSaleBillingPricingGateway(projectTDS);

                    if (projectSaleBillingPricingGateway.Table.Rows.Count > 0)
                    {
                        tbxBillPrice.DataBind();
                        ddlBillMoney.DataBind();
                    }
                    else
                    {
                        if (projectGateway.GetCountryID(int.Parse(hdfProjectId.Value)) == 1)
                        {
                            ddlBillMoney.SelectedValue = "CAD";
                        }
                        else
                        {
                            ddlBillMoney.SelectedValue = "USD";
                        }
                    }
                }
            }

            cbxFairWageApplies.DataBind();

            // Data for unit budget tab
            ProjectNavigatorProjectUnitsBudgetGateway projectNavigatorProjectUnitsBudgetGateway = new ProjectNavigatorProjectUnitsBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectUnitsBudgetGateway.Table.Rows.Count > 0)
            {
                tbxUnitsBudget.Text = projectNavigatorProjectUnitsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value)).ToString("n2");
            }

            // Data for materials budget tab
            ProjectNavigatorProjectMaterialsBudgetGateway projectNavigatorProjectMaterialsBudgetGateway = new ProjectNavigatorProjectMaterialsBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectMaterialsBudgetGateway.Table.Rows.Count > 0)
            {
                tbxMaterialsBudget.Text = projectNavigatorProjectMaterialsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value)).ToString("n2");
            }

            // Data for subcontractors budget tab
            ProjectNavigatorProjectSubcontractorsBudgetGateway projectNavigatorProjectSubcontractorsBudgetGateway = new ProjectNavigatorProjectSubcontractorsBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectSubcontractorsBudgetGateway.Table.Rows.Count > 0)
            {
                tbxSubcontractorsBudget.Text = projectNavigatorProjectSubcontractorsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2");
            }

            // Data for hotels budget tab
            ProjectNavigatorProjectHotelsBudgetGateway projectNavigatorProjectHotelsBudgetGateway = new ProjectNavigatorProjectHotelsBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectHotelsBudgetGateway.Table.Rows.Count > 0)
            {
                tbxHotelsBudget.Text = projectNavigatorProjectHotelsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2");
            }

            // Data for bondings budget tab
            ProjectNavigatorProjectBondingsBudgetGateway projectNavigatorProjectBondingsBudgetGateway = new ProjectNavigatorProjectBondingsBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectBondingsBudgetGateway.Table.Rows.Count > 0)
            {
                tbxBondingsBudget.Text = projectNavigatorProjectBondingsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2");
            }

            // Data for insurances budget tab
            ProjectNavigatorProjectInsurancesBudgetGateway projectNavigatorProjectInsurancesBudgetGateway = new ProjectNavigatorProjectInsurancesBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectInsurancesBudgetGateway.Table.Rows.Count > 0)
            {
                tbxInsurancesBudget.Text = projectNavigatorProjectInsurancesBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2");
            }

            CalculateTotalBudget();
        }
        private void LoadGeneralData()
        {
            // Data for General Data
            tbxProjectNumber.DataBind();
            tbxName.DataBind();
            tbxProposalDate.DataBind();
            tbxStartDate.DataBind();
            tbxEndDate.DataBind();
            tbxDescription.DataBind();
            cbxFairWageApplies.DataBind();

            // ... for geographical location
            hdfCountryId.DataBind();
            if (hdfCountryId.Value != "")
            {
                CountryGateway countryGateway = new CountryGateway();
                countryGateway.LoadByCountryId(Int64.Parse(hdfCountryId.Value));
                tbxCountry.Text = countryGateway.GetName(Int64.Parse(hdfCountryId.Value));
            }
            else
            {
                tbxCountry.Text = "";
            }

            hdfProvinceStateId.DataBind();
            if (hdfProvinceStateId.Value != "")
            {
                ProvinceGateway provinceGateway = new ProvinceGateway();
                provinceGateway.LoadByProvinceId(Int64.Parse(hdfProvinceStateId.Value));
                tbxProvinceState.Text = provinceGateway.GetName(Int64.Parse(hdfProvinceStateId.Value));
            }
            else
            {
                tbxProvinceState.Text = "";
            }

            hdfCountyId.DataBind();
            if (hdfCountyId.Value != "")
            {
                CountyGateway countyGateway = new CountyGateway();
                countyGateway.LoadByCountyId(Int64.Parse(hdfCountyId.Value));
                tbxCounty.Text = countyGateway.GetName(Int64.Parse(hdfCountyId.Value));
            }
            else
            {
                tbxCounty.Text = "";
            }

            hdfCityId.DataBind();
            if (hdfCityId.Value != "")
            {
                CityGateway cityGateway = new CityGateway();
                cityGateway.LoadByCityId(Int64.Parse(hdfCityId.Value));
                tbxCity.Text = cityGateway.GetName(Int64.Parse(hdfCityId.Value));
            }
            else
            {
                tbxCity.Text = "";
            }

            // ... for project
            ProjectGateway projectGateway = new ProjectGateway(projectTDS);
            int currentCompanyId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString()));

            // ... for client
            int companyId = Int32.Parse(hdfCompanyId.Value);
            CompaniesGateway companiesGateway = new CompaniesGateway();
            companiesGateway.LoadAllByCompaniesId(currentCompanyId, companyId);

            tbxClientName.Text = companiesGateway.GetName(currentCompanyId);
            hdfClientId.Value = projectGateway.GetClientID(int.Parse(hdfProjectId.Value)).ToString();
            tbxClientProjectNumber.DataBind();

            // ... ... for primary contact
            if (projectGateway.GetClientPrimaryContactID(int.Parse(hdfProjectId.Value)).HasValue)
            {
                hdfClientPrimaryContactID.Value = ((int)projectGateway.GetClientPrimaryContactID(int.Parse(hdfProjectId.Value))).ToString();
                ContactsGateway contactsGatewayForPrimaryContact = new ContactsGateway();
                contactsGatewayForPrimaryContact.LoadAllByContactId(int.Parse(hdfClientPrimaryContactID.Value), companyId);
                tbxClientPrimaryContact.Text = contactsGatewayForPrimaryContact.GetCompleteName(int.Parse(hdfClientPrimaryContactID.Value));
            }

            // ... ... for secondary contact
            if (projectGateway.GetClientSecondaryContactID(int.Parse(hdfProjectId.Value)).HasValue)
            {
                hdfClientSecondaryContactID.Value = ((int)projectGateway.GetClientSecondaryContactID(int.Parse(hdfProjectId.Value))).ToString();
                ContactsGateway contactsGatewayForSecondaryContact = new ContactsGateway();
                contactsGatewayForSecondaryContact.LoadAllByContactId(int.Parse(hdfClientSecondaryContactID.Value), companyId);
                tbxClientSecondaryContact.Text = contactsGatewayForSecondaryContact.GetCompleteName(int.Parse(hdfClientSecondaryContactID.Value));
            }

            // ... for resources
            // ... ... for project lead
            if (projectGateway.GetProjectLeadID(int.Parse(hdfProjectId.Value)).HasValue)
            {
                EmployeeGateway employeeGateway = new EmployeeGateway();
                employeeGateway.LoadByEmployeeId((int)projectGateway.GetProjectLeadID(int.Parse(hdfProjectId.Value)));
                tbxProjectLead.Text = employeeGateway.GetFullName((int)projectGateway.GetProjectLeadID(int.Parse(hdfProjectId.Value)));
            }

            // ... ... for salesman
            SalesmanGateway salesmanGateway = new SalesmanGateway();
            salesmanGateway.LoadExpandedBySalesmanId(projectGateway.GetSalesmanID(int.Parse(hdfProjectId.Value)));
            tbxSalesman.Text = salesmanGateway.GetFullName(projectGateway.GetSalesmanID(int.Parse(hdfProjectId.Value)));

            // ... ... for Pricing
            if (projectGateway.GetProjectType(int.Parse(hdfProjectId.Value)) == "Ballpark")
            {
                ProjectSaleBillingPricingGateway projectSaleBillingPricingGateway = new ProjectSaleBillingPricingGateway(projectTDS);

                if (projectSaleBillingPricingGateway.Table.Rows.Count > 0)
                {
                    if (projectSaleBillingPricingGateway.GetBillPrice(int.Parse(hdfProjectId.Value)).HasValue) tbxBillPrice.Text = ((decimal)projectSaleBillingPricingGateway.GetBillPrice(int.Parse(hdfProjectId.Value))).ToString("n2");
                    tbxBillMoney.Text = projectSaleBillingPricingGateway.GetBillMoney(int.Parse(hdfProjectId.Value));
                }
                else
                {
                    if (projectGateway.GetCountryID(int.Parse(hdfProjectId.Value)) == 1)
                    {
                        tbxBillMoney.Text = "CAD";
                    }
                    else
                    {
                        tbxBillMoney.Text = "USD";
                    }
                }
            }

            // Data for unit budget tab
            ProjectNavigatorProjectUnitsBudgetGateway projectNavigatorProjectUnitsBudgetGateway = new ProjectNavigatorProjectUnitsBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectUnitsBudgetGateway.Table.Rows.Count > 0)
            {
                tbxUnitsBudget.Text = projectNavigatorProjectUnitsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value)).ToString("n2");
            }

            // Data for materials budget tab
            ProjectNavigatorProjectMaterialsBudgetGateway projectNavigatorProjectMaterialsBudgetGateway = new ProjectNavigatorProjectMaterialsBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectMaterialsBudgetGateway.Table.Rows.Count > 0)
            {
                tbxMaterialsBudget.Text = projectNavigatorProjectMaterialsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value)).ToString("n2");
            }

            // Data for subcontractors budget tab
            ProjectNavigatorProjectSubcontractorsBudgetGateway projectNavigatorProjectSubcontractorsBudgetGateway = new ProjectNavigatorProjectSubcontractorsBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectSubcontractorsBudgetGateway.Table.Rows.Count > 0)
            {
                tbxSubcontractorsBudget.Text = projectNavigatorProjectSubcontractorsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2");
            }

            // Data for hotels budget tab
            ProjectNavigatorProjectHotelsBudgetGateway projectNavigatorProjectHotelsBudgetGateway = new ProjectNavigatorProjectHotelsBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectHotelsBudgetGateway.Table.Rows.Count > 0)
            {
                tbxHotelsBudget.Text = projectNavigatorProjectHotelsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2");
            }

            // Data for bondings budget tab
            ProjectNavigatorProjectBondingsBudgetGateway projectNavigatorProjectBondingsBudgetGateway = new ProjectNavigatorProjectBondingsBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectBondingsBudgetGateway.Table.Rows.Count > 0)
            {
                tbxBondingsBudget.Text = projectNavigatorProjectBondingsBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2");
            }

            // Data for insurances budget tab
            ProjectNavigatorProjectInsurancesBudgetGateway projectNavigatorProjectInsurancesBudgetGateway = new ProjectNavigatorProjectInsurancesBudgetGateway(projectNavigatorTDS);

            if (projectNavigatorProjectInsurancesBudgetGateway.Table.Rows.Count > 0)
            {
                tbxInsurancesBudget.Text = projectNavigatorProjectInsurancesBudgetGateway.GetBudget(int.Parse(hdfProjectId.Value), 1, 1).ToString("n2");
            }

            CalculateTotalBudget();
        }
        private void InsertProject(int projectId)
        {
            // ... Data for current project
            ProjectGateway projectGateway = new ProjectGateway(projectTDS);
            projectGateway.LoadByProjectId(projectId);

            // ... Definition of general variables
            Int64 countryId = projectGateway.GetCountryID(projectId);
            int officeId = projectGateway.GetOfficeID(projectId);
            Int64? provinceId = projectGateway.GetProvinceID(projectId);
            Int64? cityId = projectGateway.GetCityID(projectId);
            Int64? countyId = projectGateway.GetCountyID(projectId);
            int? projectLeadId = null; if (projectGateway.GetProjectLeadID(projectId).HasValue) projectLeadId = (int)projectGateway.GetProjectLeadID(projectId);
            int salesmanId = projectGateway.GetSalesmanID(projectId);
            bool deleted = false;
            int? clientPrimaryContactID = null; if (projectGateway.GetClientPrimaryContactID(projectId).HasValue) clientPrimaryContactID = (int)projectGateway.GetClientPrimaryContactID(projectId);
            int? clientSecondaryContactID = null; if (projectGateway.GetClientSecondaryContactID(projectId).HasValue) clientSecondaryContactID = (int)projectGateway.GetClientSecondaryContactID(projectId);
            int? OriginalProjectID = projectId;
            int? projectNumberCopy = null; if (projectGateway.GetLastProjectNumberCopy(projectId).HasValue) projectNumberCopy = (int)projectGateway.GetLastProjectNumberCopy(projectId) + 1; else projectNumberCopy = 1;
            string projectNumber = projectGateway.GetProjectNumber(projectId) + "-" + projectNumberCopy.ToString();
            string projectType = "Proposal";
            string projectState = projectGateway.GetProjectState(projectId);
            string name = projectGateway.GetName(projectId);
            string description = projectGateway.GetDescription(projectId);
            DateTime? proposalDate = null; if (projectGateway.GetProposalDate(projectId).HasValue) proposalDate = projectGateway.GetProposalDate(projectId);
            DateTime? startDate = null; if (projectGateway.GetStartDate(projectId).HasValue) startDate = projectGateway.GetStartDate(projectId);
            DateTime? endDate = null; if (projectGateway.GetEndDate(projectId).HasValue) endDate = projectGateway.GetEndDate(projectId);
            int clientId = projectGateway.GetClientID(projectId);
            string clientProjectNumber = projectGateway.GetClientProjectNumber(projectId);
            int? libraryCategoriesId = null; if (projectGateway.GetLibraryCategoriesId(projectId).HasValue) libraryCategoriesId = (int)projectGateway.GetLibraryCategoriesId(projectId);
            bool fairWageApplies = projectGateway.GetFairWageApplies(projectId);

            // ... Insert Project
            Project project = new Project(projectTDS);
            project.Insert(countryId, officeId, projectLeadId, salesmanId, projectNumber, projectType, projectState, name, description, proposalDate, startDate, endDate, clientId, clientPrimaryContactID, clientSecondaryContactID, clientProjectNumber, deleted, OriginalProjectID, projectNumberCopy, libraryCategoriesId, provinceId, cityId, Int32.Parse(hdfCompanyId.Value.Trim()), countyId, fairWageApplies);

            // ... Insert History
            ProjectHistory projectHistory = new ProjectHistory(projectTDS);
            projectHistory.Insert(0, 1, projectState, DateTime.Now, Convert.ToInt32(Session["loginID"]), Int32.Parse(hdfCompanyId.Value.Trim()));
        }
        private void UpdateState()
        {
            ProjectGateway projectGateway = new ProjectGateway(projectTDS);
            int projectId = int.Parse(hdfProjectId.Value);
            projectGateway.LoadByProjectId(projectId);

            Int64 countryId = projectGateway.GetCountryID(projectId);
            int officeId = projectGateway.GetOfficeID(projectId);
            Int64? provinceId = projectGateway.GetProvinceID(projectId);
            Int64? cityId = projectGateway.GetCityID(projectId);
            Int64? countyId = projectGateway.GetCountyID(projectId);
            int? projectLeadId = projectGateway.GetProjectLeadID(projectId);
            int salesmanId = projectGateway.GetSalesmanID(projectId);
            string projectType = projectGateway.GetProjectType(projectId);
            string projectState = null;

            switch ((string)Request.QueryString["state"])
            {
                //Proposal
                case "proposal_award":
                    projectState = "Awarded";
                    break;

                case "proposal_lost_bid":
                    projectState = "Lost Bid";
                    break;

                case "proposal_cancel":
                    projectState = "Canceled";
                    break;

                case "proposal_bidding":
                    projectState = "Bidding";
                    break;

                case "proposal_unpromote_to_ballpark":
                    projectState = "Active";
                    projectType = "Ballpark";
                    break;

                case "proposal_promote_to_project":
                    projectState = "Active";
                    projectType = "Project";
                    break;

                //Project
                case "project_waiting":
                    projectState = "Waiting";
                    break;

                case "project_activate":
                    projectState = "Active";
                    break;

                case "project_inactivate":
                    projectState = "Inactive";
                    break;

                case "project_complete":
                    projectState = "Complete";
                    break;

                case "project_cancel":
                    projectState = "Canceled";
                    break;

                case "project_unpromote_to_ballpark":
                    projectState = "Active";
                    projectType = "Ballpark";
                    break;

                case "project_unpromote_to_proposal":
                    projectState = "Awarded";
                    projectType = "Proposal";
                    break;

                case "project_tagAsInternal":
                    projectState = "Active";
                    projectType = "Internal";
                    break;

                //Internal Project
                case "internalProject_activate":
                    projectState = "Active";
                    break;

                case "internalProject_complete":
                    projectState = "Complete";
                    break;

                case "internalProject_cancel":
                    projectState = "Canceled";
                    break;

                case "internalProject_promote_to_proposal":
                    projectState = "Awarded";
                    projectType = "Proposal";
                    break;

                case "internalProject_promote_to_project":
                    projectState = "Active";
                    projectType = "Project";
                    break;

                //Ballpark
                case "ballparkProject_activate":
                    projectState = "Active";
                    break;

                case "ballparkProject_cancel":
                    projectState = "Canceled";
                    break;

                case "ballparkProject_promote_to_proposal":
                    projectState = "Bidding";
                    projectType = "Proposal";
                    break;

                case "ballparkProject_promote_to_project":
                    projectState = "Active";
                    projectType = "Project";
                    break;
            }

            string name = projectGateway.GetName(projectId);
            string description = projectGateway.GetDescription(projectId);
            DateTime? proposalDate = projectGateway.GetProposalDate(projectId);
            DateTime? startDate = projectGateway.GetStartDate(projectId);
            DateTime? endDate = projectGateway.GetEndDate(projectId);
            int clientId = projectGateway.GetClientID(projectId);
            string clientProjectNumber = projectGateway.GetClientProjectNumber(projectId);
            int? clientPrimaryContactId = projectGateway.GetClientPrimaryContactID(projectId);
            int? clientSecondaryContactId = projectGateway.GetClientSecondaryContactID(projectId);
            bool deleted = projectGateway.GetDeleted(projectId);
            int? libraryCategoriesId = projectGateway.GetLibraryCategoriesId(projectId);
            bool fairWageApplies = projectGateway.GetFairWageApplies(projectId);

            // Update project
            Project project = new Project(projectTDS);
            string projectNumber = project.UpdateProjectNumber(projectId, salesmanId);
            project.Update(projectId, countryId, officeId, projectLeadId, salesmanId, projectNumber, projectType, projectState, name, description, proposalDate, startDate, endDate, clientId, clientProjectNumber, clientPrimaryContactId, clientSecondaryContactId, deleted, libraryCategoriesId, provinceId, cityId, Int32.Parse(hdfCompanyId.Value.Trim()), countyId, fairWageApplies);

            //Insert in history
            ProjectHistory projectHistory = new ProjectHistory(projectTDS);
            int newRefId = projectHistory.GetNewRefId();
            projectHistory.Insert(projectId, newRefId, projectState, DateTime.Now, Convert.ToInt32(Session["loginID"]), Int32.Parse(hdfCompanyId.Value.Trim()));
        }