博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
小姐姐sql只保留指定列
阅读量:4880 次
发布时间:2019-06-11

本文共 5974 字,大约阅读时间需要 19 分钟。

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1

{
public partial class Form1 : Form
{

private void Form1_Load(object sender, EventArgs e)

{

}

public Form1()
{
InitializeComponent();
}

public void dispose(int[] saves)
{

//int[] saves = {0, 1, 4,7};

FileStream aFile = new FileStream("e:/1.txt", FileMode.Open);
StreamReader sr = new StreamReader(aFile);
string str = sr.ReadToEnd();
sr.Close();

string str2 = "";

int num = 0;
for (int i = 0; i < str.Length; ++i)
{
if(str[i] == '\n')
{
num = 0;
label3.Text = "进度:"+ Math.Round(100.0*i/ str.Length, 3) + "%";
}
if (str[i] == ',' || str[i] == '(' || str[i] == ')')
{
++num;
}
if(Array.IndexOf(saves, num)!=-1)
{
str2 += str[i];
}
Application.DoEvents();
}
label3.Text = "进度:100%";

 

aFile = new FileStream("e:/2.txt", FileMode.Create);

StreamWriter sw = new StreamWriter(aFile);
sw.WriteLine(str2);
sw.Close();
}

private void buttonExec_Click(object sender, EventArgs e)

{
try
{
string str = textBox2.Text.ToString();
string[] strArr = str.Split(new char[] { ',' });
int[] saves = new int[strArr.Length + 2];
saves[0] = 0;
for (int i = 0; i < strArr.Length; ++i)
{
saves[i + 1] = int.Parse(strArr[i]);
}
saves[strArr.Length + 1] = int.Parse(textBox1.Text.ToString()) + 1;
this.dispose(saves);
}
catch
{
label3.Text = "输入不合法";
}
}
}
}

 

 

design/

namespace WindowsFormsApplication1

{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>

/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows 窗体设计器生成的代码

/// <summary>

/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.buttonExec = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// buttonExec
//
this.buttonExec.Location = new System.Drawing.Point(160, 215);
this.buttonExec.Name = "buttonExec";
this.buttonExec.Size = new System.Drawing.Size(75, 23);
this.buttonExec.TabIndex = 6;
this.buttonExec.Text = "执行";
this.buttonExec.UseVisualStyleBackColor = true;
this.buttonExec.Click += new System.EventHandler(this.buttonExec_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(14, 217);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 21);
this.textBox1.TabIndex = 7;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 200);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 12);
this.label1.TabIndex = 8;
this.label1.Text = "总列数:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 146);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(155, 12);
this.label2.TabIndex = 10;
this.label2.Text = "保留列,用逗号隔开:1,3,4";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(14, 163);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 21);
this.textBox2.TabIndex = 9;
//
// label3
//
this.label3.Anchor = System.Windows.Forms.AnchorStyles.None;
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(115, 45);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(23, 12);
this.label3.TabIndex = 11;
this.label3.Text = "...";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 98);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(263, 12);
this.label4.TabIndex = 12;
this.label4.Text = "输入文件:e:/1.txt 文件内容只包含插入语句";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(12, 121);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(113, 12);
this.label5.TabIndex = 13;
this.label5.Text = "输出文件:e:/2.txt";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(12, 9);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(137, 12);
this.label6.TabIndex = 14;
this.label6.Text = "小姐姐出品,必出精品!";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 261);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.buttonExec);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Button buttonExec;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
}
}

 

转载于:https://www.cnblogs.com/agchuanqi/p/9052491.html

你可能感兴趣的文章
React Antd中样式的修改
查看>>
Spring 应用外部属性文件 配置 context 错误
查看>>
导入lxml找不到etree,报ImportError:DLL load failed:找不到指定的程序
查看>>
面向对象一
查看>>
大象的崛起!Hadoop七年发展风雨录
查看>>
图片二值化
查看>>
数据库常用函数
查看>>
集合之TreeSet(含JDK1.8源码分析)
查看>>
C语言学习的记忆
查看>>
Lucene学习总结之三:Lucene的索引文件格式(1) 2014-06-25 14:15 1124人阅读 ...
查看>>
vhost:一种 virtio 高性能的后端驱动实现
查看>>
面试经验合集-Java后端<一>
查看>>
声明式事务
查看>>
[ACM_搜索] ZOJ 1103 || POJ 2415 Hike on a Graph (带条件移动3盘子到同一位置的最少步数 广搜)...
查看>>
[游戏模版6] Win32 graph
查看>>
ARM工作模式寻址
查看>>
mipi差分信号原理
查看>>
Docker Compose
查看>>
如何调整chm文字字体大小
查看>>
history replaceState/pushState
查看>>