예제 #1
0
    // 伺服器位址(網域名稱)驗證
    protected void bn_TopLevelDomain_Click(object sender, EventArgs e)
    {
        Check_Internet cknet = new Check_Internet();
        int ckint = -1;

        tb_TopLevelDomain.Text = tb_TopLevelDomain.Text.Trim();

        ckint = cknet.Check_TopLevelDomain(tb_TopLevelDomain.Text);
        if (ckint == 0)
            lb_TopLevelDomain.Text = "正確";
        else
            lb_TopLevelDomain.Text = "錯誤 (錯誤代碼:" + ckint.ToString() + ")";
    }
예제 #2
0
    // 存檔
    protected void lk_save_Click(object sender, EventArgs e)
    {
        int ckint = 0;
        string SqlString = "", mErr = "";
        Check_Internet cknet = new Check_Internet();

        if (cknet.Check_Host(tb_host.Text.Trim()) != 0)
            mErr += "主機名稱錯誤!\\n";

        if (int.TryParse(tb_port.Text, out ckint))
        {
            if (ckint < 1 || ckint > 65534)
                mErr += "通訊 Port 請輸入 1 ~ 65534 之間的數字!\\n";
        }
        else
            mErr += "通訊 Port 請輸入數字!\\n";

        if (tb_id.Text.Trim() == "")
            mErr += "豋入帳號不可空白!\\n";

        if (tb_pw.Text.Trim() == "")
            mErr += "豋入密碼不可空白!\\n";

        if (mErr == "")
        {
            using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString))
            {
                SqlString = "Update Sys_Param Set sp_str = @host Where sp_no = '901';";
                SqlString += "Update Sys_Param Set sp_num = @port Where sp_no = '902';";
                SqlString += "Update Sys_Param Set sp_str = @id Where sp_no = '903';";
                SqlString += "Update Sys_Param Set sp_str = @pw Where sp_no = '904';";

                using (SqlCommand Sql_Command = new SqlCommand(SqlString, Sql_Conn))
                {
                    Sql_Conn.Open();

                    Sql_Command.Parameters.AddWithValue("host", tb_host.Text.Trim());
                    Sql_Command.Parameters.AddWithValue("port", tb_port.Text.Trim());
                    Sql_Command.Parameters.AddWithValue("id", tb_id.Text.Trim());
                    Sql_Command.Parameters.AddWithValue("pw", tb_pw.Text.Trim());

                    Sql_Command.ExecuteNonQuery();

                    Sql_Conn.Close();
                }
            }
            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "alert(\"儲存完成!\\n\");parent.close_all();", true);
        }
        else
            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "alert(\"" + mErr + "\");", true);
    }
예제 #3
0
    // 存檔
    protected void lk_save_Click(object sender, EventArgs e)
    {
        int ckint = 0;
        string SqlString = "", mErr = "";
        Check_Internet cknet = new Check_Internet();

        if (cknet.Check_Host(tb_ppa_host.Text.Trim()) != 0)
            mErr += "主機名稱錯誤!\\n";

        if (int.TryParse(tb_ppa_port.Text, out ckint))
        {
            if (ckint < 1 || ckint > 65534)
                mErr += "通訊埠請輸入 1 ~ 65534 之間的數字!\\n";
        }
        else
            mErr += "通訊埠請輸入數字!\\n";

        if (tb_ppa_id.Text.Trim() == "")
            mErr += "豋入帳號不可空白!\\n";

        if (tb_ppa_pw.Text.Trim() == "")
            mErr += "豋入密碼不可空白!\\n";

        if (mErr == "")
        {
            using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString))
            {
                SqlString = "Update POP3_Account Set ppa_host = @ppa_host, ppa_port = @ppa_port, ppa_id = @ppa_id";
                SqlString += ", ppa_pw = @ppa_pw, init_time = getdate() Where ppa_sid = @ppa_sid";

                using (SqlCommand Sql_Command = new SqlCommand(SqlString, Sql_Conn))
                {
                    Sql_Conn.Open();

                    Sql_Command.Parameters.AddWithValue("ppa_host", tb_ppa_host.Text.Trim());
                    Sql_Command.Parameters.AddWithValue("ppa_port", tb_ppa_port.Text.Trim());
                    Sql_Command.Parameters.AddWithValue("ppa_id", tb_ppa_id.Text.Trim());
                    Sql_Command.Parameters.AddWithValue("ppa_pw", tb_ppa_pw.Text.Trim());
                    Sql_Command.Parameters.AddWithValue("ppa_sid", lb_ppa_sid.Text);

                    Sql_Command.ExecuteNonQuery();

                    Sql_Conn.Close();
                }
            }
            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "alert(\"儲存完成!\\n\");parent.location.replace('9002.aspx');", true);
        }
        else
            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "alert(\"" + mErr + "\");", true);
    }
