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

📄 frmin.cs

📁 一个6合彩记帐软件
💻 CS
📖 第 1 页 / 共 2 页
字号:
			try
			{
				OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , cusconnection ) ;		
				myCommand.Fill ( myDataSet , "mshoe" ) ;	
				dataGrid.SetDataBinding(myDataSet,"mshoe");
				cusconnection.Close ( ) ;
                InitDataGridColumnHeader();
				//------------------
					
			}
			catch(Exception  ex)
			{
 			MessageBox.Show (ex.Message  );
				 
				this.Close ();
				 
			}  
		
		}
		*/
        
		private void  datagrid1See()//--绑定控件datagrid1
		{
			string sWhere="SELECT ID,shoe as 特码,mm as 金额 FROM mshoe where mm>0 order by ID  desc";
			//		 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 ( ) ;
            myDataSet.Clear();
			cusconnection.Open(); 
			string strCom = sWhere ;
			try
			{
				OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , cusconnection ) ;		
				myCommand.Fill ( myDataSet , "mshoe" ) ;	
				dataGrid1.SetDataBinding(myDataSet,"mshoe");
				cusconnection.Close ( ) ;
				//               InitDataGridColumnHeader();
				//------------------
			 
				
				
			}
			catch(Exception  ex)
			{
				MessageBox.Show (ex.Message  );
				 this.Close ();
				
				 
			}  
		
		}

		private void  datagriddel(string UserCoding)//--通过ID来删除控件datagrid指定的列值
		{
			try
			{
			 
				OleDbConnection cusconnection = new OleDbConnection(strconnection); 
				cusconnection.Open(); 		   				
				string strcmd = "DELETE FROM mshoe  WHERE id =  "+UserCoding;  
				OleDbCommand cmd = new OleDbCommand(strcmd,cusconnection); 
				cmd.ExecuteNonQuery();  
				cusconnection.Close(); 
			  
			}
			catch(Exception  ex)
			{
				MessageBox.Show (ex.Message  );
					 
				 
			}
		}
		private string  SumDate()
		{   
			
//			DateTime DT =dtp.Value;			
//			
//			string stime=DT.ToShortDateString();
			string sSum="";
//			string[] kk=new string [88];
			string[] sNum=new string[49] ;
//			int iX=40;
			int iY=49;
			try
			{
			 
				OleDbConnection cusconnection = new OleDbConnection(strconnection); 
				cusconnection.Open(); 		   				
				DataSet myDataSet = new DataSet ( ) ;
				string strCom="select sum(mm) as mll,shoe from mshoe Group By shoe ";
				OleDbDataAdapter myCommand = new OleDbDataAdapter ( strCom , cusconnection ) ;		
				myCommand.Fill ( myDataSet , "mshoe" ) ;
				string sShoe="";
				int ie;
			
				for(int i=0;i<49;i++)
				{   

					sShoe=myDataSet.Tables[0].Rows[i]["shoe"].ToString();
					ie=Int32.Parse(sShoe)-1;
					sNum[ie]=myDataSet.Tables[0].Rows[i]["mll"].ToString();
					
				}
                int iSum=0;
				for(int i=0;i<49;i++)
				{   
                  iSum+=Int32.Parse(sNum[i]);
				}
				sSum=iSum.ToString(); 
                 int iNum=0;
				for(int i=0;i<49;i++)
				{  
					iNum=i+1;
					if(iNum>0&&iNum<14)
					{
					    iY=49+(iNum-1)*24;
						this.dd[i].Location =new Point(30,iY);
					}
					else if(iNum>13&&iNum<27)
					{
						iY=49+(iNum-14)*24;
						this.dd[i].Location =new Point(141,iY);
					}
					else if(iNum>26&&iNum<40)
					{
						iY=49+(iNum-27)*24;
						this.dd[i].Location =new Point(244,iY);
					}
					else
					{
						iY=49+(iNum-40)*24;
						this.dd[i].Location =new Point(346,iY);
					}
					 this.dd[i].Text =sNum[i]+"元";
				}
				// ------------------
//				string strcmd="select sum(mm) as mll from mshoe Group By shoe ";
//				OleDbCommand cmd = new OleDbCommand(strcmd,cusconnection); 
//				cmd.CommandType=CommandType.Text;
//				cmd.Parameters.Add("@inserttime",OleDbType.Date).Value = stime;
//				OleDbDataReader reader=cmd.ExecuteReader();
//				while(reader.Read())
//				{			 
////					label3.Text=reader.GetInt32(0).ToString ();
//					sSum=reader["mll"].ToString ();
//				 
//					 
//
//				}			 
				
				cusconnection.Close(); 
				 
				 
				
			  
			}
			catch(Exception  ex)
			{
				MessageBox.Show (ex.Message  );
					 
				 
			}
             return sSum;
		}
		private void InitDataGridColumnHeader()//---datagrid控件的样式
		{
			dataGrid1.TableStyles.Clear(); //第二次调用时,这个datagrid控件已经有样式,一定要清理,不然会出问题
			
			DataGridTableStyle dts=new DataGridTableStyle(); 

			//注意:必须加上这一句,否则自定义列格式无法使用
			dts.MappingName="mshoe"; //-----这里一定要用你的数据表名,不然会不生效
           			

			dataGrid1.TableStyles.Add(dts);

			dataGrid1.TableStyles[0].GridColumnStyles.Clear();

			//========================设置表头栏位===========================
			DataGridTableStyle dtsLog = new DataGridTableStyle();

//			DataGridTextBoxColumn colIDe = new DataGridTextBoxColumn();
//			colIDe.Width=20; 
//			colIDe.HeaderText = "记录数量";
//			colIDe.MappingName = "bh";
//
//			dataGrid.TableStyles[0].GridColumnStyles.Add(colIDe);  

      
			DataGridTextBoxColumn colID = new DataGridTextBoxColumn();
			colID.Width=20; 
			colID.HeaderText = "记录序号";
			colID.MappingName = "ID";

			dataGrid1.TableStyles[0].GridColumnStyles.Add(colID);  
   
			DataGridTextBoxColumn colLog = new DataGridTextBoxColumn();
			colLog.Width=100; 
			colLog.HeaderText = "下注号码";
			colLog.MappingName = "shoe";
			 

			dataGrid1.TableStyles[0].GridColumnStyles.Add(colLog);  
   

			DataGridTextBoxColumn colCatalog = new DataGridTextBoxColumn();
			colCatalog.Width=100; 
			colCatalog.HeaderText = "下注金额";
			colCatalog.MappingName = "mm";  
			dataGrid1.TableStyles[0].GridColumnStyles.Add(colCatalog); 

			DataGridTextBoxColumn colTime = new DataGridTextBoxColumn();
			colTime.Width=100; 
			colTime.HeaderText = "记录日期";
			colTime.MappingName = "inserttime";

			dataGrid1.TableStyles[0].GridColumnStyles.Add(colTime);    

		    
			
		}

		private void txtNum_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			 if(e.KeyChar     ==   (char)13)   
			{
				this.txtMoney.Focus ();   
		    }   

		}

		private void txtMoney_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{    
            
			try
			{
				string sNum=txtNum.Text ;
				int iNum=Int32.Parse(sNum);
				if(iNum>49)
				{    
					this.txtNum.Focus ();
					txtNum.Text="";
					MessageBox.Show("你的特码超过了49,请更正!");
				}
				else
				{
					if(e.KeyChar==(char)13)   
					{
						this.button1.Focus ();   
					} 
 
				}
			}
			catch
			{
			
			txtNum.Text="";
				this.txtNum.Focus ();
			
			}
		}

		private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
