public static long Insert(MailConfig cus) { string sql = @"INSERT INTO MailConfig ([Code] ,[User] ,[Pass] ,[MailFrom] ,[DislayName] ,[Spmt] ,[Port] ,[EnableSsl] ,[Timeout] ,[UseCredentials] ,[Signature] ,[Default]) VALUES ('" + cus.Code + @"' ,'" + cus.User + @"' ,'" + cus.Pass + @"' ,'" + cus.MailFrom + @"' ,'" + cus.DislayName + @"' ,'" + cus.Spmt + @"' ," + cus.Port + @" ," + ((cus.EnableSsl == true)?1:0).ToString() + @" ," + cus.Timeout + @" ," + ((cus.UseCredentials == true)?1:0).ToString() + @" ,'" + cus.Signature + @"' ," + ((cus.Default == true)?1:0).ToString() + @")"; Provider.ExecuteNonQuery(sql); return(long.Parse(Provider.ExecuteScalar("Select @@IDENTITY").ToString())); }
public static long Insert(MailConfig cus) { string sql = @"INSERT INTO MailConfig ([Code] ,[User] ,[Pass] ,[MailFrom] ,[DislayName] ,[Spmt] ,[Port] ,[EnableSsl] ,[Timeout] ,[UseCredentials] ,[Signature] ,[Default]) VALUES ('" + cus.Code + @"' ,'" + cus.User + @"' ,'" + cus.Pass + @"' ,'" + cus.MailFrom + @"' ,'" + cus.DislayName + @"' ,'" + cus.Spmt + @"' ," + cus.Port + @" ," + ((cus.EnableSsl==true)?1:0).ToString() + @" ," + cus.Timeout + @" ," + ((cus.UseCredentials==true)?1:0).ToString() + @" ,'" + cus.Signature + @"' ," + ((cus.Default==true)?1:0).ToString() + @")"; Provider.ExecuteNonQuery(sql); return long.Parse(Provider.ExecuteScalar("Select @@IDENTITY").ToString()); }
private void lkProfile_EditValueChanged(object sender, EventArgs e) { if (lkProfile.EditValue != null) { long ID = long.Parse(lkProfile.EditValue.ToString()); mailConfig = MailConfig.Get(ID); ClearFormInfo(); SetFormInfo(); SetFormStatus("EDIT"); btnDelete.Enabled = true; } }
public static MailConfig GetByDefault() { Type Default = typeof(MailConfig); string sql = @"select * from MailConfig where Default=Yes "; DataTable dtTable = Provider.ExecuteToDataTable(sql); if (dtTable.Rows.Count > 0) { MailConfig cus = new MailConfig(); return((MailConfig)Common.GetObjectValue(dtTable.Rows[0], Default, cus)); } return(null); }
public static void Update(MailConfig cus) { string sql = @"UPDATE [MailConfig] SET [Code] = '" + cus.Code + @"' ,[User] = '" + cus.User + @"' ,[Pass] = '" + cus.Pass + @"' ,[MailFrom] = '" + cus.MailFrom + @"' ,[DislayName] = '" + cus.DislayName + @"' ,[Spmt] = '" + cus.Spmt + @"' ,[Port] = " + cus.Port + @" ,[EnableSsl] = " + ((cus.EnableSsl == true)?1:0).ToString() + @" ,[Timeout] = " + cus.Timeout + @" ,[UseCredentials] = " + ((cus.UseCredentials == true)?1:0).ToString() + @" ,[Signature] = '" + cus.Signature + @"' ,[Default] = " + ((cus.Default == true)?1:0).ToString() + @" WHERE ID=" + cus.ID; Provider.ExecuteNonQuery(sql); }
public static void Update(MailConfig cus) { string sql = @"UPDATE [MailConfig] SET [Code] = '" + cus.Code + @"' ,[User] = '" + cus.User + @"' ,[Pass] = '" + cus.Pass + @"' ,[MailFrom] = '" + cus.MailFrom + @"' ,[DislayName] = '" + cus.DislayName + @"' ,[Spmt] = '" + cus.Spmt + @"' ,[Port] = " + cus.Port + @" ,[EnableSsl] = " + ((cus.EnableSsl==true)?1:0).ToString() + @" ,[Timeout] = " + cus.Timeout + @" ,[UseCredentials] = " + ((cus.UseCredentials==true)?1:0).ToString() + @" ,[Signature] = '" + cus.Signature + @"' ,[Default] = " + ((cus.Default==true)?1:0).ToString() + @" WHERE ID=" + cus.ID; Provider.ExecuteNonQuery(sql); }
private MailConfig GetFormInfo() { MailConfig cf = new MailConfig(); cf.Code = txtCode.Text; cf.MailFrom = txtFromEmail.Text; cf.DislayName = txtDislayName.Text; cf.Spmt = txtSPMT.Text; cf.Port = int.Parse(calPort.EditValue.ToString()); cf.Default = chkDefault.Checked; cf.EnableSsl = chkEnableSsl.Checked; cf.Timeout = int.Parse(calTimeout.EditValue.ToString()); cf.User = txtUser.Text; cf.Pass = txtPass.Text; cf.Signature = htmlEditor1.BodyHtml; cf.UseCredentials = false; return cf; }
private void btnSave_Click(object sender, EventArgs e) { if (txtCode.Text.Trim() == "") { MessageBox.Show("Vui lòng nhập mã profile","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Warning); return; } if (mailConfig == null && status == "NEW") { MailConfig cf = GetFormInfo(); if (chkDefault.Checked) { MailConfig.ResetDefault(); } long ID=MailConfig.Insert(cf); MessageBox.Show("Thêm mới profile thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadMailSetting(); } else if(mailConfig!=null&&status=="EDIT") { MailConfig cf = GetFormInfo(); if (chkDefault.Checked) { MailConfig.ResetDefault(); } cf.ID = mailConfig.ID; MailConfig.Update(cf); mailConfig = cf; MessageBox.Show("Cập nhập profile thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnNew_Click(object sender, EventArgs e) { lkProfile.EditValue = null; ClearFormInfo(); mailConfig = null; SetFormStatus("NEW"); btnDelete.Enabled = false; }
private void SetFormStatus(string s) { status = s; if (s == "NEW") { txtCode.Enabled = true; mailConfig = null; } else if (s == "EDIT") { txtCode.Enabled = false; } }
public static MailConfig GetByDefault() { Type Default = typeof(MailConfig); string sql = @"select * from MailConfig where Default=Yes "; DataTable dtTable = Provider.ExecuteToDataTable(sql); if (dtTable.Rows.Count > 0) { MailConfig cus = new MailConfig(); return (MailConfig)Common.GetObjectValue(dtTable.Rows[0], Default, cus); } return null; }
public void SetSender(MailConfig mailConfig) { Sender = mailConfig; }
public void SetSender(MailConfig mailConfig) { lblMailFrom.Text = mailConfig.DislayName+" <"+mailConfig.MailFrom+">"; }