예제 #4
0
    // 新增前判斷及處理
    protected void ods_Ad_Member_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
    {
        Check_Internet cknet = new Check_Internet();
        string mErr = "", adb_email = "";

        if (e.InputParameters["adb_name"] != null)
        {
            if (e.InputParameters["adb_name"].ToString().Trim() == "")
                mErr += "請輸入會員姓名!\\n";
        }
        else
            mErr += "請輸入會員姓名!\\n";

        if (e.InputParameters["adb_email"] != null)
        {
            // 電子信箱一律轉成小寫
            adb_email = e.InputParameters["adb_email"].ToString().Trim().ToLower();
        }

        if (adb_email == "")
            mErr += "請輸入電子郵件信箱!\\n";
        else
        {
            if (cknet.Check_Email(adb_email) != 0)
                mErr = "電子郵件信箱格式錯誤!\\n";
            else
                e.InputParameters["adb_email"] = adb_email;
        }

        if (mErr != "")
        {
            mErr += "無法新增,請重新輸入!\\n";

            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "alert(\"" + mErr + "\");add_display();", true);
            e.Cancel = true;		// 取消新增動件
        }
    }
예제 #5
0
    // 存檔
    protected void lk_save_Click(object sender, EventArgs e)
    {
        string mErr = "", SqlString = "", tmpstr = "";
        int fr_sex = 0, fr_symbol = 0, icnt = 0;
        Check_Internet cki = new Check_Internet();

        tb_fr_name.Text = tb_fr_name.Text.Trim();
        if (tb_fr_name.Text.Length < 2)
            mErr += "請輸入「姓名」!\\n";

        if (rb_fr_sex1.Checked || rb_fr_sex2.Checked)
        {
            if (rb_fr_sex1.Checked)
                fr_sex = 1;
            else
                fr_sex = 2;
        }
        else
            mErr += "請選擇「性別」!\\n";

        tb_fr_email.Text = tb_fr_email.Text.Trim();
        if (cki.Check_Email(tb_fr_email.Text) != 0)
            mErr += "請輸入正確的「E-Mail」格式!\\n";

        tb_fr_desc.Text = tb_fr_desc.Text.Trim();
        if (tb_fr_desc.Text.Length < 2)
            mErr += "請輸入正確的「回應內容」文字!\\n";

        if (tb_confirm.Text.Trim() != Session["D001"].ToString())
        {
            mErr += "驗證碼輸入錯誤!\\n";
            tb_confirm.Text = "";

            // 重新產生驗證碼
            Session["D001"] = getConfirmCode();
        }

        // 心情符號
        for (icnt = 0; icnt < 18; icnt++)
        {
            tmpstr = "rb_fr_symbol" + icnt.ToString().PadLeft(2, '0');

            RadioButton rb_tmp = (RadioButton)Page.FindControl(tmpstr);
            if (rb_tmp != null)
            {
                if (rb_tmp.Checked)
                    fr_symbol = icnt;
            }
        }

        if (mErr == "")
        {
            using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString))
            {

                using (SqlCommand Sql_Command = new SqlCommand(SqlString, Sql_Conn))
                {
                    Sql_Command.Connection = Sql_Conn;

                    #region 儲存資料
                    Sql_Conn.Open();

                    SqlString = "Insert Into Fm_Response (ff_sid, fr_symbol, fr_name, fr_sex, fr_email, fr_ip, fr_desc)";
                    SqlString += " Values (@ff_sid, @fr_symbol, @fr_name, @fr_sex, @fr_email, @fr_ip, @fr_desc);";

                    Sql_Command.CommandText = SqlString;

                    Sql_Command.Parameters.Clear();
                    Sql_Command.Parameters.AddWithValue("ff_sid", lb_ff_sid.Text);
                    Sql_Command.Parameters.AddWithValue("fr_symbol", fr_symbol);
                    Sql_Command.Parameters.AddWithValue("fr_name", tb_fr_name.Text);
                    Sql_Command.Parameters.AddWithValue("fr_sex", fr_sex);
                    Sql_Command.Parameters.AddWithValue("fr_email", tb_fr_email.Text);
                    Sql_Command.Parameters.AddWithValue("fr_ip", Request.ServerVariables["REMOTE_ADDR"]);
                    Sql_Command.Parameters.AddWithValue("fr_desc", tb_fr_desc.Text.Replace("\r\n","<br>"));

                    Sql_Command.ExecuteNonQuery();

                    Sql_Conn.Close();
                    #endregion

                    #region 重新統計回應篇數
                    Sql_Conn.Open();

                    SqlString = "Update Fm_Forum Set ff_response = (Select Count(*) From Fm_Response Where ff_sid = @ff_sid And is_close = 1)";
                    SqlString += " Where ff_sid = @ff_sid";

                    Sql_Command.CommandText = SqlString;

                    Sql_Command.Parameters.Clear();
                    Sql_Command.Parameters.AddWithValue("ff_sid", lb_ff_sid.Text);

                    Sql_Command.ExecuteNonQuery();

                    Sql_Conn.Close();
                    #endregion
                }
            }
        }

        if (mErr == "")
        {
            // 移除 Session
            Session.Contents.Remove("D001");

            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "parent.location.reload(true);", true);
        }
        else
            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "alert(\"" + mErr + "\");", true);
    }
