You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

57 lines
1.7 KiB

using ButcherFactory.BO.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WinFormControl;
namespace ButcherFactory.Login
{
public partial class SettingForm : Form
{
public SettingForm()
{
InitializeComponent();
sererUrlBox.Text = AppContext.ConnectInfo.ServerUrl;
dbConnectionBox.Text = AppContext.ConnectInfo.SqlConnection;
if (string.IsNullOrEmpty(dbConnectionBox.Text))
dbConnectionBox.Text = "Server=localhost;Database=LocalClientService;Integrated Security=true;Language=Simplified Chinese;";
}
bool changed = false;
private void saveBtn_Click(object sender, EventArgs e)
{
string uri = this.sererUrlBox.Text.Trim();
if (string.IsNullOrEmpty(uri))
throw new Exception("请先设置服务器地址");
if (AppContext.ConnectInfo.ServerUrl != uri)
changed = true;
AppContext.ConnectInfo.ServerUrl = uri;
AppContext.ConnectInfo.SqlConnection = dbConnectionBox.Text.Trim();
AppContext.ConnectInfo.Save();
UMessageBox.Show("设置保存成功!");
}
private void closeBtn_Click(object sender, EventArgs e)
{
if (changed)
DialogResult = DialogResult.OK;
this.Close();
}
private void updateBtn_Click(object sender, EventArgs e)
{
var sqlConnection = dbConnectionBox.Text.Trim();
if (string.IsNullOrEmpty(sqlConnection))
throw new Exception("请输入数据库地址");
DbUtil.UpdateDatabase(sqlConnection);
UMessageBox.Show("升级成功");
}
}
}