diff --git a/ButcherManageClient/SettingForm.Designer.cs b/ButcherManageClient/SettingForm.Designer.cs index f013cc2..4667b45 100644 --- a/ButcherManageClient/SettingForm.Designer.cs +++ b/ButcherManageClient/SettingForm.Designer.cs @@ -31,16 +31,16 @@ this.cancelBtn = new System.Windows.Forms.Button(); this.saveBtn = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); this.btnUpdate = new System.Windows.Forms.Button(); 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(); // // cancelBtn // 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.Size = new System.Drawing.Size(81, 53); this.cancelBtn.TabIndex = 7; @@ -51,7 +51,7 @@ // saveBtn // 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.Size = new System.Drawing.Size(81, 53); this.saveBtn.TabIndex = 6; @@ -69,20 +69,10 @@ this.label1.TabIndex = 4; 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 // 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.Size = new System.Drawing.Size(81, 53); this.btnUpdate.TabIndex = 6; @@ -98,23 +88,34 @@ this.uTextBoxWithPad1.Size = new System.Drawing.Size(706, 29); 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 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 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.Controls.Add(this.offlineSqlConInput); + this.Controls.Add(this.dbSelect); + this.Controls.Add(this.label3); this.Controls.Add(this.uTextBoxWithPad1); - this.Controls.Add(this.label2); this.Controls.Add(this.cancelBtn); this.Controls.Add(this.btnUpdate); this.Controls.Add(this.saveBtn); @@ -132,9 +133,9 @@ private System.Windows.Forms.Button cancelBtn; private System.Windows.Forms.Button saveBtn; private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; private System.Windows.Forms.Button btnUpdate; private System.Windows.Forms.TextBox uTextBoxWithPad1; - private System.Windows.Forms.TextBox offlineSqlConInput; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.ComboBox dbSelect; } } \ No newline at end of file diff --git a/ButcherManageClient/SettingForm.cs b/ButcherManageClient/SettingForm.cs index f89eb94..e40489d 100644 --- a/ButcherManageClient/SettingForm.cs +++ b/ButcherManageClient/SettingForm.cs @@ -25,9 +25,6 @@ namespace ButcherManageClient { InitializeComponent(); 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; } @@ -42,7 +39,7 @@ namespace ButcherManageClient if (string.IsNullOrEmpty(uri)) throw new Exception("请先设置服务器地址"); ButcherAppContext.Context.UrlConfig.ServerUrl = uri; - ButcherAppContext.Context.UrlConfig.OfflineSqlConnection = offlineSqlConInput.Text.Trim(); + ButcherAppContext.Context.UrlConfig.OfflineSqlConnection = (string)dbSelect.SelectedValue; ButcherAppContext.Context.Save(); @@ -53,7 +50,7 @@ namespace ButcherManageClient 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(); Dmo.UpdateTables(sqlUtil, boTypes); @@ -64,9 +61,9 @@ namespace ButcherManageClient List NeedUpdateDbDll() { var list=new List(); - 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"); return list; } @@ -106,5 +103,39 @@ namespace ButcherManageClient } return true; } + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if (!File.Exists("DBSelectTemplate.xml")) + { + var list = new List(); + 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>("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; } } }