コード例 #1
0
        private void LoadCostingUpdates()
        {
            // Data for Costing Updates tab
            ProjectCostingUpdatesGateway projectCostingUpdatesGateway = new ProjectCostingUpdatesGateway(projectTDS);

            if (projectCostingUpdatesGateway.Table.Rows.Count > 0)
            {
                int projectId = int.Parse(hdfProjectId.Value);
                decimal costsIncurredToDate = 0M;
                decimal invoicedToDate = 0M;
                decimal actualGrossMarginToDate = 0M;

                //if (projectCostingUpdatesGateway.GetExtrasToDate(int.Parse(hdfProjectId.Value)).HasValue) tbxExtrasToDate.Text = ((decimal)projectCostingUpdatesGateway.GetExtrasToDate(int.Parse(hdfProjectId.Value))).ToString("n2");
                //if (projectCostingUpdatesGateway.GetCostToComplete(int.Parse(hdfProjectId.Value)).HasValue) tbxCostToComplete.Text = ((decimal)projectCostingUpdatesGateway.GetCostToComplete(int.Parse(hdfProjectId.Value))).ToString("n2");
                //if (projectCostingUpdatesGateway.GetOriginalProfitEstimated(int.Parse(hdfProjectId.Value)).HasValue) tbxOriginalProfitEstimated.Text = ((decimal)projectCostingUpdatesGateway.GetOriginalProfitEstimated(int.Parse(hdfProjectId.Value))).ToString("n2");

                if (projectCostingUpdatesGateway.GetCostsIncurred(projectId).HasValue)
                {
                    costsIncurredToDate = (decimal)projectCostingUpdatesGateway.GetCostsIncurred(projectId);
                    tbxCostsIncurredToDate.Text = costsIncurredToDate.ToString("n2");
                }
                else
                {
                    tbxCostsIncurredToDate.Text = "0";
                }

                if (projectCostingUpdatesGateway.GetInvoicedToDate(projectId).HasValue)
                {
                    invoicedToDate = (decimal)projectCostingUpdatesGateway.GetInvoicedToDate(projectId);
                    tbxInvoicedToDate.Text = invoicedToDate.ToString("n2");
                }
                else
                {
                    tbxInvoicedToDate.Text = "0";
                }

                if (invoicedToDate != 0)
                {
                    actualGrossMarginToDate = ((invoicedToDate - costsIncurredToDate) / invoicedToDate) * 100;
                }

                tbxActualGrossMarginToDate.Text = actualGrossMarginToDate.ToString("n2");
            }
        }
コード例 #2
0
        private void InsertProjectCostingUpdates(int originalProjectId)
        {
            // ... Data for current project
            ProjectCostingUpdatesGateway projectCostingUpdatesGateway = new ProjectCostingUpdatesGateway(projectTDS);
            projectCostingUpdatesGateway.LoadByProjectId(originalProjectId);

            if (projectCostingUpdatesGateway.Table.Rows.Count > 0)
            {
                // ... Definition of general variables
                decimal? extrasToDate = null; if (projectCostingUpdatesGateway.GetExtrasToDate(originalProjectId).HasValue) extrasToDate = (decimal)projectCostingUpdatesGateway.GetExtrasToDate(originalProjectId);
                decimal? costsIncurred = null; if (projectCostingUpdatesGateway.GetCostsIncurred(originalProjectId).HasValue) costsIncurred = (decimal)projectCostingUpdatesGateway.GetCostsIncurred(originalProjectId);
                decimal? costToComplete = null; if (projectCostingUpdatesGateway.GetCostToComplete(originalProjectId).HasValue) costToComplete = (decimal)projectCostingUpdatesGateway.GetCostToComplete(originalProjectId);
                decimal? originalProfitEstimated = null; if (projectCostingUpdatesGateway.GetOriginalProfitEstimated(originalProjectId).HasValue) originalProfitEstimated = (decimal)projectCostingUpdatesGateway.GetOriginalProfitEstimated(originalProjectId);
                decimal? invoicedToDate = null; if (projectCostingUpdatesGateway.GetInvoicedToDate(originalProjectId).HasValue) invoicedToDate = (decimal)projectCostingUpdatesGateway.GetInvoicedToDate(originalProjectId);

                // ... Insert Costing Updates
                ProjectCostingUpdates projectCostingUpdates = new ProjectCostingUpdates(projectTDS);
                projectCostingUpdates.Insert(0, extrasToDate, costsIncurred, costToComplete, originalProfitEstimated, invoicedToDate, Int32.Parse(hdfCompanyId.Value.Trim()));
            }
        }