| @ -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; } | |||||
| } | |||||
| } | |||||
| @ -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; } | |||||
| } | |||||
| } | |||||
| @ -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); | |||||
| } | |||||
| } | |||||
| } | |||||
| @ -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; | |||||
| } | |||||
| } | |||||
| } | |||||
| @ -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(); | |||||
| } | |||||
| } | |||||
| @ -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(); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @ -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; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @ -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; | |||||
| } | |||||
| } | |||||
| } | |||||
| @ -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 | |||||
| } | |||||
| } | |||||
| @ -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; | |||||
| } | |||||
| } | |||||
| } | |||||
| @ -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(); | |||||
| } | |||||
| } | |||||
| } | |||||
| @ -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; | |||||
| } | |||||
| } | |||||
| @ -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); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @ -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; | |||||
| } | |||||
| } | } | ||||
| } | |||||
| } | } | ||||
| @ -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; | |||||
| } | |||||
| } | |||||
| @ -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("升级成功"); | |||||
| } | |||||
| } | |||||
| } | |||||
| @ -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> | |||||