Browse Source

AddLogin

master
yibo 7 years ago
parent
commit
3c9a0b9dd8
29 changed files with 3721 additions and 101 deletions
  1. +25
    -0
      ButcherFactory.BO/Base/Goods.cs
  2. +41
    -0
      ButcherFactory.BO/Base/WpfUser.cs
  3. +28
    -0
      ButcherFactory.BO/ButcherFactory.BO.csproj
  4. +35
    -0
      ButcherFactory.BO/Utils/AppContext.cs
  5. +50
    -0
      ButcherFactory.BO/Utils/DbUtil.cs
  6. +72
    -0
      ButcherFactory.BO/Utils/FormUtil.cs
  7. +163
    -0
      ButcherFactory.BO/Utils/LoginUtil.cs
  8. +63
    -0
      ButcherFactory.BO/Utils/XmlUtil.cs
  9. +17
    -1
      ButcherFactory.Form/ButcherFactory.Form.csproj
  10. +10
    -11
      ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.Designer.cs
  11. +31
    -0
      ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.cs
  12. +38
    -0
      ButcherFactory.Form/SegmentationPick_/SegmentationPickOut.Designer.cs
  13. +31
    -0
      ButcherFactory.Form/SegmentationPick_/SegmentationPickOut.cs
  14. +35
    -3
      ButcherFactory.Login/ButcherFactory.Login.csproj
  15. +0
    -20
      ButcherFactory.Login/Form1.cs
  16. +163
    -0
      ButcherFactory.Login/Login.Designer.cs
  17. +110
    -0
      ButcherFactory.Login/Login.cs
  18. +2262
    -0
      ButcherFactory.Login/Login.resx
  19. +67
    -3
      ButcherFactory.Login/Program.cs
  20. +100
    -58
      ButcherFactory.Login/Properties/Resources.Designer.cs
  21. +24
    -5
      ButcherFactory.Login/Properties/Resources.resx
  22. BIN
      ButcherFactory.Login/Resources/cancelBtn.png
  23. BIN
      ButcherFactory.Login/Resources/gn.png
  24. BIN
      ButcherFactory.Login/Resources/gn_n.png
  25. BIN
      ButcherFactory.Login/Resources/login.png
  26. BIN
      ButcherFactory.Login/Resources/okBtn.png
  27. +154
    -0
      ButcherFactory.Login/SettingForm.Designer.cs
  28. +57
    -0
      ButcherFactory.Login/SettingForm.cs
  29. +145
    -0
      ButcherFactory.Login/SettingForm.resx

+ 25
- 0
ButcherFactory.BO/Base/Goods.cs View File

@ -0,0 +1,25 @@
using Forks.EnterpriseServices.DomainObjects2;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ButcherFactory.BO.Base
{
[MapToTable("Butcher_Goods")]
public class Goods
{
public long ID { get; set; }
public string Name { get; set; }
public string MainUnit { get; set; }
public decimal? Standard { get; set; }
public decimal? UpWeight { get; set; }
public decimal? DownWeight { get; set; }
}
}

+ 41
- 0
ButcherFactory.BO/Base/WpfUser.cs View File

