Exemple #1
0
        public string Differences(IncidentCost other)
        {
            if (this == null || other == null)
            {
                return(string.Empty);
            }

            var res = new StringBuilder();

            if (this.Description != other.Description)
            {
                res.Append("Description=>").Append(other.Description).Append(";");
            }

            if (this.Amount != other.Amount)
            {
                res.Append("Amount=>").Append(other.Amount).Append(";");
            }

            if (this.Quantity != other.Quantity)
            {
                res.Append("Quantity=>").Append(other.Quantity).Append(";");
            }

            return(res.ToString());
        }
Exemple #2
0
        public static ReadOnlyCollection <IncidentCost> ByBusinessRiskId(long businessRiskId, int companyId)
        {
            var res = new List <IncidentCost>();

            using (var cmd = new SqlCommand("IndecidentCost_GetByBusinessRiskId"))
            {
                using (var cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["cns"].ConnectionString))
                {
                    cmd.Connection = cnn;
                    try
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(DataParameter.Input("@BusinessRiskId", businessRiskId));
                        cmd.Parameters.Add(DataParameter.Input("@CompanyId", companyId));
                        cmd.Connection.Open();
                        using (var rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                var newIncidentCost = new IncidentCost
                                {
                                    Id             = rdr.GetInt64(ColumnsIncidentCostGet.Id),
                                    CompanyId      = rdr.GetInt32(ColumnsIncidentCostGet.CompanyId),
                                    IncidentId     = rdr.GetInt64(ColumnsIncidentCostGet.IncidentActionId),
                                    BusinessRiskId = businessRiskId,
                                    Description    = rdr.GetString(ColumnsIncidentCostGet.Description),
                                    Amount         = rdr.GetDecimal(ColumnsIncidentCostGet.Amount),
                                    Quantity       = rdr.GetDecimal(ColumnsIncidentCostGet.Quantity),
                                    Responsible    = new Employee
                                    {
                                        Id       = rdr.GetInt32(ColumnsIncidentCostGet.ResponsibleId),
                                        Name     = rdr.GetString(ColumnsIncidentCostGet.ResponsibleName),
                                        LastName = rdr.GetString(ColumnsIncidentCostGet.ResponsibleLastName)
                                    },
                                    Active = rdr.GetBoolean(ColumnsIncidentCostGet.Active)
                                };

                                if (!rdr.IsDBNull(ColumnsIncidentCostGet.Date))
                                {
                                    newIncidentCost.Date = rdr.GetDateTime(ColumnsIncidentCostGet.Date);
                                }

                                res.Add(newIncidentCost);
                            }
                        }
                    }
                    finally
                    {
                        if (cmd.Connection.State != ConnectionState.Closed)
                        {
                            cmd.Connection.Close();
                        }
                    }
                }
            }

            return(new ReadOnlyCollection <IncidentCost>(res));
        }