예제 #6
0
    // 存檔
    protected void lk_save_Click(object sender, EventArgs e)
    {
        string mErr = "", SqlString = "", tmpstr = "";
        int mb_sex = 0, mb_symbol = 0, icnt = 0;
        Check_Internet cki = new Check_Internet();

        tb_mb_name.Text = tb_mb_name.Text.Trim();
        if (tb_mb_name.Text.Length < 2)
            mErr += "請輸入「姓名」!\\n";

        if (rb_mb_sex1.Checked || rb_mb_sex2.Checked)
        {
            if (rb_mb_sex1.Checked)
                mb_sex = 1;
            else
                mb_sex = 2;
        }
        else
            mErr += "請選擇「性別」!\\n";

        tb_mb_email.Text = tb_mb_email.Text.Trim();
        if (cki.Check_Email(tb_mb_email.Text) != 0)
            mErr += "請輸入正確的「E-Mail」格式!\\n";

        tb_mb_desc.Text = tb_mb_desc.Text.Trim();
        if (tb_mb_desc.Text.Length < 4)
            mErr += "請輸入正確的留言「內容」文字!\\n";

        if (tb_confirm.Text.Trim() != Session["C001"].ToString())
        {
            mErr += "驗證碼輸入錯誤!\\n";
            tb_confirm.Text = "";

            // 重新產生驗證碼
            Session["C001"] = getConfirmCode();
        }

        // 心情符號
        for (icnt = 0; icnt < 18; icnt++)
        {
            tmpstr = "rb_mb_symbol" + icnt.ToString().PadLeft(2, '0');

            RadioButton rb_tmp = (RadioButton)Page.FindControl(tmpstr);
            if (rb_tmp != null)
            {
                if (rb_tmp.Checked)
                    mb_symbol = icnt;
            }
        }

        if (mErr == "")
        {
            using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString))
            {
                SqlString = "Insert Into Ms_Board (mb_symbol, mb_name, mb_sex, mb_email, mb_ip, mb_desc)";
                SqlString += " Values (@mb_symbol, @mb_name, @mb_sex, @mb_email, @mb_ip, @mb_desc);";

                using (SqlCommand Sql_Command = new SqlCommand(SqlString, Sql_Conn))
                {
                    Sql_Conn.Open();

                    Sql_Command.Parameters.AddWithValue("mb_symbol", mb_symbol);
                    Sql_Command.Parameters.AddWithValue("mb_name", tb_mb_name.Text);
                    Sql_Command.Parameters.AddWithValue("mb_sex", mb_sex);
                    Sql_Command.Parameters.AddWithValue("mb_email", tb_mb_email.Text);
                    Sql_Command.Parameters.AddWithValue("mb_ip", Request.ServerVariables["REMOTE_ADDR"]);
                    Sql_Command.Parameters.AddWithValue("mb_desc", tb_mb_desc.Text.Replace("\r\n","<br>"));

                    Sql_Command.ExecuteNonQuery();
                }
            }
        }

        if (mErr == "")
        {
            // 移除 Session
            Session.Contents.Remove("C001");

            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "parent.location.replace(\"C001.aspx\");", true);
        }
        else
            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "alert(\"" + mErr + "\");", true);
    }