@ -0,0 +1,41 @@
using Forks.EnterpriseServices.DomainObjects2;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ButcherFactory.BO
{
[MapToTable("WpfUser")]
public class WpfUser
{
public long ID { get; set; }
public string Name { get; set; }
[DbColumn(AllowNull = false, DbType = SqlDbType.Binary, Length = 16)]
public byte[] Password { get; set; }
public string Role { get; set; }
List<string> _roleList;
[NonDmoProperty]
public List<string> RoleList
{
get
{
if (_roleList == null)
{
_roleList = new List<string>();
if (!string.IsNullOrEmpty(Role))
_roleList.AddRange(Role.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
}
return _roleList;
}
}
[NonDmoProperty]
public bool Login { get; set; }
}
}

+ 28
- 0
ButcherFactory.BO/ButcherFactory.BO.csproj View File

@ -30,8 +30,25 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Forks.EnterpriseServices, Version=3.1.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Forks.EnterpriseServices.dll</HintPath>
</Reference>
<Reference Include="Forks.JsonRpc.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Forks.JsonRpc.Client.dll</HintPath>
</Reference>
<Reference Include="Forks.Utils, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Forks.Utils.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.0.3.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
@ -39,7 +56,18 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Base\Goods.cs" />
<Compile Include="Base\WpfUser.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\AppContext.cs" />
<Compile Include="Utils\DbUtil.cs" />
<Compile Include="Utils\FormUtil.cs" />
<Compile Include="Utils\LoginUtil.cs" />
<Compile Include="Utils\XmlUtil.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="BaseInfo\" />
<Folder Include="Bill\" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.


+ 35
- 0
ButcherFactory.BO/Utils/AppContext.cs View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ButcherFactory.BO.Utils
{
public static class AppContext
{
public static bool RpcFacadeInited { get; set; }
static ServerUrlConfig _connectInfo = ServerUrlConfig.Init();
public static ServerUrlConfig ConnectInfo { get { return _connectInfo; } }
static WpfUser _user = LoginUtil.InitUserFromLocal();
public static WpfUser User { get { return _user; } }
}
public class ServerUrlConfig
{
public static ServerUrlConfig Init()
{
return XmlUtil.DeserializeFromFile<ServerUrlConfig>();
}
public string ServerUrl { get; set; }
public string SqlConnection { get; set; }
public void Save()
{
XmlUtil.SerializerObjToFile(this);
}
}
}

+ 50
- 0
ButcherFactory.BO/Utils/DbUtil.cs View File

@ -0,0 +1,50 @@
using Forks.EnterpriseServices.DomainObjects2;
using Forks.Utils;
using Forks.Utils.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace ButcherFactory.BO.Utils
{
public static class DbUtil
{
public static void UpdateDatabase(string sqlConnection)
{
using (ISqlUtil sqlUtil = new SqlUtil(sqlConnection))
{
var boTypes = GetTypes();
Dmo.UpdateTables(sqlUtil, boTypes);
}
}
static IEnumerable<Type> GetTypes()
{
var asm = Assembly.GetAssembly(typeof(WpfUser));
foreach (var t in asm.GetExportedTypes())
{
if (t.IsAbstract)
{
continue;
}
if (t.IsClass && IsMapTable(t))
{
yield return t;
}
}
}
static bool IsMapTable(Type t)
{
var attr = ReflectionUtil.GetAttribute<MapToTableAttribute>(t);
if (attr == null)
{
return false;
}
return true;
}
}
}

+ 72
- 0
ButcherFactory.BO/Utils/FormUtil.cs View File

@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
namespace ButcherFactory.BO.Utils
{
public static class FormUtil
{
public static Form CreateFrom()
{
#if DEBUG
var dll = @"C:\BwpB3Project\src\ButcherFactorySolution\ButcherFactory.Form\bin\Debug\ButcherFactory.Form.dll";
#endif
#if !DEBUG
var dll = Path.Combine(Directory.GetCurrentDirectory(), "ButcherFactory.Form.dll");
#endif
if (!File.Exists(dll))
throw new Exception("缺少必要的程序集文件 ButcherFactory.Form.dll");
var formType = typeof(IWithRoleForm);
Form form = null;
foreach (var type in Assembly.LoadFile(dll).GetTypes())
{
if (formType.IsAssignableFrom(type))
{
var instance = (IWithRoleForm)Activator.CreateInstance(type);
foreach (var item in instance.RoleName)
{
if (AppContext.User.Login)
{
if (LoginUtil.UserIsInRole(item))
{
if (!AppContext.User.RoleList.Contains(item))
AppContext.User.RoleList.Add(item);
form = instance.Generate();
break;
}
else if (AppContext.User.RoleList.Contains(item))
{
AppContext.User.RoleList.Remove(item);
}
}
else
{
if (AppContext.User.RoleList.Contains(item))
form = instance.Generate();
break;
}
}
}
if (form != null)
break;
}
if (AppContext.User.Login)
LoginUtil.UpdateUserRole();
return form;
}
}
public interface IWithRoleForm
{
List<string> RoleName { get; }
Form Generate();
}
}

+ 163
- 0
ButcherFactory.BO/Utils/LoginUtil.cs View File

@ -0,0 +1,163 @@
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.JsonRpc.Client;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using TSingSoft.WebPluginFramework;
namespace ButcherFactory.BO.Utils
{
public static class LoginUtil
{
public static WpfUser InitUserFromLocal()
{
if (string.IsNullOrEmpty(AppContext.ConnectInfo.SqlConnection))
return new WpfUser();
using (var session = Dmo.NewSession(AppContext.ConnectInfo.SqlConnection))
{
var query = new DmoQuery(typeof(WpfUser));
var obj = session.ExecuteScalar(query);
if (obj != null)
return (WpfUser)obj;
}
return new WpfUser();
}
public static void InitRpcFacade()
{
if (string.IsNullOrEmpty(AppContext.ConnectInfo.ServerUrl))
throw new Exception("请先设置服务器地址");
if (!AppContext.RpcFacadeInited)
{
RpcFacade.Init(AppContext.ConnectInfo.ServerUrl, "ButcherFactorySolution");
AppContext.RpcFacadeInited = true;
}
}
public static void ReInitRpcFacade()
{
if (AppContext.RpcFacadeInited)
RpcFacade.ReInit(AppContext.ConnectInfo.ServerUrl);
}
public static void LoginOut()
{
if (AppContext.User.Login)
{
try
{
AppContext.User.Login = false;
RpcFacade.Logout();
}
catch { };
}
}
public static string GetUserNameByCode(string code, out string error)
{
try
{
error = string.Empty;
const string wpfUserMethod = "/MainSystem/B3ClientService/Rpcs/UserInfoRpc/GetUserName";
return RpcFacade.Call<string>(wpfUserMethod, code);
}
catch (Exception ex)
{
error = ex.ToString();
}
return string.Empty;
}
public static void Login(string userName, string pwd)
{
RpcFacade.Login(userName, pwd);
AppContext.User.Login = true;
AppContext.User.Name = userName;
FillUserEmpInfo(userName);
AppContext.User.Password = EncodePwd(pwd);
using (var session = Dmo.NewSession(AppContext.ConnectInfo.SqlConnection))
{
var table = DmoInfo.Get(typeof(WpfUser)).MappedDBObject;
var sql = string.Format(@"delete from [{0}]", table);
session.ExecuteSqlNonQuery(sql);
session.Insert(AppContext.User);
session.Commit();
}
}
static void FillUserEmpInfo(string name)
{
const string wpfUserMethod = "/MainSystem/B3ClientService/Rpcs/UserInfoRpc/GetUserID";
AppContext.User.ID = RpcFacade.Call<long>(wpfUserMethod);
}
public static byte[] EncodePwd(string pwd)
{
using (MD5 md5 = MD5.Create())
return md5.ComputeHash(Encoding.Unicode.GetBytes(pwd));
}
public static bool UserIsInRole(string roleName)
{
const string method = "/MainSystem/B3ClientService/Rpcs/UserInfoRpc/UserIsInRole";
return RpcFacade.Call<bool>(method, roleName);
}
public static void UpdateUserRole()
{
using (var session = Dmo.NewSession(AppContext.ConnectInfo.SqlConnection))
{
var update = new DQUpdateDom(typeof(WpfUser));
update.Columns.Add(new DQUpdateColumn("Role", string.Join(" ", AppContext.User.RoleList)));
session.ExecuteNonQuery(update);
session.Commit();
}
}
public static void AddUserRole(string role)
{
if (AppContext.User.RoleList.Contains(role))
return;
AppContext.User.RoleList.Add(role);
UpdateUserRole();
}
public static bool TestConnection(int? millisecondsTimeout = null)
{
var url = AppContext.ConnectInfo.ServerUrl;
if (string.IsNullOrEmpty(url))
return false;
var uri = new Uri(url);
if (millisecondsTimeout == null)
{
millisecondsTimeout = 50;
}
return TestConnection(uri.Host, uri.Port, millisecondsTimeout.Value);
}
public static bool TestConnection(string host, int port, int millisecondsTimeout)
{
var client = new System.Net.Sockets.TcpClient();
try
{
var ar = client.BeginConnect(host, port, null, null);
ar.AsyncWaitHandle.WaitOne(millisecondsTimeout);
return client.Connected;
}
catch (Exception)
{
return false;
}
finally
{
client.Close();
}
}
}
}

+ 63
- 0
ButcherFactory.BO/Utils/XmlUtil.cs View File

@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace ButcherFactory.BO.Utils
{
public static class XmlUtil
{
static string currentPath = Directory.GetCurrentDirectory();
public static void SerializerObjToFile(object obj, string fileName = "")
{
if (string.IsNullOrWhiteSpace(fileName))
{
fileName = Path.Combine(currentPath, obj.GetType().Name + ".xml");
}
var ser = new XmlSerializer(obj.GetType());
using (var stream = File.Open(fileName, FileMode.Create))
{
ser.Serialize(stream, obj);
}
}
public static T DeserializeFromFile<T>(string fileName = "")
where T : new()
{
if (string.IsNullOrWhiteSpace(fileName))
{
fileName = Path.Combine(currentPath, typeof(T).Name + ".xml");
}
if (!File.Exists(fileName))
{
return new T();
}
using (var reader = new StreamReader(fileName))
{
var xs = new XmlSerializer(typeof(T));
object obj = xs.Deserialize(reader);
reader.Close();
return (T)obj;
}
}
public static T XmlDeserializeObject<T>(string xmlOfObject) where T : class
{
using (MemoryStream ms = new MemoryStream())
{
using (StreamWriter sr = new StreamWriter(ms, Encoding.UTF8))
{
sr.Write(xmlOfObject);
sr.Flush();
ms.Seek(0, SeekOrigin.Begin);
XmlSerializer serializer = new XmlSerializer(typeof(T));
return serializer.Deserialize(ms) as T;
}
}
}
}
}

+ 17
- 1
ButcherFactory.Form/ButcherFactory.Form.csproj View File

@ -7,7 +7,7 @@
<ProjectGuid>{2485631B-624C-43E0-9287-86FA1C8485FC}</ProjectGuid> <ProjectGuid>{2485631B-624C-43E0-9287-86FA1C8485FC}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ButcherFactory.Form</RootNamespace>
<RootNamespace>ButcherFactory</RootNamespace>
<AssemblyName>ButcherFactory.Form</AssemblyName> <AssemblyName>ButcherFactory.Form</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
@ -32,6 +32,9 @@
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
@ -39,7 +42,19 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CarcassInStore_\CarcassInStoreForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="CarcassInStore_\CarcassInStoreForm.Designer.cs">
<DependentUpon>CarcassInStoreForm.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SegmentationPick_\SegmentationPickOut.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SegmentationPick_\SegmentationPickOut.Designer.cs">
<DependentUpon>SegmentationPickOut.cs</DependentUpon>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\ButcherFactory.BO\ButcherFactory.BO.csproj"> <ProjectReference Include="..\ButcherFactory.BO\ButcherFactory.BO.csproj">
@ -47,6 +62,7 @@
<Name>ButcherFactory.BO</Name> <Name>ButcherFactory.BO</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.


ButcherFactory.Login/Form1.Designer.cs → ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.Designer.cs View File

@ -1,16 +1,16 @@
namespace ButcherFactory.Login
namespace ButcherFactory.CarcassInStore_
{ {
partial class Form1
partial class CarcassInStoreForm
{ {
/// <summary> /// <summary>
/// 必需的设计器变量。
/// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
/// <summary> /// <summary>
/// 清理所有正在使用的资源。
/// Clean up any resources being used.
/// </summary> /// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
@ -20,20 +20,19 @@
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Windows 窗体设计器生成的代码
#region Windows Form Designer generated code
/// <summary> /// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Text = "Form1";
this.Text = "CarcassInStoreForm";
} }
#endregion #endregion
} }
}
}

