Esempio n. 1
0
 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
 }
Esempio n. 2
0
    protected void btDGSubmit_Click(object sender, EventArgs e)
    {
        #region Authorize
        if (!clsSecurity.LoginChecker("admin"))
        {
            ucColorBox1.Redirect("/", "เกิดข้อผิดพลาด", "คุณไม่ได้รับสิทธิ์ในการบันทึกข้อมูล กรุณาล็อคอินด้วยสิทธิ์ Admin");
            return;
        }
        #endregion
        #region Variable
        StringBuilder strSQL = new StringBuilder();
        #endregion
        #region SQL Builder
        for (int i = 0; i < gvDefault.Rows.Count; i++)
        {
            Label    lblDGID          = (Label)gvDefault.Rows[i].FindControl("lblDGID");
            TextBox  txtDGWord        = (TextBox)gvDefault.Rows[i].FindControl("txtDGWord");
            TextBox  txtDGWordReplace = (TextBox)gvDefault.Rows[i].FindControl("txtDGWordReplace");
            CheckBox cbDGActive       = (CheckBox)gvDefault.Rows[i].FindControl("cbDGActive");
            TextBox  txtDGSort        = (TextBox)gvDefault.Rows[i].FindControl("txtDGSort");

            if (lblDGID != null && cbDGActive != null)
            {
                #region SQL Query
                strSQL.Append("UPDATE ");
                strSQL.Append(tableDefault + " ");
                strSQL.Append("SET ");
                strSQL.Append("Word='" + clsSQL.CodeFilter(txtDGWord.Text) + "',");
                strSQL.Append("WordReplace='" + clsSQL.CodeFilter(txtDGWordReplace.Text) + "',");
                strSQL.Append("Sort=" + clsSQL.CodeFilter(txtDGSort.Text) + ",");
                strSQL.Append("Active='" + (cbDGActive.Checked ? "1" : "0") + "' ");
                strSQL.Append("WHERE ");
                strSQL.Append("UID=" + lblDGID.Text);
                strSQL.Append(";");
                #endregion
            }
        }
        #endregion

        if (clsSQL.Execute(strSQL.ToString(), dbType, cs))
        {
            ucColorBox1.Redirect(webDefault, "ดำเนินการเสร็จสิ้น", "แก้ไขข้อมูลเสร็จเรียบร้อย");
        }
        else
        {
            ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะบันทึกข้อมูลลงฐานข้อมูล<br/>" + strSQL.ToString(), AlertImage: ucColorBox.Alerts.Fail);
        }
    }
    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);
        }
    }
Esempio n. 4
0
    /// <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);
    }
Esempio n. 5
0
    protected void btDGSubmit_Click(object sender, EventArgs e)
    {
        #region AdminChecker
        if (!clsSecurity.LoginChecker("admin"))
        {
            ucColorBox1.Redirect("/", "เกิดข้อผิดพลาด", "คุณไม่ได้รับสิทธิ์ในการบันทึกข้อมูล กรุณาล็อคอินด้วยสิทธิ์ Admin");
            return;
        }
        #endregion
        #region Variable
        var strSQL = new StringBuilder();
        #endregion
        #region Procedure
        for (int i = 0; i < gvDefault.Rows.Count; i++)
        {
            #region CurrentPageChecker
            var cbDGCurrentPage = (CheckBox)gvDefault.Rows[i].FindControl("cbDGCurrentPage");
            if (!cbDGCurrentPage.Checked)
            {
                continue;
            }
            #endregion
            Label    lblDGID    = (Label)gvDefault.Rows[i].FindControl("lblDGID");
            CheckBox cbDGActive = (CheckBox)gvDefault.Rows[i].FindControl("cbDGActive");
            TextBox  txtDGSort  = (TextBox)gvDefault.Rows[i].FindControl("txtDGSort");
            if (lblDGID != null && cbDGActive != null)
            {
                #region SQL Query
                strSQL.Append("UPDATE ");
                strSQL.Append(tableDefault + " ");
                strSQL.Append("SET ");
                strSQL.Append("Sort=" + clsSQL.CodeFilter(txtDGSort.Text) + ",");
                strSQL.Append("StatusFlag='" + (cbDGActive.Checked ? "A" : "I") + "' ");
                strSQL.Append("WHERE ");
                strSQL.Append("UID=" + lblDGID.Text);
                strSQL.Append(";");
                #endregion
            }
        }

        if (clsSQL.Execute(strSQL.ToString()))
        {
            ucColorBox1.Redirect("/Management/" + webDefault, "ดำเนินการเสร็จสิ้น", "แก้ไขข้อมูลเสร็จเรียบร้อย");
        }
        else
        {
            ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะบันทึกข้อมูลลงฐานข้อมูล<br/>" + strSQL.ToString(), AlertImage: ucColorBox.Alerts.Fail);
        }
        #endregion
    }