예제 #7
0
    // 修改前的判斷及處理
    protected void ods_Ad_List_Updating(object sender, ObjectDataSourceMethodEventArgs e)
    {
        Check_Internet cknet = new Check_Internet();
        string mErr = "", adl_email = "";

        if (e.InputParameters["adl_email"] == null)
            mErr = "請輸入電子郵件信箱!\\n";
        else
        {
            // 電子信箱一律轉成小寫
            adl_email = e.InputParameters["adl_email"].ToString().Trim().ToLower();
            if (adl_email == "")
                mErr += "請輸入電子郵件信箱!\\n";
            else
            {
                if (cknet.Check_Email(adl_email) != 0)
                    mErr = "電子郵件信箱錯誤!!\\n" + adl_email;
                else
                    e.InputParameters["adl_email"] = adl_email;
            }
        }

        if (mErr == "")
            e.InputParameters["adm_sid"] = lb_adm_sid.Text;
        else {
            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "alert(\"" + mErr + "\");", true);
            e.Cancel = true;		// 取消修改動作
        }
    }
예제 #8
0
    // 存檔
    protected void lk_save_Click(object sender, EventArgs e)
    {
        string mErr = "", SqlString = "", tmpstr = "";
        int fr_sex = 0, fr_symbol = 0, icnt = 0, is_show = 0, is_close = 0;
        Check_Internet cki = new Check_Internet();

        tb_fr_name.Text = tb_fr_name.Text.Trim();
        if (tb_fr_name.Text.Length < 2)
            mErr += "請輸入「姓名」!\\n";

        if (rb_fr_sex1.Checked || rb_fr_sex2.Checked)
        {
            if (rb_fr_sex1.Checked)
                fr_sex = 1;
            else
                fr_sex = 2;
        }
        else
            mErr += "請選擇「性別」!\\n";

        tb_fr_email.Text = tb_fr_email.Text.Trim();
        if (cki.Check_Email(tb_fr_email.Text) != 0)
            mErr += "請輸入正確的「E-Mail」格式!\\n";

        tb_fr_desc.Text = tb_fr_desc.Text.Trim();
        if (tb_fr_desc.Text.Length < 4)
            mErr += "請輸入正確的「內容」文字!\\n";

        // 心情符號
        for (icnt = 0; icnt < 18; icnt++)
        {
            tmpstr = "rb_fr_symbol" + icnt.ToString().PadLeft(2, '0');

            RadioButton rb_tmp = (RadioButton)Page.FindControl(tmpstr);
            if (rb_tmp != null)
            {
                if (rb_tmp.Checked)
                    fr_symbol = icnt;
            }
        }

        tb_instead.Text = tb_instead.Text.Trim();
        if (rb_is_show0.Checked)
        {
            is_show = 0;
            if (tb_instead.Text == "")
                mErr = "請輸入「替代文字」!\\n";
        }
        else
            is_show = 1;

        if (rb_is_close0.Checked)
            is_close = 0;
        else
            is_close = 1;

        if (mErr == "")
        {
            using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString))
            {
                using (SqlCommand Sql_Command = new SqlCommand())
                {
                    Sql_Command.Connection = Sql_Conn;

                    SqlString = "Update Fm_Response Set fr_symbol = @fr_symbol, fr_name = @fr_name, fr_sex = @fr_sex";
                    SqlString += ", fr_email = @fr_email, fr_desc = @fr_desc, is_show = @is_show";
                    SqlString += ", instead = @instead, is_close = @is_close Where ff_sid = @ff_sid And fr_sid = @fr_sid;";

                    #region 儲存資料
                    Sql_Conn.Open();

                    Sql_Command.CommandText = SqlString;

                    Sql_Command.Parameters.Clear();
                    Sql_Command.Parameters.AddWithValue("ff_sid", ff_sid);
                    Sql_Command.Parameters.AddWithValue("fr_sid", fr_sid);
                    Sql_Command.Parameters.AddWithValue("fr_symbol", fr_symbol);
                    Sql_Command.Parameters.AddWithValue("fr_name", tb_fr_name.Text);
                    Sql_Command.Parameters.AddWithValue("fr_sex", fr_sex);
                    Sql_Command.Parameters.AddWithValue("fr_email", tb_fr_email.Text);
                    Sql_Command.Parameters.AddWithValue("fr_desc", tb_fr_desc.Text.Replace("\r\n","<br>"));
                    Sql_Command.Parameters.AddWithValue("is_show", is_show);
                    Sql_Command.Parameters.AddWithValue("instead", tb_instead.Text);
                    Sql_Command.Parameters.AddWithValue("is_close", is_close);

                    Sql_Command.ExecuteNonQuery();

                    Sql_Conn.Close();
                    #endregion

                    #region 重新統計回應篇數
                    Sql_Conn.Open();

                    SqlString = "Update Fm_Forum Set ff_response = (Select Count(*) From Fm_Response Where ff_sid = @ff_sid And is_close = 1)";
                    SqlString += " Where ff_sid = @ff_sid";

                    Sql_Command.CommandText = SqlString;

                    Sql_Command.Parameters.Clear();
                    Sql_Command.Parameters.AddWithValue("ff_sid", ff_sid);

                    Sql_Command.ExecuteNonQuery();

                    Sql_Conn.Close();
                    #endregion
                }
            }
        }

        if (mErr == "")
            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "parent.location.reload(true);", true);
        else
            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "alert(\"" + mErr + "\");", true);
    }
