private void btnUpdate2_Click(object sender, EventArgs e) { btnUpdate2.Enabled = false; var i = 0; progressBar1.Maximum = dataGridView1.Rows.Count; Thread t = new Thread(new ThreadStart(() => { TMM.Service.DocService bll = new TMM.Service.DocService(); bll.Initialize(); foreach (DataGridViewRow row in dataGridView1.Rows) { Thread.Sleep(10); //执行数据库操作 string err = string.Empty; UpdateDoc(row, bll, ref err); i++; progressBar1.Value = i; } btnUpdate2.Enabled = true; MessageBox.Show("批量操作更新完成"); })); t.IsBackground = true; t.Start(); }
/// <summary> /// 根据某一分类ID,获取两级子分类的ID,如果没有子分类,则返回传入分类ID本身 /// </summary> /// <param name="catalogId"></param> /// <returns></returns> public static int[] GetCatalogIds(int catalogId) { TMM.Service.DocService ds = new TMM.Service.DocService(); ds.Initialize(); List <int> l = new List <int>(); l.Add(catalogId); IList <S_Catalog> c1 = ds.SCatalogBll.GetSubList(catalogId); c1.ToList().ForEach(s => { l.Add(s.CatalogId); s.SubCatalog.ToList().ForEach(ss => l.Add(ss.CatalogId)); }); if (l.Count > 0) { return(l.ToArray()); } else { return(null); } }
/// <summary> /// 根据某一分类ID,获取两级子分类的ID,如果没有子分类,则返回传入分类ID本身 /// </summary> /// <param name="catalogId"></param> /// <returns></returns> public static int[] GetCatalogIds(int catalogId) { TMM.Service.DocService ds = new TMM.Service.DocService(); ds.Initialize(); List<int> l = new List<int>(); l.Add(catalogId); IList<S_Catalog> c1 = ds.SCatalogBll.GetSubList(catalogId); c1.ToList().ForEach(s => { l.Add(s.CatalogId); s.SubCatalog.ToList().ForEach(ss => l.Add(ss.CatalogId)); }); if (l.Count > 0) { return l.ToArray(); } else return null; }
private void btnUpdate2_Click(object sender, EventArgs e) { btnUpdate2.Enabled = false; var i = 0; progressBar1.Maximum = dataGridView1.Rows.Count; Thread t = new Thread(new ThreadStart(() => { TMM.Service.DocService bll = new TMM.Service.DocService(); bll.Initialize(); foreach (DataGridViewRow row in dataGridView1.Rows) { Thread.Sleep(10); //执行数据库操作 string err = string.Empty; UpdateDoc(row,bll,ref err); i++; progressBar1.Value = i; } btnUpdate2.Enabled = true; MessageBox.Show("批量操作更新完成"); })); t.IsBackground = true; t.Start(); }