Browse Source

支持多账套登录

master
yibo 7 years ago
parent
commit
27bcd94246
2 changed files with 66 additions and 34 deletions
  1. +27
    -26
      ButcherManageClient/SettingForm.Designer.cs
  2. +39
    -8
      ButcherManageClient/SettingForm.cs

+ 27
- 26
ButcherManageClient/SettingForm.Designer.cs View File

@ -31,16 +31,16 @@
this.cancelBtn = new System.Windows.Forms.Button(); this.cancelBtn = new System.Windows.Forms.Button();
this.saveBtn = new System.Windows.Forms.Button(); this.saveBtn = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.btnUpdate = new System.Windows.Forms.Button(); this.btnUpdate = new System.Windows.Forms.Button();
this.uTextBoxWithPad1 = new System.Windows.Forms.TextBox(); this.uTextBoxWithPad1 = new System.Windows.Forms.TextBox();
this.offlineSqlConInput = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.dbSelect = new System.Windows.Forms.ComboBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// cancelBtn // cancelBtn
// //
this.cancelBtn.Font = new System.Drawing.Font("宋体", 20F); this.cancelBtn.Font = new System.Drawing.Font("宋体", 20F);
this.cancelBtn.Location = new System.Drawing.Point(402, 183);
this.cancelBtn.Location = new System.Drawing.Point(402, 175);
this.cancelBtn.Name = "cancelBtn"; this.cancelBtn.Name = "cancelBtn";
this.cancelBtn.Size = new System.Drawing.Size(81, 53); this.cancelBtn.Size = new System.Drawing.Size(81, 53);
this.cancelBtn.TabIndex = 7; this.cancelBtn.TabIndex = 7;
@ -51,7 +51,7 @@
// saveBtn // saveBtn
// //
this.saveBtn.Font = new System.Drawing.Font("宋体", 20F); this.saveBtn.Font = new System.Drawing.Font("宋体", 20F);
this.saveBtn.Location = new System.Drawing.Point(255, 183);
this.saveBtn.Location = new System.Drawing.Point(255, 175);
this.saveBtn.Name = "saveBtn"; this.saveBtn.Name = "saveBtn";
this.saveBtn.Size = new System.Drawing.Size(81, 53); this.saveBtn.Size = new System.Drawing.Size(81, 53);
this.saveBtn.TabIndex = 6; this.saveBtn.TabIndex = 6;
@ -69,20 +69,10 @@
this.label1.TabIndex = 4; this.label1.TabIndex = 4;
this.label1.Text = "服务器地址:"; this.label1.Text = "服务器地址:";
// //
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("宋体", 15F);
this.label2.Location = new System.Drawing.Point(18, 109);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(129, 20);
this.label2.TabIndex = 8;
this.label2.Text = "离线数据库:";
//
// btnUpdate // btnUpdate
// //
this.btnUpdate.Font = new System.Drawing.Font("宋体", 20F); this.btnUpdate.Font = new System.Drawing.Font("宋体", 20F);
this.btnUpdate.Location = new System.Drawing.Point(550, 183);
this.btnUpdate.Location = new System.Drawing.Point(550, 175);
this.btnUpdate.Name = "btnUpdate"; this.btnUpdate.Name = "btnUpdate";
this.btnUpdate.Size = new System.Drawing.Size(81, 53); this.btnUpdate.Size = new System.Drawing.Size(81, 53);
this.btnUpdate.TabIndex = 6; this.btnUpdate.TabIndex = 6;
@ -98,23 +88,34 @@
this.uTextBoxWithPad1.Size = new System.Drawing.Size(706, 29); this.uTextBoxWithPad1.Size = new System.Drawing.Size(706, 29);
this.uTextBoxWithPad1.TabIndex = 11; this.uTextBoxWithPad1.TabIndex = 11;
// //
// offlineSqlConInput
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("宋体", 15F);
this.label3.Location = new System.Drawing.Point(18, 110);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(129, 20);
this.label3.TabIndex = 12;
this.label3.Text = "离线数据库:";
//
// dbSelect
// //
this.offlineSqlConInput.Font = new System.Drawing.Font("宋体", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.offlineSqlConInput.Location = new System.Drawing.Point(140, 107);
this.offlineSqlConInput.Name = "offlineSqlConInput";
this.offlineSqlConInput.Size = new System.Drawing.Size(706, 29);
this.offlineSqlConInput.TabIndex = 11;
this.dbSelect.Font = new System.Drawing.Font("宋体", 15F);
this.dbSelect.FormattingEnabled = true;
this.dbSelect.Location = new System.Drawing.Point(140, 107);
this.dbSelect.Name = "dbSelect";
this.dbSelect.Size = new System.Drawing.Size(208, 28);
this.dbSelect.TabIndex = 13;
// //
// SettingForm // SettingForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(872, 284);
this.ClientSize = new System.Drawing.Size(886, 269);
this.ControlBox = false; this.ControlBox = false;
this.Controls.Add(this.offlineSqlConInput);
this.Controls.Add(this.dbSelect);
this.Controls.Add(this.label3);
this.Controls.Add(this.uTextBoxWithPad1); this.Controls.Add(this.uTextBoxWithPad1);
this.Controls.Add(this.label2);
this.Controls.Add(this.cancelBtn); this.Controls.Add(this.cancelBtn);
this.Controls.Add(this.btnUpdate); this.Controls.Add(this.btnUpdate);
this.Controls.Add(this.saveBtn); this.Controls.Add(this.saveBtn);
@ -132,9 +133,9 @@
private System.Windows.Forms.Button cancelBtn; private System.Windows.Forms.Button cancelBtn;
private System.Windows.Forms.Button saveBtn; private System.Windows.Forms.Button saveBtn;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button btnUpdate; private System.Windows.Forms.Button btnUpdate;
private System.Windows.Forms.TextBox uTextBoxWithPad1; private System.Windows.Forms.TextBox uTextBoxWithPad1;
private System.Windows.Forms.TextBox offlineSqlConInput;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox dbSelect;
} }
} }