+ 31
- 0
ButcherFactory.Form/CarcassInStore_/CarcassInStoreForm.cs View File

@ -0,0 +1,31 @@
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;
namespace ButcherFactory.CarcassInStore_
{
public partial class CarcassInStoreForm : Form, IWithRoleForm
{
public CarcassInStoreForm()
{
InitializeComponent();
}
public List<string> RoleName
{
get { return new List<string> { "车间业务.白条入库"}; }
}
public Form Generate()
{
return this;
}
}
}

+ 38
- 0
ButcherFactory.Form/SegmentationPick_/SegmentationPickOut.Designer.cs View File

@ -0,0 +1,38 @@
namespace ButcherFactory.SegmentationPick_
{
partial class SegmentationPickOut
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Text = "SegmentationPickOut";
}
#endregion
}
}

+ 31
- 0
ButcherFactory.Form/SegmentationPick_/SegmentationPickOut.cs View File

@ -0,0 +1,31 @@
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;
namespace ButcherFactory.SegmentationPick_
{
public partial class SegmentationPickOut : Form, IWithRoleForm
{
public SegmentationPickOut()
{
InitializeComponent();
}
public List<string> RoleName
{
get { return new List<string> { "车间业务.领料退料" }; }
}
public Form Generate()
{
return this;
}
}
}

