|
|
@ -12,6 +12,7 @@ using System.Windows.Media; |
|
|
using System.Windows.Media.Imaging; |
|
|
using System.Windows.Media.Imaging; |
|
|
using System.Windows.Navigation; |
|
|
using System.Windows.Navigation; |
|
|
using System.Windows.Shapes; |
|
|
using System.Windows.Shapes; |
|
|
|
|
|
using WinFormControl; |
|
|
|
|
|
|
|
|
namespace ButcherFactory.Tools |
|
|
namespace ButcherFactory.Tools |
|
|
{ |
|
|
{ |
|
|
@ -23,6 +24,19 @@ namespace ButcherFactory.Tools |
|
|
public MainWindow() |
|
|
public MainWindow() |
|
|
{ |
|
|
{ |
|
|
InitializeComponent(); |
|
|
InitializeComponent(); |
|
|
|
|
|
var list = XmlUtil.DeserializeFromFile<List<DbSelectEntity>>("DbSelectList.xml"); |
|
|
|
|
|
dbComboBox.SelectedValuePath = "Value"; |
|
|
|
|
|
dbComboBox.DisplayMemberPath = "Name"; |
|
|
|
|
|
dbComboBox.ItemsSource = list; |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(AppContext.ConnectInfo.SqlConnection)) |
|
|
|
|
|
{ |
|
|
|
|
|
var idx = list.FindIndex(x => x.Value == AppContext.ConnectInfo.SqlConnection); |
|
|
|
|
|
if (idx > -1) |
|
|
|
|
|
dbComboBox.SelectedIndex = idx; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.serverUrlBox.Text = AppContext.ConnectInfo.ServerUrl; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e) |
|
|
private void Button_Click(object sender, RoutedEventArgs e) |
|
|
@ -34,5 +48,36 @@ namespace ButcherFactory.Tools |
|
|
DbUtil.UpdateDatabase(AppContext.ConnectInfo.SqlConnection); |
|
|
DbUtil.UpdateDatabase(AppContext.ConnectInfo.SqlConnection); |
|
|
MessageBox.Show("数据库升级成功"); |
|
|
MessageBox.Show("数据库升级成功"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void SaveBtnClick(object sender, RoutedEventArgs e) |
|
|
|
|
|
{ |
|
|
|
|
|
string uri = this.serverUrlBox.Text.Trim(); |
|
|
|
|
|
if (string.IsNullOrEmpty(uri)) |
|
|
|
|
|
throw new Exception("请先设置服务器地址"); |
|
|
|
|
|
AppContext.ConnectInfo.ServerUrl = uri; |
|
|
|
|
|
AppContext.ConnectInfo.SqlConnection = (string)dbComboBox.SelectedValue; |
|
|
|
|
|
AppContext.ConnectInfo.Save(); |
|
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("设置保存成功!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void CloseBtnClick(object sender, RoutedEventArgs e) |
|
|
|
|
|
{ |
|
|
|
|
|
Application.Current.Shutdown(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void ServerUrlTextBoxClick(object sender, MouseButtonEventArgs e) |
|
|
|
|
|
{ |
|
|
|
|
|
var keyBoard = new VirtualKeyPad(); |
|
|
|
|
|
if (keyBoard.ShowDialog() == true) |
|
|
|
|
|
serverUrlBox.Text = keyBoard.Result; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class DbSelectEntity |
|
|
|
|
|
{ |
|
|
|
|
|
public string Name { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public string Value { get; set; } |
|
|
} |
|
|
} |
|
|
} |
|
|
} |