private void BindPromotion() { clsDefault clsDefault = new clsDefault(); int UID = int.Parse(clsDefault.URLRouting("id")); if (!string.IsNullOrEmpty(UID.ToString())) { var tbPromotion = from p in db.Promotions where p.UID == UID select p; foreach (Promotion p in tbPromotion) { lblUID.Text = p.UID.ToString(); lblSubject.Text = p.PromotionName; lblDetail.Text = p.Detail.Replace("'Upload/","'/Upload/"); PicFull.ImageUrl = p.PicFull; lblSiteMap.Text = p.PromotionName; Page.MetaKeywords = p.MetaKeywords; Page.MetaDescription = p.MetaDescription; } } else { Response.Redirect("PromotionView.aspx"); } }
private void BindPackage() { clsDefault clsDefault = new clsDefault(); //int UID = Convert.ToInt32(clsDefault.URLRouting("id")); //if (!string.IsNullOrEmpty(UID.ToString())) //{ // var tbPackage = from p in db.Packages // where p.UID == UID // select p; // //foreach (Package p in tbPackage) // //{ // // lblUID.Text = p.UID.ToString(); // // lblSubject.Text = p.PackageName; // // lblDetail.Text = p.Detail; // // PicFull.ImageUrl = p.PicFull; // // lblUnitPrice.Text = p.UnitPrice.ToString(); // // lblSiteMap.Text = p.PackageName; // // Page.MetaKeywords = p.MetaKeywords; // // Page.MetaDescription = p.MetaDescription; // //} //} //else //{ // Response.Redirect("PackageView.aspx"); //} }
protected void btLogin_Click(object sender, EventArgs e) { #region Variable var clsSQL = new clsSQL(); var clsDefault = new clsDefault(); var clsColorBox = new clsColorBox(); #endregion #region Procedure if (clsSecurity.LoginChecker( clsSQL.CodeFilter(txtUsername.Text), clsSQL.CodeFilter(txtPassword.Text), cbEnableCookie.Checked)) { //ucColorBox.Redirect(Request.RawUrl, "เข้าสู่ระบบแล้ว"); Response.Redirect(Request.RawUrl); } else { var script = "document.getElementById('dvUCLogon').scrollIntoView(true);"; Page.ClientScript.RegisterStartupScript(Page.GetType(), "ucColorBoxScroller", script, true); ucColorBox.Alert("Login Alert", "ไม่พบข้อมูลที่คุณกรอก", AlertImage: global::ucColorBox.Alerts.Fail); lblLogin.Text = clsDefault.AlertMessageColor("ไม่พบข้อมูลที่คุณกรอก", clsDefault.AlertType.Warn); } #endregion }
private void BindNews() { clsDefault clsDefault = new clsDefault(); if (!string.IsNullOrEmpty(clsDefault.URLRouting("id"))) { int UID = Convert.ToInt32(clsDefault.URLRouting("id")); if (!string.IsNullOrEmpty(UID.ToString())) { var tbNews = from n in db.News where n.UID == UID select n; foreach (New n in tbNews) { lblUID.Text = n.UID.ToString(); lblSubject.Text = n.Subject; lblDetail.Text = n.Detail; PicFull.ImageUrl = n.PicFull; lblSiteMap.Text = n.Subject; Page.MetaKeywords = n.MetaKeywords; Page.MetaDescription = n.MetaDescription; } } else { Response.Redirect("NewsViews.aspx"); } } else { Response.Redirect("NewsViews.aspx"); } }
/// <summary> /// ลบข้อมูล Session และ Cookie /// </summary> /// <param name="CookieDelete">true = ลบ Cookie ด้วย</param> /// <returns></returns> public bool LoginDelete(bool CookieDelete = true) { #region Variable var clsDefault = new clsDefault(); var result = false; #endregion #region Procedure try { if (System.Web.HttpContext.Current.Session[_sessionName] != null) { System.Web.HttpContext.Current.Session.Remove(_sessionName); } if (CookieDelete) { clsDefault.CookieDelete(_sessionName); } result = true; } catch (Exception) { result = false; } #endregion return(result); }
private void BindEvent() { clsDefault clsDefault = new clsDefault(); int UID = Convert.ToInt32(clsDefault.URLRouting("id")); //Convert.ToInt32(Request.QueryString["UID"]); if (!string.IsNullOrEmpty(UID.ToString())) { var tbEvent = from ev in db.Events where ev.UID == UID select ev; foreach (Event ev in tbEvent) { lblUID.Text = ev.UID.ToString(); lblSubject.Text = ev.Subject; lblDetail.Text = ev.Detail; PicFull.ImageUrl = ev.PicFull; lblSiteMap.Text = ev.Subject; Page.MetaKeywords = ev.MetaKeywords; Page.MetaDescription = ev.MetaDescription; } } else { Response.Redirect("EventView.aspx"); } }
private void BindPromotion() { clsDefault clsDefault = new clsDefault(); int UID = int.Parse(clsDefault.URLRouting("id")); if (!string.IsNullOrEmpty(UID.ToString())) { var tbPromotion = from p in db.Promotions where p.UID == UID select p; foreach (Promotion p in tbPromotion) { lblUID.Text = p.UID.ToString(); lblSubject.Text = p.PromotionName; lblDetail.Text = p.Detail.Replace("'Upload/", "'/Upload/"); PicFull.ImageUrl = p.PicFull; lblSiteMap.Text = p.PromotionName; Page.MetaKeywords = p.MetaKeywords; Page.MetaDescription = p.MetaDescription; } } else { Response.Redirect("PromotionView.aspx"); } }
/// <summary> /// ลบข้อมูล Session และ Cookie /// </summary> /// <param name="CookieDelete">true = ลบ Cookie ด้วย</param> /// <returns></returns> public bool LoginDelete(bool CookieDelete = true) { clsDefault clsDefault = new clsDefault(); bool rtnValue = false; try { if (System.Web.HttpContext.Current.Session[_sessionName] != null) { System.Web.HttpContext.Current.Session.Remove(_sessionName); } if (CookieDelete) { clsDefault.CookieDelete(_sessionName); } rtnValue = true; } catch (Exception ex) { rtnValue = false; } return(rtnValue); }
protected void Page_Load(object sender, EventArgs e) { //pathUpload = this.ResolveClientUrl(pathUpload); clsDefault clsDefault = new clsDefault(); pathUpload = clsDefault.ApplicationPath(pathUpload); }
protected void Page_Load(object sender, EventArgs e) { clsDefault clsDefault = new clsDefault(); if (!Page.IsPostBack) { BindContent(); } }
/// <summary> /// ใช้ตรวจสอบ Username Password และสร้าง Session Cookie /// </summary> /// <param name="Username">Login Username</param> /// <param name="Password">Login Password</param> /// <param name="CreateCookie">สร้าง Cookie ด้วยไหม</param> /// <returns>ผลการล็อคอิน</returns> /// <example> /// clsSecurity.LoginChecker("offduiclub","off1234",false); /// clsSecurity.LoginChecker("offduiclub","off1234"); /// </example> public bool LoginChecker(string Username, string Password, bool CreateCookie = false) { bool rtnValue = false; DataTable dt = new DataTable(); clsDefault clsDefault = new clsDefault(); clsSQL clsSQL = new clsSQL(); StringBuilder strSQL = new StringBuilder(); #region SQL Query strSQL.Append("SELECT "); strSQL.Append("[User].UID,"); strSQL.Append("[User].Username,"); strSQL.Append("UserGroup.Name AS UserGroupName,"); strSQL.Append("ISNULL(UserGroup.Authority,'') AS GroupAuthority,"); strSQL.Append("ISNULL([User].Authority,'') AS UserAuthority "); strSQL.Append("FROM "); strSQL.Append("[User] "); strSQL.Append("INNER JOIN UserGroup "); strSQL.Append("ON [User].UserGroupUID=UserGroup.UID AND UserGroup.Active='1' "); strSQL.Append("WHERE "); strSQL.Append("[User].Username="******"Username "); strSQL.Append("AND [User].Password="******"Password "); strSQL.Append("AND [User].Active='1'"); #endregion dt = clsSQL.Bind( strSQL.ToString(), new string[, ] { { "" + _parameterChar + "Username", Username }, { "" + _parameterChar + "Password", Encrypt(Password) } }, _dbType, _cs ); if (dt != null && dt.Rows.Count > 0) { rtnValue = true; SetLoginSession( _sessionName, new string[] { dt.Rows[0]["UID"].ToString(), dt.Rows[0]["Username"].ToString(), dt.Rows[0]["UserGroupName"].ToString(), dt.Rows[0]["GroupAuthority"].ToString(), dt.Rows[0]["UserAuthority"].ToString() } ); if (CreateCookie) { clsDefault.CookieCreate(_sessionName, Encrypt(dt.Rows[0]["UID"].ToString())); } } return(rtnValue); }
/// <summary> /// ใช้ตรวจสอบ Username Password และสร้าง Session Cookie /// </summary> /// <param name="Username">Login Username</param> /// <param name="Password">Login Password</param> /// <param name="CreateCookie">สร้าง Cookie ด้วยไหม</param> /// <returns>ผลการล็อคอิน</returns> /// <example> /// clsSecurity.LoginChecker("offduiclub","off1234",false); /// clsSecurity.LoginChecker("offduiclub","off1234"); /// </example> public bool LoginChecker(string Username, string Password, bool CreateCookie = false) { #region Variable var result = false; var dt = new DataTable(); var clsDefault = new clsDefault(); var clsSQL = new clsSQL(_dbType, _cs); var strSQL = new StringBuilder(); #endregion #region Procedure #region SQLQuery strSQL.Append("SELECT "); strSQL.Append("A.UID,"); strSQL.Append("A.Username,"); strSQL.Append("B.Name AS UserGroupName,"); strSQL.Append((_dbType == clsSQL.DBType.MySQL?"IFNULL":"ISNULL") + "(B.Authority,'') AS GroupAuthority,"); strSQL.Append((_dbType == clsSQL.DBType.MySQL?"IFNULL":"ISNULL") + "(A.Authority,'') AS UserAuthority "); strSQL.Append("FROM "); strSQL.Append("[User] A "); strSQL.Append("INNER JOIN UserGroup B "); strSQL.Append("ON A.UserGroupUID=B.UID AND B.StatusFlag='A' "); strSQL.Append("WHERE "); strSQL.Append("A.Username="******"Username "); strSQL.Append("AND A.Password="******"Password "); strSQL.Append("AND A.StatusFlag='A'"); #endregion dt = clsSQL.Bind( strSQL.ToString(), new string[, ] { { "" + _parameterChar + "Username", Username }, { "" + _parameterChar + "Password", Encrypt(Password) } } ); if (dt != null && dt.Rows.Count > 0) { result = true; SetLoginSession( _sessionName, new string[] { dt.Rows[0]["UID"].ToString(), dt.Rows[0]["Username"].ToString(), dt.Rows[0]["UserGroupName"].ToString(), dt.Rows[0]["GroupAuthority"].ToString(), dt.Rows[0]["UserAuthority"].ToString() } ); if (CreateCookie) { clsDefault.CookieCreate(_sessionName, Encrypt(dt.Rows[0]["UID"].ToString())); } } #endregion return(result); }
protected void Page_Load(object sender, EventArgs e) { #region Variable Assign if (Request.QueryString["MaxWidth"] != null) { if (Request.QueryString["MaxWidth"].ToString() != "") { maxWidth = int.Parse(Request.QueryString["MaxWidth"].ToString()); } } if (Request.QueryString["MaxHeight"] != null) { if (Request.QueryString["MaxHeight"].ToString() != "") { maxHeight = int.Parse(Request.QueryString["MaxHeight"].ToString()); } } if (Request.QueryString["MaxSize"] != null) { if (Request.QueryString["MaxSize"].ToString() != "") { maxSize = int.Parse(Request.QueryString["MaxSize"].ToString()); } } if (Request.QueryString["Watermark"] != null) { if (Request.QueryString["Watermark"].ToString() != "") { watermark = Request.QueryString["Watermark"].ToString(); } } if (Request.QueryString["PathUpload"] != null) { if (Request.QueryString["PathUpload"].ToString() != "") { pathUpload = Request.QueryString["PathUpload"].ToString(); } } if (Request.QueryString["PrefixName"] != null) { if (Request.QueryString["PrefixName"].ToString() != "") { prefixName = Request.QueryString["PrefixName"].ToString(); } } #endregion //pathUpload = this.ResolveClientUrl(pathUpload); clsDefault clsDefault = new clsDefault(); pathUpload = clsDefault.ApplicationPath(pathUpload); }
protected void Page_Load(object sender, EventArgs e) { BindNews(); BindContent(); clsDefault clsDefault = new clsDefault(); //Response.Write(clsDefault.URLRouting("id")); //Response.Write(clsDefault.URLRouting("name")); if (Security.LoginGroup == "Admin") { pnAdmin.Visible = true; //btEdit.Visible = true; btDelete.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { BindPromotion(); BindContent(); clsDefault clsDefault = new clsDefault(); if (Security.LoginGroup == "Admin") { pnAdminButton.Visible = true; //btAdmin.Visible = true; } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { BindArticle(); BindContent(); clsDefault clsDefault = new clsDefault(); if (Security.LoginGroup == "Admin") { pnAdmin.Visible = true; //btEdit.Visible = true; btDelete.Visible = true; } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { BindNews(); BindContent(); clsDefault clsDefault = new clsDefault(); Response.Write(clsDefault.URLRouting("id")); Response.Write(clsDefault.URLRouting("name")); if (Security.LoginGroup == "Admin") { pnAdminButton.Visible = true; //btAdmin.Visible = true; } } }
protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { BindNews(); BindContent(); clsDefault clsDefault = new clsDefault(); Response.Write(clsDefault.URLRouting("id")); Response.Write(clsDefault.URLRouting("name")); if (Security.LoginGroup == "Admin") { pnAdminButton.Visible = true; //btAdmin.Visible = true; } } }
protected void btLogin_Click(object sender, EventArgs e) { clsSQL clsSQL = new clsSQL(); clsDefault clsDefault = new clsDefault(); if (clsSecurity.LoginChecker( clsSQL.CodeFilter(txtUsername.Text), clsSQL.CodeFilter(txtPassword.Text), cbEnableCookie.Checked)) { //LoginChecker(); Response.Redirect(Request.RawUrl); } else { lblLogin.Text = clsDefault.AlertMessageColor("ไม่พบข้อมูลที่คุณกรอก", clsDefault.AlertType.Warn); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (_dataSource != null && _dataSource.Rows.Count > 0) { lblTitle.Text = _title; gvDefault.PageSize = _pageSize; gvDefault.DataSource = _dataSource; gvDefault.DataBind(); gvDefault.BottomPagerRow.Visible = true; } else { clsDefault clsDefault = new clsDefault(); lblMessage.Text = clsDefault.AlertMessageColor("ไม่พบข้อมูล", clsDefault.AlertType.Warn); pnGVHeader.Visible = false; } } }
private void BindArticle() { clsDefault clsDefault = new clsDefault(); int UID = Convert.ToInt32(clsDefault.URLRouting("id")); if (!string.IsNullOrEmpty(UID.ToString())) { try { var tbArticle = from a in db.Articles where a.UID == UID select a; foreach (Article a in tbArticle) { lblUID.Text = a.UID.ToString(); lblSubject.Text = a.Subject; lblDetail.Text = a.Detail; PicFull.ImageUrl = a.PicFull; lblSiteMap.Text = a.Subject; Page.MetaKeywords = a.MetaKeywords; Page.MetaDescription = a.MetaDescription; //Update View Article a.NumberView = a.NumberView + 1; NumberView.Text = a.NumberView.ToString() + " View"; NumberLike.Text = a.NumberLike.ToString(); NumberDisLike.Text = a.NumberDislike.ToString(); } db.SubmitChanges(); } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('" + ex.ToString() + "')", true); } } else { Response.Redirect("ArticleView.aspx"); } }
private void BindArticle() { clsDefault clsDefault = new clsDefault(); int UID = Convert.ToInt32(clsDefault.URLRouting("id")); if (!string.IsNullOrEmpty(UID.ToString())) { try { var tbArticle = from a in db.Articles where a.UID == UID select a; foreach (Article a in tbArticle) { lblUID.Text = a.UID.ToString(); lblSubject.Text = a.Subject; lblDetail.Text = a.Detail; PicFull.ImageUrl = a.PicFull; lblSiteMap.Text = a.Subject; Page.MetaKeywords = a.MetaKeywords; Page.MetaDescription = a.MetaDescription; //Update View Article a.NumberView = a.NumberView + 1; NumberView.Text = a.NumberView.ToString()+" View"; NumberLike.Text = a.NumberLike.ToString(); NumberDisLike.Text = a.NumberDislike.ToString(); } db.SubmitChanges(); } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('" + ex.ToString() + "')", true); } } else { Response.Redirect("ArticleView.aspx"); } }
protected void btDelete_Click(object sender, EventArgs e) { var clsDefault = new clsDefault(); try { var fi = new FileInfo(Server.MapPath(hidFileName.Value)); if (fi.Exists) { fi.Delete(); BindDetail(Request.QueryString["id"].ToString()); lblSQL.Text = clsDefault.AlertMessageFlat("ลบไฟล์เสร็จสมบูรณ์", clsDefault.AlertType.Success); } else { lblSQL.Text = clsDefault.AlertMessageFlat("ไม่พบไฟล์ : " + fi.FullName, clsDefault.AlertType.Fail); } } catch (Exception ex) { lblSQL.Text = clsDefault.AlertMessageFlat("เกิดข้อผิดพลาดขณะลบไฟล์ : " + ex.Message, clsDefault.AlertType.Fail); } }
protected void btDisLike_Click(object sender, ImageClickEventArgs e) { clsDefault clsDefault = new clsDefault(); int UID = Convert.ToInt32(clsDefault.URLRouting("id")); try { //var tbArticle = from a in db.Articles // where a.UID == UID // select a; //foreach (Article a in tbArticle) //{ // //Update Like Article // a.NumberDislike = a.NumberDislike + 1; // NumberDisLike.Text = a.NumberDislike.ToString(); //} //db.SubmitChanges(); } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(this.GetType(), "Information", "alert('" + ex.ToString() + "')", true); } }
/// <summary> /// ดึงค่า Session จาก Index ที่กำหนด /// </summary> /// <param name="SessionName">ชื่อ Session ที่ใช้เก็บการล็อคอิน</param> /// <param name="ArrayIndex">Index ของตัวแปรที่ต้องการ</param> /// <returns></returns> private string GetLoginSession(string SessionName, int ArrayIndex) { clsDefault clsDefault = new clsDefault(); clsSQL clsSQL = new clsSQL(); StringBuilder strSQL = new StringBuilder(); string rtnValue = ""; if (System.Web.HttpContext.Current.Session[SessionName] != null) { #region Find Session Login Value string[] arrLogin = System.Web.HttpContext.Current.Session[_sessionName].ToString().Split(_sessionSeparate, StringSplitOptions.None); if (ArrayIndex < arrLogin.Count()) { rtnValue = arrLogin[ArrayIndex]; } #endregion } else { #region No Session string strCookie; DataTable dt = new DataTable(); if (clsDefault.CookieChecker(_sessionName, out strCookie)) { strCookie = Decrypt(strCookie); #region SQL Query strSQL.Append("SELECT "); strSQL.Append("[User].UID,"); strSQL.Append("[User].Username,"); strSQL.Append("UserGroup.Name AS UserGroupName,"); strSQL.Append("ISNULL(UserGroup.Authority,'') AS GroupAuthority,"); strSQL.Append("ISNULL([User].Authority,'') AS UserAuthority "); strSQL.Append("FROM "); strSQL.Append("[User] "); strSQL.Append("INNER JOIN UserGroup "); strSQL.Append("ON [User].UserGroupUID=UserGroup.UID AND UserGroup.Active='1' "); strSQL.Append("WHERE "); strSQL.Append("[User].UID=" + _parameterChar + "UID "); strSQL.Append("AND [User].Active='1'"); #endregion dt = clsSQL.Bind( strSQL.ToString(), new string[,] { { "" + _parameterChar + "UID", strCookie } }, _dbType, _cs ); if (dt != null && dt.Rows.Count > 0) { SetLoginSession( _sessionName, new string[] { strCookie, dt.Rows[0]["Username"].ToString(), dt.Rows[0]["UserGroupName"].ToString(), dt.Rows[0]["GroupAuthority"].ToString(), dt.Rows[0]["UserAuthority"].ToString() } ); if (System.Web.HttpContext.Current.Session[_sessionName] != null) { #region Find Session Login Value string[] arrLogin = System.Web.HttpContext.Current.Session[_sessionName].ToString().Split(_sessionSeparate, StringSplitOptions.None); if (ArrayIndex < arrLogin.Count()) { rtnValue = arrLogin[ArrayIndex]; } #endregion } } else { LoginDelete(); } } #endregion } return rtnValue; }
/// <summary> /// ใช้ตรวจสอบสถานะสมาชิก จาก Session และ Cookie /// </summary> /// <param name="GroupName">ชื่อสถานะที่ต้องการตรวจสอบ</param> /// <param name="CreateSession">กรณีพบ Cookie ให้สร้าง Session ด้วยเลยไหม</param> /// <returns>true = พบข้อมูลการล็อคอิน , false = ไม่พบข้อมูลการล็อคอิน</returns> /// <example> /// clsSecurity.LoginChecker("admin"); /// clsSecurity.LoginChecker(); /// </example> public bool LoginChecker(string GroupName = "", bool CreateSession = true) { bool rtnValue = false; clsDefault clsDefault = new clsDefault(); clsSQL clsSQL = new clsSQL(); StringBuilder strSQL = new StringBuilder(); #region Session if (HttpContext.Current.Session[_sessionName] != null) { if (!string.IsNullOrEmpty(GroupName)) { if (GetLoginSession(_sessionName,_sessionGroup).ToLower() == GroupName.ToLower()) { rtnValue = true; } else { rtnValue = false; } } else { rtnValue = true; } } #endregion #region No Session Check Cookie else { string strCookie; DataTable dt = new DataTable(); if (clsDefault.CookieChecker(_sessionName, out strCookie)) { strCookie = Decrypt(strCookie); #region SQL Query strSQL.Append("SELECT "); strSQL.Append("[User].UID,"); strSQL.Append("[User].Username,"); strSQL.Append("UserGroup.Name AS UserGroupName,"); strSQL.Append("ISNULL(UserGroup.Authority,'') AS GroupAuthority,"); strSQL.Append("ISNULL([User].Authority,'') AS UserAuthority "); strSQL.Append("FROM "); strSQL.Append("[User] "); strSQL.Append("INNER JOIN UserGroup "); strSQL.Append("ON [User].UserGroupUID=UserGroup.UID AND UserGroup.Active='1' "); strSQL.Append("WHERE "); strSQL.Append("[User].UID=" + _parameterChar + "UID "); strSQL.Append("AND [User].Active='1'"); #endregion dt = clsSQL.Bind( strSQL.ToString(), new string[,] { { "" + _parameterChar + "UID", strCookie } }, _dbType, _cs ); if (dt != null && dt.Rows.Count > 0) { if (!string.IsNullOrEmpty(GroupName)) { if (dt.Rows[0]["UserGroupName"].ToString().ToLower() == GroupName.ToLower()) { if (CreateSession) { SetLoginSession( _sessionName, new string[] { strCookie, dt.Rows[0]["Username"].ToString(), dt.Rows[0]["UserGroupName"].ToString(), dt.Rows[0]["GroupAuthority"].ToString(), dt.Rows[0]["UserAuthority"].ToString() } ); } rtnValue = true; } } else { if (CreateSession) { SetLoginSession( _sessionName, new string[] { strCookie, dt.Rows[0]["Username"].ToString(), dt.Rows[0]["UserGroupName"].ToString(), dt.Rows[0]["GroupAuthority"].ToString(), dt.Rows[0]["UserAuthority"].ToString() } ); } rtnValue = true; } } else { LoginDelete(); } } } #endregion return rtnValue; }
/// <summary> /// ใช้ตรวจสอบ Username Password และสร้าง Session Cookie /// </summary> /// <param name="Username">Login Username</param> /// <param name="Password">Login Password</param> /// <param name="CreateCookie">สร้าง Cookie ด้วยไหม</param> /// <returns>ผลการล็อคอิน</returns> /// <example> /// clsSecurity.LoginChecker("offduiclub","off1234",false); /// clsSecurity.LoginChecker("offduiclub","off1234"); /// </example> public bool LoginChecker(string Username, string Password, bool CreateCookie = false) { bool rtnValue = false; DataTable dt = new DataTable(); clsDefault clsDefault = new clsDefault(); clsSQL clsSQL = new clsSQL(); StringBuilder strSQL=new StringBuilder(); #region SQL Query strSQL.Append("SELECT "); strSQL.Append("[User].UID,"); strSQL.Append("[User].Username,"); strSQL.Append("UserGroup.Name AS UserGroupName,"); strSQL.Append("ISNULL(UserGroup.Authority,'') AS GroupAuthority,"); strSQL.Append("ISNULL([User].Authority,'') AS UserAuthority "); strSQL.Append("FROM "); strSQL.Append("[User] "); strSQL.Append("INNER JOIN UserGroup "); strSQL.Append("ON [User].UserGroupUID=UserGroup.UID AND UserGroup.Active='1' "); strSQL.Append("WHERE "); strSQL.Append("[User].Username="******"Username "); strSQL.Append("AND [User].Password="******"Password "); strSQL.Append("AND [User].Active='1'"); #endregion dt = clsSQL.Bind( strSQL.ToString(), new string[,] { { "" + _parameterChar + "Username", Username }, { "" + _parameterChar + "Password", Encrypt(Password) } }, _dbType, _cs ); if (dt != null && dt.Rows.Count > 0) { rtnValue = true; SetLoginSession( _sessionName, new string[] { dt.Rows[0]["UID"].ToString(), dt.Rows[0]["Username"].ToString(), dt.Rows[0]["UserGroupName"].ToString(), dt.Rows[0]["GroupAuthority"].ToString(), dt.Rows[0]["UserAuthority"].ToString() } ); if (CreateCookie) { clsDefault.CookieCreate(_sessionName, Encrypt(dt.Rows[0]["UID"].ToString())); } } return rtnValue; }
/// <summary> /// ลบข้อมูล Session และ Cookie /// </summary> /// <param name="CookieDelete">true = ลบ Cookie ด้วย</param> /// <returns></returns> public bool LoginDelete(bool CookieDelete=true) { clsDefault clsDefault = new clsDefault(); bool rtnValue = false; try { if (System.Web.HttpContext.Current.Session[_sessionName] != null) { System.Web.HttpContext.Current.Session.Remove(_sessionName); } if (CookieDelete) { clsDefault.CookieDelete(_sessionName); } rtnValue = true; } catch (Exception ex) { rtnValue = false; } return rtnValue; }
/// <summary> /// ส่งเมล์จาก EmailTemplate โดยระบุค่าตัวแปรได้ /// </summary> /// <param name="TemplateName">ชื่อ Template</param> /// <param name="From">เมล์ต้นทาง</param> /// <param name="To">เมล์ปลายทาง</param> /// <param name="Parameter">ค่าที่ใช้แทนในเมล์ เช่น [Username],nithi.re</param> /// <param name="outMessage">ข้อความแจ้งเตือนเมื่อเกิดข้อผิดพลาด</param> /// <param name="FromAliasName">ชื่อเมล์ต้นทาง</param> /// <param name="Cc">เมล์แนบ</param> /// <param name="Bcc">เมล์ไม่เปิดเผย</param> /// <param name="Signature">ข้อความท้ายเมล์</param> /// <returns>true=ส่งผ่าน , false=ส่งไม่ผ่าน</returns> /// <example> /// clsMail clsMail=new clsMail(); /// string outMessage; /// clsMail.SendTemplate( /// "UserRegisterConfirm", /// "*****@*****.**", /// "*****@*****.**", /// new string[,] { { "[Username]", "ยูสเซอร์เนม" }, { "[UIDEncrypt]", "ยูไอดีเอ็นคริบ" } }, /// out outMessage); /// </example> public bool SendTemplate(string TemplateName, string From, string To, string[,] Parameter, out string outMessage, string FromAliasName = "", string Cc = "", string Bcc = "", string Signature = "") { #region Variable bool rtnValue = false; outMessage = ""; StringBuilder strSQL = new StringBuilder(); DataTable dt = new DataTable(); clsSQL clsSQL = new clsSQL(); clsLanguage clsLanguage = new clsLanguage(); clsData clsData = new clsData(); clsDefault clsDefault = new clsDefault(); #endregion #region Found Language #region SQL Query strSQL.Append("SELECT "); strSQL.Append("EmailTemplate.UID,Language.Name LanguageName,EmailTemplate.Subject,EmailTemplate.Message "); strSQL.Append("FROM "); strSQL.Append("EmailTemplate "); strSQL.Append("INNER JOIN Language ON EmailTemplate.LanguageUID=Language.UID "); strSQL.Append("AND Language.Active='1' "); //strSQL.Append("AND Language.Name='" + clsLanguage.LanguageCurrent + "' "); strSQL.Append("WHERE "); strSQL.Append("EmailTemplate.Active='1' "); strSQL.Append("AND EmailTemplate.Name='" + TemplateName + "' "); strSQL.Append("ORDER BY "); strSQL.Append("Language.Sort ASC"); #endregion dt = clsSQL.Bind(strSQL.ToString(), dbType, cs); strSQL.Length = 0; strSQL.Capacity = 0; #endregion if (dt != null && dt.Rows.Count > 0) { #region Find LanguageRow bool languageMatch = false; int i; for (i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["LanguageName"].ToString() == clsLanguage.LanguageCurrent) { languageMatch = true; break; } } if (!languageMatch) { i = 0; } #endregion #region Parameter Replace string subject = dt.Rows[i]["Subject"].ToString(); string message = dt.Rows[i]["Message"].ToString(); subject = clsData.Replacer(subject, Parameter); message = clsData.Replacer(message, Parameter); if (Send(From, To, subject, message, out outMessage, FromAliasName, Cc, Bcc, Signature)) { SendTemplateLog(dt.Rows[i]["UID"].ToString(), From, To, Cc, Bcc, "Complete"); rtnValue = true; } else { SendTemplateLog(dt.Rows[i]["UID"].ToString(), From, To, Cc, Bcc, clsDefault.Left(outMessage, 90)); rtnValue = false; } #endregion } else { outMessage = "ไม่พบข้อมูล EmailTemplate"; return(false); } return(rtnValue); }
private string CenterBuilder() { #region Variable clsDefault clsDefault = new clsDefault(); clsSQL clsSQL = new clsSQL(); clsLanguage clsLanguage = new clsLanguage(); StringBuilder strSQL = new StringBuilder(); StringBuilder strCenter = new StringBuilder(); DataTable dtGroup = new DataTable(); DataTable dt = new DataTable(); #endregion #region MedicalCenterGroup : SQL Query strSQL.Append("SELECT "); strSQL.Append("MedicalCenterGroup.UID,"); strSQL.Append("MedicalCenterGroup.Name "); strSQL.Append("FROM "); strSQL.Append("MedicalCenterGroup "); strSQL.Append("INNER JOIN Language ON MedicalCenterGroup.LanguageUID=Language.UID AND Language.Active='1' "); strSQL.Append("WHERE "); strSQL.Append("MedicalCenterGroup.Active='1' "); strSQL.Append("AND Language.Name='" + clsLanguage.LanguageCurrent + "' "); strSQL.Append("ORDER BY "); strSQL.Append("MedicalCenterGroup.Sort"); #endregion dtGroup = clsSQL.Bind(strSQL.ToString(), dbType, cs); strSQL.Length = 0; strSQL.Capacity = 0; strCenter.Append("<div style='padding:0 10px 0 10px;width:400px;'>"); if (dtGroup != null && dtGroup.Rows.Count > 0) { for (int i = 0; i < dtGroup.Rows.Count; i++) { strCenter.Append("<h4>" + dtGroup.Rows[i]["Name"].ToString() + "</h4>"); #region MedicalCenter #region MedicalCenter : SQL Query strSQL.Append("SELECT "); //strSQL.Append("UID,"); strSQL.Append("DepartmentUID UID,"); strSQL.Append("Name "); strSQL.Append("FROM "); strSQL.Append("MedicalCenter "); strSQL.Append("WHERE "); strSQL.Append("MedicalCenterGroupUID=" + dtGroup.Rows[i]["UID"].ToString() + " "); strSQL.Append("AND Active='1' "); #endregion dt = clsSQL.Bind(strSQL.ToString(), dbType, cs); strSQL.Length = 0; strSQL.Capacity = 0; if (dt != null && dt.Rows.Count > 0) { strCenter.Append("<table cellpadding='0' cellspacing='0'>"); for (int j = 0; j < dt.Rows.Count; j++) { if ((j + 1) % 2 != 0) { strCenter.Append("<tr>"); strCenter.Append("<td style='width:200px;'>"); strCenter.Append("<a href='/MedicalCenter/" + dt.Rows[j]["UID"].ToString() + "/" + clsDefault.URLRoutingFilter(dt.Rows[j]["Name"]) + "/'>"); strCenter.Append(dt.Rows[j]["Name"].ToString()); strCenter.Append("</a>"); strCenter.Append("</td>"); } else { strCenter.Append("<td style='width:200px;'>"); strCenter.Append("<a href='/MedicalCenter/" + dt.Rows[j]["UID"].ToString() + "/" + clsDefault.URLRoutingFilter(dt.Rows[j]["Name"]) + "/'>"); strCenter.Append(dt.Rows[j]["Name"].ToString()); strCenter.Append("</a>"); strCenter.Append("</td>"); strCenter.Append("</tr>"); } } if (dt.Rows.Count % 2 != 0) { strCenter.Append("<td style='width:200px;'>"); strCenter.Append("</td>"); strCenter.Append("</tr>"); } strCenter.Append("</table>"); dt = null; } else { strCenter.Append("<div style='text-align:center;'>-</div>"); } #endregion } } else { strCenter.Append("-"); } strCenter.Append("</div>"); /* * * * strCenter.Append("<tr>"); * strCenter.Append("<td style='width:200px;'>"); * strCenter.Append("<a href='/Center/" + dt.Rows[i]["MedicalCenterUID"].ToString() + "/" + dt.Rows[i]["MedicalCenterName"].ToString() + "/'>"); * strCenter.Append(dt.Rows[i]["MedicalCenterName"].ToString()); * strCenter.Append("</a>"); * strCenter.Append("</td>"); * strCenter.Append("<td style='width:200px;'>"); * strCenter.Append("<a href='/Center/" + dt.Rows[i]["MedicalCenterUID"].ToString() + "/" + dt.Rows[i]["MedicalCenterName"].ToString() + "/'>"); * strCenter.Append(dt.Rows[i]["MedicalCenterName"].ToString()); * strCenter.Append("</a>"); * strCenter.Append("</td>"); * strCenter.Append("</tr>"); * * */ return(strCenter.ToString()); }
/// <summary> /// ใช้ตรวจสอบสถานะสมาชิก จาก Session และ Cookie /// </summary> /// <param name="GroupName">ชื่อสถานะที่ต้องการตรวจสอบ</param> /// <param name="CreateSession">กรณีพบ Cookie ให้สร้าง Session ด้วยเลยไหม</param> /// <returns>true = พบข้อมูลการล็อคอิน , false = ไม่พบข้อมูลการล็อคอิน</returns> /// <example> /// clsSecurity.LoginChecker("admin"); /// clsSecurity.LoginChecker(); /// </example> public bool LoginChecker(string GroupName = "", bool CreateSession = true) { #region Variable var result = false; var clsDefault = new clsDefault(); var clsSQL = new clsSQL(_dbType, _cs); var strSQL = new StringBuilder(); var strCookie = ""; var dt = new DataTable(); #endregion #region Procedure #region Session if (HttpContext.Current.Session[_sessionName] != null) { if (!string.IsNullOrEmpty(GroupName)) { if (GetLoginSession(_sessionName, _sessionGroup).ToLower() == GroupName.ToLower()) { result = true; } else { result = false; } } else { result = true; } } #endregion #region No Session Check Cookie else { if (clsDefault.CookieChecker(_sessionName, out strCookie)) { strCookie = Decrypt(strCookie); #region SQLQuery strSQL.Append("SELECT "); strSQL.Append("A.UID,"); strSQL.Append("A.Username,"); strSQL.Append("B.Name AS UserGroupName,"); strSQL.Append((_dbType == clsSQL.DBType.MySQL?"IFNULL":"ISNULL") + "(B.Authority,'') AS GroupAuthority,"); strSQL.Append((_dbType == clsSQL.DBType.MySQL?"IFNULL":"ISNULL") + "(A.Authority,'') AS UserAuthority "); strSQL.Append("FROM "); strSQL.Append("[User] A "); strSQL.Append("INNER JOIN UserGroup B "); strSQL.Append("ON A.UserGroupUID=B.UID AND B.StatusFlag='A' "); strSQL.Append("WHERE "); strSQL.Append("A.UID=" + _parameterChar + "UID "); strSQL.Append("AND A.StatusFlag='A'"); #endregion dt = clsSQL.Bind( strSQL.ToString(), new string[, ] { { "" + _parameterChar + "UID", strCookie } } ); if (dt != null && dt.Rows.Count > 0) { #region FoundData if (!string.IsNullOrEmpty(GroupName)) { if (dt.Rows[0]["UserGroupName"].ToString().ToLower() == GroupName.ToLower()) { if (CreateSession) { SetLoginSession( _sessionName, new string[] { strCookie, dt.Rows[0]["Username"].ToString(), dt.Rows[0]["UserGroupName"].ToString(), dt.Rows[0]["GroupAuthority"].ToString(), dt.Rows[0]["UserAuthority"].ToString() } ); } result = true; } } else { if (CreateSession) { SetLoginSession( _sessionName, new string[] { strCookie, dt.Rows[0]["Username"].ToString(), dt.Rows[0]["UserGroupName"].ToString(), dt.Rows[0]["GroupAuthority"].ToString(), dt.Rows[0]["UserAuthority"].ToString() } ); } result = true; } #endregion } else { LoginDelete(); } } } #endregion #endregion return(result); }
private void MenuBuilder() { #region Variable clsSQL clsSQL = new clsSQL(); clsDefault clsDefault = new clsDefault(); ucMenuMega.Item item = new ucMenuMega.Item(); StringBuilder strSQL = new StringBuilder(); DataTable dt = new DataTable(); DataTable dtService = new DataTable(); #endregion item = new ucMenuMega.Item(); item.UID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "About Hospital"; break; case "km-KH": item.Name = "គេហទំព័រដើម"; break; default: item.Name = "รู้จักเรา"; break; } item.Detail = ""; item.URL = ""; ucMenuMega1.Items.Add(item); #region รู้จักเรา item = new ucMenuMega.Item(); item.UID = 11; item.ParentUID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Overview"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ទស្សនីយភាពរួមមន្ទីពេទ្យបាងកកចាន់បុរី"+"</span>"; break; default: item.Name = "โรงพยาบาลกรุงเทพจันทบุรี"; break; } item.Detail = ""; item.URL = "/AboutHospital"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 12; item.ParentUID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Hospital Facilities"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "គ្រឿងបរិក្ខាផេ្សងៗ"+"</span>"; break; default: item.Name = "สิ่งอำนวยความสะดวกในโรงพยาบาล"; break; } item.Detail = ""; item.URL = "/Facilities"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 13; item.ParentUID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Award & Accreditations"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "រង្វាន់ធានាគុណភាពសេវាកម្ម"+"</span>"; break; default: item.Name = "รางวัลและการประกันคุณภาพบริการ"; break; } item.Detail = ""; item.URL = "/Awards"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 14; item.ParentUID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Advanced Technologies"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "បច្ទេកវិទ្យាទំនើប"+"</span>"; break; default: item.Name = "เทคโนโลยีเพื่อการรักษาผู้ป่วย"; break; } item.Detail = ""; item.URL = "/AdvancedTechnologies"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 15; item.ParentUID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Hospital Network"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "បណ្តាញរបស់មន្ទីពេទ្យ"+"</span>"; break; default: item.Name = "กลุ่มโรงพยาบาลเครือข่าย"; break; } item.Detail = ""; item.URL = "/HospitalNetwork"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 16; item.ParentUID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Vision & Mission"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ទស្សនៈវិស័យរបស់" + "</span>"; break; default: item.Name = "วิสัยทัศน์ และ พันธกิจ"; break; } item.Detail = ""; item.URL = "/VisionMission"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 17; item.ParentUID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "About Chanthaburi"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "About Chanthaburi" + "</span>"; break; default: item.Name = "ข้อมูลทั่วไปของจังหวัดจันทบุรี"; break; } item.Detail = ""; item.URL = "/AboutChanthaburi"; ucMenuMega1.Items.Add(item); #endregion item = new ucMenuMega.Item(); item.UID = 2; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Healthcare Services"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "គ្លីនិក& មជ្ឈមណ្ឌលព្យាបាលជំងឺផ្សេងៗ"+"</span>"; break; default: item.Name = "บริการทางการแพทย์"; break; } item.Detail = ""; item.MegaData = CenterBuilder(); ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 3; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Patient Services"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "សេវាកម្មអ្នកជម្ងឺ"+"</span>"; break; default: item.Name = "บริการสำหรับผู้ป่วย"; break; } item.Detail = ""; ucMenuMega1.Items.Add(item); #region บริการสำหรับผู้ป่วย item = new ucMenuMega.Item(); item.UID = 31; item.ParentUID = 3; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Room & Facilities"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "បរិក្ខាប្រើប្រាស់ក្នុងបន្ទប់"+"</span>"; break; default: item.Name = "ห้องพักผู้ป่วยและสิ่งอำนวยความสะดวก"; break; } item.Detail = ""; item.URL = ""; ucMenuMega1.Items.Add(item); #region Service #region ServiceGroup #region SQL Query strSQL.Append("SELECT "); strSQL.Append("ServiceGroup.UID,ServiceGroup.Name "); strSQL.Append("FROM "); strSQL.Append("ServiceGroup "); strSQL.Append("INNER JOIN Language "); strSQL.Append("ON ServiceGroup.LanguageUID=Language.UID AND Language.Active='1' "); strSQL.Append("WHERE "); strSQL.Append("ServiceGroup.Active='1' "); strSQL.Append("AND Language.Name='" + ucLanguageDB1.LanguageCurrent + "' "); strSQL.Append("ORDER BY "); strSQL.Append("ServiceGroup.Sort ASC"); #endregion dt = clsSQL.Bind(strSQL.ToString(), dbType, cs); strSQL.Length = 0; strSQL.Capacity = 0; if (dt != null && dt.Rows.Count > 0) { for (int g = 0; g < dt.Rows.Count; g++) { item = new ucMenuMega.Item(); item.UID = int.Parse("31"+(g+1).ToString()); item.ParentUID = 31; item.Name = dt.Rows[g]["Name"].ToString(); item.Detail = ""; item.URL = ""; ucMenuMega1.Items.Add(item); #region Service #region SQL Query strSQL.Append("SELECT "); //strSQL.Append("UID,"); strSQL.Append("Service.DepartmentUID UID,"); strSQL.Append("Service.Name "); strSQL.Append("FROM "); strSQL.Append("Service "); strSQL.Append("INNER JOIN Language "); strSQL.Append("ON Service.LanguageUID=Language.UID AND Language.Active='1' "); strSQL.Append("WHERE "); strSQL.Append("Service.Active='1' "); strSQL.Append("AND Service.ServiceGroupUID='" + dt.Rows[g]["UID"].ToString() + "' "); strSQL.Append("AND Language.Name='" + ucLanguageDB1.LanguageCurrent + "' "); strSQL.Append("ORDER BY "); strSQL.Append("Service.Sort ASC"); #endregion dtService = clsSQL.Bind(strSQL.ToString(), dbType, cs); strSQL.Length = 0; strSQL.Capacity = 0; if (dtService != null && dtService.Rows.Count > 0) { for (int s = 0; s < dtService.Rows.Count; s++) { item = new ucMenuMega.Item(); item.UID = int.Parse("31" + (g + 1).ToString()+(s+1).ToString()); item.ParentUID = int.Parse("31" + (g + 1).ToString()); item.Name = dtService.Rows[s]["Name"].ToString(); item.Detail = ""; item.URL = "/Service/"+dtService.Rows[s]["UID"].ToString()+"/"+clsDefault.URLRoutingFilter(dtService.Rows[s]["Name"].ToString())+"/"; ucMenuMega1.Items.Add(item); } dtService = null; } #endregion } dt = null; } #endregion #endregion item = new ucMenuMega.Item(); item.UID = 33; item.ParentUID = 3; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Chivawattana Membership Card"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ចូលជាសមាជិកកម្មវិធីជីវះវឌ្ឍនះ"+"</span>"; break; default: item.Name = "สมาชิกบัตรชีววัฒนะ"; break; } item.Detail = ""; item.URL = "/Chivawattana/"; ucMenuMega1.Items.Add(item); /* item = new ucMenuMega.Item(); item.UID = 34; item.ParentUID = 3; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Checkup Result"; break; default: item.Name = "ผลตรวจสุขภาพ"; break; } item.Detail = ""; item.URL = "/CheckupCondition/"; ucMenuMega1.Items.Add(item); */ item = new ucMenuMega.Item(); item.UID = 35; item.ParentUID = 3; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Health Packages"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "កញ្ចប់ សុខភាព"+"</span>"; break; default: item.Name = "แพคเกจตรวจสุขภาพ"; break; } item.Detail = ""; item.URL = "/HealthPackage"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 36; item.ParentUID = 3; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Packages"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "កញ្ចប់ សុខភាព"+"</span>"; break; default: item.Name = "แพคเกจโรคทั่วไป"; break; } item.Detail = ""; item.URL = "/Package"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 37; item.ParentUID = 3; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Promotions"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ការផ្ដល់ជូនពិសេស"+"</span>"; break; default: item.Name = "โปรโมชั่น"; break; } item.Detail = ""; item.URL = "/Promotion"; ucMenuMega1.Items.Add(item); #endregion item = new ucMenuMega.Item(); item.UID = 4; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Find a Doctor"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ស្វែងរកគ្រូពេទ្យ & ធ្វើការណាត់"+"</span>"; break; default: item.Name = "ค้นหาและนัดหมายแพทย์"; break; } item.Detail = ""; item.URL = "/DoctorSchedule"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 5; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Hospital News"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ព័ត៍មាន"+"</span>"; break; default: item.Name = "ข่าวสารโรงพยาบาล"; break; } item.Detail = ""; ucMenuMega1.Items.Add(item); #region ข่าวสารโรงพยาบาล item = new ucMenuMega.Item(); item.UID = 51; item.ParentUID = 5; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Events"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ព្រឹត្តការណ៍"+"</span>"; break; default: item.Name = "กิจกรรม"; break; } item.Detail = ""; item.URL = "/Event"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 52; item.ParentUID = 5; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "News"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ព័ត៍មាន"+"</span>"; break; default: item.Name = "ข่าวประชาสัมพันธ์"; break; } item.Detail = ""; item.URL = "/News"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 53; item.ParentUID = 5; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Health Articles"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "សុខភាព មាត្រា"+"</span>"; break; default: item.Name = "บทความสุขภาพ"; break; } item.Detail = ""; item.URL = "/Article"; ucMenuMega1.Items.Add(item); #endregion item = new ucMenuMega.Item(); item.UID = 6; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Contact Us"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ទំនាក់ទំនងមន្ទីពេទ្យបាងកកចាន់បុរី"+"</span>"; break; default: item.Name = "ติดต่อเรา"; break; } item.Detail = ""; ucMenuMega1.Items.Add(item); #region ติดต่อเรา item = new ucMenuMega.Item(); item.UID = 61; item.ParentUID = 6; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Inquiry"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "សាកសួរពត៌មានលំអិត"+"</span>"; break; default: item.Name = "ฝากคำถามถึงโรงพยาบาล"; break; } item.Detail = ""; item.URL = "/Inquiry/"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 62; item.ParentUID = 6; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Feedback"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ផ្តល់មតិរិះគន់ដើម្បីកែប្រែ"+"</span>"; break; default: item.Name = "แนะนำ/ติชม ถึงผู้บริหาร"; break; } item.Detail = ""; item.URL = "/Feedback/"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 63; item.ParentUID = 6; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Webboard"; break; case "km-KH": item.Name = "Webboard"; break; default: item.Name = "เว็บบอร์ดตอบปัญหาสุขภาพ"; break; } item.Detail = ""; item.URL = "/Webboard/"; //ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 64; item.ParentUID = 6; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Maps & Directions"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ផែនទី"+"</span>"; break; default: item.Name = "แผนที่และการเดินทาง"; break; } item.Detail = ""; item.URL = "/Maps/"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 65; item.ParentUID = 6; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Jobs"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "រួមការងារជាមួយយើង"+"</span>"; break; default: item.Name = "ร่วมงานกับเรา"; break; } item.Detail = ""; item.URL = "/Jobs/"; ucMenuMega1.Items.Add(item); #endregion }
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 }
/// <summary> /// ดึงค่า Session จาก Index ที่กำหนด /// </summary> /// <param name="SessionName">ชื่อ Session ที่ใช้เก็บการล็อคอิน</param> /// <param name="ArrayIndex">Index ของตัวแปรที่ต้องการ</param> /// <returns></returns> private string GetLoginSession(string SessionName, int ArrayIndex) { clsDefault clsDefault = new clsDefault(); clsSQL clsSQL = new clsSQL(); StringBuilder strSQL = new StringBuilder(); string rtnValue = ""; if (System.Web.HttpContext.Current.Session[SessionName] != null) { #region Find Session Login Value string[] arrLogin = System.Web.HttpContext.Current.Session[_sessionName].ToString().Split(_sessionSeparate, StringSplitOptions.None); if (ArrayIndex < arrLogin.Count()) { rtnValue = arrLogin[ArrayIndex]; } #endregion } else { #region No Session string strCookie; DataTable dt = new DataTable(); if (clsDefault.CookieChecker(_sessionName, out strCookie)) { strCookie = Decrypt(strCookie); #region SQL Query strSQL.Append("SELECT "); strSQL.Append("[User].UID,"); strSQL.Append("[User].Username,"); strSQL.Append("UserGroup.Name AS UserGroupName,"); strSQL.Append("ISNULL(UserGroup.Authority,'') AS GroupAuthority,"); strSQL.Append("ISNULL([User].Authority,'') AS UserAuthority "); strSQL.Append("FROM "); strSQL.Append("[User] "); strSQL.Append("INNER JOIN UserGroup "); strSQL.Append("ON [User].UserGroupUID=UserGroup.UID AND UserGroup.Active='1' "); strSQL.Append("WHERE "); strSQL.Append("[User].UID=" + _parameterChar + "UID "); strSQL.Append("AND [User].Active='1'"); #endregion dt = clsSQL.Bind( strSQL.ToString(), new string[, ] { { "" + _parameterChar + "UID", strCookie } }, _dbType, _cs ); if (dt != null && dt.Rows.Count > 0) { SetLoginSession( _sessionName, new string[] { strCookie, dt.Rows[0]["Username"].ToString(), dt.Rows[0]["UserGroupName"].ToString(), dt.Rows[0]["GroupAuthority"].ToString(), dt.Rows[0]["UserAuthority"].ToString() } ); if (System.Web.HttpContext.Current.Session[_sessionName] != null) { #region Find Session Login Value string[] arrLogin = System.Web.HttpContext.Current.Session[_sessionName].ToString().Split(_sessionSeparate, StringSplitOptions.None); if (ArrayIndex < arrLogin.Count()) { rtnValue = arrLogin[ArrayIndex]; } #endregion } } else { LoginDelete(); } } #endregion } return(rtnValue); }
private void SliderBuilder() { #region Variable clsDefault clsDefault = new clsDefault(); clsSQL clsSQL = new clsSQL(); clsLanguage clsLanguage = new clsLanguage(); StringBuilder strSQL = new StringBuilder(); StringBuilder strSliderItem = new StringBuilder(); StringBuilder strOutput = new StringBuilder(); StringBuilder strScript = new StringBuilder(); DataTable dt = new DataTable(); bool foundChecker = false; string languageDefault = ""; #endregion #region SQL Query strSQL.Append("SELECT "); strSQL.Append("Language.Name LanguageName,"); strSQL.Append("Slider.Photo,"); strSQL.Append("Slider.Name "); strSQL.Append("FROM "); strSQL.Append("Slider "); strSQL.Append("INNER JOIN Language ON "); strSQL.Append("Slider.LanguageUID=Language.UID "); strSQL.Append("AND Language.Active='1' "); strSQL.Append("WHERE "); strSQL.Append("Slider.Active='1' "); strSQL.Append("ORDER BY "); strSQL.Append("Language.Sort ASC,Slider.Sort ASC"); #endregion dt = clsSQL.Bind(strSQL.ToString(), dbType, cs); if (dt != null && dt.Rows.Count > 0) { #region Find Language for (int i = 0; i < dt.Rows.Count; i++) { if (i == 0) languageDefault = dt.Rows[i]["LanguageName"].ToString(); if (dt.Rows[i]["LanguageName"].ToString() == clsLanguage.LanguageCurrent) { foundChecker = true; strSliderItem.Append("<li>"); strSliderItem.Append("<img src='" + dt.Rows[i]["Photo"].ToString() + "' "); strSliderItem.Append("alt='" + (dt.Rows[i]["Name"] != DBNull.Value ? dt.Rows[i]["Name"].ToString() : "") + "' "); strSliderItem.Append("title='" + (dt.Rows[i]["Name"] != DBNull.Value ? dt.Rows[i]["Name"].ToString() : "") + "'/>"); strSliderItem.Append("</li>"); } } #endregion #region Default Language if (!foundChecker) { for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["LanguageName"].ToString() == languageDefault) { strSliderItem.Append("<li>"); strSliderItem.Append("<img src='" + dt.Rows[i]["Photo"].ToString() + "' "); strSliderItem.Append("alt='" + (dt.Rows[i]["Name"] != DBNull.Value ? dt.Rows[i]["Name"].ToString() : "") + "' "); strSliderItem.Append("title='" + (dt.Rows[i]["Name"] != DBNull.Value ? dt.Rows[i]["Name"].ToString() : "") + "'/>"); strSliderItem.Append("</li>"); } } } #endregion #region div Builder strOutput.Append("<div id='Slider' style='display:block;width:" + _width + ";height:" + _height + ";overflow:hidden;'>"); strOutput.Append("<ul class='bjqs'>"); strOutput.Append(strSliderItem.ToString()); strOutput.Append("</ul>"); strOutput.Append("</div>"); #endregion } else { strOutput.Append(""); } lblSlider.Text = strOutput.ToString(); }
/// <summary> /// ใช้ตรวจสอบสถานะสมาชิก จาก Session และ Cookie /// </summary> /// <param name="GroupName">ชื่อสถานะที่ต้องการตรวจสอบ</param> /// <param name="CreateSession">กรณีพบ Cookie ให้สร้าง Session ด้วยเลยไหม</param> /// <returns>true = พบข้อมูลการล็อคอิน , false = ไม่พบข้อมูลการล็อคอิน</returns> /// <example> /// clsSecurity.LoginChecker("admin"); /// clsSecurity.LoginChecker(); /// </example> public bool LoginChecker(string GroupName = "", bool CreateSession = true) { bool rtnValue = false; clsDefault clsDefault = new clsDefault(); clsSQL clsSQL = new clsSQL(); StringBuilder strSQL = new StringBuilder(); #region Session if (HttpContext.Current.Session[_sessionName] != null) { if (!string.IsNullOrEmpty(GroupName)) { if (GetLoginSession(_sessionName, _sessionGroup).ToLower() == GroupName.ToLower()) { rtnValue = true; } else { rtnValue = false; } } else { rtnValue = true; } } #endregion #region No Session Check Cookie else { string strCookie; DataTable dt = new DataTable(); if (clsDefault.CookieChecker(_sessionName, out strCookie)) { strCookie = Decrypt(strCookie); #region SQL Query strSQL.Append("SELECT "); strSQL.Append("[User].UID,"); strSQL.Append("[User].Username,"); strSQL.Append("UserGroup.Name AS UserGroupName,"); strSQL.Append("ISNULL(UserGroup.Authority,'') AS GroupAuthority,"); strSQL.Append("ISNULL([User].Authority,'') AS UserAuthority "); strSQL.Append("FROM "); strSQL.Append("[User] "); strSQL.Append("INNER JOIN UserGroup "); strSQL.Append("ON [User].UserGroupUID=UserGroup.UID AND UserGroup.Active='1' "); strSQL.Append("WHERE "); strSQL.Append("[User].UID=" + _parameterChar + "UID "); strSQL.Append("AND [User].Active='1'"); #endregion dt = clsSQL.Bind( strSQL.ToString(), new string[, ] { { "" + _parameterChar + "UID", strCookie } }, _dbType, _cs ); if (dt != null && dt.Rows.Count > 0) { if (!string.IsNullOrEmpty(GroupName)) { if (dt.Rows[0]["UserGroupName"].ToString().ToLower() == GroupName.ToLower()) { if (CreateSession) { SetLoginSession( _sessionName, new string[] { strCookie, dt.Rows[0]["Username"].ToString(), dt.Rows[0]["UserGroupName"].ToString(), dt.Rows[0]["GroupAuthority"].ToString(), dt.Rows[0]["UserAuthority"].ToString() } ); } rtnValue = true; } } else { if (CreateSession) { SetLoginSession( _sessionName, new string[] { strCookie, dt.Rows[0]["Username"].ToString(), dt.Rows[0]["UserGroupName"].ToString(), dt.Rows[0]["GroupAuthority"].ToString(), dt.Rows[0]["UserAuthority"].ToString() } ); } rtnValue = true; } } else { LoginDelete(); } } } #endregion return(rtnValue); }
private void SliderBuilder() { #region Variable clsDefault clsDefault = new clsDefault(); clsSQL clsSQL = new clsSQL(); clsLanguage clsLanguage = new clsLanguage(); StringBuilder strSQL = new StringBuilder(); StringBuilder strSliderItem = new StringBuilder(); StringBuilder strOutput = new StringBuilder(); StringBuilder strScript = new StringBuilder(); DataTable dt = new DataTable(); bool foundChecker = false; string languageDefault = ""; #endregion #region SQL Query strSQL.Append("SELECT "); strSQL.Append("Language.Name LanguageName,"); strSQL.Append("Slider.Photo,"); strSQL.Append("Slider.Name "); strSQL.Append("FROM "); strSQL.Append("Slider "); strSQL.Append("INNER JOIN Language ON "); strSQL.Append("Slider.LanguageUID=Language.UID "); strSQL.Append("AND Language.Active='1' "); strSQL.Append("WHERE "); strSQL.Append("Slider.Active='1' "); strSQL.Append("ORDER BY "); strSQL.Append("Language.Sort ASC,Slider.Sort ASC"); #endregion dt = clsSQL.Bind(strSQL.ToString(), dbType, cs); if (dt != null && dt.Rows.Count > 0) { #region Find Language for (int i = 0; i < dt.Rows.Count; i++) { if (i == 0) { languageDefault = dt.Rows[i]["LanguageName"].ToString(); } if (dt.Rows[i]["LanguageName"].ToString() == clsLanguage.LanguageCurrent) { foundChecker = true; strSliderItem.Append("<li>"); strSliderItem.Append("<img src='" + dt.Rows[i]["Photo"].ToString() + "' "); strSliderItem.Append("alt='" + (dt.Rows[i]["Name"] != DBNull.Value ? dt.Rows[i]["Name"].ToString() : "") + "' "); strSliderItem.Append("title='" + (dt.Rows[i]["Name"] != DBNull.Value ? dt.Rows[i]["Name"].ToString() : "") + "'/>"); strSliderItem.Append("</li>"); } } #endregion #region Default Language if (!foundChecker) { for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["LanguageName"].ToString() == languageDefault) { strSliderItem.Append("<li>"); strSliderItem.Append("<img src='" + dt.Rows[i]["Photo"].ToString() + "' "); strSliderItem.Append("alt='" + (dt.Rows[i]["Name"] != DBNull.Value ? dt.Rows[i]["Name"].ToString() : "") + "' "); strSliderItem.Append("title='" + (dt.Rows[i]["Name"] != DBNull.Value ? dt.Rows[i]["Name"].ToString() : "") + "'/>"); strSliderItem.Append("</li>"); } } } #endregion #region div Builder strOutput.Append("<div id='Slider' style='display:block;width:" + _width + ";height:" + _height + ";overflow:hidden;'>"); strOutput.Append("<ul class='bjqs'>"); strOutput.Append(strSliderItem.ToString()); strOutput.Append("</ul>"); strOutput.Append("</div>"); #endregion } else { strOutput.Append(""); } lblSlider.Text = strOutput.ToString(); }
protected void Page_Load(object sender, EventArgs e) { clsDefault clsDefault = new clsDefault(); pathUpload = clsDefault.ApplicationPath(pathUpload); }
protected void btLogin_Click(object sender, EventArgs e) { clsSQL clsSQL = new clsSQL(); clsDefault clsDefault = new clsDefault(); if(clsSecurity.LoginChecker( clsSQL.CodeFilter(txtUsername.Text), clsSQL.CodeFilter(txtPassword.Text), cbEnableCookie.Checked)) { //LoginChecker(); Response.Redirect(Request.RawUrl); } else { lblLogin.Text = clsDefault.AlertMessageColor("ไม่พบข้อมูลที่คุณกรอก", clsDefault.AlertType.Warn); } }
private void MenuBuilder() { #region Variable clsSQL clsSQL = new clsSQL(); clsDefault clsDefault = new clsDefault(); ucMenuMega.Item item = new ucMenuMega.Item(); StringBuilder strSQL = new StringBuilder(); DataTable dt = new DataTable(); DataTable dtService = new DataTable(); #endregion item = new ucMenuMega.Item(); item.UID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "About Hospital"; break; case "km-KH": item.Name = "គេហទំព័រដើម"; break; default: item.Name = "รู้จักเรา"; break; } item.Detail = ""; item.URL = ""; ucMenuMega1.Items.Add(item); #region รู้จักเรา item = new ucMenuMega.Item(); item.UID = 11; item.ParentUID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Overview"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ទស្សនីយភាពរួមមន្ទីពេទ្យបាងកកចាន់បុរី" + "</span>"; break; default: item.Name = "โรงพยาบาลกรุงเทพจันทบุรี"; break; } item.Detail = ""; item.URL = "/AboutHospital"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 12; item.ParentUID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Hospital Facilities"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "គ្រឿងបរិក្ខាផេ្សងៗ" + "</span>"; break; default: item.Name = "สิ่งอำนวยความสะดวกในโรงพยาบาล"; break; } item.Detail = ""; item.URL = "/Facilities"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 13; item.ParentUID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Award & Accreditations"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "រង្វាន់ធានាគុណភាពសេវាកម្ម" + "</span>"; break; default: item.Name = "รางวัลและการประกันคุณภาพบริการ"; break; } item.Detail = ""; item.URL = "/Awards"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 14; item.ParentUID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Advanced Technologies"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "បច្ទេកវិទ្យាទំនើប" + "</span>"; break; default: item.Name = "เทคโนโลยีเพื่อการรักษาผู้ป่วย"; break; } item.Detail = ""; item.URL = "/AdvancedTechnologies"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 15; item.ParentUID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Hospital Network"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "បណ្តាញរបស់មន្ទីពេទ្យ" + "</span>"; break; default: item.Name = "กลุ่มโรงพยาบาลเครือข่าย"; break; } item.Detail = ""; item.URL = "/HospitalNetwork"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 16; item.ParentUID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Vision & Mission"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ទស្សនៈវិស័យរបស់" + "</span>"; break; default: item.Name = "วิสัยทัศน์ และ พันธกิจ"; break; } item.Detail = ""; item.URL = "/VisionMission"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 17; item.ParentUID = 1; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "About Chanthaburi"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "About Chanthaburi" + "</span>"; break; default: item.Name = "ข้อมูลทั่วไปของจังหวัดจันทบุรี"; break; } item.Detail = ""; item.URL = "/AboutChanthaburi"; ucMenuMega1.Items.Add(item); #endregion item = new ucMenuMega.Item(); item.UID = 2; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Healthcare Services"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "គ្លីនិក& មជ្ឈមណ្ឌលព្យាបាលជំងឺផ្សេងៗ" + "</span>"; break; default: item.Name = "บริการทางการแพทย์"; break; } item.Detail = ""; item.MegaData = CenterBuilder(); ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 3; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Patient Services"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "សេវាកម្មអ្នកជម្ងឺ" + "</span>"; break; default: item.Name = "บริการสำหรับผู้ป่วย"; break; } item.Detail = ""; ucMenuMega1.Items.Add(item); #region บริการสำหรับผู้ป่วย item = new ucMenuMega.Item(); item.UID = 31; item.ParentUID = 3; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Room & Facilities"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "បរិក្ខាប្រើប្រាស់ក្នុងបន្ទប់" + "</span>"; break; default: item.Name = "ห้องพักผู้ป่วยและสิ่งอำนวยความสะดวก"; break; } item.Detail = ""; item.URL = ""; ucMenuMega1.Items.Add(item); #region Service #region ServiceGroup #region SQL Query strSQL.Append("SELECT "); strSQL.Append("ServiceGroup.UID,ServiceGroup.Name "); strSQL.Append("FROM "); strSQL.Append("ServiceGroup "); strSQL.Append("INNER JOIN Language "); strSQL.Append("ON ServiceGroup.LanguageUID=Language.UID AND Language.Active='1' "); strSQL.Append("WHERE "); strSQL.Append("ServiceGroup.Active='1' "); strSQL.Append("AND Language.Name='" + ucLanguageDB1.LanguageCurrent + "' "); strSQL.Append("ORDER BY "); strSQL.Append("ServiceGroup.Sort ASC"); #endregion dt = clsSQL.Bind(strSQL.ToString(), dbType, cs); strSQL.Length = 0; strSQL.Capacity = 0; if (dt != null && dt.Rows.Count > 0) { for (int g = 0; g < dt.Rows.Count; g++) { item = new ucMenuMega.Item(); item.UID = int.Parse("31" + (g + 1).ToString()); item.ParentUID = 31; item.Name = dt.Rows[g]["Name"].ToString(); item.Detail = ""; item.URL = ""; ucMenuMega1.Items.Add(item); #region Service #region SQL Query strSQL.Append("SELECT "); //strSQL.Append("UID,"); strSQL.Append("Service.DepartmentUID UID,"); strSQL.Append("Service.Name "); strSQL.Append("FROM "); strSQL.Append("Service "); strSQL.Append("INNER JOIN Language "); strSQL.Append("ON Service.LanguageUID=Language.UID AND Language.Active='1' "); strSQL.Append("WHERE "); strSQL.Append("Service.Active='1' "); strSQL.Append("AND Service.ServiceGroupUID='" + dt.Rows[g]["UID"].ToString() + "' "); strSQL.Append("AND Language.Name='" + ucLanguageDB1.LanguageCurrent + "' "); strSQL.Append("ORDER BY "); strSQL.Append("Service.Sort ASC"); #endregion dtService = clsSQL.Bind(strSQL.ToString(), dbType, cs); strSQL.Length = 0; strSQL.Capacity = 0; if (dtService != null && dtService.Rows.Count > 0) { for (int s = 0; s < dtService.Rows.Count; s++) { item = new ucMenuMega.Item(); item.UID = int.Parse("31" + (g + 1).ToString() + (s + 1).ToString()); item.ParentUID = int.Parse("31" + (g + 1).ToString()); item.Name = dtService.Rows[s]["Name"].ToString(); item.Detail = ""; item.URL = "/Service/" + dtService.Rows[s]["UID"].ToString() + "/" + clsDefault.URLRoutingFilter(dtService.Rows[s]["Name"].ToString()) + "/"; ucMenuMega1.Items.Add(item); } dtService = null; } #endregion } dt = null; } #endregion #endregion item = new ucMenuMega.Item(); item.UID = 33; item.ParentUID = 3; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Chivawattana Membership Card"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ចូលជាសមាជិកកម្មវិធីជីវះវឌ្ឍនះ" + "</span>"; break; default: item.Name = "สมาชิกบัตรชีววัฒนะ"; break; } item.Detail = ""; item.URL = "/Chivawattana/"; ucMenuMega1.Items.Add(item); /* * item = new ucMenuMega.Item(); * item.UID = 34; * item.ParentUID = 3; * switch (ucLanguageDB1.LanguageCurrent) * { * case "en-US": * item.Name = "Checkup Result"; * break; * default: * item.Name = "ผลตรวจสุขภาพ"; * break; * } * item.Detail = ""; * item.URL = "/CheckupCondition/"; * ucMenuMega1.Items.Add(item); */ item = new ucMenuMega.Item(); item.UID = 35; item.ParentUID = 3; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Health Packages"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "កញ្ចប់ សុខភាព" + "</span>"; break; default: item.Name = "แพคเกจตรวจสุขภาพ"; break; } item.Detail = ""; item.URL = "/HealthPackage"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 36; item.ParentUID = 3; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Packages"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "កញ្ចប់ សុខភាព" + "</span>"; break; default: item.Name = "แพคเกจโรคทั่วไป"; break; } item.Detail = ""; item.URL = "/Package"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 37; item.ParentUID = 3; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Promotions"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ការផ្ដល់ជូនពិសេស" + "</span>"; break; default: item.Name = "โปรโมชั่น"; break; } item.Detail = ""; item.URL = "/Promotion"; ucMenuMega1.Items.Add(item); #endregion item = new ucMenuMega.Item(); item.UID = 4; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Find a Doctor"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ស្វែងរកគ្រូពេទ្យ & ធ្វើការណាត់" + "</span>"; break; default: item.Name = "ค้นหาและนัดหมายแพทย์"; break; } item.Detail = ""; item.URL = "/DoctorSchedule"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 5; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Hospital News"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ព័ត៍មាន" + "</span>"; break; default: item.Name = "ข่าวสารโรงพยาบาล"; break; } item.Detail = ""; ucMenuMega1.Items.Add(item); #region ข่าวสารโรงพยาบาล item = new ucMenuMega.Item(); item.UID = 51; item.ParentUID = 5; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Events"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ព្រឹត្តការណ៍" + "</span>"; break; default: item.Name = "กิจกรรม"; break; } item.Detail = ""; item.URL = "/Event"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 52; item.ParentUID = 5; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "News"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ព័ត៍មាន" + "</span>"; break; default: item.Name = "ข่าวประชาสัมพันธ์"; break; } item.Detail = ""; item.URL = "/News"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 53; item.ParentUID = 5; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Health Articles"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "សុខភាព មាត្រា" + "</span>"; break; default: item.Name = "บทความสุขภาพ"; break; } item.Detail = ""; item.URL = "/Article"; ucMenuMega1.Items.Add(item); #endregion item = new ucMenuMega.Item(); item.UID = 6; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Contact Us"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ទំនាក់ទំនងមន្ទីពេទ្យបាងកកចាន់បុរី" + "</span>"; break; default: item.Name = "ติดต่อเรา"; break; } item.Detail = ""; ucMenuMega1.Items.Add(item); #region ติดต่อเรา item = new ucMenuMega.Item(); item.UID = 61; item.ParentUID = 6; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Inquiry"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "សាកសួរពត៌មានលំអិត" + "</span>"; break; default: item.Name = "ฝากคำถามถึงโรงพยาบาล"; break; } item.Detail = ""; item.URL = "/Inquiry/"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 62; item.ParentUID = 6; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Feedback"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ផ្តល់មតិរិះគន់ដើម្បីកែប្រែ" + "</span>"; break; default: item.Name = "แนะนำ/ติชม ถึงผู้บริหาร"; break; } item.Detail = ""; item.URL = "/Feedback/"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 63; item.ParentUID = 6; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Webboard"; break; case "km-KH": item.Name = "Webboard"; break; default: item.Name = "เว็บบอร์ดตอบปัญหาสุขภาพ"; break; } item.Detail = ""; item.URL = "/Webboard/"; //ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 64; item.ParentUID = 6; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Maps & Directions"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "ផែនទី" + "</span>"; break; default: item.Name = "แผนที่และการเดินทาง"; break; } item.Detail = ""; item.URL = "/Maps/"; ucMenuMega1.Items.Add(item); item = new ucMenuMega.Item(); item.UID = 65; item.ParentUID = 6; switch (ucLanguageDB1.LanguageCurrent) { case "en-US": item.Name = "Jobs"; break; case "km-KH": item.Name = "<span style='font-size:7.5pt;'>" + "រួមការងារជាមួយយើង" + "</span>"; break; default: item.Name = "ร่วมงานกับเรา"; break; } item.Detail = ""; item.URL = "/Jobs/"; ucMenuMega1.Items.Add(item); #endregion }
private string CenterBuilder() { #region Variable clsDefault clsDefault = new clsDefault(); clsSQL clsSQL = new clsSQL(); clsLanguage clsLanguage = new clsLanguage(); StringBuilder strSQL = new StringBuilder(); StringBuilder strCenter = new StringBuilder(); DataTable dtGroup = new DataTable(); DataTable dt = new DataTable(); #endregion #region MedicalCenterGroup : SQL Query strSQL.Append("SELECT "); strSQL.Append("MedicalCenterGroup.UID,"); strSQL.Append("MedicalCenterGroup.Name "); strSQL.Append("FROM "); strSQL.Append("MedicalCenterGroup "); strSQL.Append("INNER JOIN Language ON MedicalCenterGroup.LanguageUID=Language.UID AND Language.Active='1' "); strSQL.Append("WHERE "); strSQL.Append("MedicalCenterGroup.Active='1' "); strSQL.Append("AND Language.Name='" + clsLanguage.LanguageCurrent + "' "); strSQL.Append("ORDER BY "); strSQL.Append("MedicalCenterGroup.Sort"); #endregion dtGroup = clsSQL.Bind(strSQL.ToString(), dbType, cs); strSQL.Length = 0; strSQL.Capacity = 0; strCenter.Append("<div style='padding:0 10px 0 10px;width:400px;'>"); if (dtGroup != null && dtGroup.Rows.Count > 0) { for (int i = 0; i < dtGroup.Rows.Count; i++) { strCenter.Append("<h4>" + dtGroup.Rows[i]["Name"].ToString() + "</h4>"); #region MedicalCenter #region MedicalCenter : SQL Query strSQL.Append("SELECT "); //strSQL.Append("UID,"); strSQL.Append("DepartmentUID UID,"); strSQL.Append("Name "); strSQL.Append("FROM "); strSQL.Append("MedicalCenter "); strSQL.Append("WHERE "); strSQL.Append("MedicalCenterGroupUID=" + dtGroup.Rows[i]["UID"].ToString() + " "); strSQL.Append("AND Active='1' "); #endregion dt = clsSQL.Bind(strSQL.ToString(), dbType, cs); strSQL.Length = 0; strSQL.Capacity = 0; if (dt != null && dt.Rows.Count > 0) { strCenter.Append("<table cellpadding='0' cellspacing='0'>"); for (int j = 0; j < dt.Rows.Count; j++) { if ((j+1) % 2 != 0) { strCenter.Append("<tr>"); strCenter.Append("<td style='width:200px;'>"); strCenter.Append("<a href='/MedicalCenter/" + dt.Rows[j]["UID"].ToString() + "/" + clsDefault.URLRoutingFilter(dt.Rows[j]["Name"]) + "/'>"); strCenter.Append(dt.Rows[j]["Name"].ToString()); strCenter.Append("</a>"); strCenter.Append("</td>"); } else { strCenter.Append("<td style='width:200px;'>"); strCenter.Append("<a href='/MedicalCenter/" + dt.Rows[j]["UID"].ToString() + "/" + clsDefault.URLRoutingFilter(dt.Rows[j]["Name"]) + "/'>"); strCenter.Append(dt.Rows[j]["Name"].ToString()); strCenter.Append("</a>"); strCenter.Append("</td>"); strCenter.Append("</tr>"); } } if (dt.Rows.Count % 2 != 0) { strCenter.Append("<td style='width:200px;'>"); strCenter.Append("</td>"); strCenter.Append("</tr>"); } strCenter.Append("</table>"); dt = null; } else { strCenter.Append("<div style='text-align:center;'>-</div>"); } #endregion } } else { strCenter.Append("-"); } strCenter.Append("</div>"); /* strCenter.Append("<tr>"); strCenter.Append("<td style='width:200px;'>"); strCenter.Append("<a href='/Center/" + dt.Rows[i]["MedicalCenterUID"].ToString() + "/" + dt.Rows[i]["MedicalCenterName"].ToString() + "/'>"); strCenter.Append(dt.Rows[i]["MedicalCenterName"].ToString()); strCenter.Append("</a>"); strCenter.Append("</td>"); strCenter.Append("<td style='width:200px;'>"); strCenter.Append("<a href='/Center/" + dt.Rows[i]["MedicalCenterUID"].ToString() + "/" + dt.Rows[i]["MedicalCenterName"].ToString() + "/'>"); strCenter.Append(dt.Rows[i]["MedicalCenterName"].ToString()); strCenter.Append("</a>"); strCenter.Append("</td>"); strCenter.Append("</tr>"); */ return strCenter.ToString(); }
/// <summary> /// ส่งเมล์จาก EmailTemplate โดยระบุค่าตัวแปรได้ /// </summary> /// <param name="TemplateName">ชื่อ Template</param> /// <param name="From">เมล์ต้นทาง</param> /// <param name="To">เมล์ปลายทาง</param> /// <param name="Parameter">ค่าที่ใช้แทนในเมล์ เช่น [Username],nithi.re</param> /// <param name="outMessage">ข้อความแจ้งเตือนเมื่อเกิดข้อผิดพลาด</param> /// <param name="FromAliasName">ชื่อเมล์ต้นทาง</param> /// <param name="Cc">เมล์แนบ</param> /// <param name="Bcc">เมล์ไม่เปิดเผย</param> /// <param name="Signature">ข้อความท้ายเมล์</param> /// <returns>true=ส่งผ่าน , false=ส่งไม่ผ่าน</returns> /// <example> /// clsMail clsMail=new clsMail(); /// string outMessage; /// clsMail.SendTemplate( /// "UserRegisterConfirm", /// "*****@*****.**", /// "*****@*****.**", /// new string[,] { { "[Username]", "ยูสเซอร์เนม" }, { "[UIDEncrypt]", "ยูไอดีเอ็นคริบ" } }, /// out outMessage); /// </example> public bool SendTemplate(string TemplateName, string From, string To, string[,] Parameter, out string outMessage, string FromAliasName = "", string Cc = "", string Bcc = "", string Signature = "") { #region Variable bool rtnValue = false; outMessage = ""; StringBuilder strSQL = new StringBuilder(); DataTable dt = new DataTable(); clsSQL clsSQL = new clsSQL(); clsLanguage clsLanguage = new clsLanguage(); clsData clsData=new clsData(); clsDefault clsDefault = new clsDefault(); #endregion #region Found Language #region SQL Query strSQL.Append("SELECT "); strSQL.Append("EmailTemplate.UID,Language.Name LanguageName,EmailTemplate.Subject,EmailTemplate.Message "); strSQL.Append("FROM "); strSQL.Append("EmailTemplate "); strSQL.Append("INNER JOIN Language ON EmailTemplate.LanguageUID=Language.UID "); strSQL.Append("AND Language.Active='1' "); //strSQL.Append("AND Language.Name='" + clsLanguage.LanguageCurrent + "' "); strSQL.Append("WHERE "); strSQL.Append("EmailTemplate.Active='1' "); strSQL.Append("AND EmailTemplate.Name='" + TemplateName + "' "); strSQL.Append("ORDER BY "); strSQL.Append("Language.Sort ASC"); #endregion dt = clsSQL.Bind(strSQL.ToString(), dbType, cs); strSQL.Length = 0; strSQL.Capacity = 0; #endregion if (dt != null && dt.Rows.Count > 0) { #region Find LanguageRow bool languageMatch = false; int i; for (i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["LanguageName"].ToString() == clsLanguage.LanguageCurrent) { languageMatch = true; break; } } if (!languageMatch) i = 0; #endregion #region Parameter Replace string subject = dt.Rows[i]["Subject"].ToString(); string message = dt.Rows[i]["Message"].ToString(); subject = clsData.Replacer(subject, Parameter); message = clsData.Replacer(message, Parameter); if (Send(From, To, subject, message, out outMessage, FromAliasName, Cc, Bcc, Signature)) { SendTemplateLog(dt.Rows[i]["UID"].ToString(), From, To, Cc, Bcc, "Complete"); rtnValue = true; } else { SendTemplateLog(dt.Rows[i]["UID"].ToString(), From, To, Cc, Bcc, clsDefault.Left(outMessage,90)); rtnValue = false; } #endregion } else { outMessage = "ไม่พบข้อมูล EmailTemplate"; return false; } return rtnValue; }