示例#1
0
        /// <summary>
        /// Method to get one record by primary key
        /// </summary>
        public Johnny.CMS.OM.SystemInfo.MailSettings GetModel(int id)
        {
            //Set up a return value
            Johnny.CMS.OM.SystemInfo.MailSettings model = null;

            StringBuilder strSql = new StringBuilder();

            strSql.Append("SELECT [Id], [SmtpServerIP], [SmtpServerPort], [MailId], [MailPassword] ");
            strSql.Append(" FROM [cms_mailsettings] ");
            strSql.Append(" WHERE [Id]=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;
            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters))
            {
                if (sdr.Read())
                {
                    model = new Johnny.CMS.OM.SystemInfo.MailSettings(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2), sdr.GetString(3), sdr.GetString(4));
                }
                else
                {
                    model = new Johnny.CMS.OM.SystemInfo.MailSettings();
                }
            }
            return(model);
        }
示例#2
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            SetMessage("");

            //validation
            if (!CheckInputEmptyAndLength(txtSmtpServerIP, "E00101", "E00102"))
                return;
            if (!CheckInputEmptyAndLength(txtSmtpServerPort, "E00101", "E00102"))
                return;
            if (!CheckInputEmptyAndLength(txtMailId, "E00101", "E00102"))
                return;
            if (!CheckInputEmptyAndLength(txtMailPassword, "E00101", "E00102"))
                return;

            Johnny.CMS.BLL.SystemInfo.MailSettings bll = new Johnny.CMS.BLL.SystemInfo.MailSettings();
            Johnny.CMS.OM.SystemInfo.MailSettings model = new Johnny.CMS.OM.SystemInfo.MailSettings();

            model.SmtpServerIP = txtSmtpServerIP.Text;
            model.SmtpServerPort = DataConvert.GetInt32(txtSmtpServerPort.Text);
            model.MailId = txtMailId.Text;
            model.MailPassword = txtMailPassword.Text;

            bll.AddOrUpdate(model);
            SetMessage(GetMessage("C00003"));
        }
示例#3
0
        /// <summary>
        /// Update one record
        /// </summary>
        public void Update(Johnny.CMS.OM.SystemInfo.MailSettings model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("UPDATE [cms_mailsettings] SET ");
            strSql.Append("[SmtpServerIP]=@smtpserverip,");
            strSql.Append("[SmtpServerPort]=@smtpserverport,");
            strSql.Append("[MailId]=@mailid,");
            strSql.Append("[MailPassword]=@mailpassword");
            //strSql.Append(" WHERE [Id]=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",             SqlDbType.Int,       4),
                new SqlParameter("@smtpserverip",   SqlDbType.VarChar,  50),
                new SqlParameter("@smtpserverport", SqlDbType.Int,       4),
                new SqlParameter("@mailid",         SqlDbType.VarChar, 100),
                new SqlParameter("@mailpassword",   SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.Id;
            parameters[1].Value = model.SmtpServerIP;
            parameters[2].Value = model.SmtpServerPort;
            parameters[3].Value = model.MailId;
            parameters[4].Value = model.MailPassword;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
示例#4
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            SetMessage("");

            //validation
            if (!CheckInputEmptyAndLength(txtSmtpServerIP, "E00101", "E00102"))
            {
                return;
            }
            if (!CheckInputEmptyAndLength(txtSmtpServerPort, "E00101", "E00102"))
            {
                return;
            }
            if (!CheckInputEmptyAndLength(txtMailId, "E00101", "E00102"))
            {
                return;
            }
            if (!CheckInputEmptyAndLength(txtMailPassword, "E00101", "E00102"))
            {
                return;
            }

            Johnny.CMS.BLL.SystemInfo.MailSettings bll   = new Johnny.CMS.BLL.SystemInfo.MailSettings();
            Johnny.CMS.OM.SystemInfo.MailSettings  model = new Johnny.CMS.OM.SystemInfo.MailSettings();

            model.SmtpServerIP   = txtSmtpServerIP.Text;
            model.SmtpServerPort = DataConvert.GetInt32(txtSmtpServerPort.Text);
            model.MailId         = txtMailId.Text;
            model.MailPassword   = txtMailPassword.Text;

            bll.AddOrUpdate(model);
            SetMessage(GetMessage("C00003"));
        }
示例#5
0
 /// <summary>
 /// Add or update one record
 /// </summary>
 public void AddOrUpdate(Johnny.CMS.OM.SystemInfo.MailSettings model)
 {
     if (!dal.IsExist(1))
     {
         dal.Add(model);
     }
     else
     {
         dal.Update(model);
     }
 }
示例#6
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            if (!this.IsPostBack)
            {
                Johnny.CMS.BLL.SystemInfo.MailSettings bll = new Johnny.CMS.BLL.SystemInfo.MailSettings();
                Johnny.CMS.OM.SystemInfo.MailSettings model = new Johnny.CMS.OM.SystemInfo.MailSettings();
                model = bll.GetModel(1);

                txtSmtpServerIP.Text = model.SmtpServerIP;
                txtSmtpServerPort.Text = DataConvert.GetString(model.SmtpServerPort);
                txtMailId.Text = model.MailId;
                txtMailPassword.Text = model.MailPassword;
                btnAdd.ButtonType = Johnny.Controls.Web.Button.Button.EnumButtonType.Save;
            }
        }       