예제 #9
0
    // 存檔
    protected void lk_save_Click(object sender, EventArgs e)
    {
        string mErr = "", SqlString = "", tmpstr = "";
        int ff_sex = 0, ff_symbol = 0, icnt = 0, is_show = 0, is_close = 0, ff_top = 0;
        Check_Internet cki = new Check_Internet();

        tb_ff_top.Text = tb_ff_top.Text.Trim();
        if (int.TryParse(tb_ff_top.Text, out ff_top))
        {
            if (ff_top < 0 || ff_top > 255)
                mErr = "「優先順序」請輸入 0 ~ 255 的數字,0:普通;255:置頂,數字越大越上面!\\n";
        }
        else
        {
            mErr = "「優先順序」請輸入 0 ~ 255 的數字,0:普通;255:置頂,數字越大越上面!\\n";
            tb_ff_top.Text = "0";
        }

        tb_ff_name.Text = tb_ff_name.Text.Trim();
        if (tb_ff_name.Text.Length < 2)
            mErr += "請輸入「姓名」!\\n";

        if (rb_ff_sex1.Checked || rb_ff_sex2.Checked)
        {
            if (rb_ff_sex1.Checked)
                ff_sex = 1;
            else
                ff_sex = 2;
        }
        else
            mErr += "請選擇「性別」!\\n";

        tb_ff_email.Text = tb_ff_email.Text.Trim();
        if (cki.Check_Email(tb_ff_email.Text) != 0)
            mErr += "請輸入正確的「E-Mail」格式!\\n";

        tb_ff_topic.Text = tb_ff_topic.Text.Trim();
        if (tb_ff_topic.Text.Length < 2)
            mErr += "請輸入正確的「主題」文字!\\n";

        tb_ff_desc.Text = tb_ff_desc.Text.Trim();
        if (tb_ff_desc.Text.Length < 4)
            mErr += "請輸入正確的「內容」文字!\\n";

        // 心情符號
        for (icnt = 0; icnt < 18; icnt++)
        {
            tmpstr = "rb_ff_symbol" + icnt.ToString().PadLeft(2, '0');

            RadioButton rb_tmp = (RadioButton)Page.FindControl(tmpstr);
            if (rb_tmp != null)
            {
                if (rb_tmp.Checked)
                    ff_symbol = icnt;
            }
        }

        tb_instead.Text = tb_instead.Text.Trim();
        if (rb_is_show0.Checked)
        {
            is_show = 0;
            if (tb_instead.Text == "")
                mErr = "請輸入「替代文字」!\\n";
        }
        else
            is_show = 1;

        if (rb_is_close0.Checked)
            is_close = 0;
        else
            is_close = 1;

        if (mErr == "")
        {
            using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString))
            {
                SqlString = "Update Fm_Forum Set ff_top = @ff_top, ff_symbol = @ff_symbol, ff_name = @ff_name, ff_sex = @ff_sex";
                SqlString += ", ff_email = @ff_email, ff_topic = @ff_topic, ff_desc = @ff_desc, is_show = @is_show";
                SqlString += ", instead = @instead, is_close = @is_close Where ff_sid = @ff_sid;";

                using (SqlCommand Sql_Command = new SqlCommand(SqlString, Sql_Conn))
                {
                    Sql_Conn.Open();

                    Sql_Command.Parameters.AddWithValue("ff_sid", ff_sid);
                    Sql_Command.Parameters.AddWithValue("ff_top", ff_top);
                    Sql_Command.Parameters.AddWithValue("ff_symbol", ff_symbol);
                    Sql_Command.Parameters.AddWithValue("ff_name", tb_ff_name.Text);
                    Sql_Command.Parameters.AddWithValue("ff_sex", ff_sex);
                    Sql_Command.Parameters.AddWithValue("ff_email", tb_ff_email.Text);
                    Sql_Command.Parameters.AddWithValue("ff_topic", tb_ff_topic.Text);
                    Sql_Command.Parameters.AddWithValue("ff_desc", tb_ff_desc.Text.Replace("\r\n","<br>"));
                    Sql_Command.Parameters.AddWithValue("is_show", is_show);
                    Sql_Command.Parameters.AddWithValue("instead", tb_instead.Text);
                    Sql_Command.Parameters.AddWithValue("is_close", is_close);

                    Sql_Command.ExecuteNonQuery();
                }
            }
        }

        if (mErr == "")
            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "parent.location.reload(true);", true);
        else
            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "alert(\"" + mErr + "\");", true);
    }