+ 39
- 8
ButcherManageClient/SettingForm.cs View File

@ -25,9 +25,6 @@ namespace ButcherManageClient
{ {
InitializeComponent(); InitializeComponent();
uTextBoxWithPad1.Text = ButcherAppContext.Context.UrlConfig.ServerUrl; uTextBoxWithPad1.Text = ButcherAppContext.Context.UrlConfig.ServerUrl;
offlineSqlConInput.Text = ButcherAppContext.Context.UrlConfig.OfflineSqlConnection;
if (string.IsNullOrEmpty(offlineSqlConInput.Text))
offlineSqlConInput.Text = "Server=localhost;Database=LocalClientService;Integrated Security=true;Language=Simplified Chinese;";
mInited = rpcFacadeInited; mInited = rpcFacadeInited;
} }
@ -42,7 +39,7 @@ namespace ButcherManageClient
if (string.IsNullOrEmpty(uri)) if (string.IsNullOrEmpty(uri))
throw new Exception("请先设置服务器地址"); throw new Exception("请先设置服务器地址");
ButcherAppContext.Context.UrlConfig.ServerUrl = uri; ButcherAppContext.Context.UrlConfig.ServerUrl = uri;
ButcherAppContext.Context.UrlConfig.OfflineSqlConnection = offlineSqlConInput.Text.Trim();
ButcherAppContext.Context.UrlConfig.OfflineSqlConnection = (string)dbSelect.SelectedValue;
ButcherAppContext.Context.Save(); ButcherAppContext.Context.Save();
@ -53,7 +50,7 @@ namespace ButcherManageClient
private void btnUpdate_Click(object sender, EventArgs e) private void btnUpdate_Click(object sender, EventArgs e)
{ {
using (ISqlUtil sqlUtil = new SqlUtil(offlineSqlConInput.Text.Trim()))
using (ISqlUtil sqlUtil = new SqlUtil(ButcherAppContext.Context.UrlConfig.OfflineSqlConnection))
{ {
var boTypes = GetTypes(); var boTypes = GetTypes();
Dmo.UpdateTables(sqlUtil, boTypes); Dmo.UpdateTables(sqlUtil, boTypes);
@ -64,9 +61,9 @@ namespace ButcherManageClient
List<string> NeedUpdateDbDll() List<string> NeedUpdateDbDll()
{ {
var list=new List<string>(); var list=new List<string>();
list.Add("SegmentationWeight.dll");
list.Add("TrunksIousOutInStore.dll");
list.Add("SegmentationInStore.dll");
//list.Add("SegmentationWeight.dll");
//list.Add("TrunksIousOutInStore.dll");
//list.Add("SegmentationInStore.dll");
list.Add("BO.dll"); list.Add("BO.dll");
return list; return list;
} }
@ -106,5 +103,39 @@ namespace ButcherManageClient
} }
return true; return true;
} }
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!File.Exists("DBSelectTemplate.xml"))
{
var list = new List<DBSelectTemplate>();
list.Add(new DBSelectTemplate() { Name = "本机", Value = LOCALDB });
list.Add(new DBSelectTemplate() { Name = "194服务器", Value = REMOTEDB.Replace("{IP}", "172.28.1.194").Replace("{PWD}", "Wanfu2014") });
list.Add(new DBSelectTemplate() { Name = "99服务器", Value = REMOTEDB.Replace("{IP}", "172.28.1.99").Replace("{PWD}", "Wanfu2014") });
BO.Utils.XmlUtil.SerializerObjToFile(list, "DBSelectTemplate.xml");
}
var db = BO.Utils.XmlUtil.DeserializeFromFile<List<DBSelectTemplate>>("DBSelectTemplate.xml");
dbSelect.DisplayMember = "Name";
dbSelect.ValueMember = "Value";
dbSelect.DataSource = db;
if (!string.IsNullOrEmpty(ButcherAppContext.Context.UrlConfig.OfflineSqlConnection))
{
var idx = db.FindIndex(x => x.Value == ButcherAppContext.Context.UrlConfig.OfflineSqlConnection);
if (idx > 0)
dbSelect.SelectedIndex = idx;
}
}
const string LOCALDB = "Server=.;Database=LocalClientService;Integrated Security=true;Language=Simplified Chinese;";
const string REMOTEDB = "Server={IP};Database=LocalClientService;User ID=sa;Password={PWD};Language=Simplified Chinese;";
}
public class DBSelectTemplate
{
public string Name { get; set; }
public string Value { get; set; }
} }
} }

Loading…
Cancel
Save