コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd1 = new OpenFileDialog();

            ofd1.ShowDialog();

            //得到上传文件的完整名
            string loadFullName = ofd1.FileName.ToString();

            this.textBox2.Text = loadFullName;

            if (string.IsNullOrEmpty(loadFullName))
            {
                MessageBox.Show("请选择导入文件");
                return;
            }

            if (loadFullName.EndsWith(".xls") || loadFullName.EndsWith(".xlsx"))
            {
                oldDataTable = ExcelHelper.ImportExcel(loadFullName, 0, 1);
            }
            else if (loadFullName.EndsWith(".csv"))
            {
                oldDataTable = CSVFileHelper.OpenCSV(this.textBox2.Text.Trim(), 1);
            }
            else
            {
                Program.logger.LogInfo("无法识别的文件格式,请选择excel或者csv文件");
                return;
            }

            if (oldDataTable == null || oldDataTable.Rows.Count == 0)
            {
                MessageBox.Show("已分配额度导入数据为0条");
                return;
            }
            MessageBox.Show(string.Format("导入成功,共{0}条", oldDataTable.Rows.Count));
            Program.logger.LogInfo(string.Format("已分配额度表导入成功,共{0}条", oldDataTable.Rows.Count));
        }
コード例 #2
0
        private void button6_Click(object sender, EventArgs e)
        {
            string fileName = string.Format("券单导入_{0}", DateTime.Now.ToString("yyyyMMdd"));

            CSVFileHelper.SaveCSV(newDataTable, fileName);
        }