コード例 #1
0
        /// <summary>
        /// 产生对账明细
        /// </summary>
        /// <param name="hb">行别</param>
        /// <param name="model">请求报文</param>
        /// <param name="outFileName">产生的对账文件</param>
        private void GenerateDuiZhangDetail(string hb, WtwyzzjcdzModel model, out string outFileName)
        {
            string fileName = "";

            fileName += "11";//机构码
            fileName += "G501";
            fileName += "_W";

            DateTime dt      = new DateTime();
            string   strDate = dt.ToString("yyyyMMdd");

            fileName += strDate;
            fileName += ".";
            fileName += "380910";//6位银行代号

            outFileName = fileName;

            string filePath = BasicOperation.GetFilePath(hb) + fileName;//文件的完整路径


            List <ZbmxzModel> list = db2Operation.GetZbmxzByJyrq(model.Qsrq, model.Zzrq);

            FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write);

            using (StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding("gb2312")))
            {
                string summaryLine = string.Empty;
                summaryLine += model.Yhzh;
                summaryLine += ",";
                summaryLine += strDate;
                summaryLine += ",";
                summaryLine += model.Zje;
                summaryLine += ",";
                summaryLine += model.Zbs;
                summaryLine += ",";
                sw.WriteLine(summaryLine);//汇总行
            }

            //明细行
            for (int i = 1; i <= list.Count; i++)
            {
                string detailLine = string.Empty;
                detailLine += i.ToString();
                detailLine += ",";
                detailLine += list[i].Jyrq;
                detailLine += ",";
                detailLine += list[i].Jysj;
                detailLine += ",";
                detailLine += BasicOperation.GenerateBatchCode("110000000", i);//批次号
                detailLine += ",";
                detailLine += BasicOperation.GenerateName("李", i);
                detailLine += ",";
                detailLine += list[i].Zh;
                detailLine += ",";
                detailLine += list[i].Fse;
                detailLine += ",";
                detailLine += list[i].Yhls; //银行流水
                detailLine += ",";
                detailLine += list[i].Jdbz; //记账标志
                detailLine += ",";
                detailLine += list[i].Yhls; //备注中添写银行流水号
                detailLine += ",";

                using (StreamWriter sw = new StreamWriter(filePath, true, Encoding.GetEncoding("gb2312")))
                {
                    sw.WriteLine(detailLine);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 产生对账明细
        /// </summary>
        private void GenerateDuiZhangDetail(string hb, out string outFileName)
        {
            string strDate  = DateTime.Now.ToShortDateString();
            string fileName = "";

            fileName   += model.Jgm;
            fileName   += "Z";//支取
            fileName   += "_W";
            fileName   += strDate;
            fileName   += ".";
            fileName   += "380910";//6位银行代号
            outFileName = fileName;

            List <ZbmxzModel> list     = db2Operation.GetZbmxzByRqrq(db2Operation.GetDjrqrq());
            string            filePath = BasicOperation.GetFilePath(hb) + fileName;//文件的完整路径
            FileStream        fs       = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write);

            using (StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding("gb2312")))
            {
                //汇总行:机构码,交易日期,总金额,总笔数
                string summaryLine = string.Empty;
                summaryLine += model.Jgm;
                summaryLine += ",";
                summaryLine += strDate;
                summaryLine += ",";
                summaryLine += model.Zje;
                summaryLine += ",";
                summaryLine += model.Zbs;
                summaryLine += ",";
                sw.WriteLine(summaryLine);
            }

            //明细行
            for (int i = 1; i <= list.Count; i++)
            {
                string detailLine = string.Empty;
                detailLine += i.ToString();
                detailLine += ",";
                detailLine += list[i].Jyrq;
                detailLine += ",";
                detailLine += list[i].Jysj;
                detailLine += ",";
                detailLine += BasicOperation.GenerateBatchCode("110000000", i);//批次号
                detailLine += ",";
                detailLine += BasicOperation.GenerateName("李", i);
                detailLine += ",";
                detailLine += list[i].Zh;
                detailLine += ",";
                detailLine += list[i].Fse;
                detailLine += ",";
                detailLine += list[i].Yhls; //银行流水
                detailLine += ",";
                detailLine += list[i].Jdbz; //记账标志
                detailLine += ",";
                detailLine += list[i].Yhls; //备注中添写银行流水号
                detailLine += ",";

                using (StreamWriter sw = new StreamWriter(filePath, true, Encoding.GetEncoding("gb2312")))
                {
                    sw.WriteLine(detailLine);
                }
            }
        }