+ 35
- 3
ButcherFactory.Login/ButcherFactory.Login.csproj View File

@ -32,8 +32,11 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
@ -42,20 +45,30 @@
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
<Reference Include="WinFormControl, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="WinFormControl, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\WinFormControl.dll</HintPath> <HintPath>..\..\..\tsref\Debug\WinFormControl.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Form1.cs">
<Compile Include="Login.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
<Compile Include="Login.Designer.cs">
<DependentUpon>Login.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SettingForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SettingForm.Designer.cs">
<DependentUpon>SettingForm.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Login.resx">
<DependentUpon>Login.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
@ -64,7 +77,11 @@
<Compile Include="Properties\Resources.Designer.cs"> <Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile> </Compile>
<EmbeddedResource Include="SettingForm.resx">
<DependentUpon>SettingForm.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
@ -84,6 +101,21 @@
<Name>ButcherFactory.BO</Name> <Name>ButcherFactory.BO</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="Resources\login.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\gn_n.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\gn.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\cancelBtn.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\okBtn.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.


+ 0
- 20
ButcherFactory.Login/Form1.cs View File

@ -1,20 +0,0 @@
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;
namespace ButcherFactory.Login
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

+ 163
- 0
ButcherFactory.Login/Login.Designer.cs View File

@ -0,0 +1,163 @@
namespace ButcherFactory.Login
{
partial class Login
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Login));
this.pwdBox = new WinFormControl.UTextBoxWithPad();
this.loginBtn = new System.Windows.Forms.Button();
this.exitBtn = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.uLabel1 = new WinFormControl.ULabel();
this.uLabel2 = new WinFormControl.ULabel();
this.userNameBox = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pwdBox
//
this.pwdBox.Font = new System.Drawing.Font("宋体", 20F);
this.pwdBox.Location = new System.Drawing.Point(329, 214);
this.pwdBox.Name = "pwdBox";
this.pwdBox.Size = new System.Drawing.Size(186, 38);
this.pwdBox.TabIndex = 2;
this.pwdBox.Type = WinFormControl.UTextBoxWithPad.TextBoxType.Normal;
this.pwdBox.UseSystemPasswordChar = true;
//
// loginBtn
//
this.loginBtn.BackgroundImage = global::ButcherFactory.Login.Properties.Resources.okBtn;
this.loginBtn.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.loginBtn.FlatAppearance.BorderSize = 0;
this.loginBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.loginBtn.Font = new System.Drawing.Font("黑体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.loginBtn.ForeColor = System.Drawing.Color.White;
this.loginBtn.Location = new System.Drawing.Point(304, 277);
this.loginBtn.Name = "loginBtn";
this.loginBtn.Size = new System.Drawing.Size(90, 50);
this.loginBtn.TabIndex = 3;
this.loginBtn.Text = "登 录";
this.loginBtn.UseVisualStyleBackColor = true;
this.loginBtn.Click += new System.EventHandler(this.loginBtn_Click);
//
// exitBtn
//
this.exitBtn.BackgroundImage = global::ButcherFactory.Login.Properties.Resources.cancelBtn;
this.exitBtn.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.exitBtn.FlatAppearance.BorderSize = 0;
this.exitBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.exitBtn.Font = new System.Drawing.Font("黑体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.exitBtn.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(37)))), ((int)(((byte)(111)))), ((int)(((byte)(158)))));
this.exitBtn.Location = new System.Drawing.Point(426, 277);
this.exitBtn.Name = "exitBtn";
this.exitBtn.Size = new System.Drawing.Size(90, 50);
this.exitBtn.TabIndex = 4;
this.exitBtn.Text = "退 出";
this.exitBtn.UseVisualStyleBackColor = true;
this.exitBtn.Click += new System.EventHandler(this.exitBtn_Click);
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
this.pictureBox1.Image = global::ButcherFactory.Login.Properties.Resources.gn_n;
this.pictureBox1.Location = new System.Drawing.Point(521, 126);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(39, 25);
this.pictureBox1.TabIndex = 6;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
//
// uLabel1
//
this.uLabel1.AutoSize = true;
this.uLabel1.BackColor = System.Drawing.Color.Transparent;
this.uLabel1.Font = new System.Drawing.Font("宋体", 18F);
this.uLabel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(37)))), ((int)(((byte)(111)))), ((int)(((byte)(158)))));
this.uLabel1.Location = new System.Drawing.Point(236, 163);
this.uLabel1.Name = "uLabel1";
this.uLabel1.Size = new System.Drawing.Size(106, 24);
this.uLabel1.TabIndex = 7;
this.uLabel1.Text = "用户名:";
//
// uLabel2
//
this.uLabel2.AutoSize = true;
this.uLabel2.BackColor = System.Drawing.Color.Transparent;
this.uLabel2.Font = new System.Drawing.Font("宋体", 18F);
this.uLabel2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(37)))), ((int)(((byte)(111)))), ((int)(((byte)(158)))));
this.uLabel2.Location = new System.Drawing.Point(236, 219);
this.uLabel2.Name = "uLabel2";
this.uLabel2.Size = new System.Drawing.Size(106, 24);
this.uLabel2.TabIndex = 8;
this.uLabel2.Text = "密 码:";
//
// userNameBox
//
this.userNameBox.Font = new System.Drawing.Font("宋体", 20F);
this.userNameBox.Location = new System.Drawing.Point(329, 157);
this.userNameBox.Name = "userNameBox";
this.userNameBox.Size = new System.Drawing.Size(186, 38);
this.userNameBox.TabIndex = 1;
this.userNameBox.Click += new System.EventHandler(this.userNameBox_Click);
//
// Login
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(676, 385);
this.Controls.Add(this.userNameBox);
this.Controls.Add(this.pwdBox);
this.Controls.Add(this.uLabel2);
this.Controls.Add(this.uLabel1);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.exitBtn);
this.Controls.Add(this.loginBtn);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Login";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Login";
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Login_MouseDown);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Login_MouseMove);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private WinFormControl.UTextBoxWithPad pwdBox;
private System.Windows.Forms.Button loginBtn;
private System.Windows.Forms.Button exitBtn;
private System.Windows.Forms.PictureBox pictureBox1;
private WinFormControl.ULabel uLabel1;
private WinFormControl.ULabel uLabel2;
private System.Windows.Forms.TextBox userNameBox;
}
}

