protected void btnSave_Click(object sender, EventArgs e) { Maticsoft.Model.MailConfig model = new Maticsoft.Model.MailConfig { Mailaddress = this.txtMailaddress.Text, Password = this.txtPassword.Text, POPPort = Convert.ToInt32(this.txtPOPPort.Text), POPServer = this.txtPOPServer.Text, POPSSL = this.chkPOPSSL.Checked, SMTPPort = Convert.ToInt32(this.txtSMTPPort.Text), SMTPServer = this.txtSMTPServer.Text, SMTPSSL = this.chkSMTPSSL.Checked, Username = this.txtUsername.Text }; if (base.CurrentUser != null) { model.UserID = base.CurrentUser.UserID; } Maticsoft.BLL.MailConfig config2 = new Maticsoft.BLL.MailConfig(); if (!config2.Exists(model.UserID, model.Mailaddress)) { config2.Add(model); base.Response.Redirect("mailconfiglist.aspx"); } else { this.lblInfo.Visible = true; this.lblInfo.Text = "This account already exists"; } }
public List<Maticsoft.Model.MailConfig> DataTableToList(DataTable dt) { List<Maticsoft.Model.MailConfig> list = new List<Maticsoft.Model.MailConfig>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { Maticsoft.Model.MailConfig item = new Maticsoft.Model.MailConfig(); if (dt.Rows[i]["ID"].ToString() != "") { item.ID = int.Parse(dt.Rows[i]["ID"].ToString()); } if (dt.Rows[i]["UserID"].ToString() != "") { item.UserID = int.Parse(dt.Rows[i]["UserID"].ToString()); } item.Mailaddress = dt.Rows[i]["Mailaddress"].ToString(); item.Username = dt.Rows[i]["Username"].ToString(); item.Password = dt.Rows[i]["Password"].ToString(); item.SMTPServer = dt.Rows[i]["SMTPServer"].ToString(); if (dt.Rows[i]["SMTPPort"].ToString() != "") { item.SMTPPort = int.Parse(dt.Rows[i]["SMTPPort"].ToString()); } if (dt.Rows[i]["SMTPSSL"].ToString() != "") { item.SMTPSSL = dt.Rows[i]["SMTPSSL"].ToString() == "1"; } item.POPServer = dt.Rows[i]["POPServer"].ToString(); if (dt.Rows[i]["POPPort"].ToString() != "") { item.POPPort = int.Parse(dt.Rows[i]["POPPort"].ToString()); } if (dt.Rows[i]["POPSSL"].ToString() != "") { item.POPSSL = dt.Rows[i]["POPSSL"].ToString() == "1"; } list.Add(item); } } return list; }
protected void btnSave_Click(object sender, EventArgs e) { Maticsoft.Model.MailConfig model = this.bll.GetModel(); if (model != null) { model.Mailaddress = this.txtMailaddress.Text; model.Password = DESEncrypt.Encrypt(this.txtPassword.Text); model.SMTPPort = Convert.ToInt32(this.txtSMTPPort.Text); model.SMTPServer = this.txtSMTPServer.Text; model.SMTPSSL = this.chkSMTPSSL.Checked; model.Username = this.txtUsername.Text; this.bll.Update(model); MessageBox.ShowSuccessTip(this, Site.TooltipSaveOK); } else { Maticsoft.Model.MailConfig config2 = new Maticsoft.Model.MailConfig { Mailaddress = this.txtMailaddress.Text, Password = DESEncrypt.Encrypt(this.txtPassword.Text), SMTPPort = Convert.ToInt32(this.txtSMTPPort.Text), SMTPServer = this.txtSMTPServer.Text, SMTPSSL = this.chkSMTPSSL.Checked, Username = this.txtUsername.Text }; if (base.CurrentUser != null) { config2.UserID = base.CurrentUser.UserID; } new Maticsoft.BLL.MailConfig(); if (!this.bll.Exists(config2.UserID, config2.Mailaddress)) { this.bll.Add(config2); MessageBox.ShowSuccessTip(this, Site.TooltipSaveOK); } } }
public Maticsoft.Model.MailConfig GetModel() { StringBuilder builder = new StringBuilder(); builder.Append("select top 1 ID,UserID,Mailaddress,Username,Password,SMTPServer,SMTPPort,SMTPSSL,POPServer,POPPort,POPSSL from Accounts_MailConfig "); Maticsoft.Model.MailConfig config = new Maticsoft.Model.MailConfig(); DataSet set = DbHelperSQL.Query(builder.ToString()); if (set.Tables[0].Rows.Count <= 0) { return null; } if (set.Tables[0].Rows[0]["ID"].ToString() != "") { config.ID = int.Parse(set.Tables[0].Rows[0]["ID"].ToString()); } if (set.Tables[0].Rows[0]["UserID"].ToString() != "") { config.UserID = int.Parse(set.Tables[0].Rows[0]["UserID"].ToString()); } config.Mailaddress = set.Tables[0].Rows[0]["Mailaddress"].ToString(); config.Username = set.Tables[0].Rows[0]["Username"].ToString(); config.Password = set.Tables[0].Rows[0]["Password"].ToString(); config.SMTPServer = set.Tables[0].Rows[0]["SMTPServer"].ToString(); if (set.Tables[0].Rows[0]["SMTPPort"].ToString() != "") { config.SMTPPort = int.Parse(set.Tables[0].Rows[0]["SMTPPort"].ToString()); } if (set.Tables[0].Rows[0]["SMTPSSL"].ToString() != "") { config.SMTPSSL = set.Tables[0].Rows[0]["SMTPSSL"].ToString() == "1"; } config.POPServer = set.Tables[0].Rows[0]["POPServer"].ToString(); if (set.Tables[0].Rows[0]["POPPort"].ToString() != "") { config.POPPort = int.Parse(set.Tables[0].Rows[0]["POPPort"].ToString()); } if (set.Tables[0].Rows[0]["POPSSL"].ToString() != "") { config.POPSSL = set.Tables[0].Rows[0]["POPSSL"].ToString() == "1"; } return config; }