Пример #1
0
    private void Approve(string id)
    {
        #region Authorize
        if (!clsSecurity.LoginChecker("admin"))
        {
            ucColorBox1.Redirect(webDefault, "กรุณาล็อคอินด้วยสิทธิ์ Admin");
            return;
        }
        #endregion
        #region Variable
        string outSQL;
        #endregion

        if (clsSQL.Update(
                tableDefault,
                new string[, ] {
            { "Active", "'1'" }
        },
                new string[, ] {
            { parameterChar + "UID", id }
        },
                "UID=" + parameterChar + "UID",
                dbType,
                cs,
                out outSQL))
        {
            ucColorBox1.Redirect(webDefault);
        }
        else
        {
            ucColorBox1.Redirect(webDefault, "เกิดข้อผิดพลาดขณะอัพเดทข้อมูล");
        }
    }
Пример #2
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 = "";
     #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[, ] {
             { "DateApprove", (!string.IsNullOrEmpty(ucDateApprove.Text)?"'" + ucDateApprove.Text + "'":"NULL") },
             { "DateSubmit", (!string.IsNullOrEmpty(ucDateSubmit.Text)?"'" + ucDateSubmit.Text + "'":"NULL") },
             { "DateInstall", (!string.IsNullOrEmpty(ucDateInstall.Text)?"'" + ucDateInstall.Text + "'":"NULL") },
             { "DateUninstall", (!string.IsNullOrEmpty(ucDateUninstall.Text)?"'" + ucDateUninstall.Text + "'":"NULL") },
             { "ProducerName", (!string.IsNullOrEmpty(txtProducerName.Text.SQLQueryFilter())?"'" + txtProducerName.Text.SQLQueryFilter() + "'":"NULL") },
             { "VerifyName", (!string.IsNullOrEmpty(txtVerifyName.Text.SQLQueryFilter())?"'" + txtVerifyName.Text.SQLQueryFilter() + "'":"NULL") },
             { "InstallName", (!string.IsNullOrEmpty(txtInstallName.Text.SQLQueryFilter())?"'" + txtInstallName.Text.SQLQueryFilter() + "'":"NULL") },
             { "MUser", "'" + clsSecurity.LoginUID + "'" },
             { "MWhen", functionGetDate }
         }, new string[, ] {
             { parameterChar + "UID", id.ToString() }
         },
                           "UID=" + parameterChar + "UID",
                           out outSQL))
         {
             ucColorBox1.ReloadParent();
         }
         else
         {
             ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail);
         }
     }
     #endregion
     #endregion
 }
Пример #3
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
    }