+ 110
- 0
ButcherFactory.Login/Login.cs View File

@ -0,0 +1,110 @@
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 Login : Form
{
public Login()
{
InitializeComponent();
userNameBox.Text = AppContext.User.Name;
pwdBox.Text = "123";
if (!string.IsNullOrEmpty(AppContext.User.Name))
pwdBox.Focus();
}
private Point mousePoint = new Point();
private void Login_MouseDown(object sender, MouseEventArgs e)
{
this.mousePoint.X = e.X;
this.mousePoint.Y = e.Y;
}
private void Login_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.Top = Control.MousePosition.Y - mousePoint.Y;
this.Left = Control.MousePosition.X - mousePoint.X;
}
}
private async void loginBtn_Click(object sender, EventArgs e)
{
var username = userNameBox.Text.Trim();
var pwd = pwdBox.Text;
if (string.IsNullOrEmpty(username))
throw new Exception("请输入用户名");
if (LoginUtil.TestConnection(1000))
{
LoginUtil.InitRpcFacade();
await Task.Factory.StartNew(() => LoginUtil.Login(username, pwd));
}
else
{
if (AppContext.User.Name != username && LoginUtil.EncodePwd(pwd) != AppContext.User.Password)
throw new Exception("请输入用户名");
}
var form = FormUtil.CreateFrom();
if (form == null)
throw new Exception("权限不符");
form.FormClosing += delegate
{
SubFormClosing();
LoginUtil.LoginOut();
};
form.Show();
Hide();
}
void SubFormClosing()
{
foreach (Form form in Application.OpenForms)
{
if (form is Login)
{
form.Show();
return;
}
}
}
private void exitBtn_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
if (new SettingForm().ShowDialog() == DialogResult.OK)
LoginUtil.ReInitRpcFacade();
}
private void userNameBox_Click(object sender, EventArgs e)
{
LoginUtil.InitRpcFacade();
var keyBoard = new NumberPad();
if (keyBoard.ShowDialog() == true)
{
string errorInfo;
userNameBox.Text = LoginUtil.GetUserNameByCode(keyBoard.Result, out errorInfo);
if (string.IsNullOrEmpty(userNameBox.Text))
throw new Exception("工号输入错误");
if (!string.IsNullOrEmpty(errorInfo))
MessageBox.Show(errorInfo);
}
}
}
}

