📄 form3.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Xml;
using System.IO;
using System.Data.SqlClient;
namespace SKXT
{
/// <summary>
/// Form3 的摘要说明。
/// </summary>
public class Form3 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button button3;
/// <summary>
/// 必需的设计器变量。
/// </summary>
public string FileName;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
private System.ComponentModel.Container components = null;
private string TAG;
private string bm;
private int i;
public Form3(string sdf,string biaoming)
{
//
// Windows 窗体设计器支持所必需的
//
TAG=sdf;
bm=biaoming;
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
private SqlConnection GetConnection()
{
SqlConnection conn=new SqlConnection();
conn.ConnectionString="data source=LIUJIALE;initial catalog=SKDB;user id=sa;password=";
return conn;
}
private SqlDataReader GetDataReader(string cmd,SqlConnection conn)
{
SqlCommand comm=null;
SqlDataReader reader=null;
comm=new SqlCommand();
comm.CommandText=cmd;
comm.Connection=conn;
reader=comm.ExecuteReader();
return reader;
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.button3 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.SuspendLayout();
//
// label1
//
this.label1.BackColor = System.Drawing.Color.CadetBlue;
this.label1.Font = new System.Drawing.Font("黑体", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(536, 32);
this.label1.TabIndex = 2;
this.label1.Text = " 数 据 上 报";
//
// label5
//
this.label5.Location = new System.Drawing.Point(8, 184);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(128, 24);
this.label5.TabIndex = 11;
this.label5.Text = " > 生成数据文件";
//
// label4
//
this.label4.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label4.Location = new System.Drawing.Point(8, 144);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(128, 24);
this.label4.TabIndex = 10;
this.label4.Text = " > 选择保存地址";
//
// label3
//
this.label3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label3.Location = new System.Drawing.Point(8, 104);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(128, 24);
this.label3.TabIndex = 9;
this.label3.Text = " > 选择上传数据";
this.label3.Click += new System.EventHandler(this.label3_Click);
//
// label2
//
this.label2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.Location = new System.Drawing.Point(8, 64);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(128, 24);
this.label2.TabIndex = 8;
this.label2.Text = " > 阅读程序说明";
//
// button2
//
this.button2.Location = new System.Drawing.Point(400, 280);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(64, 24);
this.button2.TabIndex = 15;
this.button2.Text = "导 出";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.Location = new System.Drawing.Point(304, 280);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(64, 24);
this.button1.TabIndex = 14;
this.button1.Text = "<上一步";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label6
//
this.label6.Location = new System.Drawing.Point(152, 164);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(104, 20);
this.label6.TabIndex = 16;
this.label6.Text = "选择文件保存地址";
//
// button3
//
this.button3.Location = new System.Drawing.Point(464, 160);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(38, 22);
this.button3.TabIndex = 18;
this.button3.Text = "浏览";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(256, 160);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(200, 21);
this.textBox1.TabIndex = 19;
this.textBox1.Text = "";
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// saveFileDialog1
//
this.saveFileDialog1.Filter = "“xml文件(*.xml)|*.xml|所有文件(*.*)|*.*”";
this.saveFileDialog1.Title = "选择文件保存地址";
//
// Form3
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(528, 333);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button3);
this.Controls.Add(this.label6);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form3";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "数据上报";
this.Load += new System.EventHandler(this.Form3_Load);
this.ResumeLayout(false);
}
#endregion
private void label3_Click(object sender, System.EventArgs e)
{
}
private void domainUpDown1_SelectedItemChanged(object sender, System.EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
this.Visible = false;
Form2 f2=new Form2();
f2.Show();
}
private void button2_Click(object sender, System.EventArgs e)
{
if(TAG=="0")//要补的上报记录
{
System.Xml.XmlTextWriter liu = new System.Xml.XmlTextWriter(@FileName,System.Text.Encoding.UTF8);
liu.Formatting=System.Xml.Formatting.Indented;
liu.WriteStartDocument();
liu.WriteStartElement("SBJL");
string cmd=null;
try
{
SqlConnection conncj=GetConnection();
conncj.Open();
cmd="select * from SBJL";
SqlDataReader reader = GetDataReader(cmd,conncj);
while( reader.Read())
{
liu.WriteStartElement("SBJL");
liu.WriteAttributeString("SKBM", reader.GetString(0));
liu.WriteElementString("SKMC", reader.GetString(1));
liu.WriteElementString("SZS", reader.GetString(2));
liu.WriteElementString("SCBG", reader.GetString(3));
liu.WriteElementString("SCRQ", reader.GetString(4));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -