private void LoadSaleBillingPricing()
        {
            // Data for Sale/Billing/Pricing tab
            ProjectSaleBillingPricingGateway projectSaleBillingPricingGateway = new ProjectSaleBillingPricingGateway(projectTDS);

            if (projectSaleBillingPricingGateway.Table.Rows.Count > 0)
            {
                //cbxSaleBidProject.Checked = projectSaleBillingPricingGateway.GetSaleBidProject(int.Parse(hdfProjectId.Value));
                //cbxSaleRFP.Checked = projectSaleBillingPricingGateway.GetSaleRFP(int.Parse(hdfProjectId.Value));
                //cbxSaleSoleSource.Checked = projectSaleBillingPricingGateway.GetSaleSoleSource(int.Parse(hdfProjectId.Value));
                //cbxSaleTermContract.Checked = projectSaleBillingPricingGateway.GetSaleTermContract(int.Parse(hdfProjectId.Value));
                //tbxSaleTermContractDetail.Text = projectSaleBillingPricingGateway.GetSaleTermContractDetail(int.Parse(hdfProjectId.Value));
                //cbxSaleOther.Checked = projectSaleBillingPricingGateway.GetSaleOther(int.Parse(hdfProjectId.Value));
                //tbxSaleOtherDetail.Text = projectSaleBillingPricingGateway.GetSaleOtherDetail(int.Parse(hdfProjectId.Value));
                //if (projectSaleBillingPricingGateway.GetSaleGettingJob(int.Parse(hdfProjectId.Value)).HasValue) tbxSaleGettingJob.Text = ((int)projectSaleBillingPricingGateway.GetSaleGettingJob(int.Parse(hdfProjectId.Value))).ToString();
                if (projectSaleBillingPricingGateway.GetBillPrice(int.Parse(hdfProjectId.Value)).HasValue) tbxBillPriceSaleBillingPricing.Text = ((decimal)projectSaleBillingPricingGateway.GetBillPrice(int.Parse(hdfProjectId.Value))).ToString("n2");
                tbxBillMoneySaleBillingPricing.Text = projectSaleBillingPricingGateway.GetBillMoney(int.Parse(hdfProjectId.Value));
                if (projectSaleBillingPricingGateway.GetBillSubcontractorAmount(int.Parse(hdfProjectId.Value)).HasValue) tbxBillSubcontractorAmount.Text = ((decimal)projectSaleBillingPricingGateway.GetBillSubcontractorAmount(int.Parse(hdfProjectId.Value))).ToString("n2");
                //tbxBillBidHardDollar.Text = projectSaleBillingPricingGateway.GetBillBidHardDollar(int.Parse(hdfProjectId.Value));
                //cbxBillPerUnit.Checked = projectSaleBillingPricingGateway.GetBillPerUnit(int.Parse(hdfProjectId.Value));
                //cbxBillHourly.Checked = projectSaleBillingPricingGateway.GetBillHourly(int.Parse(hdfProjectId.Value));
                //tbxBillExpectExtras.Text = projectSaleBillingPricingGateway.GetBillExpectExtras(int.Parse(hdfProjectId.Value));
                //cbxChargesWater.Checked = projectSaleBillingPricingGateway.GetChargesWater(int.Parse(hdfProjectId.Value));
                //if (projectSaleBillingPricingGateway.GetChargesWaterAmount(int.Parse(hdfProjectId.Value)).HasValue) tbxChargesWaterAmount.Text = ((decimal)projectSaleBillingPricingGateway.GetChargesWaterAmount(int.Parse(hdfProjectId.Value))).ToString("n2");
                //cbxChargesDisposal.Checked = projectSaleBillingPricingGateway.GetChargesDisposal(int.Parse(hdfProjectId.Value));
                //if (projectSaleBillingPricingGateway.GetChargesDisposalAmount(int.Parse(hdfProjectId.Value)).HasValue) tbxChargesDisposalAmount.Text = ((decimal)projectSaleBillingPricingGateway.GetChargesDisposalAmount(int.Parse(hdfProjectId.Value))).ToString("n2");
            }
            else
            {
                // ... for project
                ProjectGateway projectGateway = new ProjectGateway(projectTDS);

                if (projectGateway.GetCountryID(int.Parse(hdfProjectId.Value)) == 1)
                {
                    tbxBillMoneySaleBillingPricing.Text = "CAD";
                }
                else
                {
                    tbxBillMoneySaleBillingPricing.Text = "USD";
                }
            }

            // Databind Grid for Services
            //grdServices.DataBind();
        }
        private void InsertProjectSaleBillingPricing(int originalProjectId)
        {
            // ... Data for current project
            ProjectTDS projectTDSTemp = new ProjectTDS();
            ProjectSaleBillingPricingGateway projectSaleBillingPricingGatewayTemp = new ProjectSaleBillingPricingGateway(projectTDSTemp);
            projectSaleBillingPricingGatewayTemp.LoadAllByProjectId(originalProjectId);

            ProjectSaleBillingPricingGateway projectSaleBillingPricingGateway = new ProjectSaleBillingPricingGateway(projectTDS);
            projectSaleBillingPricingGateway.LoadAllByProjectId(originalProjectId);

            if (projectSaleBillingPricingGateway.Table.Rows.Count > 0)
            {
                // ... Definition of general variables
                bool saleBidProject = projectSaleBillingPricingGateway.GetSaleBidProject(originalProjectId);
                bool saleRFP = projectSaleBillingPricingGateway.GetSaleRFP(originalProjectId);
                bool saleSoleSource = projectSaleBillingPricingGateway.GetSaleSoleSource(originalProjectId);
                bool saleTermContract = projectSaleBillingPricingGateway.GetSaleTermContract(originalProjectId);
                string saleTermContractDetail = projectSaleBillingPricingGateway.GetSaleTermContractDetail(originalProjectId);
                bool saleOther = projectSaleBillingPricingGateway.GetSaleOther(originalProjectId);
                string saleOtherDetail = projectSaleBillingPricingGateway.GetSaleOtherDetail(originalProjectId);
                int? saleGettingJob = null; if (projectSaleBillingPricingGateway.GetSaleGettingJob(originalProjectId).HasValue) saleGettingJob = (int)projectSaleBillingPricingGateway.GetSaleGettingJob(originalProjectId);
                decimal? billPrice = null; if (projectSaleBillingPricingGateway.GetBillPrice(originalProjectId).HasValue) billPrice = (decimal)projectSaleBillingPricingGateway.GetBillPrice(originalProjectId);
                string billMoney = projectSaleBillingPricingGateway.GetBillMoney(originalProjectId);
                decimal? billSubcontractorAmount = null; if (projectSaleBillingPricingGateway.GetBillSubcontractorAmount(originalProjectId).HasValue) billSubcontractorAmount = (decimal)projectSaleBillingPricingGateway.GetBillSubcontractorAmount(originalProjectId);
                string billBidHardDollar = projectSaleBillingPricingGateway.GetBillBidHardDollar(originalProjectId);
                bool billPerUnit = projectSaleBillingPricingGateway.GetBillPerUnit(originalProjectId);
                bool billHourly = projectSaleBillingPricingGateway.GetBillHourly(originalProjectId);
                string billExpectExtras = projectSaleBillingPricingGateway.GetBillExpectExtras(originalProjectId);
                bool chargesWater = projectSaleBillingPricingGateway.GetChargesWater(originalProjectId);
                decimal? chargesWaterAmount = null; if (projectSaleBillingPricingGateway.GetChargesWaterAmount(originalProjectId).HasValue) chargesWaterAmount = (decimal)projectSaleBillingPricingGateway.GetChargesWaterAmount(originalProjectId);
                bool chargesDisposal = projectSaleBillingPricingGateway.GetChargesDisposal(originalProjectId);
                decimal? chargesDisposalAmount = null; if (projectSaleBillingPricingGateway.GetChargesDisposalAmount(originalProjectId).HasValue) chargesDisposalAmount = (decimal)projectSaleBillingPricingGateway.GetChargesDisposalAmount(originalProjectId);

                // ... Insert Sale/Billing/Pricing
                ProjectSaleBillingPricing projectSaleBillingPricing = new ProjectSaleBillingPricing(projectTDS);
                projectSaleBillingPricing.Insert(0, saleBidProject, saleRFP, saleSoleSource, saleTermContract, saleTermContractDetail, saleOther, saleOtherDetail, saleGettingJob, billPrice, billMoney, billBidHardDollar, billPerUnit, billHourly, billExpectExtras, billSubcontractorAmount, chargesWater, chargesWaterAmount, chargesDisposal, chargesDisposalAmount, Int32.Parse(hdfCompanyId.Value.Trim()));
            }
        }
        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();
        }