+ 2262
- 0
ButcherFactory.Login/Login.resx
File diff suppressed because it is too large
View File


+ 67
- 3
ButcherFactory.Login/Program.cs View File

@ -1,8 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using WinFormControl;
namespace ButcherFactory.Login namespace ButcherFactory.Login
{ {
@ -14,9 +17,70 @@ namespace ButcherFactory.Login
[STAThread] [STAThread]
static void Main() static void Main()
{ {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
try
{
//处理未捕获的异常
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
//处理UI线程异常
Application.ThreadException += Application_ThreadException;
//处理非UI线程异常
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
var aProcessName = Process.GetCurrentProcess().ProcessName;
if ((Process.GetProcessesByName(aProcessName)).GetUpperBound(0) > 0)
{
UMessageBox.Show(@"系统已经在运行中,如果要重新启动,请从进程中关闭...", @"系统警告");
}
else
{
// Mapper.Initialize(cfg => {
// cfg.AddProfile<AppProfile>();
// cfg.CreateMap<Source, Dest>();
// });
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Login());
}
}
catch (Exception e)
{
// LogUtil.WriteError(e);
UMessageBox.Show("错误:" + e.Message + " \n详细信息:" + e.StackTrace);
//UMessageBox.Show("错误:" + e.Message );
}
}
///<summary>
/// 在发生未处理异常时处理的方法
///</summary>
///<param name="sender"> </param>
///<param name="e"> </param>
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
var ex = e.Exception;
var err = String.Empty;
if (ex != null)
{
//LogUtil.WriteError(ex);
err = ex.Message;
}
UMessageBox.Show("错误:" + ex.Message + " \n详细信息:" + ex.StackTrace);
// UMessageBox.Show("错误:" + err);
}
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
var err = String.Empty;
var ex = e.ExceptionObject as Exception;
if (ex != null)
{
//LogUtil.WriteError(ex);
err = ex.Message;
}
UMessageBox.Show("错误:" + ex.Message + " \n详细信息:" + ex.StackTrace);
//UMessageBox.Show("错误:" + err);
} }
} }
} }