Пример #4
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;
        #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[, ] {
                { "Status", "'" + rbStatus.SelectedItem.Value + "'" }
            }, 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
    }
    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 Authorize
        if (!clsSecurity.LoginChecker("admin"))
        {
            ucColorBox1.Redirect("/", "กรุณาล็อคอินด้วยสิทธิ์ Admin");
            return;
        }
        #endregion
        #region Variable
        StringBuilder strSQL = new StringBuilder();
        int           id     = 0;
        string        outSQL;
        string        photoName        = "";
        string        photoPreviewName = "";
        #endregion

        #region Update
        if (Request.QueryString["id"] != null && clsDefault.QueryStringChecker("command") == "edit")
        {
            id = int.Parse(Request.QueryString["id"].ToString());
            #region Photo Upload
            if (fuPhoto.HasFile)
            {
                clsIO  clsIO = new clsIO();
                string outErrorMessage;
                string outFilename;
                string outFilenamePreview;

                #region Photo
                if (clsIO.UploadPhoto(
                        fuPhoto, pathUpload,
                        tableDefault + id.ToString(),
                        out outErrorMessage,
                        out outFilename,
                        maxWidth: photoWidth,
                        maxHeight: photoHeight))
                {
                    photoName = outFilename;
                }
                else
                {
                    ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail);
                    return;
                }
                #endregion
                #region Photo Preview
                if (clsIO.UploadPhoto(
                        fuPhoto, pathUpload,
                        tableDefault + id.ToString() + "Preview",
                        out outErrorMessage,
                        out outFilenamePreview,
                        maxWidth: photoPreviewWidth,
                        maxHeight: photoPreviewHeight))
                {
                    photoPreviewName = outFilenamePreview;
                }
                else
                {
                    ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail);
                    return;
                }
                #endregion
            }
            #endregion
            if (clsSQL.Update(tableDefault,
                              new string[, ] {
                { "UID", id.ToString() },
                { "PhotoPreview", (!string.IsNullOrEmpty(photoPreviewName)?"'" + pathUpload + photoPreviewName + "'":"PhotoPreview") },
                { "Photo", (!string.IsNullOrEmpty(photoName)?"'" + pathUpload + photoName + "'":"Photo") },
                { "Name", "'" + clsSQL.CodeFilter(txtName.Text) + "'" },
                { "Detail", "'" + clsSQL.CodeFilter(txtDetail.Text) + "'" },
                { "MUser", "'" + clsSecurity.LoginUID + "'" },
                { "MWhen", "GETDATE()" },
                { "Sort", clsSQL.CodeFilter(txtSort.Text) },
                { "Active", "'" + (cbActive.Checked ? "1" : "0") + "'" }
            }, new string[, ] {
                { parameterChar + "UID", id.ToString() }
            },
                              "UID=" + parameterChar + "UID",
                              dbType, cs, out outSQL))
            {
                ucColorBox1.ReloadParent();
            }
            else
            {
                ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail);
            }
        }
        #endregion
        #region Insert
        else
        {
            #region Find New ID
            id = clsSQL.GetNewID("UID", tableDefault, "", dbType, cs);
            if (id == 0)
            {
                ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "ไม่สามารถหา UID ใหม่ได้", AlertImage: ucColorBox.Alerts.Fail);
                return;
            }
            #endregion
            #region Photo Upload
            if (fuPhoto.HasFile)
            {
                clsIO  clsIO = new clsIO();
                string outErrorMessage;
                string outFilename;
                string outFilenamePreview;

                #region Photo
                if (clsIO.UploadPhoto(
                        fuPhoto, pathUpload,
                        tableDefault + id.ToString(),
                        out outErrorMessage,
                        out outFilename,
                        maxWidth: photoWidth,
                        maxHeight: photoHeight))
                {
                    photoName = outFilename;
                }
                else
                {
                    ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail);
                    return;
                }
                #endregion
                #region PhotoPreview
                if (clsIO.UploadPhoto(
                        fuPhoto, pathUpload,
                        tableDefault + id.ToString() + "Preview",
                        out outErrorMessage,
                        out outFilenamePreview,
                        maxWidth: photoPreviewWidth,
                        maxHeight: photoPreviewHeight))
                {
                    photoPreviewName = outFilenamePreview;
                }
                else
                {
                    ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพโหลดไฟล์รูปภาพ<br/>" + outErrorMessage, AlertImage: ucColorBox.Alerts.Fail);
                    return;
                }
                #endregion
            }
            #endregion
            if (clsSQL.Insert(tableDefault,
                              new string[, ] {
                { "UID", id.ToString() },
                { "GlobalUID", clsDefault.QueryStringChecker("globalid") },
                { "GlobalName", "'" + clsDefault.QueryStringChecker("globalname") + "'" },
                { "PhotoPreview", (!string.IsNullOrEmpty(photoPreviewName)?"'" + pathUpload + photoPreviewName + "'":"null") },
                { "Photo", (!string.IsNullOrEmpty(photoName)?"'" + pathUpload + photoName + "'":"null") },
                { "Name", "'" + clsSQL.CodeFilter(txtName.Text) + "'" },
                { "Detail", "'" + clsSQL.CodeFilter(txtDetail.Text) + "'" },
                { "[View]", "0" },
                { "CUser", "'" + clsSecurity.LoginUID + "'" },
                { "CWhen", "GETDATE()" },
                { "MUser", "'" + clsSecurity.LoginUID + "'" },
                { "MWhen", "GETDATE()" },
                { "Sort", clsSQL.CodeFilter(txtSort.Text) },
                { "Active", "'" + (cbActive.Checked ? "1" : "0") + "'" }
            }, new string[, ] {
                { }
            },
                              dbType, cs, out outSQL))
            {
                ucColorBox1.ReloadParent();
            }
            else
            {
                ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล<br/>", outSQL, AlertImage: ucColorBox.Alerts.Fail);
            }
        }
        #endregion
    }
    protected void btSubmit_Click(object sender, EventArgs e)
    {
        #region 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
    }
    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 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
    }
Пример #10
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
 }
