⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainform.cs

📁 车载GPS?今天这个就是最好的工具
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb; 
using System.Globalization;

namespace GpsClinet
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class MainForm : System.Windows.Forms.Form
	{
		private System.ComponentModel.IContainer components;
		private System.Windows.Forms.Button Save;
		private System.Windows.Forms.DateTimePicker dateTimePicker1;
		private System.Windows.Forms.Timer timer1;
		private System.Windows.Forms.DataGrid grdState;
		private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
		private System.Windows.Forms.DataGridTextBoxColumn taskid;
		private System.Windows.Forms.Button cmdQuery;
		private System.Windows.Forms.Timer timer2;
		private System.Windows.Forms.DataGridTextBoxColumn taskname;
		private taskcarReport.taskcarReport taskcarReport1;
		private string Serialnum;
		public static string strName;
		public static string strDate;
		public static string strNote;
		private DataTable dtAccept = new DataTable();
		private DataRow myDataRow;
		private int MaxRows;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button button3;
		private System.Windows.Forms.Button button4;
		private System.Windows.Forms.PictureBox pictureBox1;
		private System.Windows.Forms.Button Exit;
		internal System.Windows.Forms.TextBox Note;
		public string Connstring="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +Application.StartupPath + "/data/gas.mdb;Persist Security Info=true;Jet OLEDB:Database password=patrol_234";
		public MainForm()
		{
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <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.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
			this.Save = new System.Windows.Forms.Button();
			this.grdState = new System.Windows.Forms.DataGrid();
			this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
			this.taskid = new System.Windows.Forms.DataGridTextBoxColumn();
			this.taskname = new System.Windows.Forms.DataGridTextBoxColumn();
			this.cmdQuery = new System.Windows.Forms.Button();
			this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
			this.timer1 = new System.Windows.Forms.Timer(this.components);
			this.timer2 = new System.Windows.Forms.Timer(this.components);
			this.taskcarReport1 = new taskcarReport.taskcarReport();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.button3 = new System.Windows.Forms.Button();
			this.button4 = new System.Windows.Forms.Button();
			this.Note = new System.Windows.Forms.TextBox();
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.Exit = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.grdState)).BeginInit();
			this.SuspendLayout();
			// 
			// Save
			// 
			this.Save.Location = new System.Drawing.Point(576, 688);
			this.Save.Name = "Save";
			this.Save.Size = new System.Drawing.Size(96, 24);
			this.Save.TabIndex = 1;
			this.Save.Text = "发送";
			this.Save.Click += new System.EventHandler(this.Save_Click);
			// 
			// grdState
			// 
			this.grdState.DataMember = "";
			this.grdState.Font = new System.Drawing.Font("宋体", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.grdState.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.grdState.Location = new System.Drawing.Point(8, 168);
			this.grdState.Name = "grdState";
			this.grdState.Size = new System.Drawing.Size(184, 512);
			this.grdState.TabIndex = 3;
			this.grdState.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
																								 this.dataGridTableStyle1});
			this.grdState.Click += new System.EventHandler(this.grdState_Click);
			this.grdState.Navigate += new System.Windows.Forms.NavigateEventHandler(this.grdState_Navigate);
			// 
			// dataGridTableStyle1
			// 
			this.dataGridTableStyle1.DataGrid = this.grdState;
			this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] {
																												  this.taskid,
																												  this.taskname});
			this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGridTableStyle1.MappingName = "";
			// 
			// taskid
			// 
			this.taskid.Format = "";
			this.taskid.FormatInfo = null;
			this.taskid.HeaderText = "任务号";
			this.taskid.MappingName = "packet_id";
			this.taskid.Width = 75;
			// 
			// taskname
			// 
			this.taskname.Format = "";
			this.taskname.FormatInfo = null;
			this.taskname.HeaderText = "任务内容";
			this.taskname.MappingName = "packet_name";
			this.taskname.Width = 75;
			// 
			// cmdQuery
			// 
			this.cmdQuery.Location = new System.Drawing.Point(128, 688);
			this.cmdQuery.Name = "cmdQuery";
			this.cmdQuery.Size = new System.Drawing.Size(64, 24);
			this.cmdQuery.TabIndex = 5;
			this.cmdQuery.Text = "查找";
			this.cmdQuery.Click += new System.EventHandler(this.cmdQuery_Click);
			// 
			// dateTimePicker1
			// 
			this.dateTimePicker1.Location = new System.Drawing.Point(8, 688);
			this.dateTimePicker1.Name = "dateTimePicker1";
			this.dateTimePicker1.Size = new System.Drawing.Size(112, 21);
			this.dateTimePicker1.TabIndex = 6;
			// 
			// timer1
			// 
			this.timer1.Enabled = true;
			this.timer1.Interval = 1000;
			this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
			// 
			// timer2
			// 
			this.timer2.Interval = 1000;
			this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
			// 
			// taskcarReport1
			// 
			this.taskcarReport1.Location = new System.Drawing.Point(188, 156);
			this.taskcarReport1.Name = "taskcarReport1";
			this.taskcarReport1.SerialNo = "";
			this.taskcarReport1.Size = new System.Drawing.Size(828, 524);
			this.taskcarReport1.TabIndex = 7;
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(9, 91);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(72, 24);
			this.button1.TabIndex = 11;
			this.button1.Text = "头条信息";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(97, 91);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(88, 24);
			this.button2.TabIndex = 12;
			this.button2.Text = "前一条";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(9, 123);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(72, 24);
			this.button3.TabIndex = 13;
			this.button3.Text = "后一条";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// button4
			// 
			this.button4.Location = new System.Drawing.Point(97, 123);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(88, 24);
			this.button4.TabIndex = 14;
			this.button4.Text = "最后信息";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// Note
			// 
			this.Note.Location = new System.Drawing.Point(196, 72);
			this.Note.Multiline = true;
			this.Note.Name = "Note";
			this.Note.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.Note.Size = new System.Drawing.Size(828, 88);
			this.Note.TabIndex = 15;
			this.Note.Text = "";
			// 
			// pictureBox1
			// 
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(0, 0);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(968, 72);
			this.pictureBox1.TabIndex = 16;
			this.pictureBox1.TabStop = false;
			// 
			// Exit
			// 
			this.Exit.Location = new System.Drawing.Point(448, 688);
			this.Exit.Name = "Exit";
			this.Exit.Size = new System.Drawing.Size(80, 24);
			this.Exit.TabIndex = 17;
			this.Exit.Text = "退出";
			this.Exit.Click += new System.EventHandler(this.Exit_Click);
			// 
			// MainForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(1028, 722);
			this.ControlBox = false;
			this.Controls.Add(this.Note);
			this.Controls.Add(this.taskcarReport1);
			this.Controls.Add(this.Exit);
			this.Controls.Add(this.pictureBox1);
			this.Controls.Add(this.button4);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.dateTimePicker1);
			this.Controls.Add(this.cmdQuery);
			this.Controls.Add(this.grdState);
			this.Controls.Add(this.Save);
			this.Name = "MainForm";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			this.Load += new System.EventHandler(this.Form1_Load);
			((System.ComponentModel.ISupportInitialize)(this.grdState)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion
		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new MainForm());
		}
		private void Form1_Load(object sender, System.EventArgs e)
		{
			this.grdState.CaptionText ="当前要处理的任务";
			GetLineState();
			if (MaxRows==0)
			{
				this.Save.Enabled =false;
				return;
			}
			grdState_Click(sender,e);
			Serialnum=GetTradeMark();
}

		private void Save_Click(object sender, System.EventArgs e)
		{
			OleDbCommand cmSQL;
			OleDbDataReader drSQL;
			OleDbConnection cnSQL;
			string orderid;
			this.taskcarReport1.LoadSelectData();
			int a=Convert.ToInt16(this.taskcarReport1.recordData[3]);
			DateTime d= DateTime.Now;
			string sDate = d.ToShortDateString();
			string sTime=d.ToLongTimeString();
			orderid=Serialnum+d.ToString( "yyyyMMddhhmmss",DateTimeFormatInfo.CurrentInfo);
			try 
			{
				string mstr="INSERT INTO Complete(AcceptNO,Cdate,Ctime,Source,aaa,Detail," +
					"TaskCorp,Rust,Breakage,Failure,Press,Hearth,State,SerialBill) VALUES('" +
					orderid +"',cdate('"+sDate+"'),cdate('"+sTime+"'),'" +
					taskcarReport1.data[1]+"','" +
					taskcarReport1.data[2] +"','" +
					taskcarReport1.data[3] +"||" +
					taskcarReport1.data[4] +"||" +
					taskcarReport1.data[5] +"||" +
					taskcarReport1.data[6] +"','" +
					taskcarReport1.data[7] +"','" +
					taskcarReport1.data[8] +"','" +
					taskcarReport1.data[9] +"','" +
					taskcarReport1.data[10] +"','" +
					taskcarReport1.data[11] +"','" +
					taskcarReport1.data[12] +"',1,'"+
					this.taskcarReport1.SerialNo+"')";
				cnSQL = new OleDbConnection(Connstring); 
				cnSQL.Open(); 
				cmSQL = new OleDbCommand(mstr,cnSQL); 
				cmSQL.ExecuteNonQuery();
				cnSQL.Close();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -