sc 2 years ago
parent
commit
262eb82b66
  1. 6
      Login.xaml
  2. 24
      Login.xaml.cs
  3. 1
      formula_manage.csproj

6
Login.xaml

@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:input="clr-namespace:System.Windows.Input;assembly=PresentationCore"
xmlns:local="clr-namespace:formula_manage" xmlns:local="clr-namespace:formula_manage"
mc:Ignorable="d" mc:Ignorable="d"
Title="Login" Height="360" Width="248"> Title="Login" Height="360" Width="248">
@ -12,9 +13,8 @@
<ImageBrush ImageSource="/sunlight_logotext.jpg"/> <ImageBrush ImageSource="/sunlight_logotext.jpg"/>
</Rectangle.Fill> </Rectangle.Fill>
</Rectangle> </Rectangle>
<ComboBox Name="Name" Height="24" Margin="60,164,10,0" VerticalAlignment="Top" FontSize="14" IsEditable="True"/>
<PasswordBox Height="24" Margin="60,210,10,0" VerticalAlignment="Top" FontSize="16"/> <PasswordBox Name="Pasword" Height="24" Margin="60,210,10,0" VerticalAlignment="Top" FontSize="14" input:InputMethod.IsInputMethodEnabled="False"/>
<ComboBox Height="24" Margin="60,164,10,0" VerticalAlignment="Top" FontSize="16" IsEditable="True"/>
<TextBlock HorizontalAlignment="Left" Height="26" Margin="10,166,0,0" TextWrapping="Wrap" Text="账号" VerticalAlignment="Top" Width="41" FontSize="20" RenderTransformOrigin="0.833,0.478"/> <TextBlock HorizontalAlignment="Left" Height="26" Margin="10,166,0,0" TextWrapping="Wrap" Text="账号" VerticalAlignment="Top" Width="41" FontSize="20" RenderTransformOrigin="0.833,0.478"/>
<TextBlock HorizontalAlignment="Left" Height="26" Margin="10,210,0,0" TextWrapping="Wrap" Text="密码" VerticalAlignment="Top" Width="41" FontSize="20" RenderTransformOrigin="0.833,0.478"/> <TextBlock HorizontalAlignment="Left" Height="26" Margin="10,210,0,0" TextWrapping="Wrap" Text="密码" VerticalAlignment="Top" Width="41" FontSize="20" RenderTransformOrigin="0.833,0.478"/>
<Button Content="登录" HorizontalAlignment="Left" Height="23" Margin="60,264,0,0" VerticalAlignment="Top" Width="44" Click="Button_Click_1"/> <Button Content="登录" HorizontalAlignment="Left" Height="23" Margin="60,264,0,0" VerticalAlignment="Top" Width="44" Click="Button_Click_1"/>

24
Login.xaml.cs

@ -2,11 +2,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
@ -19,20 +21,38 @@ namespace formula_manage
/// </summary> /// </summary>
public partial class Login : Window public partial class Login : Window
{ {
public Login() public Login()
{ {
WindowStartupLocation = WindowStartupLocation.CenterScreen; WindowStartupLocation = WindowStartupLocation.CenterScreen;
InitializeComponent(); InitializeComponent();
} }
private void Button_Click(object sender, RoutedEventArgs e) private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
Regex re = new Regex("^[1-9]+[0-9]*$");
e.Handled = !re.IsMatch(e.Text);
}
private void Button_Click(object sender, RoutedEventArgs e) //退出按钮事件
{ {
this.Close(); this.Close();
} }
private void Button_Click_1(object sender, RoutedEventArgs e) private void Button_Click_1(object sender, RoutedEventArgs e) //登录按钮事件
{ {
if ((Name.Text == "engineer" || Name.Text == "ENGINEER") && (Pasword.Password == "engineer" || Pasword.Password == "ENGINEER"))
{
MainWindow Main = new MainWindow();
Main.ShowDialog();//实例化并置顶打开信息窗口
this.Close();
}
else
{
System.Windows.MessageBox.Show("账号或密码错误");
}
} }
} }
} }

1
formula_manage.csproj

@ -37,6 +37,7 @@
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

Loading…
Cancel
Save