public MessageTemplate SelectByName(string name) { string q = @"SELECT * FROM dbo.MessageTemplates WHERE Name LIKE '%{0}%' AND Deleted <> 1"; q = string.Format(q, name); using (SqlConnection conn = GetConnection()) using (OpenCbsCommand c = new OpenCbsCommand(q, conn)) using (OpenCbsReader r = c.ExecuteReader()) { if (r.Empty) { return(null); } if (!r.Read()) { return(null); } var messageTemplate = new MessageTemplate { Id = r.GetInt("Id"), Name = r.GetString("Name"), BccEmailAddresses = r.GetString("BccEmailAddresses"), Subject = r.GetString("Subject"), Body = r.GetString("Body"), EmailBody = r.GetString("EmailBody"), SendEmail = r.GetNullBool("SendEmail"), SendSMS = r.GetNullBool("SendSMS"), IsActive = r.GetBool("IsActive"), EmailAccountId = r.GetInt("EmailAccountId"), IsDefault = r.GetBool("IsDefault"), Deleted = r.GetBool("Deleted"), }; if (messageTemplate.EmailAccountId > 0) { EmailAccountManager _emailAccountManager = new EmailAccountManager(user); messageTemplate.EmailAccount = _emailAccountManager.SelectById(messageTemplate.EmailAccountId); } return(messageTemplate); } }
public List <MessageTemplate> SelectAll() { List <MessageTemplate> messageTemplates = new List <MessageTemplate>(); const string q = @"SELECT * FROM dbo.MessageTemplates where Deleted <> 1"; using (SqlConnection conn = GetConnection()) using (OpenCbsCommand c = new OpenCbsCommand(q, conn)) using (OpenCbsReader r = c.ExecuteReader()) { if (r.Empty) { return(messageTemplates); } while (r.Read()) { var messageTemplate = new MessageTemplate { Id = r.GetInt("Id"), Name = r.GetString("Name"), BccEmailAddresses = r.GetString("BccEmailAddresses"), Subject = r.GetString("Subject"), Body = r.GetString("Body"), EmailBody = r.GetString("EmailBody"), SendEmail = r.GetNullBool("SendEmail"), SendSMS = r.GetNullBool("SendSMS"), IsActive = r.GetBool("IsActive"), EmailAccountId = r.GetInt("EmailAccountId"), IsDefault = r.GetBool("IsDefault"), Deleted = r.GetBool("Deleted"), }; if (messageTemplate.EmailAccountId > 0) { EmailAccountManager _emailAccountManager = new EmailAccountManager(user); messageTemplate.EmailAccount = _emailAccountManager.SelectById(messageTemplate.EmailAccountId); } messageTemplates.Add(messageTemplate); } } return(messageTemplates); }
public List <QueuedSMS> SelectAll() { List <QueuedSMS> qeuedSMSs = new List <QueuedSMS>(); const string q = @"SELECT * FROM dbo.QueuedSMS where Deleted <> 1"; using (SqlConnection conn = GetConnection()) using (OpenCbsCommand c = new OpenCbsCommand(q, conn)) using (OpenCbsReader r = c.ExecuteReader()) { if (r.Empty) { return(qeuedSMSs); } while (r.Read()) { var queuedSMS = new QueuedSMS { Id = r.GetInt("Id"), From = r.GetString("From"), Recipient = r.GetString("Recipient"), RecipientId = r.GetNullInt("RecipientId"), ContractId = r.GetNullInt("ContractId"), Charged = r.GetNullBool("Charged"), Message = r.GetString("Message"), CreatedOnUtc = r.GetDateTime("CreatedOnUtc"), SentOnUtc = r.GetNullDateTime("SentOnUtc"), SentTries = r.GetInt("SentTries"), Response = r.GetString("Response"), Deleted = r.GetBool("Deleted"), }; qeuedSMSs.Add(queuedSMS); } } return(qeuedSMSs); }
private static EntryFee GetEntryFee(OpenCbsReader r) { EntryFee entryFee = new EntryFee { Id = r.GetInt("id"), Name = r.GetString("name_of_fee"), Min = r.GetNullDecimal("min"), Max = r.GetNullDecimal("max"), Value = r.GetNullDecimal("value"), IsRate = r.GetNullBool("rate") ?? false, Index = r.GetInt("fee_index"), CycleId = r.GetNullInt("cycle_id") }; return entryFee; }
private static void SetSavingsEvent(OpenCbsReader r, SavingEvent e, ISavingProduct pProduct) { e.Id = r.GetInt("id"); e.ContracId = r.GetInt("contract_id"); e.Code = r.GetString("code"); e.Amount = r.GetMoney("amount"); e.Description = r.GetString("description"); e.ReferenceNumber = r.GetString("reference_number"); e.Deleted = r.GetBool("deleted"); e.Date = r.GetDateTime("creation_date"); e.Cancelable = r.GetBool("cancelable"); e.IsFired = r.GetBool("is_fired"); e.CancelDate = r.GetNullDateTime("cancel_date"); if (pProduct != null) { e.ProductType = pProduct.GetType(); } if (r.GetNullSmallInt("savings_method").HasValue) { e.SavingsMethod = (OSavingsMethods)r.GetNullSmallInt("savings_method").Value; } e.IsPending = r.GetBool("pending"); e.IsLocal = r.GetNullBool("is_local"); e.PendingEventId = r.GetNullInt("pending_event_id"); e.TellerId = r.GetNullInt("teller_id"); e.LoanEventId = r.GetNullInt("loan_event_id"); if (pProduct != null) { e.ProductType = pProduct.GetType(); } if (e is SavingTransferEvent) { ((SavingTransferEvent)e).RelatedContractCode = r.GetString("related_contract_code"); } if (e is ISavingsFees) { ((ISavingsFees)e).Fee = r.GetMoney("fees"); } e.User = new User { Id = r.GetInt("user_id"), UserName = r.GetString("user_name"), Password = r.GetString("user_pass"), LastName = r.GetString("last_name"), FirstName = r.GetString("first_name") }; e.User.SetRole(r.GetString("role_code")); e.ClientType = OClientTypes.All; switch (r.GetString("client_type_code")) { case "I": e.ClientType = OClientTypes.Person; break; case "C": e.ClientType = OClientTypes.Corporate; break; case "G": e.ClientType = OClientTypes.Group; break; case "V": e.ClientType = OClientTypes.Village; break; } e.Branch = new Branch { Id = r.GetInt("branch_id") }; e.Currency = new Currency { Id = r.GetInt("currency_id"), Code = r.GetString("currency_code"), IsPivot = r.GetBool("is_pivot"), IsSwapped = r.GetBool("is_swapped") }; e.SavingProduct = new SavingsBookProduct { Id = r.GetInt("product_id") }; }