Пример #11
0
 private static void Sync(string fileFullName)
 {
     #region Variable
     var fi = new FileInfo(fileFullName);
     var dt = new DataTable();
     var dtMain = new DataTable();
     var tblPatientStatusOnMobile = "";
     var clsSQL = new clsSQL(clsGlobal.dbType, clsGlobal.cs);
     var countSuccess = 0;
     var countFail = 0;
     var countSuccessMobileStatus = 0;
     var mailMessage = new StringBuilder();
     var outSQL = "";
     var outMessage = "";
     #endregion
     #region Procedure
     if (fi.Exists)
     {
         if (!IsFileLocked(fi))
         {
             #region FileExist
             Console.WriteLine(string.Format("Find file : {0} ({1})", "Found", fi.FullName));
             Console.WriteLine(string.Format("Read file : {0}", "Processing..."));
             dt = XMLSelecter(fi.FullName);
             Console.WriteLine(string.Format("Read file : {0}", "Completed"));
             if (dt != null && dt.Rows.Count > 0)
             {
                 Console.WriteLine(string.Format("Read DataTable : {0} ({1} Rows)", "Found", dt.Rows.Count.ToString()));
                 #region UpdateToDatabase
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
                     if (dt.Rows[i]["PatientGUID"].ToString().Trim().ToLower().Contains("new-regis"))
                     {
                         continue;
                     }
                     #region Update tblPatientListSTS & tblPatientStatusOnMobile
                     if (dt.Rows[i]["WFID"].ToString().Trim() == "1" && float.Parse(dt.Rows[i]["ProStatus"].ToString().Trim()) >= 2)
                     {
                         tblPatientStatusOnMobile = clsSQL.Return("SELECT StatusOnMobile FROM Patient WHERE rowguid='" + dt.Rows[i]["PatientGUID"].ToString().Trim() + "';");
                         if (tblPatientStatusOnMobile != "R")
                         {
                             if (clsSQL.Execute(
                                 "UPDATE tblPatientList SET STS='R',SyncWhen=GETDATE() WHERE PatientUID='" + dt.Rows[i]["PatientGUID"].ToString().Trim() + "';" +
                                 "UPDATE Patient SET SyncStatus='1',SyncWhen=GETDATE(),StatusOnMobile='R' WHERE rowguid='" + dt.Rows[i]["PatientGUID"].ToString().Trim() + "';", out outMessage))
                             {
                                 countSuccessMobileStatus += 1;
                                 Console.WriteLine(string.Format("{0} : Update MobileStatus : {1} ({2})", dt.Rows[i]["HN"].ToString(), "Success", dt.Rows[i]["HN"].ToString().Trim()));
                                 mailMessage.Append(string.Format("{0} : Update MobileStatus : {1} ({2})<br/>", dt.Rows[i]["HN"].ToString(), "<span style='color:green;'>Success</span>", dt.Rows[i]["HN"].ToString().Trim()));
                             }
                             else
                             {
                                 countFail += 1;
                                 Console.WriteLine(string.Format("{0} : Update MobileStatus : {1} ({2}) : {3}", dt.Rows[i]["HN"].ToString(), "Fail", dt.Rows[i]["HN"].ToString().Trim(), outMessage));
                                 mailMessage.Append(string.Format("{0} : Update MobileStatus : {1} ({2} : {3})<br/>", dt.Rows[i]["HN"].ToString(), "<span style='color:red;'>Fail</span>", dt.Rows[i]["HN"].ToString().Trim(), outMessage));
                             }
                         }
                     }
                     #endregion
                     #region ChecklistUpdate
                     dtMain = getPatientChecklistMain(dt.Rows[i]["RowID"].ToString());
                     if (dtMain != null && dtMain.Rows.Count > 0)
                     {
                         if (dt.Rows[i]["ProStatus"].ToString().Trim() != dtMain.Rows[0]["ProStatus"].ToString().Trim() ||
                             dt.Rows[i]["ProStatusRemark"].ToString().Trim() != dtMain.Rows[0]["ProStatusRemark"].ToString().Trim()/*||
                     dtMobile.Rows[i]["RegDate"].ToString().Trim() != dtMain.Rows[0]["RegDate"].ToString().Trim() ||
                     dtMobile.Rows[i]["ModifyDate"].ToString().Trim() != dtMain.Rows[0]["ModifyDate"].ToString().Trim()*/)
                         {
                             #region UpdateChecklist
                             if (!clsSQL.Update(
                                 "tblCheckList",
                                 new string[,]
                                 {
                             {"ProStatus",dt.Rows[i]["ProStatus"].ToString().Trim() },
                             {"ProStatusRemark","'"+dt.Rows[i]["ProStatusRemark"].ToString().SQLQueryFilter()+"'" },
                             {"RegDate",(dt.Rows[i]["RegDate"].ToString()!=""?"'"+DateTime.Parse(dt.Rows[i]["RegDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")+"'":"NULL") },
                             {"SyncWhen","GETDATE()"}
                                 },
                                 new string[,] { { } },
                                 "RowID=" + dt.Rows[i]["RowID"].ToString(), out outSQL, out outMessage, true))
                             {
                                 countFail += 1;
                                 Console.WriteLine(string.Format("{0} : Update tblChecklist : {1} ({2})", dt.Rows[i]["HN"].ToString(), "Fail", outMessage));
                                 mailMessage.Append(string.Format("{0} : Update tblChecklist : {1} ({2})<br/>", dt.Rows[i]["HN"].ToString(), "<span style='color:red;'>Fail</span>", outMessage));
                             }
                             else
                             {
                                 #region LogUpdate
                                 countSuccess += 1;
                                 Console.WriteLine(string.Format("{0} : Update tblChecklist : {1} ({2})", dt.Rows[i]["HN"].ToString(), "Success", dtMain.Rows[0]["ProStatus"].ToString().Trim() + "->" + dt.Rows[i]["ProStatus"].ToString().Trim()));
                                 mailMessage.Append(string.Format("{0} : Update tblChecklist : {1} ({2})<br/>", dt.Rows[i]["HN"].ToString(), "<span style='color:green;'>Success</span>", dtMain.Rows[0]["ProStatus"].ToString().Trim() + "->" + dt.Rows[i]["ProStatus"].ToString().Trim()));
                                 #endregion
                             }
                             #endregion
                         }
                     }
                     else
                     {
                         mailMessage.Append("ไม่พบข้อมูลในไฟล์");
                     }
                     #endregion
                 }
                 #endregion
                 Console.WriteLine(string.Format("Summary : Success {0} Fail {1}", countSuccess.ToString(), countFail.ToString()));
                 Console.WriteLine(string.Format("MailSend : {0}", "Processing..."));
                 try
                 {
                     if (countSuccessMobileStatus > 0 || countSuccess > 0 || countFail > 0)
                     {
                         wsDefault.ServiceSoapClient wsDefault = new wsDefault.ServiceSoapClient();
                         if (wsDefault.MailSend(
                             System.Configuration.ConfigurationManager.AppSettings["mailTo"],
                             System.Configuration.ConfigurationManager.AppSettings["site"] + " : " + clsGlobal.ApplicationName + " Console Sync",
                             "<h1>" + System.Configuration.ConfigurationManager.AppSettings["site"] + " : " + clsGlobal.ApplicationName + " Console Sync" + "</h1><h3><span style='color:#238DBB;'>StatusUpdateSuccess : " + countSuccessMobileStatus.ToString() + "</span> , <span style='color:green;'>Success : " + countSuccess.ToString() + "</span> , <span style='color:red;'>Fail : " + countFail.ToString() + "</span></h3><h4>FileName : " + fileFullName + "</h4><hr/>" + mailMessage.ToString(),
                             "*****@*****.**",
                             System.Configuration.ConfigurationManager.AppSettings["site"] + " : " + clsGlobal.ApplicationName,
                             "", "", "<b>ServerIP</b> : " + clsGlobal.IPAddress() + "<br/><b>ExecutePath</b> : " + clsGlobal.ExecutePathBuilder() + "<br/><b>Application Version</b> : " + clsGlobal.ApplicationVersion(), false))
                         {
                             Console.WriteLine(string.Format("MailSend : {0}", "Success"));
                         }
                         else
                         {
                             Console.WriteLine(string.Format("MailSend : {0}", "Fail"));
                         }
                     }
                 }
                 catch (Exception exMail)
                 {
                     Console.WriteLine(string.Format("MailSend : {0}", "Fail : " + exMail.Message));
                 }
             }
             else
             {
                 Console.WriteLine(string.Format("Read DataTable : {0}", "No Data"));
             }
             try
             {
                 fi.Delete();
             }
             catch (Exception exDelete)
             {
                 Console.WriteLine(string.Format("Delete file : {0} ({1})", "Fail", exDelete.Message));
             }
             #endregion
         }
         else
         {
             Console.WriteLine(string.Format("Read File : {0} ({1})", "Fail", "FileIsLocked"));
         }
     }
     else
     {
         //ไม่เจอไฟล์ก็จบไป
     }
     #endregion
 }
    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
    }
