protected void btSubmit_Click(object sender, EventArgs e)
    {
        #region Variable
        string outMail = "";
        #endregion

        if (txtFromName.Text.Trim().Length > 0 &&
            txtFromPhone.Text.Trim().Length > 0 &&
            txtFromEmail.Text.Trim().Length > 0 &&
            txtMessage.Text.Trim().Length > 0)
        {
            if (clsMail.SendTemplate(
                    "Feedback",
                    clsMail.GetEmailList("AutoSystemFrom"),
                    clsMail.GetEmailList("FeedbackTo"),
                    new string[, ]
            {
                { "[FromName]", txtFromName.Text },
                { "[FromPhone]", txtFromPhone.Text },
                { "[FromEmail]", txtFromEmail.Text },
                { "[CWhen]", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") },
                { "[Message]", txtMessage.Text }
            },
                    out outMail))
            {
                txtFromName.Text  = "";
                txtFromEmail.Text = "";
                txtFromPhone.Text = "";
                txtMessage.Text   = "";

                //lblAlert.Text = clsDefault.AlertMessageColor("ระบบได้รับข้อความของคุณแล้ว");
                //lblAlert.Focus();
                ucColorBox1.Redirect("/Feedback/", "ได้รับข้อความของคุณแล้ว");
            }
            else
            {
                lblAlert.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะพยายามส่งอีเมล์<br/>" + outMail, clsDefault.AlertType.Fail);
                lblAlert.Focus();
            }
        }
        else
        {
            lblAlert.Text = clsDefault.AlertMessageColor("กรุณากรอกข้อมูลให้ครบก่อนค่ะ", clsDefault.AlertType.Warn);
        }
    }
    protected void btSubmit_Click(object sender, EventArgs e)
    {
        #region Variable
        string outMail = "";
        string outSQL  = "";
        string UID     = "";
        #endregion

        if (txtFromName.Text.Trim().Length > 0 &&
            txtFromPhone.Text.Trim().Length > 0 &&
            txtFromEmail.Text.Trim().Length > 0 &&
            txtMessage.Text.Trim().Length > 0)
        {
            UID = clsSQL.GetNewID("UID", "Inquiry", "", dbType, cs).ToString();
            if (!clsSQL.Insert(
                    "Inquiry",
                    new string[, ] {
                { "UID", UID },
                { "MedicalCenterUID", (ddlMedicalCenter.SelectedItem.Value == "null"?"null":ddlMedicalCenter.SelectedItem.Value) },
                { "Name", "'" + clsSQL.CodeFilter(txtFromName.Text) + "'" },
                { "Email", "'" + clsSQL.CodeFilter(txtFromEmail.Text) + "'" },
                { "Phone", "'" + clsSQL.CodeFilter(txtFromPhone.Text) + "'" },
                { "Message", "'" + clsSQL.CodeFilter(txtMessage.Text) + "'" },
                { "Status", "'RECEIVED'" },
                { "CWhen", "GETDATE()" },
                { "CUser", /*clsSecurity.LoginUID*/ "0" },
                { "MWhen", "GETDATE()" },
                { "MUser", /*clsSecurity.LoginUID*/ "0" },
                { "Sort", "0" },
                { "Active", "'1'" }
            },
                    new string[, ] {
                {}
            },
                    dbType,
                    cs,
                    out outSQL))
            {
                ucColorBox1.Alert(Message: "เกิดข้อผิดพลาดขณะบันทึกข้อมูล", AlertImage: ucColorBox.Alerts.Fail);
                return;
            }
            #region MailToUser
            try
            {
                //string outMailMessage="";
                //clsMail.Send(
                //    "*****@*****.**",
                //    txtFromEmail.Text.Trim(),
                //    "โรงพยาบาลกรุงเทพจันทบุรี ได้รับข้อมูลของคุณแล้ว",
                //    "คุณได้ส่งคำถาม '" + txtMessage.Text.Trim() + "' มายังโรงพยาบาล",
                //    out outMailMessage);
                if (clsMail.SendTemplate(
                        "InquiryConfirm",
                        clsMail.GetEmailList("GlobalFrom"),
                        txtFromEmail.Text,
                        new string[, ]
                {
                    { "[UID]", UID },
                    { "[MedicalCenter]", ddlMedicalCenter.SelectedItem.Text },
                    { "[FromName]", txtFromName.Text },
                    { "[FromPhone]", txtFromPhone.Text },
                    { "[FromEmail]", txtFromEmail.Text },
                    { "[CWhen]", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") },
                    { "[Message]", txtMessage.Text }
                },
                        out outMail))
                {
                    ucColorBox1.Redirect("/Inquiry/", "ได้รับข้อความของคุณแล้ว");
                }
                else
                {
                    lblAlert.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะพยายามส่งอีเมล์<br/>" + outMail, clsDefault.AlertType.Fail);
                    lblAlert.Focus();
                }
            }
            catch (Exception) { }
            #endregion
            #region MailToAdmin
            if (clsMail.SendTemplate(
                    "Inquiry",
                    clsMail.GetEmailList("AutoSystemFrom"),
                    clsMail.GetEmailList("InquiryTo"),
                    new string[, ]
            {
                { "[UID]", UID },
                { "[MedicalCenter]", ddlMedicalCenter.SelectedItem.Text },
                { "[FromName]", txtFromName.Text },
                { "[FromPhone]", txtFromPhone.Text },
                { "[FromEmail]", txtFromEmail.Text },
                { "[CWhen]", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss") },
                { "[Message]", txtMessage.Text }
            },
                    out outMail))
            {
                ucColorBox1.Redirect("/Inquiry/", "ได้รับข้อความของคุณแล้ว");
            }
            else
            {
                lblAlert.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะพยายามส่งอีเมล์<br/>" + outMail, clsDefault.AlertType.Fail);
                lblAlert.Focus();
            }
            #endregion
        }
        else
        {
            lblAlert.Text = clsDefault.AlertMessageColor("กรุณากรอกข้อมูลให้ครบก่อนค่ะ", clsDefault.AlertType.Warn);
        }
    }
 protected void btBook_Click(object sender, EventArgs e)
 {
     #region Variable
     string outSQL;
     string outMailMessage;
     clsMail clsMail;
     #endregion
     #region Insert Data
     if (clsSQL.Insert(
         "DoctorAppointment",
         new string[,]{
             {"UID",clsSQL.GetNewID("UID","DoctorAppointment","",dbType,cs).ToString()},
             {"HN","'"+clsSQL.CodeFilter(txtHN.Text)+"'"},
             {"PName","'"+clsSQL.CodeFilter(ddlPName.SelectedItem.Text)+"'"},
             {"FName","'"+clsSQL.CodeFilter(txtFName.Text)+"'"},
             {"LName","'"+clsSQL.CodeFilter(txtLName.Text)+"'"},
             {"Email","'"+clsSQL.CodeFilter(txtEmail.Text)+"'"},
             {"Phone","'"+clsSQL.CodeFilter(txtPhone.Text)+"'"},
             {"DoctorUID",clsDefault.URLRouting("doctorUID")},
             {"DoctorName","'"+clsSQL.CodeFilter(lblName1.Text)+"'"},
             {"DepartmentUID","'"+clsDefault.URLRouting("departmentUID")+"'"},
             {"DepartmentName","'"+clsSQL.CodeFilter(lblDepartment.Text)+"'"},
             {"AppointmentDate","'"+clsSQL.CodeFilter(ucDateTimeFlat1.DateTime.ToString("yyyy-MM-dd HH:mm"))+"'"},
             {"Comment","'"+clsSQL.CodeFilter(txtComment.Text)+"'"},
             {"BirthDate","'"+ucBirthDate.DateTime.ToString("yyyy-MM-dd")+"'"},
             {"NID","'"+txtNID.Text.SQLQueryFilter()+"'"},
             {"CWhen","GETDATE()"},
             {"CUser",(clsSecurity.LoginChecker()?clsSecurity.LoginUID:"0")},
             {"MWhen","GETDATE()"},
             {"MUser",(clsSecurity.LoginChecker()?clsSecurity.LoginUID:"0")},
             {"Sort","0"},
             {"Active","'1'"}
         },
         new string[,]{},
         dbType,
         cs,
         out outSQL))
     {
         lblBookAlert.Text = clsDefault.AlertMessageColor("ระบบบันทึกข้อมูลการทำนัดของคุณแล้ว", clsDefault.AlertType.Success);
         string doctor = lblName1.Text;
         #region Mail to Admin
         clsMail = new clsMail();
         if (!clsMail.SendTemplate(
             "DoctorScheduleAdmin",
             clsMail.GetEmailList("AutoSystemFrom"),
             clsMail.GetEmailList("DoctorScheduleTo"),
             new string[,]{
                 {"[PName]",ddlPName.SelectedItem.Text},
                 {"[FName]",txtFName.Text},
                 {"[LName]",txtLName.Text},
                 {"[HN]",txtHN.Text},
                 {"[Email]",txtEmail.Text},
                 {"[Phone]",txtPhone.Text},
                 {"[Doctor]",doctor},
                 {"[Department]",lblDepartment.Text},
                 {"[BookDateTime]",ucDateTimeFlat1.DateTime.ToString("dd/MM/yyyy HH:mm")},
                 {"[Comment]",txtComment.Text},
                 {"[BirthDate]",ucBirthDate.Text},
                 {"[NID]",txtNID.Text}
             },
             out outMailMessage))
         {
             lblBookAlert.Text += clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะส่งเมล์ไปยังลูกค้า", clsDefault.AlertType.Fail);
         }
         //List<clsMail.EmailList> mails = new List<global::clsMail.EmailList>();
         //mails = clsMail.GetEmailList("DoctorScheduleTo");
         //for (int i = 0; i < mails.Count; i++)
         //{
         //    lblBookAlert.Text+="<br/>"+mails[i].EmailAddress;
         //}
         lblBookAlert.Text += "<br/>"+outMailMessage;
         #endregion
             #region Mail to User
             clsMail = new clsMail();
         if(!clsMail.SendTemplate(
             "DoctorScheduleUser",
             clsMail.GetEmailList("GlobalFrom"),
             txtEmail.Text.Trim(),
             new string[,]{
                 {"[PName]",ddlPName.SelectedItem.Text},
                 {"[FName]",txtFName.Text},
                 {"[LName]",txtLName.Text},
                 {"[HN]",txtHN.Text},
                 {"[Email]",txtEmail.Text},
                 {"[Phone]",txtPhone.Text},
                 {"[Doctor]",doctor},
                 {"[Department]",lblDepartment.Text},
                 {"[BookDateTime]",ucDateTimeFlat1.DateTime.ToString("dd/MM/yyyy HH:mm")},
                 {"[Comment]",txtComment.Text}
             },
             out outMailMessage))
         {
             lblBookAlert.Text += clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะส่งเมล์ไปยังลูกค้า", clsDefault.AlertType.Fail);
         }
         #endregion
     }
     else
     {
         lblBookAlert.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>" + outSQL, clsDefault.AlertType.Fail);
     }
     #endregion
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string id = clsDefault.URLRouting("id");

            if (!string.IsNullOrEmpty(id))
            {
                string idDecrypt = clsSecurity.Decrypt(id);
                string active    = clsSQL.Return(
                    "SELECT Active FROM [User] WHERE UID=" + parameterChar + "UID",
                    new string[, ] {
                    { parameterChar + "UID", idDecrypt }
                },
                    dbType,
                    cs);

                if (!string.IsNullOrEmpty(active))
                {
                    if (active == "0")
                    {
                        string outSQL;
                        if (clsSQL.Update(
                                "[User]",
                                new string[, ] {
                            { "Active", "'1'" }, { "MWhen", "GETDATE()" }
                        },
                                new string[, ] {
                            { "@UID", idDecrypt }
                        },
                                "UID=@UID",
                                dbType,
                                cs,
                                out outSQL))
                        {
                            #region Mail to Admin
                            string outMessage;
                            string Name = clsSQL.Return(
                                "SELECT Username FROM [User] WHERE UID=" + parameterChar + "UID",
                                new string[, ] {
                                { parameterChar + "UID", idDecrypt }
                            },
                                dbType,
                                cs);
                            clsMail clsMail = new clsMail();

                            if (!clsMail.SendTemplate(
                                    "UserRegisterConfirmAdmin",
                                    clsMail.GetEmailList("AutoSystemFrom"),
                                    clsMail.GetEmailList("AdminTo"),
                                    new string[, ] {
                                { "[Username]", Name }
                            },
                                    out outMessage))
                            {
                                ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>" + outMessage, AlertImage: ucColorBox.Alerts.Fail);
                                return;
                            }
                            #endregion
                            ucColorBox1.Redirect(
                                "/",
                                "ดำเนินการเสร็จสิ้น",
                                "ระบบยืนยันสถานะสมาชิกของคุณเรียบร้อยแล้ว");
                        }
                        else
                        {
                            ucColorBox1.Redirect(
                                "/",
                                "เกิดข้อผิดพลาด",
                                "ไม่พบรหัสยืนยันของคุณ");
                        }
                    }
                    else
                    {
                        ucColorBox1.Redirect(
                            "/",
                            "ดำเนินการเสร็จสิ้น",
                            "คุณเคยทำการยืนยันอีเมล์ไว้แล้ว");
                    }
                }
                else
                {
                    ucColorBox1.Redirect(
                        "/",
                        "เกิดข้อผิดพลาด",
                        "ไม่พบรหัสยืนยันของคุณ");
                }
            }
            else
            {
                ucColorBox1.Redirect(
                    "/",
                    "เกิดข้อผิดพลาด",
                    "ไม่พบรหัสยืนยันของคุณ");
            }
        }
    }
Exemple #5
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 Variable
        StringBuilder strSQL = new StringBuilder();
        string        outSQL;
        string        outError;
        string        outPhotoName = "null";
        #endregion

        #region Check Data
        #region Find Username
        if (int.Parse(clsSQL.Return("SELECT COUNT(UID) FROM [User] WHERE Username='******'", dbType, cs)) > 0)
        {
            //lblUsername.Text = clsDefault.AlertMessageColor("Username นี้มีผู้ใช้งานแล้ว", clsDefault.AlertType.Warn);
            //lblUsername.Focus();
            txtUsername.Focus();
            ucColorBox1.Alert("ข้อมูลไม่ถูกต้อง", "Username นี้มีผู้ใช้งานแล้ว", AlertImage: ucColorBox.Alerts.Fail);
            return;
        }
        else
        {
            lblUsername.Text = "";
        }
        #endregion
        #region Find Email
        if (int.Parse(clsSQL.Return("SELECT COUNT(UID) FROM [User] WHERE Email='" + clsDefault.CodeFilter(txtEMail.Text) + "'", dbType, cs)) > 0)
        {
            //lblEmail.Text = clsDefault.AlertMessageColor("Email นี้มีผู้ใช้งานแล้ว", clsDefault.AlertType.Warn);
            //lblEmail.Focus();
            txtEMail.Focus();
            ucColorBox1.Alert("ข้อมูลไม่ถูกต้อง", "E-Mail นี้มีผู้ใช้งานแล้ว", AlertImage: ucColorBox.Alerts.Fail);
            return;
        }
        else
        {
            lblEmail.Text = "";
        }
        #endregion
        #region Find UID
        int UID = clsSQL.GetNewID("UID", "[User]", "", dbType, cs);
        if (UID == 0)
        {
            //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะหา UID", clsDefault.AlertType.Fail);
            //lblSQL.Focus();
            ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "ไม่สามารถหา UID ได้", AlertImage: ucColorBox.Alerts.Fail);
            return;
        }
        else
        {
            lblSQL.Text = "";
        }
        #endregion
        #endregion

        #region Insert
        #region Photo Upload
        if (fuPhoto.HasFile)
        {
            if (!clsIO.UploadPhoto(fuPhoto, pathPhoto, clsSecurity.LoginUID, 500, photoWidth, photoHeight, "", 0, out outError, out outPhotoName))
            {
                //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะอัพโหลดภาพ : " + outError, clsDefault.AlertType.Fail);
                //lblSQL.Focus();
                ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะอัพโหลดภาพ", AlertImage: ucColorBox.Alerts.Fail);
                return;
            }
            else
            {
                outPhotoName = "'" + pathPhoto + outPhotoName + "'";
            }
        }
        #endregion
        #region SQL Insert
        if (clsSQL.Insert(
                "[USER]",
                new string[, ] {
            { "UID", UID.ToString() },
            { "UserGroupUID", "2" },
            { "Username", "'" + clsDefault.CodeFilter(txtUsername.Text) + "'" },
            { "Password", "'" + clsSecurity.Encrypt(clsDefault.CodeFilter(txtPassword.Text)) + "'" },
            { "Photo", outPhotoName },
            { "PName", ddlPName.SelectedItem.Value != "null"?"'" + ddlPName.SelectedItem.Value + "'":"null" },
            { "FName", "'" + clsDefault.CodeFilter(txtFName.Text) + "'" },
            { "LName", "'" + clsDefault.CodeFilter(txtLName.Text) + "'" },
            { "HN", "'" + clsDefault.CodeFilter(HNConvert(txtHN.Text)) + "'" },
            { "BirthDate", ucDateTimeFlat1.DateTime != DateTime.MinValue?"'" + ucDateTimeFlat1.DateTime.ToString("yyyy-MM-dd HH:mm:ss") + "'":"null" },
            { "Gender", rbGender.SelectedItem.Value != "null"?"'" + rbGender.SelectedItem.Value + "'":"null" },
            { "Phone", "'" + clsDefault.CodeFilter(txtPhone.Text) + "'" },
            { "Mobile", "'" + clsDefault.CodeFilter(txtMobile.Text) + "'" },
            { "Email", "'" + clsDefault.CodeFilter(txtEMail.Text) + "'" },
            { "Address", "'" + clsDefault.CodeFilter(txtAddress.Text) + "'" },
            { "AddressDistrict", "'" + clsDefault.CodeFilter(txtAddressDistrict.Text) + "'" },
            { "AddressPrefecture", "'" + clsDefault.CodeFilter(txtAddressPrefecture.Text) + "'" },
            { "AddressProvince", "'" + clsDefault.CodeFilter(txtAddressProvince.Text) + "'" },
            { "AddressPostal", "'" + clsDefault.CodeFilter(txtAddressPostal.Text) + "'" },
            { "Profile", "'" + ucProfile.Text + "'" },
            { "Signature", "'" + ucSignature.Text + "'" },
            { "CUser", UID.ToString() },
            { "CWhen", "GETDATE()" },
            { "MUser", UID.ToString() },
            { "MWhen", "GETDATE()" },
            { "Sort", clsDefault.CodeFilter(txtSort.Text) },
            { "Active", "'0'" /*cbActive.Checked?"'1'":"'0'"+"'"*/ }
        },
                new string[, ] {
            { }
        },
                dbType,
                cs,
                out outSQL
                ))
        {
            clsMail clsMail = new clsMail();
            string  outMessage;
            string  idEncode = Server.UrlEncode(clsSecurity.Encrypt(UID.ToString()));

            #region Mail to User
            if (!clsMail.SendTemplate(
                    "UserRegisterConfirm",
                    clsMail.GetEmailList("GlobalFrom"),
                    txtEMail.Text,
                    new string[, ] {
                { "[Username]", txtUsername.Text },
                { "[UIDEncrypt]", idEncode }
            },
                    out outMessage))
            {
                //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>"+outMessage, clsDefault.AlertType.Fail);
                //lblSQL.Focus();
                ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>" + outMessage, AlertImage: ucColorBox.Alerts.Fail);
                return;
            }
            #endregion
            #region Mail to Admin
            if (!clsMail.SendTemplate(
                    "UserRegisterAdmin",
                    clsMail.GetEmailList("AutoSystemFrom"),
                    clsMail.GetEmailList("AdminTo"),
                    new string[, ] {
                { "[Username]", txtUsername.Text }
            },
                    out outMessage))
            {
                ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>" + outMessage, AlertImage: ucColorBox.Alerts.Fail);
                return;
            }
            #endregion
        }
        else
        {
            //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะบันทึกลงฐานข้อมูล : " + outSQL, clsDefault.AlertType.Fail);
            //lblSQL.Focus();
            ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะบันทึกข้อมูลลงฐานข้อมูล : " + outSQL, AlertImage: ucColorBox.Alerts.Fail);
            return;
        }
        #endregion
        //clsDefault.Redirect("/", "บันทึกข้อมูลเรียบร้อยแล้ว");
        ucColorBox1.Redirect("/");
        #endregion
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string id = clsDefault.URLRouting("id");

            if (!string.IsNullOrEmpty(id))
            {
                string idDecrypt = clsSecurity.Decrypt(id);
                string active = clsSQL.Return(
                    "SELECT Active FROM [User] WHERE UID=" + parameterChar + "UID",
                    new string[,] { { parameterChar + "UID", idDecrypt } }, 
                    dbType, 
                    cs);

                if (!string.IsNullOrEmpty(active))
                {
                    if (active == "0")
                    {
                        string outSQL;
                        if (clsSQL.Update(
                            "[User]",
                            new string[,] { { "Active", "'1'" }, { "MWhen", "GETDATE()" } },
                            new string[,] { { "@UID", idDecrypt } },
                            "UID=@UID",
                            dbType,
                            cs,
                            out outSQL))
                        {
                            #region Mail to Admin
                            string outMessage;
                            string Name = clsSQL.Return(
                                "SELECT Username FROM [User] WHERE UID=" + parameterChar + "UID",
                                new string[,] { { parameterChar + "UID", idDecrypt } },
                                dbType,
                                cs);
                            clsMail clsMail = new clsMail();

                            if (!clsMail.SendTemplate(
                                "UserRegisterConfirmAdmin",
                                clsMail.GetEmailList("AutoSystemFrom"),
                                clsMail.GetEmailList("AdminTo"),
                                new string[,]{
                                    {"[Username]",Name}
                                },
                                out outMessage))
                            {
                                ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>" + outMessage, AlertImage: ucColorBox.Alerts.Fail);
                                return;
                            }
                            #endregion
                            ucColorBox1.Redirect(
                                "/",
                                "ดำเนินการเสร็จสิ้น",
                                "ระบบยืนยันสถานะสมาชิกของคุณเรียบร้อยแล้ว");
                        }
                        else
                        {
                            ucColorBox1.Redirect(
                                "/",
                                "เกิดข้อผิดพลาด",
                                "ไม่พบรหัสยืนยันของคุณ");
                        }
                    }
                    else
                    {
                        ucColorBox1.Redirect(
                            "/",
                            "ดำเนินการเสร็จสิ้น",
                            "คุณเคยทำการยืนยันอีเมล์ไว้แล้ว");
                    }
                }
                else
                {
                    ucColorBox1.Redirect(
                        "/",
                        "เกิดข้อผิดพลาด",
                        "ไม่พบรหัสยืนยันของคุณ");
                }
            }
            else
            {
                ucColorBox1.Redirect(
                    "/",
                    "เกิดข้อผิดพลาด",
                    "ไม่พบรหัสยืนยันของคุณ");
            }
        }
    }
    protected void btSubmit_Click(object sender, EventArgs e)
    {
        #region Variable
        var outSQL   = "";
        var clsIO    = new clsIO();
        var outError = "";
        var outPhoto = "";
        var outMail  = "";
        #endregion
        #region Procedure
        if (fuPhoto.HasFile)
        {
            if (!clsIO.UploadPhoto(
                    fuPhoto,
                    "/Upload/Jobs/",
                    clsSQL.GetNewID("UID", "JobsHistory", "", dbType, cs).ToString(),
                    out outError,
                    out outPhoto,
                    512, 200, 200))
            {
                ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดภาพ : " + outError);
                return;
            }
        }
        #region InsertData
        if (!clsSQL.Insert(
                "JobsHistory",
                new string[, ] {
            { "JobsUID", ddlJobs.SelectedItem.Value },
            { "JobsName", "'" + txtJobsName.Text.SQLQueryFilter() + "'" },
            { "Salary", "'" + txtSalary.Text.SQLQueryFilter() + "'" },
            { "Start", "'" + txtStart.Text.SQLQueryFilter() + "'" },
            { "ProvinceChange", "'" + rbProvinceChange.SelectedItem.Value + "'" },
            { "PrenameTH", "'" + ddlPrenameTH.SelectedItem.Value + "'" },
            { "ForenameTH", "'" + txtForenameTH.Text.SQLQueryFilter() + "'" },
            { "SurnameTH", "'" + txtSurnameTH.Text.SQLQueryFilter() + "'" },
            { "PrenameEN", "'" + ddlPrenameEN.SelectedItem.Value + "'" },
            { "ForenameEN", "'" + txtForenameEN.Text.SQLQueryFilter() + "'" },
            { "SurnameEN", "'" + txtSurnameEN.Text.SQLQueryFilter() + "'" },
            { "MarriageStatus", "'" + rbMarriageStatus.SelectedItem.Value + "'" },
            { "Gender", "'" + rbGender.SelectedItem.Value + "'" },
            { "Birthdate", "'" + (ucBirthdate.Text.Trim() != ""?ucBirthdate.DateTime.ToString("yyyy-MM-dd"):"1900-01-01 00:00") + "'" },
            { "Birthplace", "'" + txtBirthplace.Text.SQLQueryFilter() + "'" },
            { "Nationality", "'" + txtNationality.Text.SQLQueryFilter() + "'" },
            { "Race", "'" + txtRace.Text.SQLQueryFilter() + "'" },
            { "Religion", "'" + txtReligion.Text.SQLQueryFilter() + "'" },
            { "Weight", "'" + txtWeight.Text.SQLQueryFilter() + "'" },
            { "Height", "'" + txtHeight.Text.SQLQueryFilter() + "'" },
            { "NID", "'" + txtNID.Text.SQLQueryFilter() + "'" },
            { "NIDCreateBy", "'" + txtNIDCreateBy.Text.SQLQueryFilter() + "'" },
            { "NIDExpire", "'" + (ucNIDExpire.Text != ""?ucNIDExpire.DateTime.ToString("yyyy-MM-dd"):"") + "'" },
            { "Phone", "'" + txtPhone.Text.SQLQueryFilter() + "'" },
            { "Email", "'" + txtEmail.Text.SQLQueryFilter() + "'" },
            { "Address", "'" + txtAddress.Text.SQLQueryFilter() + "'" },
            { "EmergencyName", "'" + txtEmergencyName.Text.SQLQueryFilter() + "'" },
            { "EmergencyPhone", "'" + txtEmergencyPhone.Text.SQLQueryFilter() + "'" },
            { "EmergencyEmail", "'" + txtEmergencyEmail.Text.SQLQueryFilter() + "'" },
            { "EmergencyAddress", "'" + txtEmergencyAddress.Text.SQLQueryFilter() + "'" },
            { "EmergencyRelationship", "'" + txtEmergencyRelationship.Text.SQLQueryFilter() + "'" },
            { "Photo", (outPhoto != ""?"'" + outPhoto + "'":"null") },
            { "Education", "'" + ucEducation.Text.SQLQueryFilter() + "'" },
            { "Experience", "'" + ucExperience.Text.SQLQueryFilter() + "'" },
            { "Resume", "null" },
            { "CWhen", "GETDATE()" },
            { "CUser", "0" },
            { "MWhen", "GETDATE()" },
            { "MUser", "0" },
            { "Sort", "0" },
            { "StatusFlag", "'A'" }
        },
                new string[, ] {
            { }
        },
                dbType,
                cs,
                out outSQL))
        {
            ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะรันคำสั่ง : " + Server.HtmlEncode(outSQL));
            return;
        }
        else
        {
            #region MailSender
            string JobsUID = clsSQL.Return("SELECT MAX(UID) FROM JobsHistory", dbType, cs);

            if (!clsMail.SendTemplate(
                    "JobsApply",
                    clsMail.GetEmailList("AutoSystemFrom"),
                    clsMail.GetEmailList("JobsTo"),
                    new string[, ]
            {
                { "[Photo]", "<img src='" + System.Configuration.ConfigurationManager.AppSettings["website"] + "/Upload/Jobs/" + outPhoto + "'/>" },
                { "[UID]", JobsUID },
                { "[JobsName]", ddlJobs.SelectedItem.Text + (txtJobsName.Text.Trim() != ""?" (" + txtJobsName.Text.SQLQueryFilter() + ")":"") },
                { "[PrenameTH]", ddlPrenameTH.SelectedItem.Text },
                { "[ForenameTH]", txtForenameTH.Text },
                { "[SurnameTH]", txtSurnameTH.Text },
                { "[Birthdate]", ucBirthdate.DateTime.ToString("dd/MM/yyyy") },
                { "[Birthplace]", txtBirthplace.Text },
                { "[Gender]", rbGender.SelectedItem.Text },
                { "[Phone]", txtPhone.Text },
                { "[Email]", txtEmail.Text },
                { "[Start]", txtStart.Text.SQLQueryFilter() },
                { "[Education]", ucEducation.Text.SQLQueryFilter() },
                { "[Experience]", ucExperience.Text.SQLQueryFilter() },
                { "[CWhen]", DateTime.Now.ToString("dd/MM/yyyy HH:mm") }
            },
                    out outMail))
            {
                lblMessage.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะพยายามส่งอีเมล์<br/>" + outMail, clsDefault.AlertType.Fail);
                lblMessage.Focus();
                return;
            }
            #endregion
            ucColorBox1.Redirect("/Jobs/");
        }
        #endregion
        #endregion
    }
    protected void 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
    }