示例#7
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);

            if (!this.IsPostBack)
            {
                Johnny.CMS.BLL.SystemInfo.MailSettings bll   = new Johnny.CMS.BLL.SystemInfo.MailSettings();
                Johnny.CMS.OM.SystemInfo.MailSettings  model = new Johnny.CMS.OM.SystemInfo.MailSettings();
                model = bll.GetModel(1);

                txtSmtpServerIP.Text   = model.SmtpServerIP;
                txtSmtpServerPort.Text = DataConvert.GetString(model.SmtpServerPort);
                txtMailId.Text         = model.MailId;
                txtMailPassword.Text   = model.MailPassword;
                btnAdd.ButtonType      = Johnny.Controls.Web.Button.Button.EnumButtonType.Save;
            }
        }
示例#8
0
        /// <summary>
        /// Method to get records with condition
        /// </summary>    	 
        public IList<Johnny.CMS.OM.SystemInfo.MailSettings> GetList()
        {
            IList<Johnny.CMS.OM.SystemInfo.MailSettings> list = new List<Johnny.CMS.OM.SystemInfo.MailSettings>();

            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT [Id], [SmtpServerIP], [SmtpServerPort], [MailId], [MailPassword] ");
            strSql.Append(" FROM [cms_mailsettings] ");
            strSql.Append(" ORDER BY [Sequence]");

            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
            {
                while (sdr.Read())
                {
                    Johnny.CMS.OM.SystemInfo.MailSettings item = new Johnny.CMS.OM.SystemInfo.MailSettings(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2), sdr.GetString(3), sdr.GetString(4));
                    list.Add(item);
                }
            }
            return list;
        }
示例#9
0
        /// <summary>
        /// Method to get records with condition
        /// </summary>
        public IList <Johnny.CMS.OM.SystemInfo.MailSettings> GetList()
        {
            IList <Johnny.CMS.OM.SystemInfo.MailSettings> list = new List <Johnny.CMS.OM.SystemInfo.MailSettings>();

            StringBuilder strSql = new StringBuilder();

            strSql.Append("SELECT [Id], [SmtpServerIP], [SmtpServerPort], [MailId], [MailPassword] ");
            strSql.Append(" FROM [cms_mailsettings] ");
            strSql.Append(" ORDER BY [Sequence]");

            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString()))
            {
                while (sdr.Read())
                {
                    Johnny.CMS.OM.SystemInfo.MailSettings item = new Johnny.CMS.OM.SystemInfo.MailSettings(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2), sdr.GetString(3), sdr.GetString(4));
                    list.Add(item);
                }
            }
            return(list);
        }
示例#10
0
        /// <summary>
        /// Method to get one record by primary key
        /// </summary>    	 
        public Johnny.CMS.OM.SystemInfo.MailSettings GetModel(int id)
        {
            //Set up a return value
            Johnny.CMS.OM.SystemInfo.MailSettings model = null;

            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT [Id], [SmtpServerIP], [SmtpServerPort], [MailId], [MailPassword] ");
            strSql.Append(" FROM [cms_mailsettings] ");
            strSql.Append(" WHERE [Id]=@id");
            SqlParameter[] parameters = {
					new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;
            using (SqlDataReader sdr = DbHelperSQL.ExecuteReader(strSql.ToString(), parameters))
            {
                if (sdr.Read())
                    model = new Johnny.CMS.OM.SystemInfo.MailSettings(sdr.GetInt32(0), sdr.GetString(1), sdr.GetInt32(2), sdr.GetString(3), sdr.GetString(4));
                else
                    model = new Johnny.CMS.OM.SystemInfo.MailSettings();
            }
            return model;
        }
示例#11
0
        /// <summary>
        /// Add one record
        /// </summary>
        public int Add(Johnny.CMS.OM.SystemInfo.MailSettings model)
        {
            StringBuilder strSql = new StringBuilder();

            //strSql.Append("DECLARE @Sequence int");
            //strSql.Append(" SELECT @Sequence=(max(Sequence)+1) FROM [cms_mailsettings]");
            //strSql.Append(" if @Sequence is NULL");
            //strSql.Append(" Set @Sequence=1");
            strSql.Append("INSERT INTO [cms_mailsettings](");
            strSql.Append("[SmtpServerIP],[SmtpServerPort],[MailId],[MailPassword]");
            strSql.Append(")");
            strSql.Append(" VALUES (");
            strSql.Append("@smtpserverip,@smtpserverport,@mailid,@mailpassword");
            strSql.Append(")");
            strSql.Append(";SELECT @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@smtpserverip",   SqlDbType.VarChar,  50),
                new SqlParameter("@smtpserverport", SqlDbType.Int,       4),
                new SqlParameter("@mailid",         SqlDbType.VarChar, 100),
                new SqlParameter("@mailpassword",   SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.SmtpServerIP;
            parameters[1].Value = model.SmtpServerPort;
            parameters[2].Value = model.MailId;
            parameters[3].Value = model.MailPassword;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#12
0
 /// <summary>
 /// Update one record
 /// </summary>
 public void Update(Johnny.CMS.OM.SystemInfo.MailSettings model)
 {
     dal.Update(model);
 }
示例#13
0
 /// <summary>
 /// Add one record
 /// </summary>
 public int Add(Johnny.CMS.OM.SystemInfo.MailSettings model)
 {
     return(dal.Add(model));
 }