/// <summary> /// 得到一个对象实体 /// </summary> public ShowShop.Model.SystemInfo.MailSetting GetModel() { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,SmtpServerIP,SmtpServerPort,MailId,MailPassword from yxs_MailSetting "); ShowShop.Model.SystemInfo.MailSetting model = new ShowShop.Model.SystemInfo.MailSetting(); DataSet ds = ChangeHope.DataBase.SQLServerHelper.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.SmtpServerIP = ds.Tables[0].Rows[0]["SmtpServerIP"].ToString(); if (ds.Tables[0].Rows[0]["SmtpServerPort"].ToString() != "") { model.SmtpServerPort = int.Parse(ds.Tables[0].Rows[0]["SmtpServerPort"].ToString()); } model.MailId = ds.Tables[0].Rows[0]["MailId"].ToString(); model.MailPassword = ds.Tables[0].Rows[0]["MailPassword"].ToString(); return model; } else { return null; } }
private void Save() { ShowShop.BLL.SystemInfo.MailSetting bll = new ShowShop.BLL.SystemInfo.MailSetting(); Model.SystemInfo.MailSetting model = new ShowShop.Model.SystemInfo.MailSetting(); try { if (txtMailId.Text.Trim()!="") { if (!ChangeHope.Common.ValidateHelper.IsEmail(txtMailId.Text.Trim())) { this.ltlMsg.Text = "操作失败,请输入正确邮箱。"; this.pnlMsg.Visible = true; this.pnlMsg.CssClass = "actionErr"; return; } } model.Id = ChangeHope.Common.StringHelper.StringToInt(this.txtId.Value); model.MailId = this.txtMailId.Text; model.MailPassword = this.txtMailPassword.Text; model.SmtpServerIP = this.txtSmtpServerIP.Text; model.SmtpServerPort = ChangeHope.Common.StringHelper.StringToInt(this.txtSmtpServerPort.Text); if (model.Id > 0) { bll.Update(model); } else { bll.Add(model); } this.ltlMsg.Text = "操作成功!"; this.pnlMsg.CssClass = "actionOk"; this.pnlMsg.Visible = true; } catch(Exception ex) { this.ltlMsg.Text = "操作失败"+ex.ToString(); this.pnlMsg.Visible = true; this.pnlMsg.CssClass = "actionErr"; } finally { bll = null; model = null; } }