Commit 76fe86c3 by 施晓雨

加入同步标记

parent 190f69a8
......@@ -52,6 +52,7 @@
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.btnSave = new System.Windows.Forms.Button();
this.btnLoadData = new System.Windows.Forms.Button();
this.btnClearData = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
......@@ -270,6 +271,7 @@
//
// groupBox3
//
this.groupBox3.Controls.Add(this.btnClearData);
this.groupBox3.Controls.Add(this.btnLoadData);
this.groupBox3.Controls.Add(this.btnSave);
this.groupBox3.Dock = System.Windows.Forms.DockStyle.Bottom;
......@@ -300,6 +302,16 @@
this.btnLoadData.UseVisualStyleBackColor = true;
this.btnLoadData.Click += new System.EventHandler(this.btnLoadData_Click);
//
// btnClearData
//
this.btnClearData.Location = new System.Drawing.Point(151, 34);
this.btnClearData.Name = "btnClearData";
this.btnClearData.Size = new System.Drawing.Size(110, 23);
this.btnClearData.TabIndex = 2;
this.btnClearData.Text = "清空本地数据";
this.btnClearData.UseVisualStyleBackColor = true;
this.btnClearData.Click += new System.EventHandler(this.btnClearData_Click);
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
......@@ -348,5 +360,6 @@
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.Button btnLoadData;
private System.Windows.Forms.Button btnClearData;
}
}
\ No newline at end of file
......@@ -94,6 +94,7 @@ namespace Kivii.Client.Test.Forms
foreach (var member in results)
{
if (conn.Exists<Member>(o => o.Kvid == member.Kvid)) continue;
member.Tag = KiviiContext.EntityTagForDbSync;//加入这个标记,代表数据本身的一些CurrentTime的标记不会被执行,完全按现有数据存入数据库
conn.Insert(member);
}
}
......@@ -116,5 +117,20 @@ namespace Kivii.Client.Test.Forms
if (conn != null) conn.Dispose();
}
}
private void btnClearData_Click(object sender, EventArgs e)
{
IDbConnection conn = null;
try
{
conn = KiviiContext.GetOpenedDbConnection<Member>();//和服务器上的用法一样,只是连接的数据库在本地的Config文件中指定了
conn.Delete<Member>(o=>o.Status>=0);
dgvResults.DataSource = null;
}
finally//这个方法不管try中有没有catch,都会最后执行,方便释放数据库连接,在客户端模式下,所有的连接不会自己自动释放,需要人为的释放,切记。
{
if (conn != null) conn.Dispose();
}
}
}
}
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