+ 100
- 58
ButcherFactory.Login/Properties/Resources.Designer.cs View File

@ -1,71 +1,113 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// 此代码由工具生成。 // 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
// 运行时版本:4.0.30319.42000
// //
// 对此文件的更改可能会导致不正确的行为,并且如果 // 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将丢失。
// 重新生成代码,这些更改将丢失。
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace ButcherFactory.Login.Properties
{
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
namespace ButcherFactory.Login.Properties {
using System;
/// <summary> /// <summary>
/// 返回此类使用的、缓存的 ResourceManager 实例
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ButcherFactory.Login.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ButcherFactory.Login.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 使用此强类型资源类,为所有资源查找
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap cancelBtn {
get {
object obj = ResourceManager.GetObject("cancelBtn", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap gn {
get {
object obj = ResourceManager.GetObject("gn", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap gn_n {
get {
object obj = ResourceManager.GetObject("gn_n", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap login {
get {
object obj = ResourceManager.GetObject("login", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap okBtn {
get {
object obj = ResourceManager.GetObject("okBtn", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
} }
return resourceMan;
}
}
/// <summary>
/// 为所有资源查找重写当前线程的 CurrentUICulture 属性,
/// 方法是使用此强类型资源类。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
} }
}
} }

+ 24
- 5
ButcherFactory.Login/Properties/Resources.resx View File

@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
@ -60,6 +60,7 @@
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
@ -68,9 +69,10 @@
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> <xsd:element name="assembly">
@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="resheader"> <xsd:element name="resheader">
@ -109,9 +112,25 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="cancelBtn" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\cancelBtn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="gn" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\gn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="gn_n" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\gn_n.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="login" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\login.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="okBtn" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\okBtn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root> </root>

BIN
ButcherFactory.Login/Resources/cancelBtn.png View File

Before After
Width: 96  |  Height: 48  |  Size: 1.3 KiB

BIN
ButcherFactory.Login/Resources/gn.png View File

Before After
Width: 31  |  Height: 18  |  Size: 977 B

BIN
ButcherFactory.Login/Resources/gn_n.png View File

Before After
Width: 37  |  Height: 22  |  Size: 1.2 KiB

BIN
ButcherFactory.Login/Resources/login.png View File

Before After
Width: 675  |  Height: 381  |  Size: 110 KiB

BIN
ButcherFactory.Login/Resources/okBtn.png View File

Before After
Width: 96  |  Height: 48  |  Size: 1.6 KiB

+ 154
- 0
ButcherFactory.Login/SettingForm.Designer.cs View File

@ -0,0 +1,154 @@
namespace ButcherFactory.Login
{
partial class SettingForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SettingForm));
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.dbConnectionBox = new WinFormControl.UTextBoxWithPad();
this.sererUrlBox = new WinFormControl.UTextBoxWithPad();
this.saveBtn = new WinFormControl.UButton();
this.closeBtn = new WinFormControl.UButton();
this.updateBtn = new WinFormControl.UButton();
this.SuspendLayout();
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("宋体", 15F);
this.label2.Location = new System.Drawing.Point(22, 112);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(129, 20);
this.label2.TabIndex = 16;
this.label2.Text = "数据库地址:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 15F);
this.label1.Location = new System.Drawing.Point(22, 47);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(129, 20);
this.label1.TabIndex = 12;
this.label1.Text = "服务器地址:";
//
// dbConnectionBox
//
this.dbConnectionBox.Font = new System.Drawing.Font("宋体", 20F);
this.dbConnectionBox.Location = new System.Drawing.Point(144, 103);
this.dbConnectionBox.Name = "dbConnectionBox";
this.dbConnectionBox.Size = new System.Drawing.Size(706, 38);
this.dbConnectionBox.TabIndex = 17;
this.dbConnectionBox.Type = WinFormControl.UTextBoxWithPad.TextBoxType.Normal;
//
// sererUrlBox
//
this.sererUrlBox.Font = new System.Drawing.Font("宋体", 20F);
this.sererUrlBox.Location = new System.Drawing.Point(144, 38);
this.sererUrlBox.Name = "sererUrlBox";
this.sererUrlBox.Size = new System.Drawing.Size(706, 38);
this.sererUrlBox.TabIndex = 17;
this.sererUrlBox.Type = WinFormControl.UTextBoxWithPad.TextBoxType.Normal;
//
// saveBtn
//
this.saveBtn.BackColor = System.Drawing.Color.Transparent;
this.saveBtn.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("saveBtn.BackgroundImage")));
this.saveBtn.FlatAppearance.BorderSize = 0;
this.saveBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.saveBtn.Font = new System.Drawing.Font("宋体", 15F);
this.saveBtn.ForeColor = System.Drawing.Color.Black;
this.saveBtn.Location = new System.Drawing.Point(144, 188);
this.saveBtn.Name = "saveBtn";
this.saveBtn.Size = new System.Drawing.Size(114, 52);
this.saveBtn.TabIndex = 18;
this.saveBtn.Text = "保 存";
this.saveBtn.UseVisualStyleBackColor = false;
this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click);
//
// closeBtn
//
this.closeBtn.BackColor = System.Drawing.Color.Transparent;
this.closeBtn.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("closeBtn.BackgroundImage")));
this.closeBtn.Font = new System.Drawing.Font("宋体", 15F);
this.closeBtn.ForeColor = System.Drawing.Color.Black;
this.closeBtn.Location = new System.Drawing.Point(373, 188);
this.closeBtn.Name = "closeBtn";
this.closeBtn.Size = new System.Drawing.Size(114, 52);
this.closeBtn.TabIndex = 19;
this.closeBtn.Text = "关 闭";
this.closeBtn.UseVisualStyleBackColor = false;
this.closeBtn.Click += new System.EventHandler(this.closeBtn_Click);
//
// updateBtn
//
this.updateBtn.BackColor = System.Drawing.Color.Transparent;
this.updateBtn.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("updateBtn.BackgroundImage")));
this.updateBtn.Font = new System.Drawing.Font("宋体", 15F);
this.updateBtn.ForeColor = System.Drawing.Color.Black;
this.updateBtn.Location = new System.Drawing.Point(601, 188);
this.updateBtn.Name = "updateBtn";
this.updateBtn.Size = new System.Drawing.Size(114, 52);
this.updateBtn.TabIndex = 20;
this.updateBtn.Text = "升 级";
this.updateBtn.UseVisualStyleBackColor = false;
this.updateBtn.Click += new System.EventHandler(this.updateBtn_Click);
//
// SettingForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(872, 284);
this.ControlBox = false;
this.Controls.Add(this.updateBtn);
this.Controls.Add(this.closeBtn);
this.Controls.Add(this.saveBtn);
this.Controls.Add(this.dbConnectionBox);
this.Controls.Add(this.sererUrlBox);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "SettingForm";
this.Text = "系统设置";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private WinFormControl.UTextBoxWithPad sererUrlBox;
private WinFormControl.UTextBoxWithPad dbConnectionBox;
private WinFormControl.UButton saveBtn;
private WinFormControl.UButton closeBtn;
private WinFormControl.UButton updateBtn;
}
}

