Browse Source

支持多账套登录

master
yibo 7 years ago
parent
commit
1531c609c1
4 changed files with 58 additions and 3 deletions
  1. +1
    -1
      ButcherFactory.BO/LocalBL/CarcassInStoreBL.cs
  2. +4
    -0
      ButcherFactory.Tools/ButcherFactory.Tools.csproj
  3. +8
    -2
      ButcherFactory.Tools/MainWindow.xaml
  4. +45
    -0
      ButcherFactory.Tools/MainWindow.xaml.cs

+ 1
- 1
ButcherFactory.BO/LocalBL/CarcassInStoreBL.cs View File

@ -86,7 +86,7 @@ namespace ButcherFactory.BO.LocalBL
{
var query = new DQueryDom(new JoinAlias(typeof(CarcassInStore)));
query.Columns.Add(DQSelectColumn.Max("RowIndex"));
query.Where.Conditions.Add(DQCondition.EQ("batchID", batchID));
query.Where.Conditions.Add(DQCondition.EQ("ProductBatch_ID", batchID));
return query.EExecuteScalar<int?>(session) ?? 0;
}


+ 4
- 0
ButcherFactory.Tools/ButcherFactory.Tools.csproj View File

@ -50,6 +50,10 @@
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="WinFormControl, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\WinFormControl.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">


+ 8
- 2
ButcherFactory.Tools/MainWindow.xaml View File

@ -1,8 +1,14 @@
<Window x:Class="ButcherFactory.Tools.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="BWP_Tools" Height="350" Width="525">
Title="BWP_Tools" Height="350" Width="525" ResizeMode="NoResize" >
<Grid Margin="0,0,2,0">
<Button Content="升级" FontSize="18px" Margin="211,133,0,0" VerticalAlignment="Top" Height="50" HorizontalAlignment="Left" Width="94" Click="Button_Click"/>
<Label Content="服务器:" HorizontalAlignment="Left" VerticalContentAlignment="Center" FontSize="18px" Margin="84,30,0,0" VerticalAlignment="Top" Height="47"/>
<TextBox Name="serverUrlBox" HorizontalAlignment="Left" Height="80" Margin="179,34,0,0" TextWrapping="Wrap" FontSize="15px" Text="" VerticalAlignment="Top" Width="229" PreviewMouseLeftButtonDown="ServerUrlTextBoxClick"/>
<Label Content="数据库:" HorizontalAlignment="Left" VerticalContentAlignment="Center" FontSize="18px" Margin="84,136,0,0" VerticalAlignment="Top" Height="47"/>
<ComboBox Name="dbComboBox" HorizontalAlignment="Left" Margin="179,142,0,0" FontSize="18px" VerticalContentAlignment="Center" VerticalAlignment="Top" Width="229" Height="37"/>
<Button Content="保存" FontSize="18px" Margin="72,217,0,0" Height="50" Width="94" HorizontalAlignment="Left" VerticalAlignment="Top" Click="SaveBtnClick"/>
<Button Content="升级" FontSize="18px" Margin="197,217,0,0" Height="50" Width="94" HorizontalAlignment="Left" VerticalAlignment="Top" Click="Button_Click"/>
<Button Content="关闭" FontSize="18px" Margin="320,217,0,0" Height="50" Width="94" HorizontalAlignment="Left" VerticalAlignment="Top" Click="CloseBtnClick"/>
</Grid>
</Window>

+ 45
- 0
ButcherFactory.Tools/MainWindow.xaml.cs View File

@ -12,6 +12,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WinFormControl;
namespace ButcherFactory.Tools
{
@ -23,6 +24,19 @@ namespace ButcherFactory.Tools
public MainWindow()
{
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)
@ -34,5 +48,36 @@ namespace ButcherFactory.Tools
DbUtil.UpdateDatabase(AppContext.ConnectInfo.SqlConnection);
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; }
}
}

Loading…
Cancel
Save