Exemple #1
0
        /// <summary>
        /// Gets the mail chimp list.
        /// </summary>
        /// <param name="branchId">The branch id.</param>
        /// <returns></returns>
        public List <Table.MailChimpList> GetMailChimpList(string branchId)
        {
            var           mailChimpLists = new List <Table.MailChimpList>();
            string        SQLString      = string.Format(@"SELECT LID,Name,BranchId FROM dbo.MailChimpLists WHERE BranchId='{0}'", branchId);
            SqlDataReader dataReader     = null;

            try
            {
                dataReader = DbHelperSQL.ExecuteReader(SQLString);
                Table.MailChimpList chimpList = null;
                while (dataReader.Read())
                {
                    chimpList        = new Table.MailChimpList();
                    chimpList.ListId = dataReader.IsDBNull(0) ? string.Empty : dataReader.GetString(0);
                    chimpList.Name   = dataReader.IsDBNull(1) ? string.Empty : dataReader.GetString(1);
                    string branchID = dataReader.IsDBNull(2) ? string.Empty : dataReader.GetString(2);
                    int    bid      = 0;
                    int.TryParse(branchId, out bid);
                    chimpList.BranchId = bid;
                    mailChimpLists.Add(chimpList);
                }
            }
            finally
            {
                if (dataReader != null)
                {
                    dataReader.Close();
                    dataReader.Dispose();
                }
            }
            return(mailChimpLists);
        }
Exemple #2
0
        public void AddMailChimpLists(Table.MailChimpList mailChimpList)
        {
            string err    = "";
            bool   logErr = false;
            string sqlCmd = string.Format(@"INSERT INTO [dbo].[MailChimpLists]
                                                               ([LID]
                                                               ,[Name]
                                                               ,[BranchId]
                                                               ,[UserId])
                                                         VALUES
                                                               (@LID
                                                               ,@Name
                                                               ,@Branchid
                                                               ,@UserId)");

            SqlParameter[] parameters =
            {
                new SqlParameter("@LID",      SqlDbType.NVarChar, 255),
                new SqlParameter("@Name",     SqlDbType.NVarChar, 255),
                new SqlParameter("@BranchId", SqlDbType.Int),
                new SqlParameter("@UserId",   SqlDbType.Int)
            };
            parameters[0].Value = mailChimpList.ListId;
            parameters[1].Value = mailChimpList.Name;
            parameters[2].Value = mailChimpList.BranchId;
            parameters[3].Value = mailChimpList.UserId;
            try
            {
                DbHelperSQL.ExecuteSql(sqlCmd, parameters);
            }
            catch (Exception ex)
            {
                //err = "AddMailChimpLists, Exception: " + ex.Message;
                //int Event_id = 2016;
                //EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category);
            }
            finally
            {
                if (logErr)
                {
                    //Trace.TraceError(err);
                    //int Event_id = 2016;
                    //EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Updates the mail chimp lists.
        /// </summary>
        /// <param name="mailChimpList">The mail chimp list.</param>
        public void UpdateMailChimpLists(Table.MailChimpList mailChimpList)
        {
            string err    = "";
            bool   logErr = false;
            string sqlCmd = string.Format(@"UPDATE [dbo].[MailChimpLists]
                                                           SET [Name] = @Name
                                                              ,[UserId] = @UserId
                                                         WHERE [LID] = @LID");

            SqlParameter[] parameters =
            {
                new SqlParameter("@LID",    SqlDbType.NVarChar, 255),
                new SqlParameter("@Name",   SqlDbType.NVarChar, 255),
                new SqlParameter("@UserId", SqlDbType.Int)
            };
            parameters[0].Value = mailChimpList.ListId;
            parameters[1].Value = mailChimpList.Name;
            parameters[2].Value = mailChimpList.UserId;
            try
            {
                DbHelperSQL.ExecuteSql(sqlCmd, parameters);
            }
            catch (Exception ex)
            {
                err = "AddMailChimpLists, Exception: " + ex.Message;
                int Event_id = 2020;
                EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category);
            }
            finally
            {
                if (logErr)
                {
                    Trace.TraceError(err);
                    int Event_id = 2020;
                    EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category);
                }
            }
        }