connectionshowaccess.cs

来自「独立完成考勤管理软件加打卡系统(C#) 是打卡加管理系统软件 」· CS 代码 · 共 513 行 · 第 1/2 页

CS
513
字号
			this.stState.Icon = ((System.Drawing.Icon)(resources.GetObject("stState.Icon")));
			this.stState.Text = "状态:";
			this.stState.Width = 150;
			// 
			// TitleLabel
			// 
			this.TitleLabel.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(255)));
			this.TitleLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.TitleLabel.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.TitleLabel.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.TitleLabel.Location = new System.Drawing.Point(0, 48);
			this.TitleLabel.Name = "TitleLabel";
			this.TitleLabel.Size = new System.Drawing.Size(808, 40);
			this.TitleLabel.TabIndex = 2;
			this.TitleLabel.Text = "连接Access数据库";
			this.TitleLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// dataGrid
			// 
			this.dataGrid.AlternatingBackColor = System.Drawing.Color.GhostWhite;
			this.dataGrid.BackColor = System.Drawing.Color.GhostWhite;
			this.dataGrid.BackgroundColor = System.Drawing.Color.Lavender;
			this.dataGrid.BorderStyle = System.Windows.Forms.BorderStyle.None;
			this.dataGrid.CaptionBackColor = System.Drawing.Color.RoyalBlue;
			this.dataGrid.CaptionForeColor = System.Drawing.Color.White;
			this.dataGrid.CaptionVisible = false;
			this.dataGrid.DataMember = "";
			this.dataGrid.FlatMode = true;
			this.dataGrid.Font = new System.Drawing.Font("Tahoma", 8F);
			this.dataGrid.ForeColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid.GridLineColor = System.Drawing.Color.RoyalBlue;
			this.dataGrid.HeaderBackColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
			this.dataGrid.HeaderForeColor = System.Drawing.Color.Lavender;
			this.dataGrid.LinkColor = System.Drawing.Color.Teal;
			this.dataGrid.Location = new System.Drawing.Point(0, 88);
			this.dataGrid.Name = "dataGrid";
			this.dataGrid.ParentRowsBackColor = System.Drawing.Color.Lavender;
			this.dataGrid.ParentRowsForeColor = System.Drawing.Color.MidnightBlue;
			this.dataGrid.SelectionBackColor = System.Drawing.Color.Teal;
			this.dataGrid.SelectionForeColor = System.Drawing.Color.PaleGreen;
			this.dataGrid.Size = new System.Drawing.Size(808, 296);
			this.dataGrid.TabIndex = 3;
			this.dataGrid.CurrentCellChanged += new System.EventHandler(this.dataGrid_CurrentCellChanged);
			// 
			// oleDbDataAdapter
			// 
			this.oleDbDataAdapter.InsertCommand = this.oleDbInsertCommand1;
			this.oleDbDataAdapter.SelectCommand = this.oleDbSelectCommand1;
			this.oleDbDataAdapter.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																									   new System.Data.Common.DataTableMapping("Table", "month10", new System.Data.Common.DataColumnMapping[] {
																																																				  new System.Data.Common.DataColumnMapping("amorpm", "amorpm"),
																																																				  new System.Data.Common.DataColumnMapping("comedate", "comedate"),
																																																				  new System.Data.Common.DataColumnMapping("day", "day"),
																																																				  new System.Data.Common.DataColumnMapping("name", "name")})});
			// 
			// oleDbInsertCommand1
			// 
			this.oleDbInsertCommand1.CommandText = "INSERT INTO month10(amorpm, comedate, day, name) VALUES (?, ?, ?, ?)";
			this.oleDbInsertCommand1.Connection = this.oleDbConnection;
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("amorpm", System.Data.OleDb.OleDbType.VarWChar, 2, "amorpm"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("comedate", System.Data.OleDb.OleDbType.DBDate, 0, "comedate"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("day", System.Data.OleDb.OleDbType.DBDate, 0, "day"));
			this.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("name", System.Data.OleDb.OleDbType.VarWChar, 50, "name"));
			// 
			// oleDbConnection
			// 
			this.oleDbConnection.ConnectionString = "Provider=\"Microsoft.Jet.OLEDB.4.0\";Data Source=\"C:\\Documents and Settings\\user\\桌面" +
				"\\考勤软件\\WindowsApplication\\access\\2006.mdb\"";
			// 
			// oleDbSelectCommand1
			// 
			this.oleDbSelectCommand1.CommandText = "SELECT amorpm, comedate, day, name FROM month10";
			this.oleDbSelectCommand1.Connection = this.oleDbConnection;
			// 
			// connectionAccessSet
			// 
			this.connectionAccessSet.DataSetName = "ConnectionAccessSet";
			this.connectionAccessSet.Locale = new System.Globalization.CultureInfo("zh-CN");
			// 
			// timer1
			// 
			this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
			// 
			// ConnectionShowAccess
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.Color.White;
			this.ClientSize = new System.Drawing.Size(806, 419);
			this.Controls.Add(this.dataGrid);
			this.Controls.Add(this.TitleLabel);
			this.Controls.Add(this.status);
			this.Controls.Add(this.tool);
			this.Cursor = System.Windows.Forms.Cursors.Hand;
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
			this.HelpButton = true;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "ConnectionShowAccess";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "ConnectionShowAccess";
			this.Load += new System.EventHandler(this.ConnectionShowAccess_Load);
			((System.ComponentModel.ISupportInitialize)(this.stStauts)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.stOperator)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.stDate)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.stTime)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.stState)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.connectionAccessSet)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion
        #region 初始化事件...
		private void ConnectionShowAccess_Load(object sender, System.EventArgs e)
		{
			try
			{
				DataTable tempTable=new DataTable(); 
				this.oleDbDataAdapter.Fill(connectionAccessSet);
				tempTable=connectionAccessSet.Tables[0];
				dataGrid.DataSource=tempTable;
				this.stDate.Text="当前日期:"+DateTime.Now.ToString("yyyy-MM-dd").Trim();
				this.stOperator.Text="当前用户:"+landFrame.strUserName;
				cmOrders=(System.Windows.Forms.CurrencyManager) BindingContext[tempTable];
				this.stStauts.Text="所有记录:"+WindowsApplication.selectCount.selectCountDB.searchCount("select count(*) from month10").Trim()+"条";
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
		}
        #endregion
		#region 工具栏事件...
		private void tool_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			try
			{
				if(e.Button.Text.ToString().Equals("首记录"))
				{
					this.dataGrid.UnSelect(this.cmOrders.Position);
					this.cmOrders.Position=0;
					this.dataGrid.Select(this.cmOrders.Position);
					this.dataGrid.CurrentRowIndex=this.cmOrders.Position;
					MessageBox.Show(this,"你已经到了记录开始了,无法继续向上移动了啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
					this.tFirst.Enabled=false;
					this.tLast.Enabled=false;
					this.tNext.Enabled=true;
					this.tEnd.Enabled=true;
					return;
				}
				else if(e.Button.Text.ToString().Equals("尾记录"))
				{
					this.dataGrid.UnSelect(this.cmOrders.Position);
					this.cmOrders.Position=this.cmOrders.Count-1;
					this.dataGrid.Select(this.cmOrders.Position);
					this.dataGrid.CurrentRowIndex=this.cmOrders.Position;
					MessageBox.Show(this,"你已经到了最后一条记录,无法继续向下移啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
					this.tFirst.Enabled=true;
					this.tLast.Enabled=true;
					this.tNext.Enabled=false;
					this.tEnd.Enabled=false;
					return;
				}
				else if(e.Button.Text.ToString().Equals("下一条记录"))
				{
					if(this.cmOrders.Position.Equals(this.cmOrders.Count-1))
					{
						MessageBox.Show(this,"你已经到了最后一条记录,无法继续向下移啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
						this.tFirst.Enabled=true;
						this.tLast.Enabled=true;
						this.tNext.Enabled=false;
						this.tEnd.Enabled=false;
					}
					else if(this.cmOrders.Position<this.cmOrders.Count-1)
					{
						this.dataGrid.UnSelect(this.cmOrders.Position);
						this.cmOrders.Position++;
						this.dataGrid.Select(this.cmOrders.Position);
						this.dataGrid.CurrentRowIndex=this.cmOrders.Position;
					}
					return;
				}
				else if(e.Button.Text.ToString().Equals("上一条记录"))
				{
					if(this.cmOrders.Position==0)
					{
						MessageBox.Show(this,"你已经到了记录开始了,无法继续向上移动了啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
						this.tFirst.Enabled=false;
						this.tLast.Enabled=false;
						this.tNext.Enabled=true;
						this.tEnd.Enabled=true;
					}
					else if(this.cmOrders.Position>0)
					{
						this.dataGrid.UnSelect(this.cmOrders.Position);
						this.cmOrders.Position--;
						this.dataGrid.Select(this.cmOrders.Position);
						this.dataGrid.CurrentRowIndex=this.cmOrders.Position;
					}
					return;
				}
				else if(e.Button.Text.ToString().Equals("删除历史"))
				{
					if(this.ds.Tables[0].Rows.Count>0)
					{
						this.cmOrders.RemoveAt(this.cmOrders.Position);
						oleDbDataAdapter.Update(ds);
					}
					else
					{
						return;
					}
					return;
				}
				else if(e.Button.Text.ToString().Equals("退出"))
				{
					DialogResult result=MessageBox.Show(this,"是否要关闭此窗体啦!!!","提示信息",MessageBoxButtons.YesNo,MessageBoxIcon.Information);
					if(result.Equals(DialogResult.Yes))
					{
						Close();
					}
					else
					{
						return;
					}
					return;
				}
				else if(e.Button.ToolTipText.ToString().Equals("查询"))
				{
					
				}
			}
			catch(Exception ele)
			{
				MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
			}
		}
        #endregion
		#region 光标移动何地显示不同的值...
		private void dataGrid_CurrentCellChanged(object sender, System.EventArgs e)
		{
				this.stState.Text="编号:"+this.dataGrid[this.dataGrid.CurrentRowIndex,0].ToString().Trim();
		}
		#endregion
		#region 时间处理事件...
		private void timer1_Tick(object sender, System.EventArgs e)
		{
		    this.stTime.Text="当前时间:"+WindowsApplication.dealTime.dealTime.dealTimeString(System.DateTime.Now.Hour,System.DateTime.Now.Minute,System.DateTime.Now.Second).Trim();
		}
		#endregion
	}
}

⌨️ 快捷键说明

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