using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.Threading;
using System.Globalization;
using System.Web; namespace Redis_AddData
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
label1.Text = "";
}
int maxSize = ; //
int minSize = ;
int currentIndex = ;
public static string tableName = "FA"; private void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false; Thread trs = new Thread(new ThreadStart(dofor));
trs.IsBackground = true;
trs.Start(); progressBar1.Minimum = minSize; string sql = "select count(id) from tablea ";
maxSize = Convert.ToInt32(databind.GetSingle(sql));
progressBar1.Maximum = maxSize;
} public void dofor()
{
SetLableText("数据加载中...");
currentIndex = minSize;
string str = "";
string sql = "select * from tablea"; SqlDataReader dr = databind.GetExecuteReader(sql, false);
DataTable Mydt = attribute.GetTableSchema();
while (dr.Read()) //读取所有记录
{
CompareInfo Compare = CultureInfo.InvariantCulture.CompareInfo; //设置indexof 不区分大小写
#region 设置显示的标签进度
SetLableText(string.Format("当前行:{0},剩余量:{1},完成比例:{2}%", currentIndex, maxSize - currentIndex, (Convert.ToDecimal(currentIndex - minSize) / Convert.ToDecimal(maxSize - minSize) * ).ToString("f0"))); SetPbValue(currentIndex);
#endregion ... this.BeginInvoke(new MethodInvoker(delegate()
{ button1.Enabled = false;
textBox1.Text = str;
})); }
currentIndex++;
} attribute.BulkToDB(Mydt); this.BeginInvoke(new MethodInvoker(delegate()
{ button1.Enabled = true;
textBox1.Text = "完成";
})); }
delegate void labDelegate(string str); private void SetLableText(string str)
{ if (label1.InvokeRequired)
{
Invoke(new labDelegate(SetLableText), new string[] { str });
} else
{
label1.Text = str;
}
}
delegate void pbDelegate(int value); private void SetPbValue(int value)
{ if (progressBar1.InvokeRequired)
{ Invoke(new pbDelegate(SetPbValue), new object[] { value }); } else
{ progressBar1.Value = value; } }
}
}

最新文章

  1. 用gcc进行程序的编译
  2. Ubuntu 安装tftp服务器
  3. oracle 秒
  4. [译] OpenStack Kilo 版本中 Neutron 的新变化
  5. CSS简写指南(转)
  6. springMVC导出 CSV案例
  7. 搭建jenkins环境(linux操作系统)
  8. 自定义控件和XControl控件
  9. Hadoop-2.2.0中文文档——MapReduce 下一代 -——集群配置
  10. RHEL7下PXE+Apache+Kickstart无人值守安装操作系统
  11. z-index的理解 z-index 属性仅在节点的 position 属性为 relative, absolute 或者 fixed 时生效.
  12. HBase配置&启动脚本分析
  13. CodeForces 150B- Quantity of Strings 推算..
  14. jquery四种监听事件的区别
  15. Nginx在windows环境下的安装与简单配置
  16. jqgrid three 树形结构
  17. Linux基础命令(三)——>文件过滤及内容编辑处理命令
  18. 第5-7次OO作业总结分析
  19. Centos6.5搭建grok匹配测试网站
  20. GMA Round 1 新年祝福

热门文章

  1. NHIBERNATE的简单框架的设计
  2. Spring Data Rest 支持Put请求
  3. 我的Emacs折腾经验谈(三) speedbar , tabbar 还有linum-mode
  4. 一步步学习Python-django开发-添加后台管理
  5. 改善C#公共程序类库质量的10种方法和工具
  6. UIColor RGB颜色对照表
  7. android openGl视频
  8. jQuery插件slides实现无缝轮播图特效
  9. CodeForces 631D Messenger
  10. Maven之(三)Maven插件