Exemple #10
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
 }
    protected void btSubmit_Click(object sender, EventArgs e)
    {
        #region Variable
        StringBuilder strSQL = new StringBuilder();
        string outSQL;
        string outError;
        string outPhotoName = "null";
        #endregion

        #region Check Data
        #region Find Username
        if (int.Parse(clsSQL.Return("SELECT COUNT(UID) FROM [User] WHERE Username='******'", dbType, cs)) > 0)
        {
            //lblUsername.Text = clsDefault.AlertMessageColor("Username นี้มีผู้ใช้งานแล้ว", clsDefault.AlertType.Warn);
            //lblUsername.Focus();
            txtUsername.Focus();
            ucColorBox1.Alert("ข้อมูลไม่ถูกต้อง", "Username นี้มีผู้ใช้งานแล้ว", AlertImage: ucColorBox.Alerts.Fail);
            return;
        }
        else { lblUsername.Text = ""; }
        #endregion
        #region Find Email
        if (int.Parse(clsSQL.Return("SELECT COUNT(UID) FROM [User] WHERE Email='" + clsDefault.CodeFilter(txtEMail.Text) + "'", dbType, cs)) > 0)
        {
            //lblEmail.Text = clsDefault.AlertMessageColor("Email นี้มีผู้ใช้งานแล้ว", clsDefault.AlertType.Warn);
            //lblEmail.Focus();
            txtEMail.Focus();
            ucColorBox1.Alert("ข้อมูลไม่ถูกต้อง", "E-Mail นี้มีผู้ใช้งานแล้ว", AlertImage: ucColorBox.Alerts.Fail);
            return;
        }
        else { lblEmail.Text = ""; }
        #endregion
        #region Find UID
        int UID = clsSQL.GetNewID("UID", "[User]", "", dbType, cs);
        if (UID == 0)
        {
            //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะหา UID", clsDefault.AlertType.Fail);
            //lblSQL.Focus();
            ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "ไม่สามารถหา UID ได้", AlertImage: ucColorBox.Alerts.Fail);
            return;
        }
        else{lblSQL.Text="";}
        #endregion
        #endregion

        #region Insert
        #region Photo Upload
        if (fuPhoto.HasFile)
        {
            if (!clsIO.UploadPhoto(fuPhoto, pathPhoto, clsSecurity.LoginUID, 500, photoWidth, photoHeight, "", 0, out outError, out outPhotoName))
            {
                //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะอัพโหลดภาพ : " + outError, clsDefault.AlertType.Fail);
                //lblSQL.Focus();
                ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะอัพโหลดภาพ", AlertImage: ucColorBox.Alerts.Fail);
                return;
            }
            else
            {
                outPhotoName = "'" + pathPhoto+outPhotoName + "'";
            }
        }
        #endregion
        #region SQL Insert
        if (clsSQL.Insert(
            "[USER]",
            new string[,]{
                {"UID",UID.ToString()},
				{"UserGroupUID","2"},
                {"Username","'"+clsDefault.CodeFilter(txtUsername.Text)+"'"},
                {"Password","'"+clsSecurity.Encrypt(clsDefault.CodeFilter(txtPassword.Text))+"'"},
                {"Photo",outPhotoName},
                {"PName",ddlPName.SelectedItem.Value!="null"?"'"+ddlPName.SelectedItem.Value+"'":"null"},
                {"FName","'"+clsDefault.CodeFilter(txtFName.Text)+"'"},
                {"LName","'"+clsDefault.CodeFilter(txtLName.Text)+"'"},
                {"HN","'"+clsDefault.CodeFilter(HNConvert(txtHN.Text))+"'"},
                {"BirthDate",ucDateTimeFlat1.DateTime!=DateTime.MinValue?"'"+ucDateTimeFlat1.DateTime.ToString("yyyy-MM-dd HH:mm:ss")+"'":"null"},
                {"Gender",rbGender.SelectedItem.Value!="null"?"'"+rbGender.SelectedItem.Value+"'":"null"},
                {"Phone","'"+clsDefault.CodeFilter(txtPhone.Text)+"'"},
                {"Mobile","'"+clsDefault.CodeFilter(txtMobile.Text)+"'"},
                {"Email","'"+clsDefault.CodeFilter(txtEMail.Text)+"'"},
                {"Address","'"+clsDefault.CodeFilter(txtAddress.Text)+"'"},
                {"AddressDistrict","'"+clsDefault.CodeFilter(txtAddressDistrict.Text)+"'"},
                {"AddressPrefecture","'"+clsDefault.CodeFilter(txtAddressPrefecture.Text)+"'"},
                {"AddressProvince","'"+clsDefault.CodeFilter(txtAddressProvince.Text)+"'"},
                {"AddressPostal","'"+clsDefault.CodeFilter(txtAddressPostal.Text)+"'"},
                {"Profile","'"+ucProfile.Text+"'"},
                {"Signature","'"+ucSignature.Text+"'"},
                {"CUser",UID.ToString()},
                {"CWhen","GETDATE()"},
                {"MUser",UID.ToString()},
                {"MWhen","GETDATE()"},
                {"Sort",clsDefault.CodeFilter(txtSort.Text)},
                {"Active","'0'"/*cbActive.Checked?"'1'":"'0'"+"'"*/}
            },
            new string[,] { { } },
            dbType,
            cs,
            out outSQL
        ))
        {
            clsMail clsMail = new clsMail();
            string outMessage;
            string idEncode = Server.UrlEncode(clsSecurity.Encrypt(UID.ToString()));

            #region Mail to User
            if (!clsMail.SendTemplate(
                "UserRegisterConfirm",
                clsMail.GetEmailList("GlobalFrom"),
                txtEMail.Text,
                new string[,]{
                    {"[Username]",txtUsername.Text},
                    {"[UIDEncrypt]",idEncode}
                },
                out outMessage))
            {
                //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>"+outMessage, clsDefault.AlertType.Fail);
                //lblSQL.Focus();
                ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>" + outMessage, AlertImage: ucColorBox.Alerts.Fail);
                return;
            }
            #endregion
            #region Mail to Admin
            if (!clsMail.SendTemplate(
                "UserRegisterAdmin",
                clsMail.GetEmailList("AutoSystemFrom"),
                clsMail.GetEmailList("AdminTo"),
                new string[,]{
                    {"[Username]",txtUsername.Text}
                },
                out outMessage))
            {
                ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะส่งเมล์ยืนยัน<br/>" + outMessage, AlertImage: ucColorBox.Alerts.Fail);
                return;
            }
            #endregion
        }
        else
        {
            //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะบันทึกลงฐานข้อมูล : " + outSQL, clsDefault.AlertType.Fail);
            //lblSQL.Focus();
            ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะบันทึกข้อมูลลงฐานข้อมูล : "+outSQL, AlertImage: ucColorBox.Alerts.Fail);
            return;
        }
        #endregion
        //clsDefault.Redirect("/", "บันทึกข้อมูลเรียบร้อยแล้ว");
        ucColorBox1.Redirect("/");
        #endregion
    }