//			string it = tabControl1.SelectedIndex.ToString ();
//			string sName=tabControl1.SelectedTab.Name ;
////            datagridSee();
//            SumDate();
////			switch (sName)
////			{								
////
////				
////				case "tabPage0":
////
////					ish="d";
////					
////					break;
////				case "tabPage1":
//					ish="2d";	 	
//					
		}

//		private void button2_Click(object sender, System.EventArgs e)
//		{
//			dataGrid.CurrentCell = new DataGridCell(dataGrid.CurrentRowIndex,0); //使当前dataGrid的单元格为选择行的第一列
//			string UserCoding = dataGrid[this.dataGrid.CurrentCell].ToString(); //就是选定行的第一列的值
//			 
//             datagriddel(UserCoding);
//			 
//			  
//		}


		 

		private void FrmIN_Load(object sender, System.EventArgs e)
		{
			for (int i = 0; i < 49; i++)
			{
				this.dd[i] = new System.Windows.Forms.Label() ;
			
 				this.dd[i].Size = new System.Drawing.Size(72, 17);
				this.dd[i].ForeColor =System.Drawing.Color.Green   ;
			    this.dd[i].Location =new Point(1,699);
				dd[i].BackColor =System.Drawing.Color.White  ;
			 
				this.dd[i].Text =" ";
				this.panel3.Controls.Add(dd[i]);
				 
			}
			datagrid1See();
		}

		private void btnDel_Click(object sender, System.EventArgs e)
		{
			
			try
			{
				dataGrid1.CurrentCell = new DataGridCell(dataGrid1.CurrentRowIndex,0); //使当前dataGrid的单元格为选择行的第一列
				string UserCoding = dataGrid1[this.dataGrid1.CurrentCell].ToString(); //就是选定行的第一列的值
			 
				datagriddel(UserCoding);
				datagrid1See();
				 
				label4.Text = SumDate()+"元";

			}
			catch
			{
				MessageBox.Show ("数据已经为空,不能再删除!!");
					 				 
			}
		}

		private void btnDelAll_Click(object sender, System.EventArgs e)
		{
			DialogResult d = MessageBox.Show("全部数据删除后,将不能恢复!?", "是清空?", MessageBoxButtons.OKCancel);
			string s = d.ToString();
			if (s == "OK")
			{
				string filename1=Application.StartupPath+@"\\ld1.mdb"; 	
				string filename2=Application.StartupPath+@"\ld1\ld1.mdb"; 
				File.Copy(filename2,filename1,true); 

				datagrid1See();
				 
				label4.Text = SumDate()+"元";
			}
		}

		private void txtNum_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
		
			try
			{
				string sNum=txtNum.Text ;
				if(txtNum.Text!="")
				{
					int iNl=sNum.Length;
					if(iNl>0)
					{
						this.txtMoney.Focus (); 
			
					}
				}
				else
				{
				this.txtNum.Focus(); 
				}
			}
			catch
			{
			    txtNum.Text="";
				this.txtNum.Focus(); 
			
			}
		 
		}

		private void dataGrid1_DClick(object sender, System.EventArgs e)
		{
			tUpdate();
			datagrid1See();
				 
			label4.Text = SumDate()+"元";
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			tUpdate();
			datagrid1See();
				 
			label4.Text = SumDate()+"元";
		}

		private void FrmIN_Closed(object sender, System.EventArgs e)
		{
			Application.Exit();
		}

		private void FrmIN_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
//		Application.Exit();
		}

	

		 

		 

	 
	}
}

⌨️ 快捷键说明

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