zoukankan      html  css  js  c++  java
  • 从数据库导入到Excel表格(同时传四个表的数据到一个Excel中)

     public static bool AddOfficialCaseRegisters(string path)//选择导出的路径
            {
                List<DataTable> dt = GetLeadinExcel(path);
                int z = 0;
                for (int i = 2; i < dt[0].Rows.Count; i++)
                {
                    string sql1 = string.Format("select * from OfficialCaseRegisters where  Identitycard='{0}' and  FillTime='{1}' ", dt[0].Rows[i][2], dt[0].Rows[0][7]);
                    DataTable tb = DBHelper.GetDataSet(sql1);
                    if (tb.Rows.Count == 0)
                    {
                        if (dt[0].Rows[i][1].ToString() != "")
                        {
                            string sql = string.Format(@"insert into OfficialCaseRegisters(ID,Name,Gender,Identitycard,UnitName,PostName,Rank,Rewards,FillUnitName,FillTime) values('{0}','{1} ','{2} ','{3} ','{4} ','{5} ','{6} ','{7} ','{8}','{9}')",
                               Guid.NewGuid().ToString(), dt[0].Rows[i][0].ToString().Trim(), dt[0].Rows[i][1].ToString(), dt[0].Rows[i][2].ToString().Trim(), dt[0].Rows[i][3].ToString().Trim(), dt[0].Rows[i][4].ToString().Trim(), dt[0].Rows[i][5].ToString().Trim(), dt[0].Rows[i][6].ToString().Trim(), dt[0].Rows[0][1].ToString().Trim(), dt[0].Rows[0][7].ToString().Trim());
                            z = DBHelper.ExecuteCommand(sql);
                        }
                    }
                }
                if (z != 0)
                {
                    for (int j = 3; j < dt[1].Rows.Count - 1; j++)
                    {
                        string sql3 = string.Format(@"insert into PraiseInfo(Id,Appointment,Attend,SumNumber,Award,RewardsThree,RewardsTwo,RewardsOne,Garland,Other,FileDepart,FileTime)
                                   values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')", Guid.NewGuid().ToString(), dt[1].Rows[j][1].ToString(), dt[1].Rows[j][2].ToString(), dt[1].Rows[j][3].ToString(), dt[1].Rows[j][4].ToString(), dt[1].Rows[j][5].ToString(), dt[1].Rows[j][6].ToString(), dt[1].Rows[j][7].ToString(), dt[1].Rows[j][8].ToString(), dt[1].Rows[j][9].ToString(), dt[0].Rows[0][1].ToString().Trim(), dt[0].Rows[0][7].ToString().Trim());
                        DBHelper.ExecuteCommand(sql3);
                    }
                    for (int k = 4; k < dt[2].Rows.Count - 1; k++)
                    {
                        string sql2 = string.Format(@"insert into PrepareCase(Id,CheckGrade,TotalNumber,TotalThan,TCondemnNumber,TCondemnThan,FCondemnNumber,FCondemnThan,TNaturalNumber,TNaturalThan,FNaturalNumber,FNaturalThan,NnturalMagNumber,NnturalMagThan,TradeManNumber,TradeManThan,FIleDepart,FileTime)
                                      values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}')",
                                      Guid.NewGuid().ToString(), dt[2].Rows[k][1].ToString(), dt[2].Rows[k][2].ToString(), dt[2].Rows[k][3].ToString(), dt[2].Rows[k][4].ToString(), dt[2].Rows[k][5].ToString(), dt[2].Rows[k][6].ToString(), dt[2].Rows[k][7].ToString(), dt[2].Rows[k][8].ToString(), dt[2].Rows[k][9].ToString(), dt[2].Rows[k][10].ToString(), dt[2].Rows[k][11].ToString(), dt[2].Rows[k][12].ToString(), dt[2].Rows[k][13].ToString(), dt[2].Rows[k][14].ToString(), dt[2].Rows[k][15].ToString(), dt[0].Rows[0][1].ToString().Trim(), dt[0].Rows[0][7].ToString().Trim());
                        DBHelper.ExecuteCommand(sql2);
                    }
                    return true;
                }
                else
                {
                    return false;
                }
            }
    
  • 相关阅读:
    自动化测试框架相关资料下载
    C++白盒测试最佳实践课程,3个免费名额火热申请中,31号前截止申请...
    亿能测试培训中心 下周进入完整自动化测试项目实训阶段
    亿能测试大讲堂
    自动化测试调查问卷送《QTP自动化测试最佳实践》
    8月白盒测试课程
    广州亿能自动化测试沙龙
    8月自动化测试课程
    广州亿能自动化测试沙龙
    史上最强的自动化测试课程7月开设
  • 原文地址:https://www.cnblogs.com/xiaofengfeng/p/1806795.html
Copyright © 2011-2022 走看看