Пример #13
0
 public string setPatientChecklistToMobile(string PatientGUID, string Episode, string HN, out int countChecklistSuccess, out int countChecklistExist, out int countChecklistFail, out int countChecklistUpdate)
 {
     System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
     #region Variable
     var result = "F";//F=False , S=Success , E=Exist , U=Update
     var dt = new DataTable();
     var outSQL = "";
     var clsSQLMain = new clsSQL(clsGlobal.dbTypeMain, clsGlobal.csMain);
     var clsSQLMobile = new clsSQL(clsGlobal.dbType, clsGlobal.cs);
     var clsTempData = new clsTempData();
     var strSQL = "";
     countChecklistSuccess = 0; countChecklistFail = 0; countChecklistExist = 0; countChecklistUpdate = 0;
     #endregion
     #region Procedure
     dt = clsTempData.getPatientChecklist(PatientGUID, Episode, HN);
     if (dt != null && dt.Rows.Count > 0)
     {
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             var proStatusMobile = "";
             strSQL = "SELECT IFNULL(ProStatus,0)ProStatus FROM patientchecklist WHERE RowID=" + dt.Rows[i]["RowID"].ToString() + ";";
             proStatusMobile = clsSQLMobile.Return(strSQL);
             if (proStatusMobile == "")
             {
                 #region Insert
                 if (!clsSQLMobile.Insert(
                     "patientchecklist",
                     new string[,]
                     {
                         {"RowID",dt.Rows[i]["RowID"].ToString() },
                         {"PatientGUID","'"+PatientGUID+"'" },
                         {"HN","'"+HN+"'" },
                         {"Episode","'"+Episode+"'" },
                         {"CheckListID",dt.Rows[i]["CheckListID"].ToString() },
                         {"ProChkList","'"+dt.Rows[i]["ProChkList"].ToString()+"'" },
                         {"ProID",dt.Rows[i]["ProID"].ToString() },
                         {"WorkFlow","'"+dt.Rows[i]["WorkFlow"].ToString()+"'" },
                         {"WFID",dt.Rows[i]["WFID"].ToString() },
                         {"WFSequen",dt.Rows[i]["WFSequen"].ToString() },
                         {"ProStatus",dt.Rows[i]["ProStatus"].ToString() },
                         {"RegDate","NULL" },
                         {"ModifyDate","NULL" },
                         {"SyncStatus",(dt.Rows[i]["SyncWhen"]!=DBNull.Value?"'1'":"'0'") },
                         {"SyncWhen",(dt.Rows[i]["SyncWhen"]!=DBNull.Value?"'"+DateTime.Parse(dt.Rows[i]["SyncWhen"].ToString()).ToString("yyyy-MM-dd HH:mm")+"'":"NULL") },
                         {"CUser","'"+clsGlobal.WindowsLogon()+"'" },
                         {"MWhen","NOW()" },
                         {"MUser","'"+clsGlobal.WindowsLogon()+"'" },
                     },
                     new string[,] { { } },
                     out outSQL, true
                     ))
                 {
                     result = "F";
                     countChecklistFail += 1;
                 }
                 else
                 {
                     result = "S";
                     countChecklistSuccess += 1;
                 }
                 #endregion
             }
             else if (int.Parse(dt.Rows[i]["ProStatus"].ToString()) > int.Parse(proStatusMobile))
             {
                 #region Update
                 if (!clsSQLMobile.Update(
                     "patientchecklist",
                     new string[,]
                     {
                         {"ProStatus",dt.Rows[i]["ProStatus"].ToString() },
                         {"RegDate",(dt.Rows[i]["RegDate"]!=DBNull.Value?"'"+DateTime.Parse(dt.Rows[i]["RegDate"].ToString()).ToString("yyyy-MM-dd HH:mm")+"'":"NULL") },
                         {"ModifyDate",(dt.Rows[i]["ModifyDate"]!=DBNull.Value?"'"+DateTime.Parse(dt.Rows[i]["ModifyDate"].ToString()).ToString("yyyy-MM-dd HH:mm")+"'":"NULL") },
                         {"SyncStatus","'0'" },
                         {"SyncWhen","NOW()" },
                         {"CUser","'"+clsGlobal.WindowsLogon()+"'" },
                         {"MWhen","NOW()" },
                         {"MUser","'"+clsGlobal.WindowsLogon()+"'" },
                     },
                     new string[,] { { } },
                     "RowID="+ dt.Rows[i]["RowID"].ToString(),
                     out outSQL, true
                     ))
                 {
                     result = "F";
                     countChecklistFail += 1;
                 }
                 else
                 {
                     result = "U";
                     countChecklistUpdate += 1;
                 }
                 #endregion
             }
             else
             {
                 result = "E";
                 countChecklistExist += 1;
             }
         }
     }
     #endregion
     return result;
 }
