/// <summary>
        /// Save
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            ProjectCostingSheetInformationTDS projectCostingSheetInformationChanges = (ProjectCostingSheetInformationTDS)Data.GetChanges();

            if (projectCostingSheetInformationChanges.BasicInformation.Rows.Count > 0)
            {
                ProjectCostingSheetInformationBasicInformationGateway projectCostingSheetInformationBasicInformationGateway = new ProjectCostingSheetInformationBasicInformationGateway(projectCostingSheetInformationChanges);

                // Update costing sheet
                foreach (ProjectCostingSheetInformationTDS.BasicInformationRow basicInformationRow in (ProjectCostingSheetInformationTDS.BasicInformationDataTable)projectCostingSheetInformationChanges.BasicInformation)
                {
                    // Unchanged values
                    int costingSheetId = basicInformationRow.CostingSheetID;
                    int projectId = basicInformationRow.ProjectID;
                    DateTime startDate = basicInformationRow.StartDate;
                    DateTime endDate = basicInformationRow.EndDate;

                    // Original values
                    string originalName = projectCostingSheetInformationBasicInformationGateway.GetNameOriginal(costingSheetId);
                    decimal originalTotalLabourHoursCad = projectCostingSheetInformationBasicInformationGateway.GetTotalLabourHoursCadOriginal(costingSheetId);
                    decimal originalTotalLabourHoursUsd = projectCostingSheetInformationBasicInformationGateway.GetTotalLabourHoursUsdOriginal(costingSheetId);
                    decimal originalTotalMaterialsCad = projectCostingSheetInformationBasicInformationGateway.GetTotalMaterialsCadOriginal(costingSheetId);
                    decimal originalTotalMaterialsUsd = projectCostingSheetInformationBasicInformationGateway.GetTotalMaterialsUsdOriginal(costingSheetId);
                    decimal originalTotalUnitsCad = projectCostingSheetInformationBasicInformationGateway.GetTotalUnitsCadOriginal(costingSheetId);
                    decimal originalTotalUnitsUsd = projectCostingSheetInformationBasicInformationGateway.GetTotalUnitsUsdOriginal(costingSheetId);
                    decimal originalTotalOtherCostsCad = projectCostingSheetInformationBasicInformationGateway.GetTotalOtherCostsCadOriginal(costingSheetId);
                    decimal originalTotalOtherCostsUsd = projectCostingSheetInformationBasicInformationGateway.GetTotalOtherCostsUsdOriginal(costingSheetId);
                    decimal originalGrandTotalCad = projectCostingSheetInformationBasicInformationGateway.GetGrandTotalCadOriginal(costingSheetId);
                    decimal originalGrandTotalUsd = projectCostingSheetInformationBasicInformationGateway.GetGrandTotalUsdOriginal(costingSheetId);
                    string originalState = projectCostingSheetInformationBasicInformationGateway.GetStateOriginal(costingSheetId);
                    bool originalDeleted = projectCostingSheetInformationBasicInformationGateway.GetDeletedOriginal(costingSheetId);
                    decimal originalTotalSubcontractorsCad = projectCostingSheetInformationBasicInformationGateway.GetTotalSubcontractorsCadOriginal(costingSheetId);
                    decimal originalTotalSubcontractorsUsd = projectCostingSheetInformationBasicInformationGateway.GetTotalSubcontractorsUsdOriginal(costingSheetId);
                    decimal originalGrandRevenue = projectCostingSheetInformationBasicInformationGateway.GetGrandRevenueOriginal(costingSheetId);
                    decimal originalGrandProfit = projectCostingSheetInformationBasicInformationGateway.GetGrandProfitOriginal(costingSheetId);
                    decimal originalGrandGrossMargin = projectCostingSheetInformationBasicInformationGateway.GetGrandGrossMarginOriginal(costingSheetId);

                    // New variables
                    string newName = projectCostingSheetInformationBasicInformationGateway.GetName(costingSheetId);
                    decimal newTotalLabourHoursCad = projectCostingSheetInformationBasicInformationGateway.GetTotalLabourHoursCad(costingSheetId);
                    decimal newTotalLabourHoursUsd = projectCostingSheetInformationBasicInformationGateway.GetTotalLabourHoursUsd(costingSheetId);
                    decimal newTotalMaterialsCad = projectCostingSheetInformationBasicInformationGateway.GetTotalMaterialsCad(costingSheetId);
                    decimal newTotalMaterialsUsd = projectCostingSheetInformationBasicInformationGateway.GetTotalMaterialsUsd(costingSheetId);
                    decimal newTotalUnitsCad = projectCostingSheetInformationBasicInformationGateway.GetTotalUnitsCad(costingSheetId);
                    decimal newTotalUnitsUsd = projectCostingSheetInformationBasicInformationGateway.GetTotalUnitsUsd(costingSheetId);
                    decimal newTotalOtherCostsCad = projectCostingSheetInformationBasicInformationGateway.GetTotalOtherCostsCad(costingSheetId);
                    decimal newTotalOtherCostsUsd = projectCostingSheetInformationBasicInformationGateway.GetTotalOtherCostsUsd(costingSheetId);
                    decimal newGrandTotalCad = projectCostingSheetInformationBasicInformationGateway.GetGrandTotalCad(costingSheetId);
                    decimal newGrandTotalUsd = projectCostingSheetInformationBasicInformationGateway.GetGrandTotalUsd(costingSheetId);
                    string newState = projectCostingSheetInformationBasicInformationGateway.GetState(costingSheetId);
                    bool newDeleted = projectCostingSheetInformationBasicInformationGateway.GetDeleted(costingSheetId);
                    decimal newTotalSubcontractorsCad = projectCostingSheetInformationBasicInformationGateway.GetTotalSubcontractorsCad(costingSheetId);
                    decimal newTotalSubcontractorsUsd = projectCostingSheetInformationBasicInformationGateway.GetTotalSubcontractorsUsd(costingSheetId);
                    decimal newGrandRevenue = projectCostingSheetInformationBasicInformationGateway.GetGrandRevenue(costingSheetId);
                    decimal newGrandProfit = projectCostingSheetInformationBasicInformationGateway.GetGrandProfit(costingSheetId);
                    decimal newGrandGrossMargin = projectCostingSheetInformationBasicInformationGateway.GetGrandGrossMargin(costingSheetId);

                    // ... Update
                    UpdateCostingSheet(costingSheetId, projectId, originalName, startDate, endDate, originalTotalLabourHoursCad, originalTotalLabourHoursUsd, originalTotalMaterialsCad, originalTotalMaterialsUsd, originalTotalUnitsCad, originalTotalUnitsUsd, originalTotalOtherCostsCad, originalTotalOtherCostsUsd, originalGrandTotalCad, originalGrandTotalUsd, originalState, originalDeleted, companyId, originalTotalSubcontractorsCad, originalTotalSubcontractorsUsd, originalGrandRevenue, originalGrandProfit, originalGrandGrossMargin, projectId, newName, startDate, endDate, newTotalLabourHoursCad, newTotalLabourHoursUsd, newTotalMaterialsCad, newTotalMaterialsUsd, newTotalUnitsCad, newTotalUnitsUsd, newTotalOtherCostsCad, newTotalOtherCostsUsd, newGrandTotalCad, newGrandTotalUsd, newState, newDeleted, companyId, newTotalSubcontractorsCad, newTotalSubcontractorsUsd, newGrandRevenue, newGrandProfit, newGrandGrossMargin);
                }
            }
        }
