// 伺服器位址(網域名稱)驗證 protected void bn_Host_Click(object sender, EventArgs e) { Check_Internet cknet = new Check_Internet(); int ckint = -1; tb_Host.Text = tb_Host.Text.Trim(); ckint = cknet.Check_Host(tb_Host.Text); if (ckint == 0) lb_Host.Text = "正確"; else lb_Host.Text = "錯誤 (錯誤代碼:" + ckint.ToString() + ")"; }
// 存檔 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); }
// 存檔 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); }