Commit 49d1305d authored by tr's avatar tr

1、数据库配置:增加粘贴时自动解析填充功能

parent 0b5c1657
...@@ -216,7 +216,7 @@ namespace Tools.MyUtils ...@@ -216,7 +216,7 @@ namespace Tools.MyUtils
/// <param name="userId"></param> /// <param name="userId"></param>
/// <param name="pwd"></param> /// <param name="pwd"></param>
/// <returns></returns> /// <returns></returns>
public static string GetLinkString(string link, string userId, string pwd, string dbName) public static string GetDbLinkString(string link, string userId, string pwd, string dbName)
{ {
return $"Password={pwd};Persist Security Info=True;User ID={userId};Initial Catalog={dbName};Data Source={link}"; return $"Password={pwd};Persist Security Info=True;User ID={userId};Initial Catalog={dbName};Data Source={link}";
} }
...@@ -225,9 +225,9 @@ namespace Tools.MyUtils ...@@ -225,9 +225,9 @@ namespace Tools.MyUtils
/// </summary> /// </summary>
/// <param name="m"></param> /// <param name="m"></param>
/// <returns></returns> /// <returns></returns>
public static string GetLinkString(DbItemModel m) public static string GetDbLinkString(DbItemModel m)
{ {
return GetLinkString(m.Link, m.UserId, m.Pwd, m.DbName); return GetDbLinkString(m.Link, m.UserId, m.Pwd, m.DbName);
} }
/// <summary> /// <summary>
/// 链接转为模型对象 /// 链接转为模型对象
......
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
this.tbLink.Name = "tbLink"; this.tbLink.Name = "tbLink";
this.tbLink.Size = new System.Drawing.Size(168, 21); this.tbLink.Size = new System.Drawing.Size(168, 21);
this.tbLink.TabIndex = 4; this.tbLink.TabIndex = 4;
this.tbLink.KeyUp += new System.Windows.Forms.KeyEventHandler(this.tbLink_KeyUp);
// //
// tbDbName // tbDbName
// //
......
...@@ -37,10 +37,10 @@ namespace Tools.MyUtils ...@@ -37,10 +37,10 @@ namespace Tools.MyUtils
DataTable _dt = null; DataTable _dt = null;
string link_cfg = $@"{Utils.ConfigPath}\links.xml"; string link_cfg = $@"{Utils.ConfigPath}\links.xml";
string Link => this.tbLink.Text.Trim(); string Link { get => this.tbLink.Text.Trim(); set => this.tbLink.Text = value; }
string DbName => this.tbDbName.Text.Trim(); string DbName { get => this.tbDbName.Text.Trim(); set => this.tbDbName.Text = value; }
string UserId => this.tbUserId.Text.Trim(); string UserId { get => this.tbUserId.Text.Trim(); set => this.tbUserId.Text = value; }
string Pwd => this.tbPwd.Text.Trim(); string Pwd { get => this.tbPwd.Text.Trim(); set => this.tbPwd.Text = value; }
public wDbSetting(object control = null) public wDbSetting(object control = null)
{ {
...@@ -139,6 +139,36 @@ namespace Tools.MyUtils ...@@ -139,6 +139,36 @@ namespace Tools.MyUtils
{ {
this.EchoControl?.GetType().GetProperty("Text")?.SetValue(this.EchoControl, m.ToString()); this.EchoControl?.GetType().GetProperty("Text")?.SetValue(this.EchoControl, m.ToString());
} }
/// <summary>
/// 链接粘贴时,自动解析
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tbLink_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyData == (Keys.Control | Keys.V))
{
var item = Utils.GetDbItemModel(this.tbLink.Text);
if (!string.IsNullOrEmpty(item.Link))
{
this.Display(item);
}
}
}
/// <summary>
/// 链接展示
/// </summary>
/// <param name="item"></param>
private void Display(DbItemModel item)
{
this.Link = item.Link;
this.DbName = item.DbName;
this.UserId = item.UserId;
this.Pwd = item.Pwd;
}
} }
...@@ -148,7 +178,7 @@ namespace Tools.MyUtils ...@@ -148,7 +178,7 @@ namespace Tools.MyUtils
public string DbName { get; set; } public string DbName { get; set; }
public string UserId { get; set; } public string UserId { get; set; }
public string Pwd { get; set; } public string Pwd { get; set; }
public string LinkString => Utils.GetLinkString(this); public string LinkString => Utils.GetDbLinkString(this);
public override string ToString() public override string ToString()
{ {
return $"{this.DbName}({this.Link})"; return $"{this.DbName}({this.Link})";
......
...@@ -55,7 +55,7 @@ namespace Tools.UI ...@@ -55,7 +55,7 @@ namespace Tools.UI
{ {
#region 初始化数据库对象 #region 初始化数据库对象
string link = Utils.GetLinkString("192.168.1.204", "sa", "sa", "FTT_PDM"); string link = Utils.GetDbLinkString("192.168.1.204", "sa", "sa", "FTT_PDM");
this.InitDBHelper(link); this.InitDBHelper(link);
#endregion #endregion
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment