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

📄 frmin.cs

📁 一个6合彩记帐软件
💻 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.IO;
namespace 六合彩
{
	/// <summary>
	/// FrmIN 的摘要说明。
	/// </summary>
	public class FrmIN : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.TextBox txtNum;
		private System.Windows.Forms.TextBox txtMoney;
     	static string strconnection = "provider=microsoft.jet.oledb.4.0;Data Source="+Application.StartupPath+@"\ld1.mdb" ;
	 
		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Panel panel3;
		private Label[] dd=new Label [49];
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Button btnDel;
		private System.Windows.Forms.Button btnDelAll;
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.MenuItem menuItem4;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public FrmIN()
		{
			//
			// 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()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FrmIN));
			this.panel3 = new System.Windows.Forms.Panel();
			this.label6 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.panel2 = new System.Windows.Forms.Panel();
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			this.button1 = new System.Windows.Forms.Button();
			this.label2 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.txtMoney = new System.Windows.Forms.TextBox();
			this.txtNum = new System.Windows.Forms.TextBox();
			this.btnDel = new System.Windows.Forms.Button();
			this.btnDelAll = new System.Windows.Forms.Button();
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.button2 = new System.Windows.Forms.Button();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.panel3.SuspendLayout();
			this.panel2.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.SuspendLayout();
			// 
			// panel3
			// 
			this.panel3.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel3.BackgroundImage")));
			this.panel3.Controls.Add(this.label6);
			this.panel3.Controls.Add(this.label4);
			this.panel3.Location = new System.Drawing.Point(304, 128);
			this.panel3.Name = "panel3";
			this.panel3.Size = new System.Drawing.Size(424, 368);
			this.panel3.TabIndex = 7;
			// 
			// label6
			// 
			this.label6.Font = new System.Drawing.Font("宋体", 11F);
			this.label6.ForeColor = System.Drawing.Color.Red;
			this.label6.Location = new System.Drawing.Point(320, 289);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(20, 20);
			this.label6.TabIndex = 0;
			this.label6.Text = "总";
			// 
			// label4
			// 
			this.label4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label4.ForeColor = System.Drawing.Color.Red;
			this.label4.Location = new System.Drawing.Point(344, 288);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(72, 16);
			this.label4.TabIndex = 6;
			this.label4.Text = "总投注金额";
			// 
			// panel2
			// 
			this.panel2.Controls.Add(this.dataGrid1);
			this.panel2.Location = new System.Drawing.Point(0, 128);
			this.panel2.Name = "panel2";
			this.panel2.Size = new System.Drawing.Size(304, 392);
			this.panel2.TabIndex = 5;
			// 
			// dataGrid1
			// 
			this.dataGrid1.DataMember = "";
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(8, 0);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.Size = new System.Drawing.Size(288, 384);
			this.dataGrid1.TabIndex = 0;
			this.dataGrid1.DoubleClick += new System.EventHandler(this.dataGrid1_DClick);
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(32, 96);
			this.button1.Name = "button1";
			this.button1.TabIndex = 4;
			this.button1.Text = "输入";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// label2
			// 
			this.label2.Font = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Bold);
			this.label2.Location = new System.Drawing.Point(40, 64);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(56, 16);
			this.label2.TabIndex = 3;
			this.label2.Text = "金额:";
			// 
			// label1
			// 
			this.label1.Font = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Bold);
			this.label1.Location = new System.Drawing.Point(40, 32);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(56, 16);
			this.label1.TabIndex = 2;
			this.label1.Text = "特码:";
			// 
			// txtMoney
			// 
			this.txtMoney.Location = new System.Drawing.Point(104, 64);
			this.txtMoney.Name = "txtMoney";
			this.txtMoney.TabIndex = 1;
			this.txtMoney.Text = "";
			this.txtMoney.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtMoney_KeyPress);
			// 
			// txtNum
			// 
			this.txtNum.ImeMode = System.Windows.Forms.ImeMode.Off;
			this.txtNum.Location = new System.Drawing.Point(104, 32);
			this.txtNum.MaxLength = 2;
			this.txtNum.Name = "txtNum";
			this.txtNum.Size = new System.Drawing.Size(96, 21);
			this.txtNum.TabIndex = 0;
			this.txtNum.Text = "";
			this.txtNum.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtNum_KeyDown);
			this.txtNum.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtNum_KeyPress);
			// 
			// btnDel
			// 
			this.btnDel.Location = new System.Drawing.Point(112, 96);
			this.btnDel.Name = "btnDel";
			this.btnDel.TabIndex = 9;
			this.btnDel.Text = "删除(Del)";
			this.btnDel.Click += new System.EventHandler(this.btnDel_Click);
			// 
			// btnDelAll
			// 
			this.btnDelAll.Location = new System.Drawing.Point(440, 72);
			this.btnDelAll.Name = "btnDelAll";
			this.btnDelAll.Size = new System.Drawing.Size(120, 23);
			this.btnDelAll.TabIndex = 10;
			this.btnDelAll.Text = "删除全部数据(F1)";
			this.btnDelAll.Click += new System.EventHandler(this.btnDelAll_Click);
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem1});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem2,
																					  this.menuItem3,
																					  this.menuItem4});
			this.menuItem1.Text = "菜单";
			this.menuItem1.Visible = false;
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 0;
			this.menuItem2.Shortcut = System.Windows.Forms.Shortcut.Del;
			this.menuItem2.Text = "删除纪录(Del)";
			this.menuItem2.Click += new System.EventHandler(this.btnDel_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 1;
			this.menuItem3.Shortcut = System.Windows.Forms.Shortcut.F1;
			this.menuItem3.Text = "删除全部(F1)";
			this.menuItem3.Click += new System.EventHandler(this.btnDelAll_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(208, 96);
			this.button2.Name = "button2";
			this.button2.TabIndex = 13;
			this.button2.Text = "更改(F2)";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 2;
			this.menuItem4.Shortcut = System.Windows.Forms.Shortcut.F2;
			this.menuItem4.Text = "更改(F2)";
			this.menuItem4.Click += new System.EventHandler(this.button2_Click);
			// 
			// FrmIN
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(752, 534);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.txtMoney);
			this.Controls.Add(this.txtNum);
			this.Controls.Add(this.btnDel);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.btnDelAll);
			this.Controls.Add(this.panel3);
			this.Controls.Add(this.panel2);
			this.Menu = this.mainMenu1;
			this.Name = "FrmIN";
			this.Text = "FrmIN";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.FrmIN_Closing);
			this.Load += new System.EventHandler(this.FrmIN_Load);
			this.Closed += new System.EventHandler(this.FrmIN_Closed);
			this.panel3.ResumeLayout(false);
			this.panel2.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion
		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new FrmIN());
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
//			this.ActiveControl=GetNextControl(txtNum,true);
			 
			if(txtMoney.Text!="")
			{  

				Insert();
				datagrid1See();
				txtNum.Text="";
				txtMoney.Text="";
				this.txtNum.Focus ();   
			 
				label4.Text = SumDate()+"元";
			}
			else
			{
			 this.txtMoney.Focus ();
			}
			 
		}
		private void tUpdate()
		{
           
			string sShoe="22";
			string sMm="0";
			try
			{

				dataGrid1.CurrentCell = new DataGridCell(dataGrid1.CurrentRowIndex,0); //使当前dataGrid的单元格为选择行的第一列
				
				string sID = dataGrid1[this.dataGrid1.CurrentCell].ToString(); //就是选定行的第一列的值

				dataGrid1.CurrentCell = new DataGridCell(dataGrid1.CurrentRowIndex,1);
				  sShoe = dataGrid1[this.dataGrid1.CurrentCell].ToString();
                 
				dataGrid1.CurrentCell = new DataGridCell(dataGrid1.CurrentRowIndex,2);
				  sMm = dataGrid1[this.dataGrid1.CurrentCell].ToString();
			  
//				lb1.Text =sShoe;
//				lb2.Text =sMm;
				
				 
				OleDbConnection cusconnection = new OleDbConnection(strconnection); 
				cusconnection.Open(); 		   				
				string strcmd = "update mshoe set shoe='"+sShoe+"',mm="+sMm+" where id="+sID;  
				OleDbCommand cmd = new OleDbCommand(strcmd,cusconnection); 
				cmd.ExecuteNonQuery(); 
				cusconnection.Close(); 
				//以下这段代码和上面实现的功能是一样,只是实现的方式不同。
				/*
					string SqlCmd = "insert into mshoe(shoe,mm,inserttime) VALUES (@shoe, @mm, @inserttime)";
 
					 OleDbCommand cmd = new OleDbCommand(SqlCmd,cusconnection); 
					cmd.Parameters.Add("@shoe", OleDbType.VarChar,8).Value =sNum;
					cmd.Parameters.Add("@mm", OleDbType.Integer).Value =22;
					cmd.Parameters.Add("@inserttime",OleDbType.Date).Value = sDateTime;
					cmd.ExecuteNonQuery();
					*/
			}
			catch(Exception  ex)
			{
				MessageBox.Show (ex.Message  );
					 
				 
			}
		
		}

		private void Insert()
		{
			string sNum=txtNum.Text ;
			int iNum=Int32.Parse(sNum); 
			sNum=iNum.ToString(); 
			
			string sDateTime=System.DateTime.Today.ToShortDateString();
			if(txtMoney.Text=="" || sNum=="")
			{
				MessageBox.Show("特码或金额没有填写,请认真检查一下。");
			
			}			 
			else
			{

				try
				{

					int iMoney=Int32.Parse(txtMoney.Text); 
				 
					OleDbConnection cusconnection = new OleDbConnection(strconnection); 
					cusconnection.Open(); 		   				
					string strcmd = "insert into mshoe(shoe,mm,inserttime) values('"+sNum +"',"+txtMoney.Text +",'"+sDateTime+"')";  
					OleDbCommand cmd = new OleDbCommand(strcmd,cusconnection); 
					cmd.ExecuteNonQuery(); 
					cusconnection.Close(); 
					//以下这段代码和上面实现的功能是一样,只是实现的方式不同。
					/*
					string SqlCmd = "insert into mshoe(shoe,mm,inserttime) VALUES (@shoe, @mm, @inserttime)";
 
					 OleDbCommand cmd = new OleDbCommand(SqlCmd,cusconnection); 
					cmd.Parameters.Add("@shoe", OleDbType.VarChar,8).Value =sNum;
					cmd.Parameters.Add("@mm", OleDbType.Integer).Value =22;
					cmd.Parameters.Add("@inserttime",OleDbType.Date).Value = sDateTime;
					cmd.ExecuteNonQuery();
					*/
				}
				catch(Exception  ex)
				{
					MessageBox.Show (ex.Message  );
					 
				 
				}
		
			}
		}
		/*
		private void  datagridSee()//--绑定控件datagrid
		{
 		   string sWhere="SELECT * FROM mshoe order by ID  asc";
//		 string sWhere="select bh as varchar, ID,shoe,mm,inserttime from( SELECT * , bh=(SELECT COUNT(name) FROM mshoe ) + 1 FROM mshoe ) t order by bh";
		  
			OleDbConnection cusconnection = new OleDbConnection(strconnection); 
			DataSet myDataSet = new DataSet ( ) ;
			cusconnection.Open(); 
			string strCom = sWhere ;

⌨️ 快捷键说明

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