コード例 #2
0
        // ////////////////////////////////////////////////////////////////////////
        // METHODS
        //
        private void LoadBasicData()
        {
            int costingSheetId = Int32.Parse(hdfCostingSheetId.Value);

            ProjectCostingSheetInformationBasicInformationGateway projectCostingSheetInformationBasicInformationGateway = new ProjectCostingSheetInformationBasicInformationGateway(projectCostingSheetInformationTDS);
            if (projectCostingSheetInformationBasicInformationGateway.Table.Rows.Count > 0)
            {
                // Load costing sheet basic data
                tbxState.Text = projectCostingSheetInformationBasicInformationGateway.GetState(costingSheetId);
                tbxTeamMembersTotalCostCAD.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetTotalLabourHoursCad(costingSheetId), 2).ToString();
                tbxTeamMembersTotalCostUSD.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetTotalLabourHoursUsd(costingSheetId), 2).ToString();
                tbxUnitsTotalCostsCAD.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetTotalUnitsCad(costingSheetId), 2).ToString();
                tbxUnitsTotalCostsUSD.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetTotalUnitsUsd(costingSheetId), 2).ToString();
                tbxMaterialsTotalCostsCAD.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetTotalMaterialsCad(costingSheetId), 2).ToString();
                tbxMaterialsTotalCostsUSD.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetTotalMaterialsUsd(costingSheetId), 2).ToString();
                tbxOtherCostsTotalCostsCAD.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetTotalOtherCostsCad(costingSheetId), 2).ToString();
                tbxOtherCostsTotalCostsUSD.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetTotalOtherCostsUsd(costingSheetId), 2).ToString();
                tbxSubcontractorsTotalCostsCAD.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetTotalSubcontractorsCad(costingSheetId), 2).ToString();
                tbxSubcontractorsTotalCostsUSD.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetTotalSubcontractorsUsd(costingSheetId), 2).ToString();
                tbxTotalCostCad.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetGrandTotalCad(costingSheetId), 2).ToString();
                tbxTotalCostUsd.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetGrandTotalUsd(costingSheetId), 2).ToString();
                GetOtherTotals();

                // Validate grid columns
                int projectId = Int32.Parse(hdfProjectId.Value);
                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(projectId);

                if (projectGateway.GetCountryID(projectId) == 1) //Canada
                {
                    tbxGrandTotal.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetGrandTotalCad(costingSheetId), 2).ToString();
                }
                else
                {
                    tbxGrandTotal.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetGrandTotalUsd(costingSheetId), 2).ToString();
                }

                tbxGrandRevenue.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetGrandRevenue(costingSheetId), 2).ToString();
                tbxRevenueTotal.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetGrandRevenue(costingSheetId), 2).ToString();
                tbxGrandProfit.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetGrandProfit(costingSheetId), 2).ToString();
                tbxGrandGrossMargin.Text = Math.Round(projectCostingSheetInformationBasicInformationGateway.GetGrandGrossMargin(costingSheetId), 2).ToString() + " %";
            }
        }