Esempio n. 6
0
    protected void btSubmit_Click(object sender, EventArgs e)
    {
        #region Authorize
        if (!clsSecurity.LoginChecker("admin"))
        {
            ucColorBox1.Redirect("/", "กรุณาล็อคอินด้วยสิทธิ์ Admin");
            return;
        }
        #endregion

        StringBuilder strSQL = new StringBuilder();
        int           id     = 0;
        string        outSQL;

        #region Update
        if (Request.QueryString["id"] != null && clsDefault.QueryStringChecker("command") == "edit")
        {
            id = int.Parse(Request.QueryString["id"].ToString());

            if (clsSQL.Update("Content",
                              new string[, ] {
                { "Content", "N'" + clsSQL.CodeFilter(ucContent.Text) + "'" },
                { "MUser", "'" + clsSecurity.LoginUID + "'" },
                { "MWhen", "GETDATE()" },
                { "Sort", clsDefault.CodeFilter(txtSort.Text) },
                { "Active", "'" + (cbActive.Checked ? "1" : "0") + "'" }
            }, new string[, ] {
                { }
            },
                              "UID=" + id.ToString(),
                              dbType, cs, out outSQL))
            {
                ucColorBox1.ReloadParent();
            }
            else
            {
                ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", outSQL, AlertImage: ucColorBox.Alerts.Fail);
            }
        }
        #endregion
    }