+ 57
- 0
ButcherFactory.Login/SettingForm.cs View File

@ -0,0 +1,57 @@
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("升级成功");
}
}
}

+ 145
- 0
ButcherFactory.Login/SettingForm.resx View File

@ -0,0 +1,145 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="saveBtn.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwCAIAAABhdOiYAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAABzSURBVGhD7dABDQAgDMAw7F05ZhCBg89AkyroeXdY
CAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKC
oCAoCAqCgqAgKAgKgoKgICgICoKCoNWdD6R7ug7J7zUqAAAAAElFTkSuQmCC
</value>
</data>
<data name="closeBtn.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwCAIAAABhdOiYAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAABzSURBVGhD7dABDQAgDMAw7F05ZhCBg89AkyroeXdY
CAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKC
oCAoCAqCgqAgKAgKgoKgICgICoKCoNWdD6R7ug7J7zUqAAAAAElFTkSuQmCC
</value>
</data>
<data name="updateBtn.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwCAIAAABhdOiYAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAABzSURBVGhD7dABDQAgDMAw7F05ZhCBg89AkyroeXdY
CAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKC
oCAoCAqCgqAgKAgKgoKgICgICoKCoNWdD6R7ug7J7zUqAAAAAElFTkSuQmCC
</value>
</data>
</root>

Loading…
Cancel
Save