Example #1
0
 private void Delete(string id)
 {
     pnDetail.Visible = false;
     #region Authorize
     if (!clsSecurity.LoginChecker("admin"))
     {
         ucColorBox1.Redirect("/", "กรุณาล็อคอินด้วยสิทธิ์ Admin");
         return;
     }
     #endregion
     #region Variable
     var clsIO  = new clsIO();
     var strSQL = new StringBuilder();
     #endregion
     #region Procedure
     #region Delete Photo
     #region SQL Query
     strSQL.Append("SELECT ");
     strSQL.Append("Photo ");
     strSQL.Append("FROM ");
     strSQL.Append(tableDefault + " ");
     strSQL.Append("WHERE ");
     strSQL.Append("UID=" + id + ";");
     #endregion
     string photoDelete = clsSQL.Return(strSQL.ToString());
     if (!string.IsNullOrEmpty(photoDelete))
     {
         clsIO.FileExist(photoDelete, true);
     }
     strSQL.Length = 0; strSQL.Capacity = 0;
     #endregion
     #region Delete Database
     #region SQL Query
     strSQL.Append("DELETE FROM ");
     strSQL.Append(tableDefault + " ");
     strSQL.Append("WHERE ");
     strSQL.Append("UID=" + id + ";");
     #endregion
     if (clsSQL.Execute(strSQL.ToString()))
     {
         ucColorBox1.Redirect(webDefault + clsDefault.QueryStringRemover(new string[] { "id", "command" }));
     }
     else
     {
         ucColorBox1.Redirect(webDefault, "เกิดข้อผิดพลาดขณะลบข้อมูล");
         return;
     }
     strSQL.Length = 0; strSQL.Capacity = 0;
     #endregion
     #endregion
 }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["globalname"] != null && Request.QueryString["globalid"] != null)
         {
             BindDefault();
         }
         else
         {
             ucColorBox1.Redirect(
                 (Request.QueryString["globalpage"] != null ?
                  Request.QueryString["globalpage"] + clsDefault.QueryStringRemover(new string[] { "globalid", "globalname", "globalpage" }) :
                  "/"),
                 "ไม่พบข้อมูลที่คุณต้องการ");
         }
     }
 }