Пример #14
0
    private void WebboardGroupBuilder(string webboardGroupUID)
    {
        #region Variable
        StringBuilder strSQL = new StringBuilder();
        DataTable     dt     = new DataTable();
        string        outSQL;
        #endregion
        #region Update Views
        if (!clsSQL.Update(
                "WebboardGroup",
                new string[, ] {
            { "Views", "Views+1" }
        },
                new string[, ] {
            { parameterChar + "UID", webboardGroupUID }
        },
                "UID=" + parameterChar + "UID",
                dbType,
                cs,
                out outSQL))
        {
            ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพเดทจำนวน Views<br/>" + outSQL, AlertImage: ucColorBox.Alerts.Fail);
            return;
        }
        #endregion
        #region Data Builder
        #region SQL Query
        strSQL.Append("SELECT ");
        strSQL.Append("Icon,");
        strSQL.Append("Name,");
        strSQL.Append("Detail,");
        strSQL.Append("MetaKeywords,");
        strSQL.Append("MetaDescription ");
        strSQL.Append("FROM ");
        strSQL.Append("WebboardGroup ");
        strSQL.Append("WHERE ");
        strSQL.Append("UID=" + parameterChar + "UID ");
        #endregion
        dt = clsSQL.Bind(strSQL.ToString(), new string[, ] {
            { parameterChar + "UID", webboardGroupUID }
        }, dbType, cs);
        if (dt != null && dt.Rows.Count > 0)
        {
            this.Title = "โรงพยาบาลกรุงเทพจันทบุรี | Webboard : " + dt.Rows[0]["Name"].ToString();
            if (dt.Rows[0]["MetaKeywords"].ToString().Trim() != "")
            {
                this.MetaKeywords = dt.Rows[0]["MetaKeywords"].ToString();
            }
            if (dt.Rows[0]["MetaDescription"].ToString().Trim() != "")
            {
                this.MetaDescription = dt.Rows[0]["MetaDescription"].ToString();
            }
            else
            {
                this.MetaDescription = dt.Rows[0]["Name"].ToString();
            }

            lblHeaderName.Text     = dt.Rows[0]["Name"].ToString();
            lblHeaderDetail.Text   = dt.Rows[0]["Detail"].ToString();
            imgHeaderIcon.ImageUrl = dt.Rows[0]["Icon"].ToString();
        }
        #endregion
    }
