/// <summary> /// บันทึก Log การส่งอีเมล์จากระบบ Template /// </summary> /// <param name="UID">EmailTemplateUID</param> /// <param name="From">จากเมล์</param> /// <param name="To">ถึงเมล์</param> /// <param name="Cc">แนบเมล์</param> /// <param name="Bcc">ไม่เปิดเผยเมล์</param> /// <param name="Result">ผลการส่ง</param> /// <returns>true=บันทึกสำเร็จ , false=บันทึกไม่สำเร็จ</returns> private bool SendTemplateLog(string UID, string From, string To, string Cc, string Bcc, string Result) { #region Variable bool rtnValue = false; clsSQL clsSQL = new clsSQL(); clsSecurity clsSecurity = new clsSecurity(); clsNet clsNet = new clsNet(); string outSQL; #endregion #region SQL Query if (clsSQL.Insert( "EmailTemplateLog", new string[, ] { { "UID", clsSQL.GetNewID("UID", "EmailTemplateLog", "", dbType, cs).ToString() }, { "EmailTemplateUID", UID }, { "EmailFrom", "'" + clsSQL.CodeFilter(From) + "'" }, { "EmailTo", "'" + clsSQL.CodeFilter(To) + "'" }, { "EmailCc", "'" + clsSQL.CodeFilter(Cc) + "'" }, { "EmailBcc", "'" + clsSQL.CodeFilter(Bcc) + "'" }, { "Result", "'" + clsSQL.CodeFilter(Result) + "'" }, { "CWhen", "GETDATE()" }, { "CUser", "0" }, { "CIP", "'" + clsNet.IPGet() + "'" }, { "CHostname", "'" + clsNet.ComNameGet() + "'" } }, new string[, ] { {} }, dbType, cs, out outSQL)) { rtnValue = true; } #endregion return(rtnValue); }
protected void btSubmit_Click(object sender, EventArgs e) { #region Variable string outMail = ""; string outSQL = ""; string UID = ""; #endregion if (txtFromName.Text.Trim().Length > 0 && txtFromPhone.Text.Trim().Length > 0 && txtFromEmail.Text.Trim().Length > 0 && txtMessage.Text.Trim().Length > 0) { UID = clsSQL.GetNewID("UID", "Inquiry", "", dbType, cs).ToString(); if (!clsSQL.Insert( "Inquiry", new string[, ] { { "UID", UID }, { "MedicalCenterUID", (ddlMedicalCenter.SelectedItem.Value == "null"?"null":ddlMedicalCenter.SelectedItem.Value) }, { "Name", "'" + clsSQL.CodeFilter(txtFromName.Text) + "'" }, { "Email", "'" + clsSQL.CodeFilter(txtFromEmail.Text) + "'" }, { "Phone", "'" + clsSQL.CodeFilter(txtFromPhone.Text) + "'" }, { "Message", "'" + clsSQL.CodeFilter(txtMessage.Text) + "'" }, { "Status", "'RECEIVED'" }, { "CWhen", "GETDATE()" }, { "CUser", /*clsSecurity.LoginUID*/ "0" }, { "MWhen", "GETDATE()" }, { "MUser", /*clsSecurity.LoginUID*/ "0" }, { "Sort", "0" }, { "Active", "'1'" } }, new string[, ] { {} }, dbType, cs, out outSQL)) { ucColorBox1.Alert(Message: "เกิดข้อผิดพลาดขณะบันทึกข้อมูล", AlertImage: ucColorBox.Alerts.Fail); return; } #region MailToUser try { //string outMailMessage=""; //clsMail.Send( // "*****@*****.**", // txtFromEmail.Text.Trim(), // "โรงพยาบาลกรุงเทพจันทบุรี ได้รับข้อมูลของคุณแล้ว", // "คุณได้ส่งคำถาม '" + txtMessage.Text.Trim() + "' มายังโรงพยาบาล", // out outMailMessage); if (clsMail.SendTemplate( "InquiryConfirm", clsMail.GetEmailList("GlobalFrom"), txtFromEmail.Text, new string[, ] { { "[UID]", UID }, { "[MedicalCenter]", ddlMedicalCenter.SelectedItem.Text }, { "[FromName]", txtFromName.Text }, { "[FromPhone]", txtFromPhone.Text }, { "[FromEmail]", txtFromEmail.Text }, { "[CWhen]", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") }, { "[Message]", txtMessage.Text } }, out outMail)) { ucColorBox1.Redirect("/Inquiry/", "ได้รับข้อความของคุณแล้ว"); } else { lblAlert.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะพยายามส่งอีเมล์<br/>" + outMail, clsDefault.AlertType.Fail); lblAlert.Focus(); } } catch (Exception) { } #endregion #region MailToAdmin if (clsMail.SendTemplate( "Inquiry", clsMail.GetEmailList("AutoSystemFrom"), clsMail.GetEmailList("InquiryTo"), new string[, ] { { "[UID]", UID }, { "[MedicalCenter]", ddlMedicalCenter.SelectedItem.Text }, { "[FromName]", txtFromName.Text }, { "[FromPhone]", txtFromPhone.Text }, { "[FromEmail]", txtFromEmail.Text }, { "[CWhen]", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") }, { "[Message]", txtMessage.Text } }, out outMail)) { ucColorBox1.Redirect("/Inquiry/", "ได้รับข้อความของคุณแล้ว"); } else { lblAlert.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะพยายามส่งอีเมล์<br/>" + outMail, clsDefault.AlertType.Fail); lblAlert.Focus(); } #endregion } else { lblAlert.Text = clsDefault.AlertMessageColor("กรุณากรอกข้อมูลให้ครบก่อนค่ะ", clsDefault.AlertType.Warn); } }
protected void btSubmit_Click(object sender, EventArgs e) { #region Authorize if (!clsSecurity.LoginChecker("admin")) { ucColorBox1.Redirect("/", "กรุณาล็อคอินด้วยสิทธิ์ Admin"); return; } #endregion #region Variable var strSQL = new StringBuilder(); var id = 0; var outSQL = ""; var photoName = ""; var photoFullName = ""; #endregion #region Update if (Request.QueryString["id"] != null && clsDefault.QueryStringChecker("command") == "edit") { id = int.Parse(Request.QueryString["id"].ToString()); clsIO clsIO = new clsIO(); string outErrorMessage; string outFilename; #region Photo Upload if (fuPhoto.HasFile) { if (clsIO.UploadPhoto( fuPhoto, pathUpload, "HealthPackage" + id.ToString() + "_T", out outErrorMessage, out outFilename, maxWidth: photoWidth, maxHeight: photoHeight)) { photoName = outFilename; } else { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail); return; } } #endregion #region PhotoFull Upload if (fuPhotoFull.HasFile) { if (clsIO.UploadPhoto( fuPhotoFull, pathUpload, "HealthPackage" + id.ToString(), out outErrorMessage, out outFilename)) { photoFullName = outFilename; } else { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail); return; } } #endregion if (clsSQL.Update(tableDefault, new string[, ] { { "LanguageUID", rbLanguage.SelectedItem.Value }, { "DepartmentUID", (txtDepartmentUID.Text != ""?clsSQL.CodeFilter(txtDepartmentUID.Text):"null") }, { "PicThumbnail", (!string.IsNullOrEmpty(photoName)?"'" + pathUpload + photoName + "'":"PicThumbnail") }, { "PicFull", (!string.IsNullOrEmpty(photoFullName)?"'" + pathUpload + photoFullName + "'":"PicFull") }, { "Name", "'" + clsSQL.CodeFilter(txtName.Text) + "'" }, { "Detail", "'" + ucContent.Text.SQLQueryFilter() + "'" }, { "DetailSub", "'" + clsSQL.CodeFilter(txtDetail.Text) + "'" }, { "ActiveDateFrom", (ucDateStart.Text != ""?"'" + ucDateStart.Text.SQLQueryFilter() + "'":"null") }, { "ActiveDateTo", (ucDateEnd.Text != ""?"'" + ucDateEnd.Text.SQLQueryFilter() + "'":"null") }, { "UnitPrice", "'" + txtPrice.Text.SQLQueryFilter() + "'" }, { "MetaKeywords", "'" + clsSQL.CodeFilter(txtMetaKeyword.Text) + "'" }, { "MetaDescription", "'" + clsSQL.CodeFilter(txtMetaDescription.Text) + "'" }, { "MUser", "'" + clsSecurity.LoginUID + "'" }, { "MWhen", "GETDATE()" }, { "StatusFlag", "'" + (cbActive.Checked ? "A" : "D") + "'" } }, 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 clsIO clsIO = new clsIO(); string outErrorMessage; string outFilename; #region Photo Upload if (fuPhoto.HasFile) { if (clsIO.UploadPhoto( fuPhoto, pathUpload, "HealthPackage" + id.ToString() + "_T", out outErrorMessage, out outFilename, maxWidth: photoWidth, maxHeight: photoHeight)) { photoName = outFilename; } else { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail); return; } } #endregion #region PhotoFull Upload if (fuPhotoFull.HasFile) { if (clsIO.UploadPhoto( fuPhotoFull, pathUpload, "HealthPackage" + id.ToString(), out outErrorMessage, out outFilename)) { photoFullName = outFilename; } else { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail); return; } } #endregion if (clsSQL.Insert(tableDefault, new string[, ] { { "LanguageUID", rbLanguage.SelectedItem.Value }, { "DepartmentUID", (txtDepartmentUID.Text != ""?clsSQL.CodeFilter(txtDepartmentUID.Text):"null") }, { "PicThumbnail", (!string.IsNullOrEmpty(photoName)?"'" + pathUpload + photoName + "'":"null") }, { "PicFull", (!string.IsNullOrEmpty(photoFullName)?"'" + pathUpload + photoFullName + "'":"null") }, { "Name", "'" + clsSQL.CodeFilter(txtName.Text) + "'" }, { "Detail", "'" + ucContent.Text.SQLQueryFilter() + "'" }, { "DetailSub", "'" + clsSQL.CodeFilter(txtDetail.Text) + "'" }, { "ActiveDateFrom", (ucDateStart.Text != ""?"'" + ucDateStart.Text.SQLQueryFilter() + "'":"null") }, { "ActiveDateTo", (ucDateEnd.Text != ""?"'" + ucDateEnd.Text.SQLQueryFilter() + "'":"null") }, { "UnitPrice", "'" + txtPrice.Text.SQLQueryFilter() + "'" }, { "MetaKeywords", "'" + clsSQL.CodeFilter(txtMetaKeyword.Text) + "'" }, { "MetaDescription", "'" + clsSQL.CodeFilter(txtMetaDescription.Text) + "'" }, { "CUser", "'" + clsSecurity.LoginUID + "'" }, { "CWhen", "GETDATE()" }, { "MUser", "'" + clsSecurity.LoginUID + "'" }, { "MWhen", "GETDATE()" }, { "StatusFlag", "'" + (cbActive.Checked ? "A" : "D") + "'" } }, new string[, ] { { } }, dbType, cs, out outSQL)) { ucColorBox1.ReloadParent(); } else { ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail); } } #endregion }
protected void btSubmit_Click(object sender, EventArgs e) { #region Authorize if (!clsSecurity.LoginChecker("admin")) { ucColorBox1.Redirect("/", "กรุณาล็อคอินด้วยสิทธิ์ Admin"); return; } #endregion #region Variable StringBuilder strSQL = new StringBuilder(); int id = 0; string outSQL; string photoName = ""; #endregion #region Update if (Request.QueryString["id"] != null && clsDefault.QueryStringChecker("command") == "edit") { id = int.Parse(Request.QueryString["id"].ToString()); #region Photo Upload if (fuPhoto.HasFile) { clsIO clsIO = new clsIO(); string outErrorMessage; string outFilename; if (clsIO.UploadPhoto( fuPhoto, pathUpload, "Service" + 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[, ] { { "UID", id.ToString() }, { "LanguageUID", rbLanguage.SelectedItem.Value }, { "ServiceGroupUID", clsDefault.QueryStringChecker("group") }, { "DepartmentUID", (txtDepartmentUID.Text != ""?"'" + clsSQL.CodeFilter(txtDepartmentUID.Text) + "'":"null") }, { "Icon", (!string.IsNullOrEmpty(photoName)?"'" + pathUpload + photoName + "'":"Icon") }, { "Name", "'" + clsSQL.CodeFilter(txtName.Text) + "'" }, { "Detail", "'" + clsSQL.CodeFilter(txtDetail.Text) + "'" }, { "[Content]", "'" + clsSQL.CodeFilter(ucContent.Text) + "'" }, { "Price", "'" + clsSQL.CodeFilter(ucPrice.Text) + "'" }, { "Location", "'" + clsSQL.CodeFilter(txtLocation.Text) + "'" }, { "OfficeHours", "'" + clsSQL.CodeFilter(txtOfficeHours.Text) + "'" }, { "Phone", "'" + clsSQL.CodeFilter(txtPhone.Text) + "'" }, { "EMail", "'" + clsSQL.CodeFilter(txtEMail.Text) + "'" }, { "MetaKeywords", "'" + clsSQL.CodeFilter(txtMetaKeyword.Text) + "'" }, { "MetaDescription", "'" + clsSQL.CodeFilter(txtMetaDescription.Text) + "'" }, { "MUser", "'" + clsSecurity.LoginUID + "'" }, { "MWhen", "GETDATE()" }, { "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) { clsIO clsIO = new clsIO(); string outErrorMessage; string outFilename; if (clsIO.UploadPhoto( fuPhoto, pathUpload, "Service" + 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() }, { "LanguageUID", rbLanguage.SelectedItem.Value }, { "ServiceGroupUID", clsDefault.QueryStringChecker("group") }, { "DepartmentUID", (txtDepartmentUID.Text.Trim() != ""?"'" + clsSQL.CodeFilter(txtDepartmentUID.Text) + "'":"null") }, { "Icon", (!string.IsNullOrEmpty(photoName)?"'" + pathUpload + photoName + "'":"null") }, { "Name", "'" + clsSQL.CodeFilter(txtName.Text) + "'" }, { "Detail", "'" + clsSQL.CodeFilter(txtDetail.Text) + "'" }, { "[Content]", "'" + clsSQL.CodeFilter(ucContent.Text) + "'" }, { "Price", "'" + clsSQL.CodeFilter(ucPrice.Text) + "'" }, { "Location", "'" + clsSQL.CodeFilter(txtLocation.Text) + "'" }, { "OfficeHours", "'" + clsSQL.CodeFilter(txtOfficeHours.Text) + "'" }, { "Phone", "'" + clsSQL.CodeFilter(txtPhone.Text) + "'" }, { "EMail", "'" + clsSQL.CodeFilter(txtEMail.Text) + "'" }, { "MetaKeywords", "'" + clsSQL.CodeFilter(txtMetaKeyword.Text) + "'" }, { "MetaDescription", "'" + clsSQL.CodeFilter(txtMetaDescription.Text) + "'" }, { "CUser", "'" + clsSecurity.LoginUID + "'" }, { "CWhen", "GETDATE()" }, { "MUser", "'" + clsSecurity.LoginUID + "'" }, { "MWhen", "GETDATE()" }, { "Sort", clsSQL.CodeFilter(txtSort.Text) }, { "Active", "'" + (cbActive.Checked ? "1" : "0") + "'" } }, new string[, ] { { } }, dbType, cs, out outSQL)) { ucColorBox1.ReloadParent(); } else { ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail); } } #endregion }
protected void btSubmit_Click(object sender, EventArgs e) { #region Authorize if (!clsSecurity.LoginChecker("admin")) { ucColorBox1.Redirect("/", "กรุณาล็อคอินด้วยสิทธิ์ Admin"); return; } #endregion #region Variable StringBuilder strSQL = new StringBuilder(); int id = 0; string outSQL; string photoName = ""; string photoPreviewName = ""; #endregion #region Update if (Request.QueryString["id"] != null && clsDefault.QueryStringChecker("command") == "edit") { id = int.Parse(Request.QueryString["id"].ToString()); #region Photo Upload if (fuPhoto.HasFile) { clsIO clsIO = new clsIO(); string outErrorMessage; string outFilename; string outFilenamePreview; #region Photo if (clsIO.UploadPhoto( fuPhoto, pathUpload, tableDefault + id.ToString(), out outErrorMessage, out outFilename, maxWidth: photoWidth, maxHeight: photoHeight)) { photoName = outFilename; } else { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail); return; } #endregion #region Photo Preview if (clsIO.UploadPhoto( fuPhoto, pathUpload, tableDefault + id.ToString() + "Preview", out outErrorMessage, out outFilenamePreview, maxWidth: photoPreviewWidth, maxHeight: photoPreviewHeight)) { photoPreviewName = outFilenamePreview; } else { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail); return; } #endregion } #endregion if (clsSQL.Update(tableDefault, new string[, ] { { "UID", id.ToString() }, { "PhotoPreview", (!string.IsNullOrEmpty(photoPreviewName)?"'" + pathUpload + photoPreviewName + "'":"PhotoPreview") }, { "Photo", (!string.IsNullOrEmpty(photoName)?"'" + pathUpload + photoName + "'":"Photo") }, { "Name", "'" + clsSQL.CodeFilter(txtName.Text) + "'" }, { "Detail", "'" + clsSQL.CodeFilter(txtDetail.Text) + "'" }, { "MUser", "'" + clsSecurity.LoginUID + "'" }, { "MWhen", "GETDATE()" }, { "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) { clsIO clsIO = new clsIO(); string outErrorMessage; string outFilename; string outFilenamePreview; #region Photo if (clsIO.UploadPhoto( fuPhoto, pathUpload, tableDefault + id.ToString(), out outErrorMessage, out outFilename, maxWidth: photoWidth, maxHeight: photoHeight)) { photoName = outFilename; } else { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail); return; } #endregion #region PhotoPreview if (clsIO.UploadPhoto( fuPhoto, pathUpload, tableDefault + id.ToString() + "Preview", out outErrorMessage, out outFilenamePreview, maxWidth: photoPreviewWidth, maxHeight: photoPreviewHeight)) { photoPreviewName = outFilenamePreview; } else { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail); return; } #endregion } #endregion if (clsSQL.Insert(tableDefault, new string[, ] { { "UID", id.ToString() }, { "GlobalUID", clsDefault.QueryStringChecker("globalid") }, { "GlobalName", "'" + clsDefault.QueryStringChecker("globalname") + "'" }, { "PhotoPreview", (!string.IsNullOrEmpty(photoPreviewName)?"'" + pathUpload + photoPreviewName + "'":"null") }, { "Photo", (!string.IsNullOrEmpty(photoName)?"'" + pathUpload + photoName + "'":"null") }, { "Name", "'" + clsSQL.CodeFilter(txtName.Text) + "'" }, { "Detail", "'" + clsSQL.CodeFilter(txtDetail.Text) + "'" }, { "[View]", "0" }, { "CUser", "'" + clsSecurity.LoginUID + "'" }, { "CWhen", "GETDATE()" }, { "MUser", "'" + clsSecurity.LoginUID + "'" }, { "MWhen", "GETDATE()" }, { "Sort", clsSQL.CodeFilter(txtSort.Text) }, { "Active", "'" + (cbActive.Checked ? "1" : "0") + "'" } }, new string[, ] { { } }, dbType, cs, out outSQL)) { ucColorBox1.ReloadParent(); } else { ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail); } } #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 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 btSubmit_Click(object sender, EventArgs e) { #region Authorize if (!clsSecurity.LoginChecker("admin")) { ucColorBox1.Redirect("/", "กรุณาล็อคอินด้วยสิทธิ์ Admin"); return; } #endregion #region Variable StringBuilder strSQL = new StringBuilder(); int id = 0; string outSQL; #endregion #region Update if (Request.QueryString["id"] != null && clsDefault.QueryStringChecker("command") == "edit") { id = int.Parse(Request.QueryString["id"].ToString()); if (clsSQL.Update(tableDefault, new string[, ] { { "Name", "'" + clsSQL.CodeFilter(txtName.Text) + "'" }, { "Detail", "'" + clsSQL.CodeFilter(txtDetail.Text) + "'" }, { "MUser", "'" + clsSecurity.LoginUID + "'" }, { "MWhen", "GETDATE()" }, { "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 if (clsSQL.Insert(tableDefault, new string[, ] { { "UID", id.ToString() }, { "LanguageUID", rbLanguage.SelectedItem.Value }, { "Name", "'" + clsSQL.CodeFilter(txtName.Text) + "'" }, { "Detail", "'" + clsSQL.CodeFilter(txtDetail.Text) + "'" }, { "CUser", "'" + clsSecurity.LoginUID + "'" }, { "CWhen", "GETDATE()" }, { "MUser", "'" + clsSecurity.LoginUID + "'" }, { "MWhen", "GETDATE()" }, { "Sort", clsSQL.CodeFilter(txtSort.Text) }, { "Active", "'" + (cbActive.Checked ? "1" : "0") + "'" } }, new string[, ] { { } }, dbType, cs, out outSQL)) { ucColorBox1.ReloadParent(); } else { ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail); } } #endregion }
/// <summary> /// บันทึก Log การส่งอีเมล์จากระบบ Template /// </summary> /// <param name="UID">EmailTemplateUID</param> /// <param name="From">จากเมล์</param> /// <param name="To">ถึงเมล์</param> /// <param name="Cc">แนบเมล์</param> /// <param name="Bcc">ไม่เปิดเผยเมล์</param> /// <param name="Result">ผลการส่ง</param> /// <returns>true=บันทึกสำเร็จ , false=บันทึกไม่สำเร็จ</returns> private bool SendTemplateLog(string UID, string From, string To, string Cc, string Bcc, string Result) { #region Variable bool rtnValue = false; clsSQL clsSQL = new clsSQL(); clsSecurity clsSecurity=new clsSecurity(); clsNet clsNet = new clsNet(); string outSQL; #endregion #region SQL Query if(clsSQL.Insert( "EmailTemplateLog", new string[,]{ {"UID",clsSQL.GetNewID("UID","EmailTemplateLog","",dbType,cs).ToString()}, {"EmailTemplateUID",UID}, {"EmailFrom","'"+clsSQL.CodeFilter(From)+"'"}, {"EmailTo","'"+clsSQL.CodeFilter(To)+"'"}, {"EmailCc","'"+clsSQL.CodeFilter(Cc)+"'"}, {"EmailBcc","'"+clsSQL.CodeFilter(Bcc)+"'"}, {"Result","'"+clsSQL.CodeFilter(Result)+"'"}, {"CWhen","GETDATE()"}, {"CUser","0"}, {"CIP","'"+clsNet.IPGet()+"'"}, {"CHostname","'"+clsNet.ComNameGet()+"'"}}, new string[,]{{}}, dbType, cs, out outSQL)) { rtnValue = true; } #endregion return rtnValue; }
protected void btSubmit_Click(object sender, EventArgs e) { #region Variable var outSQL = ""; var clsIO = new clsIO(); var outError = ""; var outPhoto = ""; var outMail = ""; #endregion #region Procedure if (fuPhoto.HasFile) { if (!clsIO.UploadPhoto( fuPhoto, "/Upload/Jobs/", clsSQL.GetNewID("UID", "JobsHistory", "", dbType, cs).ToString(), out outError, out outPhoto, 512, 200, 200)) { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดภาพ : " + outError); return; } } #region InsertData if (!clsSQL.Insert( "JobsHistory", new string[, ] { { "JobsUID", ddlJobs.SelectedItem.Value }, { "JobsName", "'" + txtJobsName.Text.SQLQueryFilter() + "'" }, { "Salary", "'" + txtSalary.Text.SQLQueryFilter() + "'" }, { "Start", "'" + txtStart.Text.SQLQueryFilter() + "'" }, { "ProvinceChange", "'" + rbProvinceChange.SelectedItem.Value + "'" }, { "PrenameTH", "'" + ddlPrenameTH.SelectedItem.Value + "'" }, { "ForenameTH", "'" + txtForenameTH.Text.SQLQueryFilter() + "'" }, { "SurnameTH", "'" + txtSurnameTH.Text.SQLQueryFilter() + "'" }, { "PrenameEN", "'" + ddlPrenameEN.SelectedItem.Value + "'" }, { "ForenameEN", "'" + txtForenameEN.Text.SQLQueryFilter() + "'" }, { "SurnameEN", "'" + txtSurnameEN.Text.SQLQueryFilter() + "'" }, { "MarriageStatus", "'" + rbMarriageStatus.SelectedItem.Value + "'" }, { "Gender", "'" + rbGender.SelectedItem.Value + "'" }, { "Birthdate", "'" + (ucBirthdate.Text.Trim() != ""?ucBirthdate.DateTime.ToString("yyyy-MM-dd"):"1900-01-01 00:00") + "'" }, { "Birthplace", "'" + txtBirthplace.Text.SQLQueryFilter() + "'" }, { "Nationality", "'" + txtNationality.Text.SQLQueryFilter() + "'" }, { "Race", "'" + txtRace.Text.SQLQueryFilter() + "'" }, { "Religion", "'" + txtReligion.Text.SQLQueryFilter() + "'" }, { "Weight", "'" + txtWeight.Text.SQLQueryFilter() + "'" }, { "Height", "'" + txtHeight.Text.SQLQueryFilter() + "'" }, { "NID", "'" + txtNID.Text.SQLQueryFilter() + "'" }, { "NIDCreateBy", "'" + txtNIDCreateBy.Text.SQLQueryFilter() + "'" }, { "NIDExpire", "'" + (ucNIDExpire.Text != ""?ucNIDExpire.DateTime.ToString("yyyy-MM-dd"):"") + "'" }, { "Phone", "'" + txtPhone.Text.SQLQueryFilter() + "'" }, { "Email", "'" + txtEmail.Text.SQLQueryFilter() + "'" }, { "Address", "'" + txtAddress.Text.SQLQueryFilter() + "'" }, { "EmergencyName", "'" + txtEmergencyName.Text.SQLQueryFilter() + "'" }, { "EmergencyPhone", "'" + txtEmergencyPhone.Text.SQLQueryFilter() + "'" }, { "EmergencyEmail", "'" + txtEmergencyEmail.Text.SQLQueryFilter() + "'" }, { "EmergencyAddress", "'" + txtEmergencyAddress.Text.SQLQueryFilter() + "'" }, { "EmergencyRelationship", "'" + txtEmergencyRelationship.Text.SQLQueryFilter() + "'" }, { "Photo", (outPhoto != ""?"'" + outPhoto + "'":"null") }, { "Education", "'" + ucEducation.Text.SQLQueryFilter() + "'" }, { "Experience", "'" + ucExperience.Text.SQLQueryFilter() + "'" }, { "Resume", "null" }, { "CWhen", "GETDATE()" }, { "CUser", "0" }, { "MWhen", "GETDATE()" }, { "MUser", "0" }, { "Sort", "0" }, { "StatusFlag", "'A'" } }, new string[, ] { { } }, dbType, cs, out outSQL)) { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะรันคำสั่ง : " + Server.HtmlEncode(outSQL)); return; } else { #region MailSender string JobsUID = clsSQL.Return("SELECT MAX(UID) FROM JobsHistory", dbType, cs); if (!clsMail.SendTemplate( "JobsApply", clsMail.GetEmailList("AutoSystemFrom"), clsMail.GetEmailList("JobsTo"), new string[, ] { { "[Photo]", "<img src='" + System.Configuration.ConfigurationManager.AppSettings["website"] + "/Upload/Jobs/" + outPhoto + "'/>" }, { "[UID]", JobsUID }, { "[JobsName]", ddlJobs.SelectedItem.Text + (txtJobsName.Text.Trim() != ""?" (" + txtJobsName.Text.SQLQueryFilter() + ")":"") }, { "[PrenameTH]", ddlPrenameTH.SelectedItem.Text }, { "[ForenameTH]", txtForenameTH.Text }, { "[SurnameTH]", txtSurnameTH.Text }, { "[Birthdate]", ucBirthdate.DateTime.ToString("dd/MM/yyyy") }, { "[Birthplace]", txtBirthplace.Text }, { "[Gender]", rbGender.SelectedItem.Text }, { "[Phone]", txtPhone.Text }, { "[Email]", txtEmail.Text }, { "[Start]", txtStart.Text.SQLQueryFilter() }, { "[Education]", ucEducation.Text.SQLQueryFilter() }, { "[Experience]", ucExperience.Text.SQLQueryFilter() }, { "[CWhen]", DateTime.Now.ToString("dd/MM/yyyy HH:mm") } }, out outMail)) { lblMessage.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะพยายามส่งอีเมล์<br/>" + outMail, clsDefault.AlertType.Fail); lblMessage.Focus(); return; } #endregion ucColorBox1.Redirect("/Jobs/"); } #endregion #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 Authorize if (!clsSecurity.LoginChecker("admin")) { ucColorBox1.Redirect(webDefault, "กรุณาล็อคอินด้วยสิทธิ์ Admin"); 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, "Group" + id.ToString(), out outErrorMessage, out outFilename, maxWidth: photoWidth, maxHeight: photoHeight, resizeMode: clsIO.ResizeMode.crop)) { photoName = outFilename; } else { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail); return; } } #endregion if (clsSQL.Update(tableDefault, new string[, ] { { "WebboardTypeUID", ddlWebboardType.SelectedItem.Value }, { "GlobalUID", "'" + clsSQL.CodeFilter(txtGlobalUID.Text) + "'" }, { "Icon", (photoName != ""?"'" + pathUpload + photoName + "'":"Icon") }, { "Name", "'" + clsSQL.CodeFilter(txtName.Text) + "'" }, { "Detail", "'" + clsSQL.CodeFilter(txtDetail.Text) + "'" }, { "MetaKeywords", "'" + clsSQL.CodeFilter(txtMetaKeywords.Text) + "'" }, { "MetaDescription", "'" + clsSQL.CodeFilter(txtMetaDescription.Text) + "'" }, { "MUser", "'" + clsSecurity.LoginUID + "'" }, { "MWhen", "GETDATE()" }, { "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, "Group" + id.ToString(), out outErrorMessage, out outFilename, maxWidth: photoWidth, maxHeight: photoHeight, resizeMode: clsIO.ResizeMode.crop)) { photoName = outFilename; } else { ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail); return; } } #endregion if (clsSQL.Insert(tableDefault, new string[, ] { { "UID", id.ToString() }, { "WebboardTypeUID", clsDefault.URLRouting("type") }, { "GlobalUID", "'" + clsSQL.CodeFilter(txtGlobalUID.Text) + "'" }, { "Icon", "'" + pathUpload + photoName + "'" }, { "Name", "'" + clsSQL.CodeFilter(txtName.Text) + "'" }, { "Detail", "'" + clsSQL.CodeFilter(txtDetail.Text) + "'" }, { "MetaKeywords", "'" + clsSQL.CodeFilter(txtMetaKeywords.Text) + "'" }, { "MetaDescription", "'" + clsSQL.CodeFilter(txtMetaDescription.Text) + "'" }, { "Views", "0" }, { "CUser", "'" + clsSecurity.LoginUID + "'" }, { "CWhen", "GETDATE()" }, { "MUser", "'" + clsSecurity.LoginUID + "'" }, { "MWhen", "GETDATE()" }, { "Sort", clsSQL.CodeFilter(txtSort.Text) }, { "Active", "'" + (cbActive.Checked ? "1" : "0") + "'" } }, new string[, ] { { } }, dbType, cs, out outSQL)) { ucColorBox1.ReloadParent(); } else { ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail); } } #endregion }