zoukankan      html  css  js  c++  java
  • 读取txt文件修改数据库

    public void DealEfileReturn(FileInfo file)
    {
    long totalRecords = 0;
    IList<EfileList> list = Baosight.BPMS.Core.Adapter.BPMSDocUtil.QueryEfileList(0, -1, new SqlFilter("projectNo='090410'and BusinessKey1='13CNSHG3200019A0' "), new SqlSort("order by BusinessKey1"), out totalRecords);
    if (list.Count > 0)
    {
    //预存字符串的变量
    string str = "";

    if (file.Exists)
    {
    using (StreamReader streamReader = new StreamReader(file.FullName, Encoding.Default))
    {
    while (streamReader.Peek() >= 0)
    {
    str = streamReader.ReadLine();
    if (str.Length > 0)
    {
    //调用事务处理
    using (DbTransactionWrapper wrapper = new DbTransactionWrapper())
    {
    string[] data = Regex.Split(str, "&&");
    #region MyRegion

    //foreach (string item in data)
    //{
    EfileList entity = new EfileList();

    entity.ProjectNo = StringFormat(data[0].Trim());
    entity.BusinessKey1 = StringFormat(data[1].Trim());
    entity.BusinessKey2 = StringFormat(data[2].Trim());

    string flas = StringFormat(data[3].Trim());

    entity.EfileConfirmDate = DateTimeFormat(data[4]);

    if (flas == "1")
    {
    Database db = DatabaseFactory.CreateDatabase(DATABASE_INSTANCE_NAME);

    string sql = string.Format(@"UPDATE T_SYS_EFILE_LIST SET EfileStatus='02',EfileConfirmDate='" + entity.EfileConfirmDate + "' WHERE projectNo='" + entity.ProjectNo + "'and BusinessKey1='" + entity.BusinessKey1 + "' and BusinessKey2='" + entity.BusinessKey2 + "'");

    int i = db.ExecuteNonQuery(CommandType.Text, sql);
    }

    else if (flas == "0")
    {
    Database db = DatabaseFactory.CreateDatabase(DATABASE_INSTANCE_NAME);

    string sql = string.Format(@"UPDATE T_SYS_EFILE_LIST SET EfileStatus='11',EfileConfirmDate='" + entity.EfileConfirmDate + "' WHERE projectNo='" + entity.ProjectNo + "'and BusinessKey1='" + entity.BusinessKey1 + "' and BusinessKey2='" + entity.BusinessKey2 + "'");

    int i = db.ExecuteNonQuery(CommandType.Text, sql);
    }
    //}
    #endregion
    wrapper.Commit();


    }
    }
    }
    streamReader.Close();
    }
    }
    else
    {
    throw (new Exception());
    }

    }

    }

  • 相关阅读:
    JavaScript基本数据类型
    被遗弃的HTML事件处理程序
    jQuery中Ajax封装的方法
    观察者模式
    Git仓库初始化与推送到远端仓库
    使用Jax-rs 开发RESTfull API 入门
    普通 Java 项目转换为 Maven 项目
    在网页边角添加GitHub链接图标
    MyBatis 3 与 Spring 4 整合关键
    Thymeleaf 3与Spring MVC 4 整合配置
  • 原文地址:https://www.cnblogs.com/zmmlczy/p/3877841.html
Copyright © 2011-2022 走看看