Esempio n. 7
0
    private void DoctorBuilderDeptOneLine()
    {
        #region Variable
        StringBuilder strSQL = new StringBuilder();
        DataTable     dt     = new DataTable();
        #endregion
        #region SQL Query
        strSQL.Append("SELECT ");
        strSQL.Append("(");
        strSQL.Append("SELECT TOP 1 MedicalCenter.UID ");
        strSQL.Append("FROM DoctorDepartment ");
        strSQL.Append("INNER JOIN MedicalCenter ON DoctorDepartment.DepartmentUID = MedicalCenter.DepartmentUID AND MedicalCenter.LanguageUID = " + (clsLanguage.LanguageCurrent == "th-TH" ? "1" : "2") + " ");
        strSQL.Append("WHERE DoctorDepartment.DoctorUID = D.UID ");
        strSQL.Append(")MedicalCenterUID,");
        strSQL.Append("(");
        strSQL.Append("SELECT MC.Name + ' , ' ");
        strSQL.Append("FROM DoctorDepartment DD ");
        strSQL.Append("INNER JOIN MedicalCenter MC ON DD.DepartmentUID = MC.DepartmentUID ");
        if (clsLanguage.LanguageCurrent == "th-TH")
        {
            strSQL.Append("AND MC.LanguageUID=1 ");
        }
        else
        {
            strSQL.Append("AND MC.LanguageUID=2 ");
        }
        strSQL.Append("WHERE DD.DoctorUID = D.UID FOR XML PATH('')");
        strSQL.Append(")Department,");
        strSQL.Append("(");
        strSQL.Append("SELECT TOP 1 DoctorDepartment.DepartmentUID ");
        strSQL.Append("FROM DoctorDepartment ");
        strSQL.Append("INNER JOIN MedicalCenter ON DoctorDepartment.DepartmentUID = MedicalCenter.DepartmentUID AND MedicalCenter.LanguageUID = " + (clsLanguage.LanguageCurrent == "th-TH" ? "1" : "2") + " ");
        strSQL.Append("WHERE DoctorDepartment.DoctorUID = D.UID ");
        strSQL.Append(")DepartmentUID,");
        strSQL.Append("D.UID,D.Photo,");
        #region Language Select
        if (clsLanguage.LanguageCurrent == "th-TH")
        {
            strSQL.Append("D.PNameTH+' '+D.FNameTH+'  '+D.LNameTH Name1,");
            strSQL.Append("D.FNameEN+'  '+D.LNameEN+', '+D.PNameEN Name2,");
            strSQL.Append("D.SpecialtyTH Specialty,");
            strSQL.Append("D.EducationTH Education,");
            strSQL.Append("D.ExperianceTH Experiance,");
            strSQL.Append("D.TypeTH Type,");
        }
        else
        {
            strSQL.Append("D.PNameTH+' '+D.FNameTH+'  '+D.LNameTH Name2,");
            strSQL.Append("D.FNameEN+'  '+D.LNameEN+', '+D.PNameEN Name1,");
            strSQL.Append("D.SpecialtyEN Specialty,");
            strSQL.Append("D.EducationEN Education,");
            strSQL.Append("D.ExperianceEN Experiance,");
            strSQL.Append("D.TypeEN Type,");
        }
        #endregion
        strSQL.Append("D.MedID,D.Phone,D.EMail ");

        strSQL.Append("FROM Doctor D ");
        strSQL.Append("WHERE D.Active = '1' ");
        #region SearchBuilder
        #region Name
        if (txtSearchName.Text.Trim() != "")
        {
            if (clsLanguage.LanguageCurrent == "th-TH")
            {
                strSQL.Append("AND (");
                strSQL.Append("D.FNameTH LIKE '%" + clsSQL.CodeFilter(txtSearchName.Text) + "%' ");
                strSQL.Append("OR D.LNameTH LIKE '%" + clsSQL.CodeFilter(txtSearchName.Text) + "%'");
                strSQL.Append(") ");
            }
            else
            {
                strSQL.Append("AND (");
                strSQL.Append("D.FNameEN LIKE '%" + clsSQL.CodeFilter(txtSearchName.Text) + "%' ");
                strSQL.Append("OR D.LNameEN LIKE '%" + clsSQL.CodeFilter(txtSearchName.Text) + "%'");
                strSQL.Append(") ");
            }
        }
        #endregion
        #region Specialty
        if (ddlSearchSpecialty.SelectedItem.Value != "null")
        {
            strSQL.Append("AND (");
            strSQL.Append("SpecialtyTH LIKE '%" + ddlSearchSpecialty.SelectedItem.Text + "%' ");
            strSQL.Append("OR SpecialtyEN LIKE '%" + ddlSearchSpecialty.SelectedItem.Text + "%' ");
            strSQL.Append(") ");
        }
        #endregion
        #region MedicalCenter
        if (ddlSearchMedicalCenter.SelectedItem.Value != "null")
        {
            strSQL.Append("AND (");
            strSQL.Append("SELECT COUNT(MedicalCenter.UID) ");
            strSQL.Append("FROM DoctorDepartment ");
            strSQL.Append("INNER JOIN MedicalCenter ON DoctorDepartment.DepartmentUID = MedicalCenter.DepartmentUID AND MedicalCenter.LanguageUID = " + (clsLanguage.LanguageCurrent == "th-TH" ? "1" : "2") + " ");
            strSQL.Append("WHERE DoctorDepartment.DoctorUID = D.UID ");
            strSQL.Append("AND MC.Name LIKE '%" + ddlSearchMedicalCenter.SelectedItem.Text + "%'");
            strSQL.Append(")>0,");
        }
        #endregion
        #region Schedule
        #region Checked
        bool cbChecked = false;
        for (int c = 0; c < cbSearchSchedule.Items.Count; c++)
        {
            if (cbSearchSchedule.Items[c].Selected)
            {
                cbChecked = true;
                break;
            }
        }
        #endregion
        if (cbChecked)
        {
            strSQL.Append("AND (");
            strSQL.Append("SELECT ");
            strSQL.Append("COUNT(UID) ");
            strSQL.Append("FROM ");
            strSQL.Append("DoctorSchedule ");
            strSQL.Append("WHERE ");
            strSQL.Append("DoctorUID=D.UID ");
            //strSQL.Append("AND DATEPART(DW,DoctorSchedule.DateActive)=1");
            strSQL.Append("AND " + clsSQL.QueryBuilderWhere(cbSearchSchedule, "DATEPART(DW,DoctorSchedule.DateActive)", "OR", false, true));
            strSQL.Append(")>0 ");
        }
        #endregion
        #endregion
        strSQL.Append("ORDER BY ");
        strSQL.Append("D.FNameTH;");
        #endregion
        #region Data Builder
        dt = clsSQL.Bind(strSQL.ToString(), dbType, cs);
        if (dt != null && dt.Rows.Count > 0)
        {
            gvDoctor.Visible    = true;
            gvDoctor.DataSource = dt;
            gvDoctor.DataBind();

            DoctorScheduleBuilder();
        }
        else
        {
            gvDoctor.Visible = false;
            lblDoctor.Text   = (clsLanguage.LanguageCurrent == "th-TH"?clsDefault.AlertMessageColor("ไม่พบข้อมูลแพทย์ที่ต้องการ.", clsDefault.AlertType.Info):clsDefault.AlertMessageColor("Not found data.", clsDefault.AlertType.Info));
        }
        #endregion
    }
