コード例 #1
0
        /// <summary>
        /// Save all to database (direct)
        /// </summary>
        /// <param name="companyId">companyId</param>        
        public void Save(int companyId)
        {
            ActualCostsAddTDS bondingChanges = (ActualCostsAddTDS)Data.GetChanges();

            if (bondingChanges != null)
            {
                if (bondingChanges.BondingCompaniesCosts.Rows.Count > 0)
                {
                    ActualCostsAddBondingCompaniesCostsGateway actualCostsAddBondingCompaniesCostsGateway = new ActualCostsAddBondingCompaniesCostsGateway(bondingChanges);

                    foreach (ActualCostsAddTDS.BondingCompaniesCostsRow row in (ActualCostsAddTDS.BondingCompaniesCostsDataTable)bondingChanges.BondingCompaniesCosts)
                    {
                        // Insert new bonding costs
                        if ((!row.Deleted) && (!row.InDatabase))
                        {
                            int projectId = row.ProjectID;
                            int refId = row.RefID;
                            int bondingCompanyId = row.BondingCompanyID;

                            decimal rateUsd = 0; if (!row.IsRateUsdNull()) rateUsd = row.RateUsd;
                            string comment = ""; if (!row.IsCommentNull()) comment = row.Comment;

                            ActualCostsBondingCompaniesCosts actualCostsBondingCompaniesCosts = new ActualCostsBondingCompaniesCosts(null);
                            actualCostsBondingCompaniesCosts.InsertDirect(projectId, refId, bondingCompanyId, row.Date, row.RateCad, rateUsd, comment, row.Deleted, row.COMPANY_ID);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            ActualCostsInformationTDS hotelCostsInformationChanges = (ActualCostsInformationTDS)Data.GetChanges();

            if (hotelCostsInformationChanges.BondingCostsBasicInformation.Rows.Count > 0)
            {
                ActualCostsInformationBondingCostsBasicInformationGateway actualCostsInformationBondingCostsBasicInformationGateway = new ActualCostsInformationBondingCostsBasicInformationGateway(hotelCostsInformationChanges);

                // Update employee
                foreach (ActualCostsInformationTDS.BondingCostsBasicInformationRow row in (ActualCostsInformationTDS.BondingCostsBasicInformationDataTable)hotelCostsInformationChanges.BondingCostsBasicInformation)
                {
                    // Insert new hours
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        string comment = ""; if (!row.IsCommentNull()) comment = row.Comment;
                        ActualCostsBondingCompaniesCosts actualCostsBondingCompaniesCosts = new ActualCostsBondingCompaniesCosts(null);
                        actualCostsBondingCompaniesCosts.InsertDirect(row.ProjectID, row.RefID, row.BondingCompanyID, row.Date, row.RateCad, row.RateUsd, comment, row.Deleted, row.COMPANY_ID);
                    }

                    // Update hours
                    if ((!row.Deleted) && (row.InDatabase))
                    {
                        int projectId = row.ProjectID;
                        int refId = row.RefID;
                        bool originalDeleted = false;
                        int originalCompanyId = companyId;

                        // Original values
                        int originalBondingId = actualCostsInformationBondingCostsBasicInformationGateway.GetBondingIDOriginal(projectId, refId);
                        DateTime originalDate = actualCostsInformationBondingCostsBasicInformationGateway.GetDateOriginal(projectId, refId);
                        decimal originalRateCad = actualCostsInformationBondingCostsBasicInformationGateway.GetRateCadOriginal(projectId, refId);
                        decimal originalRateUsd = actualCostsInformationBondingCostsBasicInformationGateway.GetRateUsdOriginal(projectId, refId);
                        string originalComment = actualCostsInformationBondingCostsBasicInformationGateway.GetCommentOriginal(projectId, refId);

                        // New values
                        int newBondingId = actualCostsInformationBondingCostsBasicInformationGateway.GetBondingID(projectId, refId);
                        DateTime newDate = actualCostsInformationBondingCostsBasicInformationGateway.GetDate(projectId, refId);
                        decimal newRateCad = actualCostsInformationBondingCostsBasicInformationGateway.GetRateCad(projectId, refId);
                        decimal newRateUsd = actualCostsInformationBondingCostsBasicInformationGateway.GetRateUsd(projectId, refId);
                        string newComment = actualCostsInformationBondingCostsBasicInformationGateway.GetComment(projectId, refId);

                        ActualCostsBondingCompaniesCosts actualCostsBondingCompaniesCosts = new ActualCostsBondingCompaniesCosts(null);
                        actualCostsBondingCompaniesCosts.UpdateDirect(projectId, refId, originalBondingId, originalDate, originalRateCad, originalRateUsd, originalComment, originalDeleted, originalCompanyId, projectId, refId, newBondingId, newDate, newRateCad, newRateUsd, newComment, originalDeleted, originalCompanyId);
                    }

                    // Delete hours
                    if ((row.Deleted) && (row.InDatabase))
                    {
                        ActualCostsBondingCompaniesCosts actualCostsBondingCompaniesCosts = new ActualCostsBondingCompaniesCosts(null);
                        actualCostsBondingCompaniesCosts.DeleteDirect(row.ProjectID, row.RefID, row.COMPANY_ID);
                    }
                }
            }
        }