Пример #15
0
    protected void btSubmit_Click(object sender, EventArgs e)
    {
        #region Security
        if (!clsSecurity.LoginChecker())
        {
            //clsDefault.Redirect("/Register", "กรุณาสมัครสมาชิก หรือ ล็อคอิน ก่อนเข้าใช้งาน");
            ucColorBox1.Redirect("/Register", "กรุณาสมัครสมาชิก หรือ ล็อคอินก่อนเข้าใช้งาน");
        }
        #endregion

        #region Variable
        StringBuilder strSQL = new StringBuilder();
        string        outSQL;
        string        outError;
        string        outPhotoName = "Photo";
        #endregion

        #region Update
        #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);
                ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะอัพโหลดภาพ : " + outError, AlertImage: ucColorBox.Alerts.Fail);
                return;
            }
            else
            {
                outPhotoName = "'" + pathPhoto + outPhotoName + "'";
            }
        }
        #endregion
        #region Check Data
        if (int.Parse(clsSQL.Return("SELECT COUNT(UID) FROM [USER] WHERE UID='" + clsSecurity.LoginUID + "' AND Password='******'", dbType, cs)) == 0)
        {
            //lblPassword.Text = clsDefault.AlertMessageColor("Password ที่คุณกรอกไม่ถูกต้อง", clsDefault.AlertType.Warn);
            ucColorBox1.Alert("ข้อมูลไม่ถูกต้อง", "Password ที่คุณกรอกไม่ถูกต้อง", AlertImage: ucColorBox.Alerts.Fail);
            lblPassword.Focus();
            return;
        }
        #endregion
        #region SQL Update
        if (!clsSQL.Update(
                "[User]",
                new string[, ] {
            { "Password", txtPasswordChange.Text.Trim() != ""?"'" + clsSecurity.Encrypt(clsDefault.CodeFilter(txtPasswordChange.Text)) + "'":"Password" },
            { "Photo", outPhotoName },
            { "UserGroupUID", "'" + ddlUserGroup.SelectedItem.Value + "'" },
            { "HN", "'" + clsDefault.CodeFilter(txtHN.Text) + "'" },
            { "PName", ddlPName.SelectedItem.Value != "null"?"'" + ddlPName.SelectedItem.Value + "'":"null" },
            { "FName", "'" + clsDefault.CodeFilter(txtFName.Text) + "'" },
            { "LName", "'" + clsDefault.CodeFilter(txtLName.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 + "'" },
            { "MUser", clsSecurity.LoginUID },
            { "MWhen", "GETDATE()" },
            { "Sort", clsDefault.CodeFilter(txtSort.Text) },
            { "Active", cbActive.Checked?"'1'":"'0'" + "'" }
        },
                new string[, ] {
            { "" + parameterChar + "UID", clsSecurity.LoginUID }
        },
                "UID=" + parameterChar + "UID",
                dbType,
                cs,
                out outSQL
                ))
        {
            //lblSQL.Text = clsDefault.AlertMessageColor("เกิดข้อผิดพลาดขณะบันทึกลงฐานข้อมูล : " + outSQL, clsDefault.AlertType.Fail);
            ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", "เกิดข้อผิดพลาดขณะบันทึกลงฐานข้อมูล : " + outSQL, AlertImage: ucColorBox.Alerts.Fail);
            return;
        }
        #endregion
        //clsDefault.Redirect("/", "บันทึกข้อมูลเรียบร้อยแล้ว");
        ucColorBox1.Redirect("/", "บันทึกข้อมูลเรียบร้อยแล้ว");
        #endregion
    }
