Пример #1
0
        public List <AccaInfo> GetCreditCardDetailsForScheduledEvents(DateTime eventDate)
        {
            List <AccaInfo> scheduledAccountInfo = new List <AccaInfo>();
            AccaInfo        accInfo    = new AccaInfo();
            CreditCardInfo  creditCard = null;
            bool            success    = true;

            using (SqlConnection conn = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                conn.Open();
                using (SqlTransaction sqlTran = conn.BeginTransaction())
                {
                    try
                    {
                        SqlParameter[] sqlParam = new SqlParameter[] { new SqlParameter("@event_date", SqlDbType.DateTime) };
                        if (eventDate != DateTime.MinValue)
                        {
                            sqlParam[0].Value = eventDate;
                        }
                        SQLHelper.ExecuteNonQuery(sqlTran, CommandType.StoredProcedure,
                                                  SQLHelper.GetSQLStatement(MODULE_NAME, "SP_UPDATESCHEDULEDEVENTS"), sqlParam);
                        sqlTran.Commit();
                    }
                    catch (Exception ex)
                    {
                        success = false;
                        sqlTran.Rollback();
                        throw ex;
                    }
                }
            }
            if (success)
            {
                try
                {
                    using (SqlDataReader reader = SQLHelper.ExecuteReader(SQLHelper.CONNECTION_STRING,
                                                                          CommandType.StoredProcedure, SQLHelper.GetSQLStatement(MODULE_NAME, "SP_GETCREDITCARD"), null))
                    {
                        while (reader.Read())
                        {
                            creditCard = new CreditCardInfo(new LookupInfo(reader.GetInt32(0), reader.GetString(1)),
                                                            reader.GetString(2), reader.GetString(3), reader.GetString(4),
                                                            reader.GetInt32(5), reader.GetInt32(6), new AddressInfo(
                                                                reader.GetString(7), reader.GetString(8), reader.GetString(9),
                                                                new CountryInfo(reader.GetInt32(10), reader.GetString(11), false),
                                                                new StateInfo(reader.GetInt32(12), reader.GetString(13)),
                                                                reader.GetString(14), "", "", ""));
                            accInfo = new AccaInfo();
                            accInfo.AccaCreditCardInfo = creditCard;
                            accInfo.AccaDesignCategory = (DesignCategory)(Convert.ToInt32(reader["category"]));
                            accInfo.ContactCount       = Convert.ToInt32(reader["contact_count"]);
                            accInfo.EventId            = Convert.ToInt32(reader["event_id"]);
                            accInfo.EventStatus        = (ScheduleEventStatus)(Convert.ToInt32(reader["status"]));
                            accInfo.UserId             = Convert.ToInt32(reader["bill_user_id"]);
                            accInfo.EventDate          = Convert.ToDateTime(reader["event_date"]);
                            accInfo.FarmName           = Convert.ToString(reader["farm_name"]);
                            accInfo.PlanName           = Convert.ToString(reader["plan_name"]);
                            accInfo.UserName           = Convert.ToString(reader["first_name"]) + " " + Convert.ToString(reader["last_name"]);
                            accInfo.PostalTariff       = Convert.ToString(reader["postal_tariff"]);
                            if (reader["message_id"] == DBNull.Value && accInfo.AccaDesignCategory == DesignCategory.PowerKard)
                            {
                                accInfo.EventStatus = ScheduleEventStatus.ACCAError;
                                accInfo.Remarks     = "Message not assigned";
                            }
                            bool isEventExists = false;
                            foreach (AccaInfo accaInfo in scheduledAccountInfo)
                            {
                                if (accaInfo.EventId == accInfo.EventId)
                                {
                                    isEventExists = true;
                                    break;
                                }
                            }
                            if (!isEventExists)
                            {
                                scheduledAccountInfo.Add(accInfo);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(scheduledAccountInfo);
        }
Пример #2
0
 private decimal CalculateAmount(AccaInfo accaInfo)
 {
     return(CalculateAmount(accaInfo.AccaDesignCategory, accaInfo.PostalTariff,
                            accaInfo.ContactCount));
 }