예제 #10
0
    // 檔案存檔
    protected void bn_save_Click(object sender, EventArgs e)
    {
        Check_Internet cknet = new Check_Internet();
        string mErr = "", adm_title = "", adm_content = "", adm_fname = "", adm_fmail = "", SqlString = "";

        adm_title = tb_adm_title.Text.Trim();
        adm_fname = tb_adm_fname.Text.Trim();
        adm_fmail = tb_adm_fmail.Text.Trim();
        adm_content = tb_preview.Text.Trim();

        #region 檢查輸入的資料
        if (adm_title == "" || adm_title == "_none")
            mErr += "請填寫郵件標題!\\n";

        if (adm_fmail == "")
            mErr += "請填寫發信者郵箱\\n";
        else if (cknet.Check_Email(adm_fmail) != 0)
            mErr += "發信者郵箱格式錯誤\\n";

        if (adm_content == "")
            mErr += "沒有郵件內容!\\n";
        #endregion

        if (mErr == "")
        {
            if (lb_md.Text == "a" && lb_adm_sid.Text == "0")
            {
                #region 新增資料
                SqlString = "Insert Into Ad_Mail (adm_title, adm_content, adm_fname, adm_fmail, adm_type)";
                SqlString += " Values (@adm_title, @adm_content, @adm_fname, @adm_fmail, @adm_type)";

                using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString))
                {
                    using (SqlCommand Sql_Command = new SqlCommand(SqlString, Sql_Conn))
                    {
                        Sql_Conn.Open();

                        Sql_Command.Parameters.AddWithValue("adm_title", adm_title);
                        Sql_Command.Parameters.AddWithValue("adm_content", adm_content);
                        Sql_Command.Parameters.AddWithValue("adm_fname", adm_fname);
                        Sql_Command.Parameters.AddWithValue("adm_fmail", adm_fmail);

                        if (rb_adm_type_1.Checked)
                            Sql_Command.Parameters.AddWithValue("adm_type", 1);
                        else
                            Sql_Command.Parameters.AddWithValue("adm_type", 2);

                        Sql_Command.ExecuteNonQuery();

                        Sql_Conn.Close();
                    }
                }
                #endregion
            }
            else
            {
                #region 修改資料
                using (SqlConnection Sql_Conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["AppSysConnectionString"].ConnectionString))
                {
                    using (SqlCommand Sql_Command = new SqlCommand())
                    {
                        Sql_Conn.Open();

                        Sql_Command.Connection = Sql_Conn;

                        // 檢查編號
                        SqlString = "Select Top 1 adm_sid From Ad_Mail Where adm_sid = @adm_sid";

                        Sql_Command.CommandText = SqlString;
                        Sql_Command.Parameters.AddWithValue("adm_sid", lb_adm_sid.Text);

                        using (SqlDataReader Sql_Reader = Sql_Command.ExecuteReader())
                        {
                            if (Sql_Reader.Read())
                            {
                                if (Sql_Reader["adm_sid"].ToString() != lb_adm_sid.Text)	// 有可能用 SQL 隱碼或其它方式進入
                                    mErr = "請使用正確方式處理!\\n";
                            }
                            else
                                mErr = "找不到指定的郵件編號!\\n";

                            Sql_Reader.Close();
                        }

                        if (mErr == "")
                        {
                            // 更新資料 (套用 Sql 的 p_Ck_Html_Files 函數檢查是否有附加檔案)
                            SqlString = "Update Ad_Mail Set adm_title = @adm_title, adm_content = @adm_content,  adm_fmail = @adm_fmail";
                            SqlString += ", adm_fname = @adm_fname, adm_type = @adm_type, init_time = getdate() Where adm_sid = @adm_sid;";

                            Sql_Command.Parameters.Clear();
                            Sql_Command.CommandText = SqlString;
                            Sql_Command.Parameters.AddWithValue("adm_sid", lb_adm_sid.Text);
                            Sql_Command.Parameters.AddWithValue("adm_title", adm_title);
                            Sql_Command.Parameters.AddWithValue("adm_content", adm_content);
                            Sql_Command.Parameters.AddWithValue("adm_fname", adm_fname);
                            Sql_Command.Parameters.AddWithValue("adm_fmail", adm_fmail);

                            if (rb_adm_type_1.Checked)
                                Sql_Command.Parameters.AddWithValue("adm_type", 1);
                            else
                                Sql_Command.Parameters.AddWithValue("adm_type", 2);

                            Sql_Command.ExecuteNonQuery();
                        }

                        Sql_Conn.Close();
                    }
                }
                #endregion
            }
        }

        if (mErr == "")
            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "alert(\"郵件儲存完成!\\n\");location.replace(\"9001.aspx" + lb_page.Text + "\");", true);
        else
            ClientScript.RegisterStartupScript(this.GetType(), "ClientScript", "alert(\"" + mErr + "\");", true);
    }