Пример #16
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 = "";
     #endregion
     #region Procedure
     #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", "'" + ucContent.Text.SQLQueryFilter() + "'" },
             { "ContentEN", "'" + ucContentEN.Text.SQLQueryFilter() + "'" },
             { "MUser", clsSecurity.LoginUID },
             { "MWhen", functionGetDate },
             { "Sort", txtSort.Text.SQLQueryFilter() },
             { "StatusFlag", "'" + (cbActive.Checked ? "A" : "I") + "'" }
         }, new string[, ] {
             { }
         },
                           "UID=" + id.ToString(),
                           out outSQL))
         {
             ucColorBox1.ReloadParent();
         }
         else
         {
             ucColorBox1.Alert("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", outSQL, AlertImage: ucColorBox.Alerts.Fail);
         }
     }
     #endregion
     #region Insert
     else
     {
         if (clsSQL.Insert("Content",
                           new string[, ] {
             { "Name", "'" + txtName.Text.SQLQueryFilter() + "'" },
             { "Detail", "'" + txtDetail.Text.SQLQueryFilter() + "'" },
             { "Content", "'" + ucContent.Text.SQLQueryFilter() + "'" },
             { "ContentEN", "'" + ucContentEN.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("เกิดข้อผิดพลาดขณะบันทึกข้อมูล", 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
 }
Пример #19
0
    private void WebboardQuestionBuilder(string webboardGroupUID, string webboardQuestionUID)
    {
        #region Variable
        StringBuilder strSQL = new StringBuilder();
        DataTable     dt     = new DataTable();
        string        outSQL;
        #endregion
        #region Update Views
        if (!clsSQL.Update(
                "WebboardQuestion",
                new string[, ] {
            { "Views", "Views+1" }
        },
                new string[, ] {
            { parameterChar + "UID", webboardQuestionUID }
        },
                "UID=" + parameterChar + "UID",
                dbType,
                cs,
                out outSQL))
        {
            ucColorBox1.Alert("เกิดข้อผิดพลาด", "เกิดข้อผิดพลาดขณะอัพเดทจำนวน Views<br/>" + outSQL, AlertImage: ucColorBox.Alerts.Fail);
            return;
        }
        #endregion
        #region Data Builder
        #region SQL Query
        strSQL.Append("SELECT ");
        strSQL.Append("Q.WebboardGroupUID,");
        strSQL.Append("Q.Photo,");
        strSQL.Append("Q.Name,");
        strSQL.Append("Q.Detail,");
        strSQL.Append("Q.MetaKeywords,");
        strSQL.Append("Q.MetaDescription,");
        strSQL.Append("Q.Views,");
        strSQL.Append("Q.CName,");
        strSQL.Append("Q.CEmail,");
        strSQL.Append("Q.CIPAddress,");
        strSQL.Append("Q.CComputerName,");
        strSQL.Append("Q.MIPAddress,");
        strSQL.Append("Q.MComputerName,");
        strSQL.Append("Q.CWhen,");
        strSQL.Append("Q.MWhen,");
        strSQL.Append("Q.Active,");
        strSQL.Append("[User].Username,");
        strSQL.Append("[User].Photo UserPhoto ");
        strSQL.Append("FROM ");
        strSQL.Append("WebboardQuestion Q ");
        strSQL.Append("LEFT JOIN ");
        strSQL.Append("[User] ON Q.CUser=[User].UID ");
        strSQL.Append("WHERE ");
        strSQL.Append("Q.UID=" + parameterChar + "UID ");
        if (clsSecurity.LoginGroup != "Admin")
        {
            strSQL.Append("AND Q.Active='1'");
        }
        #endregion
        dt = clsSQL.Bind(strSQL.ToString(), new string[, ] {
            { parameterChar + "UID", webboardQuestionUID }
        }, dbType, cs);
        if (dt != null && dt.Rows.Count > 0)
        {
            #region Header
            this.Title = "โรงพยาบาลกรุงเทพจันทบุรี | Webboard : " + dt.Rows[0]["Name"].ToString();
            if (dt.Rows[0]["MetaKeywords"].ToString().Trim() != "")
            {
                this.MetaKeywords = dt.Rows[0]["MetaKeywords"].ToString();
            }
            if (dt.Rows[0]["MetaDescription"].ToString().Trim() != "")
            {
                this.MetaDescription = dt.Rows[0]["MetaDescription"].ToString();
            }
            else
            {
                this.MetaDescription = dt.Rows[0]["Name"].ToString();
            }
            lblUser.Text = (
                dt.Rows[0]["Username"] != DBNull.Value ?
                "<span class='UserMember'><b>" + dt.Rows[0]["Username"].ToString() + "</b></span>" :
                dt.Rows[0]["CName"].ToString()
                );
            lblCWhen.Text = "<span title='" + DateTime.Parse(dt.Rows[0]["CWhen"].ToString()).ToString("dd/MM/yyyy HH:mm") + "'>" +
                            DateTime.Parse(dt.Rows[0]["CWhen"].ToString()).ToString("dd/MM/yyyy") +
                            "</span>";
            imgHeaderIcon.ImageUrl = (
                dt.Rows[0]["UserPhoto"] != DBNull.Value ?
                dt.Rows[0]["UserPhoto"].ToString() :
                "/Webboard/Images/icUser.png"
                );
            lblIPAddress.Text = dt.Rows[0]["CIPAddress"].ToString();
            if (dt.Rows[0]["Active"].ToString() == "0")
            {
                lblStatus.Text = "<span style='font-weight:normal;padding-left:10px;'><span class='Icon16 Warn Normal'></span> Hidden</span>";
            }
            #endregion

            lblHeaderName.Text = dt.Rows[0]["Name"].ToString();
            if (dt.Rows[0]["Photo"] != DBNull.Value && !string.IsNullOrEmpty(dt.Rows[0]["Photo"].ToString()))
            {
                lblDetail.Text = "<div style='text-align:center;padding:10px;background-color:#fcfcfc;border-bottom:1px dashed #EEE;'><img src='" + dt.Rows[0]["Photo"].ToString() + "' alt='" + dt.Rows[0]["Name"].ToString() + "'/></div>";
            }
            lblDetail.Text += "<div style='padding:20px;'>" + dt.Rows[0]["Detail"].ToString() + "</div>";
        }
        #endregion
    }