Esempio n. 8
0
    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
        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 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 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
    }
Esempio n. 12
0
 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
 }
Esempio n. 13
0
    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 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
    }
    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);
        }
    }
Esempio n. 16
0
 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 = "";
     #endregion
     #region Procedure
     try
     {
         #region Update
         if (Request.QueryString["id"] != null && clsDefault.QueryStringChecker("command") == "edit")
         {
             id = int.Parse(Request.QueryString["id"].ToString());
             #region Photo Upload
             if (fuPhoto.HasFile)
             {
                 var    clsIO = new clsIO();
                 string outErrorMessage;
                 string outFilename;
                 #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
             }
             #endregion
             if (clsSQL.Update(tableDefault,
                               new string[, ] {
                 { "Photo", (!string.IsNullOrEmpty(photoName)?"'" + pathUpload + photoName + "'":"Photo") },
                 { "UserGroupUID", ddlUserGroup.SelectedItem.Value },
                 { "PName", "'" + ddlPName.SelectedItem.Value + "'" },
                 { "FName", "'" + txtFName.Text.SQLQueryFilter() + "'" },
                 { "LName", "'" + txtLName.Text.SQLQueryFilter() + "'" },
                 { "BirthDate", (ucBirthdate.Text != ""?"'" + ucBirthdate.DateTime.ToString("yyyy-MM-dd") + "'":"null") },
                 { "Gender", "'" + rbGender.SelectedItem.Value + "'" },
                 { "NID", "'" + txtNID.Text.SQLQueryFilter() + "'" },
                 { "Phone", "'" + txtPhone.Text.SQLQueryFilter() + "'" },
                 { "Mobile", "'" + txtMobile.Text.SQLQueryFilter() + "'" },
                 { "Email", "'" + txtEmail.Text.SQLQueryFilter() + "'" },
                 { "Address", "'" + txtAddress.Text.SQLQueryFilter() + "'" },
                 { "AddressDistrict", "'" + txtAddressDistrict.Text.SQLQueryFilter() + "'" },
                 { "AddressPrefecture", "'" + txtAddressPrefecture.Text.SQLQueryFilter() + "'" },
                 { "AddressProvince", "'" + txtAddressProvince.Text.SQLQueryFilter() + "'" },
                 { "AddressPostal", "'" + txtAddressPostal.Text.SQLQueryFilter() + "'" },
                 { "Profile", "'" + ucProfile.Text.SQLQueryFilter() + "'" },
                 { "Signature", "'" + ucSignature.Text.SQLQueryFilter() + "'" },
                 { "MUser", "'" + clsSecurity.LoginUID + "'" },
                 { "MWhen", functionGetDate },
                 { "Sort", clsSQL.CodeFilter(txtSort.Text) },
                 { "StatusFlag", "'" + (cbActive.Checked ? "A" : "I") + "'" }
             }, new string[, ] {
                 { parameterChar + "UID", id.ToString() }
             },
                               "UID=" + parameterChar + "UID",
                               out outSQL))
             {
                 ucColorBox1.ReloadParent();
             }
             else
             {
                 ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail);
             }
         }
         #endregion
         #region Insert
         else
         {
             #region Photo Upload
             if (fuPhoto.HasFile)
             {
                 var    clsIO = new clsIO();
                 string outErrorMessage;
                 string outFilename;
                 #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
             }
             #endregion
             if (clsSQL.Insert(tableDefault,
                               new string[, ] {
                 { "UserGroupUID", ddlUserGroup.SelectedItem.Value },
                 { "[Username]", "'" + txtUsername.Text.SQLQueryFilter() + "'" },
                 { "Password", "'" + clsSecurity.Encrypt(txtPassword.Text) + "'" },
                 { "PName", "'" + ddlPName.SelectedItem.Value + "'" },
                 { "FName", "'" + txtFName.Text.SQLQueryFilter() + "'" },
                 { "LName", "'" + txtLName.Text.SQLQueryFilter() + "'" },
                 { "BirthDate", (ucBirthdate.Text != ""?"'" + ucBirthdate.DateTime.ToString("yyyy-MM-dd") + "'":"null") },
                 { "Gender", "'" + rbGender.SelectedItem.Value + "'" },
                 { "NID", "'" + txtNID.Text.SQLQueryFilter() + "'" },
                 { "Phone", "'" + txtPhone.Text.SQLQueryFilter() + "'" },
                 { "Mobile", "'" + txtMobile.Text.SQLQueryFilter() + "'" },
                 { "Email", "'" + txtEmail.Text.SQLQueryFilter() + "'" },
                 { "[Address]", "'" + txtAddress.Text.SQLQueryFilter() + "'" },
                 { "AddressDistrict", "'" + txtAddressDistrict.Text.SQLQueryFilter() + "'" },
                 { "AddressPrefecture", "'" + txtAddressPrefecture.Text.SQLQueryFilter() + "'" },
                 { "AddressProvince", "'" + txtAddressProvince.Text.SQLQueryFilter() + "'" },
                 { "AddressPostal", "'" + txtAddressPostal.Text.SQLQueryFilter() + "'" },
                 { "Profile", "'" + ucProfile.Text.SQLQueryFilter() + "'" },
                 { "Signature", "'" + ucSignature.Text.SQLQueryFilter() + "'" },
                 { "CUser", "'" + clsSecurity.LoginUID + "'" },
                 { "CWhen", functionGetDate },
                 { "MUser", "'" + clsSecurity.LoginUID + "'" },
                 { "MWhen", functionGetDate },
                 { "Sort", clsSQL.CodeFilter(txtSort.Text) },
                 { "StatusFlag", "'" + (cbActive.Checked ? "A" : "I") + "'" }
             }, new string[, ] {
                 { }
             },
                               out outSQL))
             {
                 ucColorBox1.ReloadParent();
             }
             else
             {
                 ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail);
             }
         }
         #endregion
     }
     catch (Exception ex)
     {
         lblSQL.Text = "<div style='color:red;'>เกิดข้อผิดพลาด : " + ex.Message + "</div>";
         lblSQL.Focus();
     }
     #endregion
 }
