public ActionResult EnviarCorreo([FromBody] Login.strLogin datos) { clsMail mail = new clsMail(); var lista = new List <string>() { datos.Email }; if (mail.SMTPMail_recuperacion("Requperacion de contraseña", " Recuperacion de contraseña", lista, "*****@*****.**", "Jesus Chon")) { return(Ok ( new { data = "Correo enviado Exitosamente", Tipo = "200" } )); } else { return(Ok ( new { data = "Error al enviar correo ", Tipo = "202" } )); } }
public static bool blnSendForgotEmail(string strUserName, string strSubject) { const string udcErrorMethod = "subSendForgotEmail"; const string strFromAddress = "*****@*****.**"; const string strFromName = "BookMyShow-BackOffice"; string pstrHostName = clsSettings.Get("Common", "SMTPServer", ""); string strFileName = System.AppDomain.CurrentDomain.BaseDirectory + "Common\\Templates\\ForgotPassword.tpl"; string strBody = ""; bool blnReturn = false; if (File.Exists(strFileName) == true) { StreamReader stmFile = new StreamReader(strFileName); strBody = stmFile.ReadToEnd(); stmFile.Close(); } strBody = strBody.Replace(("{%User_dtmDateTime%}"), DateTime.Now.ToString("d MMMM yyyy")); strBody = strBody.Replace(("{%User_strEmail%}"), strUserName); try { clsMail objMail = new clsMail(); objMail.blnAddTo("Admin", clsSettings.Get("BackOffice", "ForgotMailRequest", "").ToString()); //objMail.blnAddCC("Viraj", "*****@*****.**"); objMail.blnAddFrom(strFromName, strFromAddress); blnReturn = objMail.blnSendMail(strSubject, strBody); } catch (Exception ex) { clsLog.blnLogError(udcErrorSource, udcErrorMethod, "Error sending mail !!!", ex.ToString()); } return(blnReturn); }
internal static bool blnMailimintSettlementFile(string strFileName, string strFilePath, string strFileType) { const string udcErrorMethod = "blnMailimintSettlementFile"; string strEmailList = "", strEmailListCC = ""; bool blnReturn = false; try { clsMail objMail = new clsMail(); if (strFileType == "S") { strEmailList = clsSettings.Get("IMINT", "EmailList", ""); strEmailListCC = clsSettings.Get("IMINT", "EmailListCC", ""); } else if (strFileType == "R") { strEmailList = clsSettings.Get("IMINT", "RefundEmailList", ""); strEmailListCC = clsSettings.Get("IMINT", "RefundEmailListCC", ""); } foreach (string strEmailId in strEmailList.Split(new char[] { '|' })) { if (strEmailId.Length > 0) { objMail.blnAddTo("3i-infotech", strEmailId); } } foreach (string strEmailIdCC in strEmailListCC.Split(new char[] { '|' })) { if (strEmailIdCC.Length > 0) { objMail.blnAddTo("imint", strEmailIdCC); } } objMail.blnAddFrom("BookMyShow", "*****@*****.**"); objMail.MailPriority = System.Net.Mail.MailPriority.High; objMail.blnAddAttachment(strFilePath); blnReturn = objMail.blnSendMail(strFileName, strFileName); objMail = null; } catch (Exception ex) { blnReturn = false; clsLog.blnLogError(udcErrorSource, udcErrorMethod, "Error mailing imint Settlement File : " + strFileName, ex.ToString()); } return(blnReturn); }
public bool DoctorScheduleSyncer() { #region Variable clsSQL clsSQL = new clsSQL(); FileInfo fi = new FileInfo(System.Web.HttpContext.Current.Server.MapPath("/Upload/Doctor/SQLQuery.txt")); string sqlQuery = ""; bool result = false; #endregion if (fi.Exists) { StreamReader StrWer; try { StrWer = File.OpenText(System.Web.HttpContext.Current.Server.MapPath("/Upload/Doctor/SQLQuery.txt")); while (!(StrWer.EndOfStream)) { sqlQuery = sqlQuery + StrWer.ReadLine(); } StrWer.Close(); } catch (Exception) { } if (sqlQuery != "") { clsMail clsMail = new clsMail(); string outMail = ""; string outSQLError = ""; if (!clsSQL.Execute(sqlQuery, dbType, cs,out outSQLError)) { clsMail.Send("*****@*****.**", "*****@*****.**", "DoctorScheduleSyncer : Error Insert (OnWeb)", outSQLError + "<hr/>"+sqlQuery, out outMail); //lblDoctorScheduleSyncer.Text = "DoctorScheduleSyncer : เกิดข้อผิดพลาดขณะรันคำสั่ง<br/>"+sqlQuery; fi.Delete(); } else { fi.Delete(); result = true; } } } else { result = true; } return result; }
public bool DoctorScheduleSyncer() { #region Variable clsSQL clsSQL = new clsSQL(); FileInfo fi = new FileInfo(System.Web.HttpContext.Current.Server.MapPath("/Upload/Doctor/SQLQuery.txt")); string sqlQuery = ""; bool result = false; #endregion if (fi.Exists) { StreamReader StrWer; try { StrWer = File.OpenText(System.Web.HttpContext.Current.Server.MapPath("/Upload/Doctor/SQLQuery.txt")); while (!(StrWer.EndOfStream)) { sqlQuery = sqlQuery + StrWer.ReadLine(); } StrWer.Close(); } catch (Exception) { } if (sqlQuery != "") { clsMail clsMail = new clsMail(); string outMail = ""; string outSQLError = ""; if (!clsSQL.Execute(sqlQuery, dbType, cs, out outSQLError)) { clsMail.Send("*****@*****.**", "*****@*****.**", "DoctorScheduleSyncer : Error Insert (OnWeb)", outSQLError + "<hr/>" + sqlQuery, out outMail); //lblDoctorScheduleSyncer.Text = "DoctorScheduleSyncer : เกิดข้อผิดพลาดขณะรันคำสั่ง<br/>"+sqlQuery; fi.Delete(); } else { fi.Delete(); result = true; } } } else { result = true; } return(result); }
private void _callSendEmailHoiVien() { using (QL_HOIVIEN_KTEntities context = new QL_HOIVIEN_KTEntities()) { WaitDialogForm _wait = new WaitDialogForm("Đang kiểm tra send mail ...", "Vui lòng đợi giây lát"); var query = (from p in context.QL_HOIVIEN let age = DateTime.Now.Year - p.HV_NGAY_SINH.Value.Year let monthBirth = p.HV_NGAY_SINH.Value.Month let dayBirth = p.HV_NGAY_SINH.Value.Day where (age == 16 || age == 60) && DateTime.Now.Month >= monthBirth && DateTime.Now.Day >= dayBirth && ((p.HV_SENDMAIL_16TUOI ?? false) == false || (p.HV_SENDMAIL_60TUOI ?? false) == false) select p); string messageHtml = ""; foreach (var item in query) { int age = DateTime.Now.Year - item.HV_NGAY_SINH.Value.Year; Boolean found = false; if (age == 16 && (item.HV_SENDMAIL_16TUOI ?? false) == false) { item.HV_SENDMAIL_16TUOI = true; found = true; } else if (age == 60 && (item.HV_SENDMAIL_60TUOI ?? false) == false) { item.HV_SENDMAIL_60TUOI = true; found = true; } if (found) { string hoten = item.HV_HO + " " + item.HV_TEN; messageHtml += string.Format("<p><b>{0}</b>-Ngày sinh:{1}({2} tuổi) - Địa chỉ:{3}</p>", hoten, item.HV_NGAY_SINH.Value.ToString("dd/MM/yyyy"), age.ToString(), item.HV_THUONGTRU_DIACHI); } } if (messageHtml != "") { context.SaveChanges(); clsMail mail = new clsMail(); mail.sendMail(messageHtml); } _wait.Close(); } }
//Djora 19.05.21 public void KreirajPDF(string imefajla, string kojiprint, string ParamZaStampu) { string adresaFrom = ""; string lozinka = ""; // Pretvara pravi password u skremblovani. Ove dve linije mi treba samo u debug modu radi testa //clsPasswords pom = new clsPasswords(); //lozinka = pom.EncodePasswordToBase64("62+Wt9#H*v"); //Djora 07.09.21 pocetak ----------------------------------- DataBaseBroker db = new DataBaseBroker(); DataTable dt = new DataTable(); string sql = " SELECT DISTINCT dbo.Radnik.E_mail, dbo.Radnik.EmailPass FROM dbo.Radnik INNER JOIN " + " dbo.KadrovskaEvidencija ON dbo.Radnik.id_kadrovskaevidencija = dbo.KadrovskaEvidencija.ID_KadrovskaEvidencija " + " WHERE(dbo.Radnik.id_kadrovskaevidencija <> 1) AND (dbo.KadrovskaEvidencija.ID_KadrovskaEvidencija = @param0)"; dt = db.ParamsQueryDT(sql, Program.idkadar); if (dt.Rows.Count != 0) { foreach (DataRow row in dt.Rows) { adresaFrom = row["E_mail"].ToString().Trim(); //lozinka = row["EmailPass"].ToString().Trim(); clsPasswords ps = new clsPasswords(); lozinka = ps.DecodeFrom64(row["EmailPass"].ToString().Trim()); } } else { MessageBox.Show("Mail nije poslat. Trazite od IT sluzbe da vam otvori mail !", "UPOZORENJE", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //Djora 07.09.21 kraj --------------------------------------- //Izvlaci iz connestionstring-a user name i password string[] niz0 = Program.connectionString.Split(';'); string DatabaseUsername = niz0[2].Split('=')[1]; string DatabasePassword = niz0[3].Split('=')[1]; //Djora 22.10.21 30.08.21 Inicijacija Vrednosti //Djora 07.09.21 //string[,] niz = { { "Ko salje", "*****@*****.**", "t", "" }, { "Password", "@R01d1969S", "t", "" }, { "Kome se salje", "*****@*****.**", "t", "" }, { "Tema", "Ovo je Subject", "t", "" }, { "Poruka", "Ovo je Body", "t", "" } }; string[,] niz = { { "Ko šalje", adresaFrom, "t", "" }, { "Password", lozinka, "t", "" }, { "Kome se šalje", "", "t", "" }, { "Naslov", "", "t", "" }, { "Poruka", "", "t", "" } }; //Djora 22.10.21 Prikaz forme za unos mag.polja, lota i kolicine sa njihovim inicijalnim vrednostima string[,] niz2 = { }; //ivana 19.10.2021. //niz2 = Dijalog.Prikazi(niz); niz2 = Dijalog.Prikazi(niz, "Mail"); //Djora 30.08.21 if (niz2.Length == 0) { return; } //string URL = ""; //string RS = "http://sql2019/ReportServer/Pages/ReportViewer.aspx?%2fPlate%2fPlatnaKartica"; //string Command = "Render"; //string Format = "PDF"; ////Parametri koji se predaju //string mbr = "1"; //Inicijalno //string mes = "0320k"; //Zadaje se //string idfirma = "5"; //Zadaje se //string server = "server"; //Zadaje se //string database = "BankomVeza"; //Zadaje se //string username = "******"; //Zadaje se //string password = "******"; //Zadaje se //string URL = " "; ////URL = "http://" + LoginForm.ReportServer + "/ReportServer/Pages/ReportViewer.aspx?%2fIzvestaji%2f" + kojiprint + imefajla + "&rs:Command=Render&rs:Format=PDF" + "&database=" + Program.NazivBaze + "&Firma=" + Program.imeFirme + "&slike=" + LoginForm.ReportSlike; //+ "&rs:ParameterLanguage=" + culture.ToString() + ParamZaStampu; //URL = RS + "&rs:Command=" + Command + "&rs:Format=" + Format + "&mbr=" + mbr + "&mes=" + mes + "&idfirma=" + idfirma + "&server=" + server + "&database=" + database + "&username="******"&password="******"http://sql2019/ReportServer/Pages/ReportViewer.aspx?%2fIzvestaji%2fprnKonacniUlazniRacun&rs:Command=Render&rs:Format=PDF&database="BankomTest&server=server&username=sa&password=password&Firma=Bankom&slike=\\sql2016\\D\\logo\\&id=1564246"; //Djora 03.06.21 //string URL = @"http://" + LoginForm.ReportServer + "/ReportServer/Pages/ReportViewer.aspx?%2fIzvestaji%2f" + kojiprint + imefajla + "&rs:Command=Render&rs:Format=PDF&database=" + Program.NazivBaze + "&server=server&username=sa&password=password&Firma=" + Program.imeFirme + "&slike=\\sql2016\\D\\logo\\" + ParamZaStampu; //Djora 30.08.21 //string URL = @"http://" + LoginForm.ReportServer + "/ReportServer/Pages/ReportViewer.aspx?%2fIzvestaji%2f" + kojiprint + imefajla + "&rs:Command=Render&rs:Format=PDF&database=BankomTest&server=server&username=sa&password=password&Firma=" + Program.imeFirme + "&slike=\\sql2016\\D\\logo\\" + ParamZaStampu; string URL = @"http://" + LoginForm.ReportServer + "/ReportServer/Pages/ReportViewer.aspx?%2fIzvestaji%2f" + kojiprint + imefajla + "&rs:Command=Render&rs:Format=PDF&database=" + Program.NazivBaze + "&server=" + LoginForm.ImeServera + "&username="******"&password="******"&Firma=" + Program.imeFirme + "&slike=" + LoginForm.ReportSlike + ParamZaStampu; URL = URL.Replace("#", "%23").Replace("+", "%2b");//prilagodi specijalne karaktere kod passworda (znak + i # prave probleme) System.Diagnostics.Debug.WriteLine(ParamZaStampu); System.Net.HttpWebRequest Req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(URL); Req.Credentials = System.Net.CredentialCache.DefaultCredentials; Req.Method = "GET"; //Folder gde je aplikacija pokrenuta string directory = AppDomain.CurrentDomain.BaseDirectory; //Djora 18.10.21 poc -------------------------- string mailDir = directory + "mail"; if (!Directory.Exists(mailDir)) { System.IO.Directory.CreateDirectory(mailDir); } else { System.IO.DirectoryInfo di = new DirectoryInfo(mailDir); foreach (FileInfo file in di.GetFiles()) { file.Delete(); } } //Djora 18.10.21 kraj -------------------------- //Putanja gde ce biti snimljen fajl. //Djora 18.10.21 //string path = directory + @"mail\" + imefajla + ".pdf"; //@"D:\xxxx.pdf"; string path = mailDir + @"\" + imefajla + ".pdf"; //@"D:\xxxx.pdf"; System.Net.WebResponse objResponse = Req.GetResponse(); System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Create); System.IO.Stream stream = objResponse.GetResponseStream(); byte[] buf = new byte[1024]; int len = stream.Read(buf, 0, 1024); while (len > 0) { fs.Write(buf, 0, len); len = stream.Read(buf, 0, 1024); } stream.Close(); fs.Close(); //Djora 30.08.21 clsMail pismo = new clsMail(); //pismo.KonekcijaNaSmtp("*****@*****.**", "@R01d1969S", "*****@*****.**","Dokument", "Ovo je proba", path, "mail.bankom.rs"); pismo.KonekcijaNaSmtp(niz2[0, 1], niz2[1, 1], niz2[2, 1], niz2[3, 1], niz2[4, 1], path, "mail.bankom.rs"); //--------------------------------------------------------------------------------------------------- //Djora 30.08.21 //////newFileName = directory + @"mail\mail_lista.csv"; //////File.WriteAllText(newFileName, String.Empty); //////createCSV(niz[1, 1], "Hello C#", "Ovo je napisano u C#", directory +@"mail\", "xxxx.pdf"); ////////createCSV("*****@*****.**", "Hello C#", "Ovo je napisano u C#", "proba.txt"); //////string putanja = directory + @"mail\start.bat"; ////////Process.Start(putanja); //////Process.Start(@".\mail\start.bat"); //////MessageBox.Show("Gotovo !"); //////// //Slanje maila //////// //posaljiMail("@R01d1969S", "*****@*****.**", "Plata " + mes, "Plata za mesec mart", path, "Luka Djoric <*****@*****.**>", row["Ime"].ToString(), row["E_Mail"].ToString()); }
protected void btBook_Click(object sender, EventArgs e) { #region Variable string outSQL; string outMailMessage; clsMail clsMail; #endregion #region Insert Data if (clsSQL.Insert( "DoctorAppointment", new string[,]{ {"UID",clsSQL.GetNewID("UID","DoctorAppointment","",dbType,cs).ToString()}, {"HN","'"+clsSQL.CodeFilter(txtHN.Text)+"'"}, {"PName","'"+clsSQL.CodeFilter(ddlPName.SelectedItem.Text)+"'"}, {"FName","'"+clsSQL.CodeFilter(txtFName.Text)+"'"}, {"LName","'"+clsSQL.CodeFilter(txtLName.Text)+"'"}, {"Email","'"+clsSQL.CodeFilter(txtEmail.Text)+"'"}, {"Phone","'"+clsSQL.CodeFilter(txtPhone.Text)+"'"}, {"DoctorUID",clsDefault.URLRouting("doctorUID")}, {"DoctorName","'"+clsSQL.CodeFilter(lblName1.Text)+"'"}, {"DepartmentUID","'"+clsDefault.URLRouting("departmentUID")+"'"}, {"DepartmentName","'"+clsSQL.CodeFilter(lblDepartment.Text)+"'"}, {"AppointmentDate","'"+clsSQL.CodeFilter(ucDateTimeFlat1.DateTime.ToString("yyyy-MM-dd HH:mm"))+"'"}, {"Comment","'"+clsSQL.CodeFilter(txtComment.Text)+"'"}, {"BirthDate","'"+ucBirthDate.DateTime.ToString("yyyy-MM-dd")+"'"}, {"NID","'"+txtNID.Text.SQLQueryFilter()+"'"}, {"CWhen","GETDATE()"}, {"CUser",(clsSecurity.LoginChecker()?clsSecurity.LoginUID:"0")}, {"MWhen","GETDATE()"}, {"MUser",(clsSecurity.LoginChecker()?clsSecurity.LoginUID:"0")}, {"Sort","0"}, {"Active","'1'"} }, new string[,]{}, dbType, cs, out outSQL)) { lblBookAlert.Text = clsDefault.AlertMessageColor("ระบบบันทึกข้อมูลการทำนัดของคุณแล้ว", clsDefault.AlertType.Success); string doctor = lblName1.Text; #region Mail to Admin clsMail = new clsMail(); if (!clsMail.SendTemplate( "DoctorScheduleAdmin", clsMail.GetEmailList("AutoSystemFrom"), clsMail.GetEmailList("DoctorScheduleTo"), new string[,]{ {"[PName]",ddlPName.SelectedItem.Text}, {"[FName]",txtFName.Text}, {"[LName]",txtLName.Text}, {"[HN]",txtHN.Text}, {"[Email]",txtEmail.Text}, {"[Phone]",txtPhone.Text}, {"[Doctor]",doctor}, {"[Department]",lblDepartment.Text}, {"[BookDateTime]",ucDateTimeFlat1.DateTime.ToString("dd/MM/yyyy HH:mm")}, {"[Comment]",txtComment.Text}, {"[BirthDate]",ucBirthDate.Text}, {"[NID]",txtNID.Text} }, out outMailMessage)) { lblBookAlert.Text += clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะส่งเมล์ไปยังลูกค้า", clsDefault.AlertType.Fail); } //List<clsMail.EmailList> mails = new List<global::clsMail.EmailList>(); //mails = clsMail.GetEmailList("DoctorScheduleTo"); //for (int i = 0; i < mails.Count; i++) //{ // lblBookAlert.Text+="<br/>"+mails[i].EmailAddress; //} lblBookAlert.Text += "<br/>"+outMailMessage; #endregion #region Mail to User clsMail = new clsMail(); if(!clsMail.SendTemplate( "DoctorScheduleUser", clsMail.GetEmailList("GlobalFrom"), txtEmail.Text.Trim(), new string[,]{ {"[PName]",ddlPName.SelectedItem.Text}, {"[FName]",txtFName.Text}, {"[LName]",txtLName.Text}, {"[HN]",txtHN.Text}, {"[Email]",txtEmail.Text}, {"[Phone]",txtPhone.Text}, {"[Doctor]",doctor}, {"[Department]",lblDepartment.Text}, {"[BookDateTime]",ucDateTimeFlat1.DateTime.ToString("dd/MM/yyyy HH:mm")}, {"[Comment]",txtComment.Text} }, out outMailMessage)) { lblBookAlert.Text += clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะส่งเมล์ไปยังลูกค้า", clsDefault.AlertType.Fail); } #endregion } else { lblBookAlert.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>" + outSQL, clsDefault.AlertType.Fail); } #endregion }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string id = clsDefault.URLRouting("id"); if (!string.IsNullOrEmpty(id)) { string idDecrypt = clsSecurity.Decrypt(id); string active = clsSQL.Return( "SELECT Active FROM [User] WHERE UID=" + parameterChar + "UID", new string[, ] { { parameterChar + "UID", idDecrypt } }, dbType, cs); if (!string.IsNullOrEmpty(active)) { if (active == "0") { string outSQL; if (clsSQL.Update( "[User]", new string[, ] { { "Active", "'1'" }, { "MWhen", "GETDATE()" } }, new string[, ] { { "@UID", idDecrypt } }, "UID=@UID", dbType, cs, out outSQL)) { #region Mail to Admin string outMessage; string Name = clsSQL.Return( "SELECT Username FROM [User] WHERE UID=" + parameterChar + "UID", new string[, ] { { parameterChar + "UID", idDecrypt } }, dbType, cs); clsMail clsMail = new clsMail(); if (!clsMail.SendTemplate( "UserRegisterConfirmAdmin", clsMail.GetEmailList("AutoSystemFrom"), clsMail.GetEmailList("AdminTo"), new string[, ] { { "[Username]", Name } }, out outMessage)) { ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>" + outMessage, AlertImage: ucColorBox.Alerts.Fail); return; } #endregion ucColorBox1.Redirect( "/", "ดำเนินการเสร็จสิ้น", "ระบบยืนยันสถานะสมาชิกของคุณเรียบร้อยแล้ว"); } else { ucColorBox1.Redirect( "/", "เกิดข้อผิดพลาด", "ไม่พบรหัสยืนยันของคุณ"); } } else { ucColorBox1.Redirect( "/", "ดำเนินการเสร็จสิ้น", "คุณเคยทำการยืนยันอีเมล์ไว้แล้ว"); } } else { ucColorBox1.Redirect( "/", "เกิดข้อผิดพลาด", "ไม่พบรหัสยืนยันของคุณ"); } } else { ucColorBox1.Redirect( "/", "เกิดข้อผิดพลาด", "ไม่พบรหัสยืนยันของคุณ"); } } }
protected void btSubmit_Click(object sender, EventArgs e) { #region Validation if (!ucCaptchaEncrypt1.Checker()) { lblCaptcha.Text = clsDefault.AlertMessageColor("คำตอบไม่ถูกต้อง", clsDefault.AlertType.Fail); lblCaptcha.Focus(); return; } #endregion #region Authorize if (!clsSecurity.LoginChecker() && (txtCName.Text.Trim() == "" || txtCEmail.Text.Trim() == "")) { //ucColorBox1.Redirect("/Webboard/", "กรุณาล็อคอิน หรือ ระบุชื่อและอีเมล์ก่อนส่งข้อมูล"); ucColorBox1.Alert("เกิดข้อผิดพลาด", "กรุณาล็อคอิน หรือ กรอกชื่อและอีเมล์ก่อน", AlertImage: ucColorBox.Alerts.Fail); return; } #endregion #region Variable clsIO clsIO = new clsIO(); StringBuilder strSQL = new StringBuilder(); int id = 0; string outSQL; string outErrorMessage; string outFilename; string photoName = ""; #endregion #region Update if (clsDefault.URLRouting("id") != "" && clsDefault.URLRouting("command") == "Edit") { id = int.Parse(clsDefault.URLRouting("id")); #region Photo Upload if (fuPhoto.HasFile) { if (clsIO.UploadPhoto( fuPhoto, pathUpload, "Q" + id.ToString(), out outErrorMessage, out outFilename, maxWidth: photoWidth, maxHeight: photoHeight)) { photoName = outFilename; } else { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail); return; } } #endregion if (clsSQL.Update(tableDefault, new string[, ] { { "WebboardGroupUID", ddlWebboardGroup.SelectedItem.Value }, { "Photo", (photoName == ""?"Photo":"'" + pathUpload + photoName + "'") }, { "Name", "'" + clsSQL.CodeFilter(ReservedWords(txtName.Text)) + "'" }, { "Detail", "'" + clsSQL.CodeFilter(ReservedWords(ucDetail.Text)) + "'" }, { "MetaKeywords", "'" + clsSQL.CodeFilter(txtMetaKeywords.Text) + "'" }, { "MetaDescription", "'" + clsSQL.CodeFilter(txtMetaDescription.Text) + "'" }, { "Status", (ddlStatus.SelectedItem.Value != "N"?"'" + ddlStatus.SelectedItem.Value + "'":"null") }, { "MUser", (clsSecurity.LoginChecker()?clsSecurity.LoginUID:"0") }, { "MWhen", "GETDATE()" }, { "MIPAddress", "'" + clsNet.IPGet() + "'" }, { "MComputername", "'" + clsNet.ComNameGet() + "'" }, { "Sort", clsSQL.CodeFilter(txtSort.Text) }, { "Active", "'" + (cbActive.Checked ? "1" : "0") + "'" } }, new string[, ] { { parameterChar + "UID", id.ToString() } }, "UID=" + parameterChar + "UID", dbType, cs, out outSQL)) { ucColorBox1.ReloadParent(); } else { ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail); } } #endregion #region Insert else { #region Find New ID id = clsSQL.GetNewID("UID", tableDefault, "", dbType, cs); if (id == 0) { ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "ไม่สามารถหา UID ใหม่ได้", AlertImage: ucColorBox.Alerts.Fail); return; } #endregion #region Photo Upload if (fuPhoto.HasFile) { if (clsIO.UploadPhoto( fuPhoto, pathUpload, "Q" + id.ToString(), out outErrorMessage, out outFilename, maxWidth: photoWidth, maxHeight: photoHeight)) { photoName = outFilename; } else { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail); return; } } #endregion if (clsSQL.Insert(tableDefault, new string[, ] { { "UID", id.ToString() }, { "WebboardGroupUID", ddlWebboardGroup.SelectedItem.Value }, { "Photo", (photoName == ""?"''":"'" + pathUpload + photoName + "'") }, { "Name", "'" + clsSQL.CodeFilter(ReservedWords(txtName.Text)) + "'" }, { "Detail", "'" + clsSQL.CodeFilter(ReservedWords(ucDetail.Text)) + "'" }, { "MetaKeywords", "'" + clsSQL.CodeFilter(txtMetaKeywords.Text) + "'" }, { "MetaDescription", "'" + clsSQL.CodeFilter(txtMetaDescription.Text) + "'" }, { "Status", (ddlStatus.SelectedItem.Value != "N"?"'" + ddlStatus.SelectedItem.Value + "'":"null") }, { "Views", "0" }, { "CName", (txtCName.Text.Trim() == ""?"null":"'" + clsSQL.CodeFilter(txtCName.Text) + "'") }, { "CEmail", (txtCEmail.Text.Trim() == ""?"null":"'" + clsSQL.CodeFilter(txtCEmail.Text) + "'") }, { "CUser", (clsSecurity.LoginChecker()?clsSecurity.LoginUID:"0") }, { "CWhen", "GETDATE()" }, { "CIPAddress", "'" + clsNet.IPGet() + "'" }, { "CComputername", "'" + clsNet.ComNameGet() + "'" }, { "MUser", (clsSecurity.LoginChecker()?clsSecurity.LoginUID:"0") }, { "MWhen", "GETDATE()" }, { "MIPAddress", "'" + clsNet.IPGet() + "'" }, { "MComputername", "'" + clsNet.ComNameGet() + "'" }, { "Sort", clsSQL.CodeFilter(txtSort.Text) }, { "Active", "'" + (approveEnable != "1"?"1":"0") + "'" } }, new string[, ] { { } }, dbType, cs, out outSQL)) { string outMessage; clsMail clsMail = new clsMail(); if (approveEnable != "1") { clsMail.SendTemplate( "WebboardTopicAlert", clsMail.GetEmailList("GlobalFrom"), clsMail.GetEmailList("WebboardTo"), new string[, ] { { "[Username]", clsSecurity.LoginUsername }, { "[CName]", clsSQL.CodeFilter(txtCName.Text) }, { "[CEmail]", clsSQL.CodeFilter(txtCName.Text) }, { "[IPAddress]", clsNet.IPGet() }, { "[ComputerName]", clsNet.ComNameGet() }, { "[Name]", clsDefault.URLRoutingFilter(txtName.Text) }, { "[Detail]", clsSQL.CodeFilter(ucDetail.Text) }, { "[CWhen]", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") }, { "[WebboardGroupUID]", ddlWebboardGroup.SelectedItem.Value }, { "[UID]", id.ToString() } }, out outMessage); ucColorBox1.ReloadParent(); } else { clsMail.SendTemplate( "WebboardTopicApprove", clsMail.GetEmailList("GlobalFrom"), clsMail.GetEmailList("WebboardTo"), new string[, ] { { "[Username]", clsSecurity.LoginUsername }, { "[CName]", clsSQL.CodeFilter(txtCName.Text) }, { "[CEmail]", clsSQL.CodeFilter(txtCName.Text) }, { "[IPAddress]", clsNet.IPGet() }, { "[ComputerName]", clsNet.ComNameGet() }, { "[Name]", clsDefault.URLRoutingFilter(txtName.Text) }, { "[Detail]", clsSQL.CodeFilter(ucDetail.Text) }, { "[CWhen]", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") }, { "[WebboardGroupUID]", ddlWebboardGroup.SelectedItem.Value }, { "[UID]", id.ToString() } }, out outMessage); ucColorBox1.Redirect(webDefault + clsDefault.URLRouting("group") + "/", "ดำเนินการเสร็จสิ้น", "เมื่อเจ้าหน้าที่ทำการตรวจสอบข้อมูลคำถามของคุณเรียบร้อยแล้ว จะทำการเผยแพร่โดยเร็ว"); } } else { ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail); } } #endregion }
protected void btSubmit_Click(object sender, EventArgs e) { #region Variable StringBuilder strSQL = new StringBuilder(); string outSQL; string outError; string outPhotoName = "null"; #endregion #region Check Data #region Find Username if (int.Parse(clsSQL.Return("SELECT COUNT(UID) FROM [User] WHERE Username='******'", dbType, cs)) > 0) { //lblUsername.Text = clsDefault.AlertMessageColor("Username นี้มีผู้ใช้งานแล้ว", clsDefault.AlertType.Warn); //lblUsername.Focus(); txtUsername.Focus(); ucColorBox1.Alert("ข้อมูลไม่ถูกต้อง", "Username นี้มีผู้ใช้งานแล้ว", AlertImage: ucColorBox.Alerts.Fail); return; } else { lblUsername.Text = ""; } #endregion #region Find Email if (int.Parse(clsSQL.Return("SELECT COUNT(UID) FROM [User] WHERE Email='" + clsDefault.CodeFilter(txtEMail.Text) + "'", dbType, cs)) > 0) { //lblEmail.Text = clsDefault.AlertMessageColor("Email นี้มีผู้ใช้งานแล้ว", clsDefault.AlertType.Warn); //lblEmail.Focus(); txtEMail.Focus(); ucColorBox1.Alert("ข้อมูลไม่ถูกต้อง", "E-Mail นี้มีผู้ใช้งานแล้ว", AlertImage: ucColorBox.Alerts.Fail); return; } else { lblEmail.Text = ""; } #endregion #region Find UID int UID = clsSQL.GetNewID("UID", "[User]", "", dbType, cs); if (UID == 0) { //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะหา UID", clsDefault.AlertType.Fail); //lblSQL.Focus(); ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "ไม่สามารถหา UID ได้", AlertImage: ucColorBox.Alerts.Fail); return; } else { lblSQL.Text = ""; } #endregion #endregion #region Insert #region Photo Upload if (fuPhoto.HasFile) { if (!clsIO.UploadPhoto(fuPhoto, pathPhoto, clsSecurity.LoginUID, 500, photoWidth, photoHeight, "", 0, out outError, out outPhotoName)) { //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะอัพโหลดภาพ : " + outError, clsDefault.AlertType.Fail); //lblSQL.Focus(); ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะอัพโหลดภาพ", AlertImage: ucColorBox.Alerts.Fail); return; } else { outPhotoName = "'" + pathPhoto + outPhotoName + "'"; } } #endregion #region SQL Insert if (clsSQL.Insert( "[USER]", new string[, ] { { "UID", UID.ToString() }, { "UserGroupUID", "2" }, { "Username", "'" + clsDefault.CodeFilter(txtUsername.Text) + "'" }, { "Password", "'" + clsSecurity.Encrypt(clsDefault.CodeFilter(txtPassword.Text)) + "'" }, { "Photo", outPhotoName }, { "PName", ddlPName.SelectedItem.Value != "null"?"'" + ddlPName.SelectedItem.Value + "'":"null" }, { "FName", "'" + clsDefault.CodeFilter(txtFName.Text) + "'" }, { "LName", "'" + clsDefault.CodeFilter(txtLName.Text) + "'" }, { "HN", "'" + clsDefault.CodeFilter(HNConvert(txtHN.Text)) + "'" }, { "BirthDate", ucDateTimeFlat1.DateTime != DateTime.MinValue?"'" + ucDateTimeFlat1.DateTime.ToString("yyyy-MM-dd HH:mm:ss") + "'":"null" }, { "Gender", rbGender.SelectedItem.Value != "null"?"'" + rbGender.SelectedItem.Value + "'":"null" }, { "Phone", "'" + clsDefault.CodeFilter(txtPhone.Text) + "'" }, { "Mobile", "'" + clsDefault.CodeFilter(txtMobile.Text) + "'" }, { "Email", "'" + clsDefault.CodeFilter(txtEMail.Text) + "'" }, { "Address", "'" + clsDefault.CodeFilter(txtAddress.Text) + "'" }, { "AddressDistrict", "'" + clsDefault.CodeFilter(txtAddressDistrict.Text) + "'" }, { "AddressPrefecture", "'" + clsDefault.CodeFilter(txtAddressPrefecture.Text) + "'" }, { "AddressProvince", "'" + clsDefault.CodeFilter(txtAddressProvince.Text) + "'" }, { "AddressPostal", "'" + clsDefault.CodeFilter(txtAddressPostal.Text) + "'" }, { "Profile", "'" + ucProfile.Text + "'" }, { "Signature", "'" + ucSignature.Text + "'" }, { "CUser", UID.ToString() }, { "CWhen", "GETDATE()" }, { "MUser", UID.ToString() }, { "MWhen", "GETDATE()" }, { "Sort", clsDefault.CodeFilter(txtSort.Text) }, { "Active", "'0'" /*cbActive.Checked?"'1'":"'0'"+"'"*/ } }, new string[, ] { { } }, dbType, cs, out outSQL )) { clsMail clsMail = new clsMail(); string outMessage; string idEncode = Server.UrlEncode(clsSecurity.Encrypt(UID.ToString())); #region Mail to User if (!clsMail.SendTemplate( "UserRegisterConfirm", clsMail.GetEmailList("GlobalFrom"), txtEMail.Text, new string[, ] { { "[Username]", txtUsername.Text }, { "[UIDEncrypt]", idEncode } }, out outMessage)) { //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>"+outMessage, clsDefault.AlertType.Fail); //lblSQL.Focus(); ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>" + outMessage, AlertImage: ucColorBox.Alerts.Fail); return; } #endregion #region Mail to Admin if (!clsMail.SendTemplate( "UserRegisterAdmin", clsMail.GetEmailList("AutoSystemFrom"), clsMail.GetEmailList("AdminTo"), new string[, ] { { "[Username]", txtUsername.Text } }, out outMessage)) { ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>" + outMessage, AlertImage: ucColorBox.Alerts.Fail); return; } #endregion } else { //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะบันทึกลงฐานข้อมูล : " + outSQL, clsDefault.AlertType.Fail); //lblSQL.Focus(); ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะบันทึกข้อมูลลงฐานข้อมูล : " + outSQL, AlertImage: ucColorBox.Alerts.Fail); return; } #endregion //clsDefault.Redirect("/", "บันทึกข้อมูลเรียบร้อยแล้ว"); ucColorBox1.Redirect("/"); #endregion }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string id = clsDefault.URLRouting("id"); if (!string.IsNullOrEmpty(id)) { string idDecrypt = clsSecurity.Decrypt(id); string active = clsSQL.Return( "SELECT Active FROM [User] WHERE UID=" + parameterChar + "UID", new string[,] { { parameterChar + "UID", idDecrypt } }, dbType, cs); if (!string.IsNullOrEmpty(active)) { if (active == "0") { string outSQL; if (clsSQL.Update( "[User]", new string[,] { { "Active", "'1'" }, { "MWhen", "GETDATE()" } }, new string[,] { { "@UID", idDecrypt } }, "UID=@UID", dbType, cs, out outSQL)) { #region Mail to Admin string outMessage; string Name = clsSQL.Return( "SELECT Username FROM [User] WHERE UID=" + parameterChar + "UID", new string[,] { { parameterChar + "UID", idDecrypt } }, dbType, cs); clsMail clsMail = new clsMail(); if (!clsMail.SendTemplate( "UserRegisterConfirmAdmin", clsMail.GetEmailList("AutoSystemFrom"), clsMail.GetEmailList("AdminTo"), new string[,]{ {"[Username]",Name} }, out outMessage)) { ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>" + outMessage, AlertImage: ucColorBox.Alerts.Fail); return; } #endregion ucColorBox1.Redirect( "/", "ดำเนินการเสร็จสิ้น", "ระบบยืนยันสถานะสมาชิกของคุณเรียบร้อยแล้ว"); } else { ucColorBox1.Redirect( "/", "เกิดข้อผิดพลาด", "ไม่พบรหัสยืนยันของคุณ"); } } else { ucColorBox1.Redirect( "/", "ดำเนินการเสร็จสิ้น", "คุณเคยทำการยืนยันอีเมล์ไว้แล้ว"); } } else { ucColorBox1.Redirect( "/", "เกิดข้อผิดพลาด", "ไม่พบรหัสยืนยันของคุณ"); } } else { ucColorBox1.Redirect( "/", "เกิดข้อผิดพลาด", "ไม่พบรหัสยืนยันของคุณ"); } } }
protected void btSendMail_Click(object sender, EventArgs e) { #region Variable var strSQL = new StringBuilder(); var clsSQL = new clsSQL(clsGlobal.dbType, clsGlobal.cs); var clsDefault = new clsDefault(); #endregion #region Procedure if (hidFileName.Value != "") { #region SQLQuery strSQL.Append("INSERT INTO "); strSQL.Append("P5_Job"); strSQL.Append("(FileName,Name,Detail,ContactName,ContactPhone,ContactEmail,Location,CWhen,MWhen)"); strSQL.Append("VALUES("); strSQL.Append("'" + hidFileName.Value.Trim() + "',"); strSQL.Append("'" + txtName.Text.SQLQueryFilter() + "',"); strSQL.Append("'" + txtDetail.Text.SQLQueryFilter() + "',"); strSQL.Append("'" + txtContactName.Text.SQLQueryFilter() + "',"); strSQL.Append("'" + txtContactPhone.Text.SQLQueryFilter() + "',"); strSQL.Append("'" + txtContactEmail.Text.SQLQueryFilter() + "',"); strSQL.Append("'" + txtLocation.Text.SQLQueryFilter() + "',"); strSQL.Append("GETDATE(),"); strSQL.Append("GETDATE()"); strSQL.Append(");"); #endregion if (clsSQL.Execute(strSQL.ToString())) { #region MailSender var clsMail = new clsMail(); var outMessage = ""; //Send to Admin try { if (!clsMail.SendByGmail( "*****@*****.**", "G00des1gn", System.Configuration.ConfigurationManager.AppSettings["mailTo"], "P5GraphicDesign : มีใบงานใหม่ '" + txtName.Text.SQLQueryFilter() + "'", string.Format("<h1>มีใบงานใหม่ : {0}</h1><div><b>จาก</b> : {1}</div><div><b>เบอร์โทร</b> : {2}</div><div><b>รายละเอียด</b> : {3}</div><hr/><a href='http://www.p5graphicdesign.com/Management/Job.aspx'>คลิกที่นี่เพื่อดูข้อมูล</a>", txtName.Text.SQLQueryFilter(), txtContactName.Text.SQLQueryFilter(), txtContactPhone.Text.SQLQueryFilter(), txtDetail.Text.SQLQueryFilter()), out outMessage, "P5GraphicDesign : มีใบงานใหม่ '" + txtName.Text.SQLQueryFilter() + "'", "*****@*****.**", "", "", System.Net.Mail.MailPriority.High)) { Response.Write("Send to Admin : " + outMessage); //ucColorBox1.Alert("พบข้อผิดพลาดขณะส่งเมล์", outMessage, AlertImage: ucColorBox.Alerts.Fail); return; } } catch (Exception exMailToAdmin) { Response.Write(exMailToAdmin.Message); } if (txtContactEmail.Text.Trim() != "" && txtContactEmail.Text.Contains("@") && txtContactEmail.Text.Contains(".")) { //Send to Customer try { if (!clsMail.SendByGmail( "*****@*****.**", "G00des1gn", txtContactEmail.Text.Trim(), "P5GraphicDesign : ได้รับใบงาน '" + txtName.Text.SQLQueryFilter() + "' ของคุณแล้ว", string.Format("<h1>ได้รับใบงานใหม่เรียบร้อยแล้ว : {0}</h1><div><b>จาก</b> : {1}</div><div><b>เบอร์โทร</b> : {2}</div><div><b>รายละเอียด</b> : {3}</div>", txtName.Text.SQLQueryFilter(), txtContactName.Text.SQLQueryFilter(), txtContactPhone.Text.SQLQueryFilter(), txtDetail.Text.SQLQueryFilter()), out outMessage, "P5GraphicDesign : ได้รับใบงาน '" + txtName.Text.SQLQueryFilter() + "' ของคุณแล้ว", "", "", "", System.Net.Mail.MailPriority.High)) { Response.Write(outMessage); //ucColorBox1.Alert("พบข้อผิดพลาดขณะส่งเมล์", outMessage, AlertImage: ucColorBox.Alerts.Fail); return; } } catch (Exception exMailToCustomer) { Response.Write("Send to Customer : " + exMailToCustomer.Message); } } #endregion txtName.Text = ""; txtDetail.Text = ""; txtContactName.Text = ""; txtContactPhone.Text = ""; txtLocation.Text = ""; hidFileName.Value = ""; lblSendMailAlert.Text = clsDefault.AlertMessageFlat("บันทึกข้อมูลเสร็จสมบูรณ์", clsDefault.AlertType.Success); lblSendMailAlert.Focus(); } else { lblSendMailAlert.Text = clsDefault.AlertMessageFlat("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>" + strSQL.ToString(), clsDefault.AlertType.Fail); lblSendMailAlert.Focus(); } } else { lblSendMailAlert.Text = clsDefault.AlertMessageFlat("โปรดเลือกอัพโหลดไฟล์ก่อนทำการส่งข้อมูล", clsDefault.AlertType.Fail); lblSendMailAlert.Focus(); } #endregion }
protected void btSubmit_Click(object sender, EventArgs e) { #region Validation if (!ucCaptchaEncrypt1.Checker()) { lblCaptcha.Text = clsDefault.AlertMessageColor("คำตอบไม่ถูกต้อง", clsDefault.AlertType.Fail); lblCaptcha.Focus(); return; } #endregion #region Authorize if (!clsSecurity.LoginChecker() && (txtCName.Text.Trim()=="" || txtCEmail.Text.Trim()=="")) { //ucColorBox1.Redirect("/Webboard/", "กรุณาล็อคอิน หรือ ระบุชื่อและอีเมล์ก่อนส่งข้อมูล"); ucColorBox1.Alert("เกิดข้อผิดพลาด", "กรุณาล็อคอิน หรือ กรอกชื่อและอีเมล์ก่อน", AlertImage: ucColorBox.Alerts.Fail); return; } #endregion #region Variable clsIO clsIO = new clsIO(); StringBuilder strSQL = new StringBuilder(); int id = 0; string outSQL; string outErrorMessage; string outFilename; string photoName = ""; #endregion #region Update if (clsDefault.URLRouting("id")!="" && clsDefault.URLRouting("command") == "Edit") { id = int.Parse(clsDefault.URLRouting("id")); #region Photo Upload if (fuPhoto.HasFile) { if (clsIO.UploadPhoto( fuPhoto, pathUpload, "Q" + id.ToString(), out outErrorMessage, out outFilename, maxWidth: photoWidth, maxHeight: photoHeight)) { photoName = outFilename; } else { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail); return; } } #endregion if (clsSQL.Update(tableDefault, new string[,]{ {"WebboardGroupUID",ddlWebboardGroup.SelectedItem.Value}, {"Photo",(photoName==""?"Photo":"'"+pathUpload+photoName+"'")}, {"Name","'"+clsSQL.CodeFilter(ReservedWords(txtName.Text))+"'"}, {"Detail","'"+clsSQL.CodeFilter(ReservedWords(ucDetail.Text))+"'"}, {"MetaKeywords","'"+clsSQL.CodeFilter(txtMetaKeywords.Text)+"'"}, {"MetaDescription","'"+clsSQL.CodeFilter(txtMetaDescription.Text)+"'"}, {"Status",(ddlStatus.SelectedItem.Value!="N"?"'"+ddlStatus.SelectedItem.Value+"'":"null")}, {"MUser",(clsSecurity.LoginChecker()?clsSecurity.LoginUID:"0")}, {"MWhen","GETDATE()"}, {"MIPAddress","'"+clsNet.IPGet()+"'"}, {"MComputername","'"+clsNet.ComNameGet()+"'"}, {"Sort",clsSQL.CodeFilter(txtSort.Text)}, {"Active","'" + (cbActive.Checked ? "1" : "0") + "'"} }, new string[,] { { parameterChar + "UID", id.ToString() } }, "UID=" + parameterChar + "UID", dbType, cs, out outSQL)) { ucColorBox1.ReloadParent(); } else { ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail); } } #endregion #region Insert else { #region Find New ID id = clsSQL.GetNewID("UID", tableDefault, "", dbType, cs); if (id == 0) { ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "ไม่สามารถหา UID ใหม่ได้", AlertImage: ucColorBox.Alerts.Fail); return; } #endregion #region Photo Upload if (fuPhoto.HasFile) { if (clsIO.UploadPhoto( fuPhoto, pathUpload, "Q" + id.ToString(), out outErrorMessage, out outFilename, maxWidth: photoWidth, maxHeight: photoHeight)) { photoName = outFilename; } else { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail); return; } } #endregion if (clsSQL.Insert(tableDefault, new string[,]{ {"UID",id.ToString()}, {"WebboardGroupUID",ddlWebboardGroup.SelectedItem.Value}, {"Photo",(photoName==""?"''":"'"+pathUpload+photoName+"'")}, {"Name","'"+clsSQL.CodeFilter(ReservedWords(txtName.Text))+"'"}, {"Detail","'"+clsSQL.CodeFilter(ReservedWords(ucDetail.Text))+"'"}, {"MetaKeywords","'"+clsSQL.CodeFilter(txtMetaKeywords.Text)+"'"}, {"MetaDescription","'"+clsSQL.CodeFilter(txtMetaDescription.Text)+"'"}, {"Status",(ddlStatus.SelectedItem.Value!="N"?"'"+ddlStatus.SelectedItem.Value+"'":"null")}, {"Views","0"}, {"CName",(txtCName.Text.Trim()==""?"null":"'"+clsSQL.CodeFilter(txtCName.Text)+"'")}, {"CEmail",(txtCEmail.Text.Trim()==""?"null":"'"+clsSQL.CodeFilter(txtCEmail.Text)+"'")}, {"CUser",(clsSecurity.LoginChecker()?clsSecurity.LoginUID:"0")}, {"CWhen","GETDATE()"}, {"CIPAddress","'"+clsNet.IPGet()+"'"}, {"CComputername","'"+clsNet.ComNameGet()+"'"}, {"MUser",(clsSecurity.LoginChecker()?clsSecurity.LoginUID:"0")}, {"MWhen","GETDATE()"}, {"MIPAddress","'"+clsNet.IPGet()+"'"}, {"MComputername","'"+clsNet.ComNameGet()+"'"}, {"Sort",clsSQL.CodeFilter(txtSort.Text)}, {"Active","'" + (approveEnable!="1"?"1":"0") + "'"} }, new string[,] { { } }, dbType, cs, out outSQL)) { string outMessage; clsMail clsMail = new clsMail(); if (approveEnable != "1") { clsMail.SendTemplate( "WebboardTopicAlert", clsMail.GetEmailList("GlobalFrom"), clsMail.GetEmailList("WebboardTo"), new string[,]{ {"[Username]",clsSecurity.LoginUsername}, {"[CName]",clsSQL.CodeFilter(txtCName.Text)}, {"[CEmail]",clsSQL.CodeFilter(txtCName.Text)}, {"[IPAddress]",clsNet.IPGet()}, {"[ComputerName]",clsNet.ComNameGet()}, {"[Name]",clsDefault.URLRoutingFilter(txtName.Text)}, {"[Detail]",clsSQL.CodeFilter(ucDetail.Text)}, {"[CWhen]",DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")}, {"[WebboardGroupUID]",ddlWebboardGroup.SelectedItem.Value}, {"[UID]",id.ToString()} }, out outMessage); ucColorBox1.ReloadParent(); } else { clsMail.SendTemplate( "WebboardTopicApprove", clsMail.GetEmailList("GlobalFrom"), clsMail.GetEmailList("WebboardTo"), new string[,]{ {"[Username]",clsSecurity.LoginUsername}, {"[CName]",clsSQL.CodeFilter(txtCName.Text)}, {"[CEmail]",clsSQL.CodeFilter(txtCName.Text)}, {"[IPAddress]",clsNet.IPGet()}, {"[ComputerName]",clsNet.ComNameGet()}, {"[Name]",clsDefault.URLRoutingFilter(txtName.Text)}, {"[Detail]",clsSQL.CodeFilter(ucDetail.Text)}, {"[CWhen]",DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss")}, {"[WebboardGroupUID]",ddlWebboardGroup.SelectedItem.Value}, {"[UID]",id.ToString()} }, out outMessage); ucColorBox1.Redirect(webDefault + clsDefault.URLRouting("group") + "/", "ดำเนินการเสร็จสิ้น", "เมื่อเจ้าหน้าที่ทำการตรวจสอบข้อมูลคำถามของคุณเรียบร้อยแล้ว จะทำการเผยแพร่โดยเร็ว"); } } else { ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail); } } #endregion }
protected void btBook_Click(object sender, EventArgs e) { #region Variable string outSQL; string outMailMessage; clsMail clsMail; #endregion #region Insert Data if (clsSQL.Insert( "DoctorAppointment", new string[, ] { { "UID", clsSQL.GetNewID("UID", "DoctorAppointment", "", dbType, cs).ToString() }, { "HN", "'" + clsSQL.CodeFilter(txtHN.Text) + "'" }, { "PName", "'" + clsSQL.CodeFilter(ddlPName.SelectedItem.Text) + "'" }, { "FName", "'" + clsSQL.CodeFilter(txtFName.Text) + "'" }, { "LName", "'" + clsSQL.CodeFilter(txtLName.Text) + "'" }, { "Email", "'" + clsSQL.CodeFilter(txtEmail.Text) + "'" }, { "Phone", "'" + clsSQL.CodeFilter(txtPhone.Text) + "'" }, { "DoctorUID", clsDefault.URLRouting("doctorUID") }, { "DoctorName", "'" + clsSQL.CodeFilter(lblName1.Text) + "'" }, { "DepartmentUID", "'" + clsDefault.URLRouting("departmentUID") + "'" }, { "DepartmentName", "'" + clsSQL.CodeFilter(lblDepartment.Text) + "'" }, { "AppointmentDate", "'" + clsSQL.CodeFilter(ucDateTimeFlat1.DateTime.ToString("yyyy-MM-dd HH:mm")) + "'" }, { "Comment", "'" + clsSQL.CodeFilter(txtComment.Text) + "'" }, { "BirthDate", "'" + ucBirthDate.DateTime.ToString("yyyy-MM-dd") + "'" }, { "NID", "'" + txtNID.Text.SQLQueryFilter() + "'" }, { "CWhen", "GETDATE()" }, { "CUser", (clsSecurity.LoginChecker()?clsSecurity.LoginUID:"0") }, { "MWhen", "GETDATE()" }, { "MUser", (clsSecurity.LoginChecker()?clsSecurity.LoginUID:"0") }, { "Sort", "0" }, { "Active", "'1'" } }, new string[, ] { }, dbType, cs, out outSQL)) { lblBookAlert.Text = clsDefault.AlertMessageColor("ระบบบันทึกข้อมูลการทำนัดของคุณแล้ว", clsDefault.AlertType.Success); string doctor = lblName1.Text; #region Mail to Admin clsMail = new clsMail(); if (!clsMail.SendTemplate( "DoctorScheduleAdmin", clsMail.GetEmailList("AutoSystemFrom"), clsMail.GetEmailList("DoctorScheduleTo"), new string[, ] { { "[PName]", ddlPName.SelectedItem.Text }, { "[FName]", txtFName.Text }, { "[LName]", txtLName.Text }, { "[HN]", txtHN.Text }, { "[Email]", txtEmail.Text }, { "[Phone]", txtPhone.Text }, { "[Doctor]", doctor }, { "[Department]", lblDepartment.Text }, { "[BookDateTime]", ucDateTimeFlat1.DateTime.ToString("dd/MM/yyyy HH:mm") }, { "[Comment]", txtComment.Text }, { "[BirthDate]", ucBirthDate.Text }, { "[NID]", txtNID.Text } }, out outMailMessage)) { lblBookAlert.Text += clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะส่งเมล์ไปยังลูกค้า", clsDefault.AlertType.Fail); } //List<clsMail.EmailList> mails = new List<global::clsMail.EmailList>(); //mails = clsMail.GetEmailList("DoctorScheduleTo"); //for (int i = 0; i < mails.Count; i++) //{ // lblBookAlert.Text+="<br/>"+mails[i].EmailAddress; //} lblBookAlert.Text += "<br/>" + outMailMessage; #endregion #region Mail to User clsMail = new clsMail(); if (!clsMail.SendTemplate( "DoctorScheduleUser", clsMail.GetEmailList("GlobalFrom"), txtEmail.Text.Trim(), new string[, ] { { "[PName]", ddlPName.SelectedItem.Text }, { "[FName]", txtFName.Text }, { "[LName]", txtLName.Text }, { "[HN]", txtHN.Text }, { "[Email]", txtEmail.Text }, { "[Phone]", txtPhone.Text }, { "[Doctor]", doctor }, { "[Department]", lblDepartment.Text }, { "[BookDateTime]", ucDateTimeFlat1.DateTime.ToString("dd/MM/yyyy HH:mm") }, { "[Comment]", txtComment.Text } }, out outMailMessage)) { lblBookAlert.Text += clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะส่งเมล์ไปยังลูกค้า", clsDefault.AlertType.Fail); } #endregion } else { lblBookAlert.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>" + outSQL, clsDefault.AlertType.Fail); } #endregion }
protected void btSubmit_Click(object sender, EventArgs e) { #region Variable StringBuilder strSQL = new StringBuilder(); string outSQL; string outError; string outPhotoName = "null"; #endregion #region Check Data #region Find Username if (int.Parse(clsSQL.Return("SELECT COUNT(UID) FROM [User] WHERE Username='******'", dbType, cs)) > 0) { //lblUsername.Text = clsDefault.AlertMessageColor("Username นี้มีผู้ใช้งานแล้ว", clsDefault.AlertType.Warn); //lblUsername.Focus(); txtUsername.Focus(); ucColorBox1.Alert("ข้อมูลไม่ถูกต้อง", "Username นี้มีผู้ใช้งานแล้ว", AlertImage: ucColorBox.Alerts.Fail); return; } else { lblUsername.Text = ""; } #endregion #region Find Email if (int.Parse(clsSQL.Return("SELECT COUNT(UID) FROM [User] WHERE Email='" + clsDefault.CodeFilter(txtEMail.Text) + "'", dbType, cs)) > 0) { //lblEmail.Text = clsDefault.AlertMessageColor("Email นี้มีผู้ใช้งานแล้ว", clsDefault.AlertType.Warn); //lblEmail.Focus(); txtEMail.Focus(); ucColorBox1.Alert("ข้อมูลไม่ถูกต้อง", "E-Mail นี้มีผู้ใช้งานแล้ว", AlertImage: ucColorBox.Alerts.Fail); return; } else { lblEmail.Text = ""; } #endregion #region Find UID int UID = clsSQL.GetNewID("UID", "[User]", "", dbType, cs); if (UID == 0) { //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะหา UID", clsDefault.AlertType.Fail); //lblSQL.Focus(); ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "ไม่สามารถหา UID ได้", AlertImage: ucColorBox.Alerts.Fail); return; } else{lblSQL.Text="";} #endregion #endregion #region Insert #region Photo Upload if (fuPhoto.HasFile) { if (!clsIO.UploadPhoto(fuPhoto, pathPhoto, clsSecurity.LoginUID, 500, photoWidth, photoHeight, "", 0, out outError, out outPhotoName)) { //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะอัพโหลดภาพ : " + outError, clsDefault.AlertType.Fail); //lblSQL.Focus(); ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะอัพโหลดภาพ", AlertImage: ucColorBox.Alerts.Fail); return; } else { outPhotoName = "'" + pathPhoto+outPhotoName + "'"; } } #endregion #region SQL Insert if (clsSQL.Insert( "[USER]", new string[,]{ {"UID",UID.ToString()}, {"UserGroupUID","2"}, {"Username","'"+clsDefault.CodeFilter(txtUsername.Text)+"'"}, {"Password","'"+clsSecurity.Encrypt(clsDefault.CodeFilter(txtPassword.Text))+"'"}, {"Photo",outPhotoName}, {"PName",ddlPName.SelectedItem.Value!="null"?"'"+ddlPName.SelectedItem.Value+"'":"null"}, {"FName","'"+clsDefault.CodeFilter(txtFName.Text)+"'"}, {"LName","'"+clsDefault.CodeFilter(txtLName.Text)+"'"}, {"HN","'"+clsDefault.CodeFilter(HNConvert(txtHN.Text))+"'"}, {"BirthDate",ucDateTimeFlat1.DateTime!=DateTime.MinValue?"'"+ucDateTimeFlat1.DateTime.ToString("yyyy-MM-dd HH:mm:ss")+"'":"null"}, {"Gender",rbGender.SelectedItem.Value!="null"?"'"+rbGender.SelectedItem.Value+"'":"null"}, {"Phone","'"+clsDefault.CodeFilter(txtPhone.Text)+"'"}, {"Mobile","'"+clsDefault.CodeFilter(txtMobile.Text)+"'"}, {"Email","'"+clsDefault.CodeFilter(txtEMail.Text)+"'"}, {"Address","'"+clsDefault.CodeFilter(txtAddress.Text)+"'"}, {"AddressDistrict","'"+clsDefault.CodeFilter(txtAddressDistrict.Text)+"'"}, {"AddressPrefecture","'"+clsDefault.CodeFilter(txtAddressPrefecture.Text)+"'"}, {"AddressProvince","'"+clsDefault.CodeFilter(txtAddressProvince.Text)+"'"}, {"AddressPostal","'"+clsDefault.CodeFilter(txtAddressPostal.Text)+"'"}, {"Profile","'"+ucProfile.Text+"'"}, {"Signature","'"+ucSignature.Text+"'"}, {"CUser",UID.ToString()}, {"CWhen","GETDATE()"}, {"MUser",UID.ToString()}, {"MWhen","GETDATE()"}, {"Sort",clsDefault.CodeFilter(txtSort.Text)}, {"Active","'0'"/*cbActive.Checked?"'1'":"'0'"+"'"*/} }, new string[,] { { } }, dbType, cs, out outSQL )) { clsMail clsMail = new clsMail(); string outMessage; string idEncode = Server.UrlEncode(clsSecurity.Encrypt(UID.ToString())); #region Mail to User if (!clsMail.SendTemplate( "UserRegisterConfirm", clsMail.GetEmailList("GlobalFrom"), txtEMail.Text, new string[,]{ {"[Username]",txtUsername.Text}, {"[UIDEncrypt]",idEncode} }, out outMessage)) { //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>"+outMessage, clsDefault.AlertType.Fail); //lblSQL.Focus(); ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>" + outMessage, AlertImage: ucColorBox.Alerts.Fail); return; } #endregion #region Mail to Admin if (!clsMail.SendTemplate( "UserRegisterAdmin", clsMail.GetEmailList("AutoSystemFrom"), clsMail.GetEmailList("AdminTo"), new string[,]{ {"[Username]",txtUsername.Text} }, out outMessage)) { ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>" + outMessage, AlertImage: ucColorBox.Alerts.Fail); return; } #endregion } else { //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะบันทึกลงฐานข้อมูล : " + outSQL, clsDefault.AlertType.Fail); //lblSQL.Focus(); ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะบันทึกข้อมูลลงฐานข้อมูล : "+outSQL, AlertImage: ucColorBox.Alerts.Fail); return; } #endregion //clsDefault.Redirect("/", "บันทึกข้อมูลเรียบร้อยแล้ว"); ucColorBox1.Redirect("/"); #endregion }