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()));
        }
Ejemplo n.º 2
0
        private void PostPageChanges()
        {
            // Definition of general variables
            Int64 countryId = Int64.Parse(ddlCountry.SelectedValue);
            int officeId = int.Parse(ddlOffice.SelectedValue);
            Int64 provinceId = Int64.Parse(ddlProvince.SelectedValue);
            Int64 cityId = Int64.Parse(ddlCity.SelectedValue);
            Int64 countyId = Int64.Parse(ddlCounty.SelectedValue);
            int? projectLeadId = null; if ((ddlProjectLead.SelectedValue != "-1") && (ddlProjectLead.SelectedIndex > -1)) projectLeadId = int.Parse(ddlProjectLead.SelectedValue);
            int salesmanId = int.Parse(ddlSalesman.SelectedValue);
            bool deleted = false;
            int? clientPrimaryContactID = null;
            int? clientSecondaryContactID = null;

            projectTDS = new ProjectTDS();
            Project project = new Project(projectTDS);
            ProjectHistory projectHistory = new ProjectHistory(projectTDS);
            string projectNumber = project.GenerateProjectNumber(countryId, officeId, salesmanId, DateTime.Now, Int32.Parse(hdfCompanyId.Value.Trim()));

            // Insert Ballpark
            if (rbtnBallpark.Checked)
            {
                // ... Definition of variables
                string type = "Ballpark";
                string state = "Active";
                string ballparkProjectName = tbxBallparkProjectName.Text.Trim();
                string ballparkProjectDescription = tbxBallparkProjectDescription.Text.Trim();
                int ballparkProjectClientId = int.Parse(ddlBallparkProjectClient.SelectedValue);
                DateTime? ballparkProjectDate = null; if (tkrdpBallparkProjectDate.SelectedDate.HasValue) ballparkProjectDate = DateTime.Parse(tkrdpBallparkProjectDate.SelectedDate.Value.Month.ToString() + '/' + tkrdpBallparkProjectDate.SelectedDate.Value.Day.ToString() + '/' + tkrdpBallparkProjectDate.SelectedDate.Value.Year.ToString());
                DateTime? ballparkProjectStartDate = null; if (tkrdpBallparkProjectPotentialStartDate.SelectedDate.HasValue) ballparkProjectStartDate = DateTime.Parse(tkrdpBallparkProjectPotentialStartDate.SelectedDate.Value.Month.ToString() + '/' + tkrdpBallparkProjectPotentialStartDate.SelectedDate.Value.Day.ToString() + '/' + tkrdpBallparkProjectPotentialStartDate.SelectedDate.Value.Year.ToString());
                DateTime? ballparkProjectEndDate = null; if (tkrdpBallparkProjectPotentialEndDate.SelectedDate.HasValue) ballparkProjectEndDate = DateTime.Parse(tkrdpBallparkProjectPotentialEndDate.SelectedDate.Value.Month.ToString() + '/' + tkrdpBallparkProjectPotentialEndDate.SelectedDate.Value.Day.ToString() + '/' + tkrdpBallparkProjectPotentialEndDate.SelectedDate.Value.Year.ToString());

                // ... Insert
                project.Insert(countryId, officeId, projectLeadId, salesmanId, projectNumber, type, state, ballparkProjectName, ballparkProjectDescription, ballparkProjectDate, ballparkProjectStartDate, ballparkProjectEndDate, ballparkProjectClientId, clientPrimaryContactID, clientSecondaryContactID, "", deleted, null, null, null, provinceId, cityId, Int32.Parse(hdfCompanyId.Value.Trim()), countyId, false);
                projectHistory.Insert(0, 1, state, DateTime.Now, Convert.ToInt32(Session["loginID"]), Int32.Parse(hdfCompanyId.Value.Trim()));
            }

            // ... Insert Proposal
            if (rbtnProposal.Checked)
            {
                // ... Definition of variables
                string type = "Proposal";
                string state = "Bidding";
                string proposalName = tbxProposalName.Text.Trim();
                string proposalDescription = tbxProposalDescription.Text.Trim();
                int proposalClientId = int.Parse(ddlProposalClient.SelectedValue);
                string clientProposalNumber = tbxClientProposalNumber.Text.Trim();
                DateTime? proposalDate = null; if (tkrdpProposalDate.SelectedDate.HasValue) proposalDate = DateTime.Parse(tkrdpProposalDate.SelectedDate.Value.Month.ToString() + '/' + tkrdpProposalDate.SelectedDate.Value.Day.ToString() + '/' + tkrdpProposalDate.SelectedDate.Value.Year.ToString());
                DateTime? proposalStartDate = null; if (tkrdpProposalPotencialStartDate.SelectedDate.HasValue) proposalStartDate = DateTime.Parse(tkrdpProposalPotencialStartDate.SelectedDate.Value.Month.ToString() + '/' + tkrdpProposalPotencialStartDate.SelectedDate.Value.Day.ToString() + '/' + tkrdpProposalPotencialStartDate.SelectedDate.Value.Year.ToString());
                DateTime? proposalEndDate = null; if (tkrdpProposalPotencialEndDate.SelectedDate.HasValue) proposalEndDate = DateTime.Parse(tkrdpProposalPotencialEndDate.SelectedDate.Value.Month.ToString() + '/' + tkrdpProposalPotencialEndDate.SelectedDate.Value.Day.ToString() + '/' + tkrdpProposalPotencialEndDate.SelectedDate.Value.Year.ToString());

                // ... Insert
                project.Insert(countryId, officeId, projectLeadId, salesmanId, projectNumber, type, state, proposalName, proposalDescription, proposalDate, proposalStartDate, proposalEndDate, proposalClientId, clientPrimaryContactID, clientSecondaryContactID, clientProposalNumber, deleted, null, null, null, provinceId, cityId, Int32.Parse(hdfCompanyId.Value.Trim()), countyId, false);
                projectHistory.Insert(0, 1, state, DateTime.Now, Convert.ToInt32(Session["loginID"]), Int32.Parse(hdfCompanyId.Value.Trim()));
            }

            // ... Insert Internal Project
            if (rbtnInternalProject.Checked)
            {
                // ... Definition of variables
                string type = "Internal";
                string state = "Active";
                string internalProjectName = tbxInternalProjectName.Text.Trim();
                string internalProjectDescription = tbxInternalProjectDescription.Text.Trim();
                int internalProjectClientId = int.Parse(ddlInternalProjectClient.SelectedValue);
                DateTime? internalProjectDate = null; if (tkrdpInternalProjectDate.SelectedDate.HasValue) internalProjectDate = DateTime.Parse(tkrdpInternalProjectDate.SelectedDate.Value.Month.ToString() + '/' + tkrdpInternalProjectDate.SelectedDate.Value.Day.ToString() + '/' + tkrdpInternalProjectDate.SelectedDate.Value.Year.ToString());

                // ... Insert
                project.Insert(countryId, officeId, projectLeadId, salesmanId, projectNumber, type, state, internalProjectName, internalProjectDescription, internalProjectDate, null, null, internalProjectClientId, clientPrimaryContactID, clientSecondaryContactID, "", deleted, null, null, null, provinceId, cityId, Int32.Parse(hdfCompanyId.Value.Trim()), countyId, false);
                projectHistory.Insert(0, 1, state, DateTime.Now, Convert.ToInt32(Session["loginID"]), Int32.Parse(hdfCompanyId.Value.Trim()));
            }
        }