using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Text; using System.Windows.Forms; using Stone.Common; namespace Stone.User { public partial class frmServer : Form { public frmServer() { InitializeComponent(); } private void frmSqlServer_Load(object sender, EventArgs e) { this.txtServer.Text = MyAppconfig.ReadValue("Server"); } private void btnTest_Click(object sender, EventArgs e) { this.btnTest.Enabled = false; this.Update(); try { Stone.Common.WinService.Service service = new Common.WinService.Service(); service.Url = this.txtServer.Text.Trim(); if (service.Test("OK") == "OK") { MyMessageBox.ShowInfoMessage("服务器测试成功!"); } else { MyMessageBox.ShowInfoMessage("服务器测试失败!"); } } catch (Exception ex) { MyMessageBox.ShowErrorMessage(ex.Message); this.txtServer.Focus(); this.txtServer.SelectAll(); } finally { this.btnTest.Enabled = true; } } private void btnOK_Click(object sender, EventArgs e) { try { if (this.txtServer.Text.Trim() == "") throw new Exception("服务器地址不能为空!"); MyAppconfig.WriteValue("Server", this.txtServer.Text.Trim()); MyMessageBox.ShowInfoMessage("配置保存成功!"); Application.Restart(); } catch (Exception ex) { MyMessageBox.ShowErrorMessage(ex.Message); this.txtServer.Focus(); this.txtServer.SelectAll(); } } private void btnCancel_Click(object sender, EventArgs e) { this.Close(); } } }