📄 frmall.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace 通讯录
{
/// <summary>
/// frmall 的摘要说明。
/// </summary>
public class frmall : System.Windows.Forms.Form
{
private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public frmall()
{
//
// 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.dataGrid1 = new System.Windows.Forms.DataGrid();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.CaptionVisible = false;
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(0, 32);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(776, 392);
this.dataGrid1.TabIndex = 0;
//
// label1
//
this.label1.BackColor = System.Drawing.Color.Olive;
this.label1.Dock = System.Windows.Forms.DockStyle.Top;
this.label1.Font = new System.Drawing.Font("宋体", 15F, 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(800, 32);
this.label1.TabIndex = 1;
this.label1.Text = "所有信息";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// button1
//
this.button1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button1.Location = new System.Drawing.Point(696, 440);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 32);
this.button1.TabIndex = 2;
this.button1.Text = "退出";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// frmall
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(800, 485);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.dataGrid1);
this.Name = "frmall";
this.Text = "查看所以信息";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.frmall_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
this.Dispose();
}
private void frmall_Load(object sender, System.EventArgs e)
{
Classdb displayall=new Classdb();
DataSet ds=new DataSet();
SqlConnection con=displayall.conds();
string str="select name as '姓名',telephone as '电话',mobilepho as '手机',email as '电子邮件'";
str +=",qq as 'QQ',nowaddress as '现居地',familyaddress as '家乡',others as '备注',adddate as '添加日期',images as '照片' from stuinf";
SqlDataAdapter da=new SqlDataAdapter(str,con);
try
{
con.Open();
da.Fill(ds);
int i=ds.Tables[0].Rows.Count;
label1.Text="查询结果,总共有 ";
label1.Text +=i.ToString();
label1.Text +=" 条记录";
dataGrid1.DataSource=ds.Tables[0].DefaultView;
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.ToString());}
finally
{
con.Dispose();
da.Dispose();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -