1、问题描述
一共有3表,A是源操作表,B、C目的操作表。A B C 中都有两个个相同的字段。问题:现在用A中的这个关键字段分别去B和C中取得对应项的数据,在写回A表中的对应的另外一个字段。
这个工具目前设定的是;操作excel表,文件格式:.csv | .xls
2、结果
点击确定,完成转换。
3、代码
A、打开工具箱:添加openFileDialog控件,命名采用默认的就行了。
B、这次的代码做了stylecop规范检查。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ModifyData
{
/// <summary>
/// 窗口类
/// </summary>
public partial class Form1 : Form
{
#region private member
/// <summary>
/// 新建文件保存路径
/// </summary>
private string savePath = string.Empty;
/// <summary>
/// CSV文件数据集
/// </summary>
private DataSet fundCSVDs = null;
/// <summary>
/// 交易支付数据集
/// </summary>
private DataSet payXLSDs = null;
/// <summary>
/// 交易退款数据集
/// </summary>
private DataSet backXLSDs = null;
/// <summary>
/// 数据库连接
/// </summary>
private OleDbConnection conn;
/// <summary>
/// 源文件
/// </summary>
private string orinFileName = string.Empty;
/// <summary>
/// 目标文件
/// </summary>
private string[] aimFileName = new string[2];
/// <summary>
/// 批量读取
/// </summary>
private string[] everyRead = new string[300];
#endregion
#region 构造函数
/// <summary>
/// 构造函数
/// </summary>
public Form1()
{
this.InitializeComponent();
tbOrign.ReadOnly = true;
tbAim1.ReadOnly = true;
tbAim2.ReadOnly = true;
}
#endregion
#region 控件方法
/// <summary>
/// 添加源浏览文件
/// </summary>
/// <param name="sender">消息对象</param>
/// <param name="e">消息体</param>
private void BtnOrinSelect_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "Excel表格(CSV格式(*.csv)|*.csv";
openFileDialog1.FileName = string.Empty;
openFileDialog1.ShowDialog();
string selectFileName = openFileDialog1.FileName;
// 获取保存文件名路径
this.savePath = selectFileName;
tbOrign.Text = selectFileName;
// 获取文件名
this.orinFileName = tbOrign.Text.Remove(0, selectFileName.LastIndexOf("\\") + 1);
}
/// <summary>
/// 添加目的文件1
/// </summary>
/// <param name="sender">消息对象</param>
/// <param name="e">消息体</param>
private void BtnAim1_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "Excel表格(*.xls)|*.xls";
openF