/// <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); }
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")); }
/// <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); }
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")); }
/// <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); } }
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; } }
/// <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; }
/// <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); }
/// <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; }
/// <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)); } }
/// <summary> /// Update one record /// </summary> public void Update(Johnny.CMS.OM.SystemInfo.MailSettings model) { dal.Update(model); }
/// <summary> /// Add one record /// </summary> public int Add(Johnny.CMS.OM.SystemInfo.MailSettings model) { return(dal.Add(model)); }