Esempio n. 17
0
    /// <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 Authorize
        if (!clsSecurity.LoginChecker("admin") && !clsSecurity.LoginChecker("hr"))
        {
            ucColorBox1.Redirect("/", "กรุณาล็อคอินด้วยสิทธิ์ Admin");
            return;
        }
        #endregion
        #region Variable
        var strSQL = new StringBuilder();
        var id     = 0;
        var outSQL = "";
        #endregion
        #region Procedure
        #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", "'" + txtName.Text.SQLQueryFilter() + "'" },
                { "Detail", "'" + ucDetail.Text.SQLQueryFilter() + "'" },
                { "MUser", "'" + clsSecurity.LoginUID + "'" },
                { "MWhen", "GETDATE()" },
                { "Sort", clsSQL.CodeFilter(txtSort.Text) },
                { "StatusFlag", "'" + (cbActive.Checked ? "A" : "D") + "'" }
            }, new string[, ] {
                { parameterChar + "UID", id.ToString() }
            },
                              "UID=" + parameterChar + "UID",
                              dbType, cs, out outSQL))
            {
                ucColorBox1.ReloadParent();
            }
            else
            {
                ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", Server.HtmlEncode(outSQL), AlertImage: ucColorBox.Alerts.Fail);
            }
        }
        #endregion
        #region Insert
        else
        {
            if (clsSQL.Insert(tableDefault,
                              new string[, ] {
                { "Name", "'" + txtName.Text.SQLQueryFilter() + "'" },
                { "Detail", "'" + ucDetail.Text.SQLQueryFilter() + "'" },
                { "CUser", "'" + clsSecurity.LoginUID + "'" },
                { "CWhen", "GETDATE()" },
                { "MUser", "'" + clsSecurity.LoginUID + "'" },
                { "MWhen", "GETDATE()" },
                { "Sort", clsSQL.CodeFilter(txtSort.Text) },
                { "StatusFlag", "'" + (cbActive.Checked ? "A" : "D") + "'" }
            }, new string[, ] {
                { }
            },
                              dbType, cs, out outSQL))
            {
                ucColorBox1.ReloadParent();
            }
            else
            {
                ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", Server.HtmlEncode(outSQL), AlertImage: ucColorBox.Alerts.Fail);
            }
        }
        #endregion
        #endregion
    }
 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 = "";
     #endregion
     #region Procedure
     #region Update
     if (Request.QueryString["id"] != null && clsDefault.QueryStringChecker("command") == "edit")
     {
         id = int.Parse(Request.QueryString["id"].ToString());
         #region Photo Upload
         if (fuPhoto.HasFile)
         {
             var    clsIO = new clsIO();
             string outErrorMessage; string outFilename;
             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
         if (clsSQL.Update(tableDefault,
                           new string[, ] {
             { "Photo", (!string.IsNullOrEmpty(photoName)?"'" + pathUpload + photoName + "'":"Photo") },
             { "Name", "'" + txtName.Text.SQLQueryFilter() + "'" },
             { "Detail", "'" + txtDetail.Text.SQLQueryFilter() + "'" },
             { "MUser", clsSecurity.LoginUID },
             { "MWhen", functionGetDate },
             { "Sort", clsSQL.CodeFilter(txtSort.Text) },
             { "StatusFlag", "'" + (cbActive.Checked ? "A" : "I") + "'" }
         }, new string[, ] {
             { parameterChar + "UID", id.ToString() }
         },
                           "UID=" + parameterChar + "UID",
                           out outSQL))
         {
             ucColorBox1.ReloadParent();
         }
         else
         {
             ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail);
         }
     }
     #endregion
     #region Insert
     else
     {
         #region Photo Upload
         if (fuPhoto.HasFile)
         {
             clsIO  clsIO = new clsIO();
             string outErrorMessage; string outFilename;
             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
         if (clsSQL.Insert(tableDefault,
                           new string[, ] {
             { "Photo", (!string.IsNullOrEmpty(photoName)?"'" + pathUpload + photoName + "'":"null") },
             { "Name", "'" + txtName.Text.SQLQueryFilter() + "'" },
             { "Detail", "'" + txtDetail.Text.SQLQueryFilter() + "'" },
             { "CUser", clsSecurity.LoginUID },
             { "CWhen", functionGetDate },
             { "MUser", clsSecurity.LoginUID },
             { "MWhen", functionGetDate },
             { "Sort", txtSort.Text.SQLQueryFilter() },
             { "StatusFlag", "'" + (cbActive.Checked ? "A" : "I") + "'" }
         }, new string[, ] {
             { }
         },
                           out outSQL))
         {
             ucColorBox1.ReloadParent();
         }
         else
         {
             ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail);
         }
     }
     #endregion
     #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
    }