/// <summary> /// 异步 开始事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void worker_DoWork(object sender, DoWorkEventArgs e) { //需要执行的代码 worker.ReportProgress(5, "开始导入代理商类型...\r\n"); //导入代理商类型 AgentTypeDao agentTypeDao = new AgentTypeDao(); for (int i = 0; i < dgAgentType.RowCount; i++) { AgentType agentType = new AgentType(); agentType.agentNo = dgAgentType[0, i].Value.ToString(); agentType.agentType = dgAgentType[1, i].Value.ToString(); agentType.agentFeeMonth = this.dtFeeMonth.Value.ToString("yyyy-MM"); agentTypeDao.Delete(agentType); agentTypeDao.Add(agentType); } worker.ReportProgress(6, "导入代理商类型完成...\r\n"); worker.ReportProgress(7, "开始导入代理商类型说明...\r\n"); //导入代理商类型说明 AgentTypeCommentDao agentTypeCommentDao = new AgentTypeCommentDao(); for (int i = 0; i < dgAgentTypeComment.RowCount; i++) { AgentTypeComment agentTypeComment = new AgentTypeComment(); agentTypeComment.agentType = dgAgentTypeComment[0, i].Value.ToString(); agentTypeComment.agentTypeComment = dgAgentTypeComment[1, i].Value.ToString(); agentTypeComment.agentFeeMonth = this.dtFeeMonth.Value.ToString("yyyy-MM"); agentTypeCommentDao.Delete(agentTypeComment); agentTypeCommentDao.Add(agentTypeComment); } ImportLog importLog = new ChinaUnion_BO.ImportLog(); importLog.type="Agent"; importLog.import_month = this.dtFeeMonth.Value.ToString("yyyy-MM"); ImportLogDao importLogDao = new ChinaUnion_DataAccess.ImportLogDao(); importLogDao.Delete(importLog); importLogDao.Add(importLog); worker.ReportProgress(8, "导入代理商类型完成...\r\n"); //MessageBox.Show("数据上传完毕"); }