📄 tongxun.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.OleDb ;
namespace HoursInfo
{
/// <summary>
/// tongxun 的摘要说明。
/// </summary>
public class tongxun : System.Windows.Forms.Form
{
OleDbDataReader reader;
bool m_BIDconTrol;
long m_nID;
string stro;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.ComboBox leibie;
private System.Windows.Forms.Button chaxun;
private System.Windows.Forms.Button add;
private System.Windows.Forms.Button delete;
private System.Windows.Forms.Button amend;
private System.Windows.Forms.TextBox name;
private System.Windows.Forms.TextBox dianhua;
private System.Windows.Forms.TextBox dianhua2;
private System.Windows.Forms.TextBox dizhi;
private System.Data.OleDb.OleDbConnection oleDbConnection1;
private System.Windows.Forms.DateTimePicker dateTimePicker1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button showAll;
private System.Windows.Forms.Button deleteAll;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public tongxun()
{
//
// 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.label1 = new System.Windows.Forms.Label();
this.name = new System.Windows.Forms.TextBox();
this.dianhua = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.dianhua2 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.leibie = new System.Windows.Forms.ComboBox();
this.add = new System.Windows.Forms.Button();
this.delete = new System.Windows.Forms.Button();
this.amend = new System.Windows.Forms.Button();
this.listView1 = new System.Windows.Forms.ListView();
this.dizhi = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.chaxun = new System.Windows.Forms.Button();
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
this.label6 = new System.Windows.Forms.Label();
this.showAll = new System.Windows.Forms.Button();
this.deleteAll = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(240, 20);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(100, 12);
this.label1.TabIndex = 0;
this.label1.Text = "名 字:";
//
// name
//
this.name.Location = new System.Drawing.Point(312, 16);
this.name.Name = "name";
this.name.Size = new System.Drawing.Size(128, 21);
this.name.TabIndex = 1;
this.name.Text = "";
//
// dianhua
//
this.dianhua.Location = new System.Drawing.Point(80, 48);
this.dianhua.Name = "dianhua";
this.dianhua.Size = new System.Drawing.Size(128, 21);
this.dianhua.TabIndex = 3;
this.dianhua.Text = "";
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 53);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(100, 19);
this.label2.TabIndex = 2;
this.label2.Text = "电 话1:";
//
// dianhua2
//
this.dianhua2.Location = new System.Drawing.Point(312, 48);
this.dianhua2.Name = "dianhua2";
this.dianhua2.Size = new System.Drawing.Size(128, 21);
this.dianhua2.TabIndex = 5;
this.dianhua2.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(240, 53);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(100, 19);
this.label3.TabIndex = 4;
this.label3.Text = "电 话2:";
//
// label4
//
this.label4.Location = new System.Drawing.Point(8, 20);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(100, 20);
this.label4.TabIndex = 6;
this.label4.Text = "联系人分类:";
//
// leibie
//
this.leibie.Location = new System.Drawing.Point(80, 16);
this.leibie.Name = "leibie";
this.leibie.Size = new System.Drawing.Size(128, 20);
this.leibie.TabIndex = 7;
//
// add
//
this.add.Location = new System.Drawing.Point(600, 16);
this.add.Name = "add";
this.add.TabIndex = 8;
this.add.Text = "增加";
this.add.Click += new System.EventHandler(this.add_Click);
//
// delete
//
this.delete.Location = new System.Drawing.Point(688, 16);
this.delete.Name = "delete";
this.delete.TabIndex = 9;
this.delete.Text = "删除";
this.delete.Click += new System.EventHandler(this.delete_Click);
//
// amend
//
this.amend.Location = new System.Drawing.Point(600, 48);
this.amend.Name = "amend";
this.amend.TabIndex = 10;
this.amend.Text = "修改";
this.amend.Click += new System.EventHandler(this.amend_Click);
//
// listView1
//
this.listView1.Location = new System.Drawing.Point(8, 104);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(848, 424);
this.listView1.TabIndex = 11;
this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
//
// dizhi
//
this.dizhi.Location = new System.Drawing.Point(80, 80);
this.dizhi.Name = "dizhi";
this.dizhi.Size = new System.Drawing.Size(576, 21);
this.dizhi.TabIndex = 13;
this.dizhi.Text = "";
//
// label5
//
this.label5.Location = new System.Drawing.Point(8, 85);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(100, 12);
this.label5.TabIndex = 12;
this.label5.Text = "所 在地 址:";
//
// chaxun
//
this.chaxun.Location = new System.Drawing.Point(688, 48);
this.chaxun.Name = "chaxun";
this.chaxun.TabIndex = 14;
this.chaxun.Text = "查询";
this.chaxun.Click += new System.EventHandler(this.chaxun_Click);
//
// dateTimePicker1
//
this.dateTimePicker1.Location = new System.Drawing.Point(744, 80);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.Size = new System.Drawing.Size(112, 21);
this.dateTimePicker1.TabIndex = 15;
//
// label6
//
this.label6.Location = new System.Drawing.Point(680, 85);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(72, 12);
this.label6.TabIndex = 16;
this.label6.Text = "当前时间:";
//
// showAll
//
this.showAll.Location = new System.Drawing.Point(776, 48);
this.showAll.Name = "showAll";
this.showAll.TabIndex = 18;
this.showAll.Text = "列出全部";
this.showAll.Click += new System.EventHandler(this.showAll_Click);
//
// deleteAll
//
this.deleteAll.Location = new System.Drawing.Point(776, 16);
this.deleteAll.Name = "deleteAll";
this.deleteAll.TabIndex = 17;
this.deleteAll.Text = "全部删除";
this.deleteAll.Click += new System.EventHandler(this.deleteAll_Click);
//
// tongxun
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(864, 534);
this.Controls.Add(this.showAll);
this.Controls.Add(this.deleteAll);
this.Controls.Add(this.dateTimePicker1);
this.Controls.Add(this.chaxun);
this.Controls.Add(this.dizhi);
this.Controls.Add(this.dianhua2);
this.Controls.Add(this.dianhua);
this.Controls.Add(this.name);
this.Controls.Add(this.label5);
this.Controls.Add(this.listView1);
this.Controls.Add(this.amend);
this.Controls.Add(this.delete);
this.Controls.Add(this.add);
this.Controls.Add(this.leibie);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.label6);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(872, 561);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(872, 561);
this.Name = "tongxun";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "通讯录";
this.Load += new System.EventHandler(this.tongxun_Load);
this.ResumeLayout(false);
}
#endregion
private void tongxun_Load(object sender, System.EventArgs e)
{
m_BIDconTrol = true;
listView1.GridLines = true ;//显示各个记录的分隔线
listView1.FullRowSelect = true ; //要选择就是一行
listView1.View = View.Details ; //定义列表显示的方式
listView1.Scrollable = true ; //需要时候显示滚动条
listView1.MultiSelect = true ; // false为不可以多行选择,true为可以多行选择
listView1.HeaderStyle = ColumnHeaderStyle.Nonclickable ;
// 针对数据库的字段名称,建立与之适应显示表头
listView1.Columns.Add ( "编号" , 40 , HorizontalAlignment.Left );
listView1.Columns.Add ( "分类" ,40 , HorizontalAlignment.Left );
listView1.Columns.Add ( "名字" , 80 , HorizontalAlignment.Left );
listView1.Columns.Add ( "电话1" , 100 , HorizontalAlignment.Left );
listView1.Columns.Add ( "电话2" , 100, HorizontalAlignment.Left );
listView1.Columns.Add ( "地址" ,404, HorizontalAlignment.Left );
listView1.Columns.Add ( "录入时间" ,80, HorizontalAlignment.Left );
listView1.Visible = true ;
leibie.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
leibie.Items.AddRange(new object[] {
"",
"朋友",
"同行",
"家人",
"业主",
});
leibie.Name = "findquyu";
leibie.Text = "同行";
oleDbConnection1.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+ Application.StartupPath+"\\矢量工作站.mdb";
Console.Write (oleDbConnection1.ConnectionString.ToString());
}
private void add_Click(object sender, System.EventArgs e)
{
if(m_BIDconTrol == false)
{
listView1.Items.Clear();
m_nID = 0;
}
m_BIDconTrol = true;
m_nID++;
string strliebie = leibie.Text;
if(strliebie == "" || strliebie == " ")
{
strliebie = " ";
}
string strname = name.Text;
if(strname == "" || strname == " ")
{
strname = " ";
}
string strdianhua = dianhua.Text;
if(strdianhua == "" || strdianhua == " ")
{
strdianhua = " ";
}
string strdianhua2 = dianhua2.Text;
if(strdianhua2 == "" || strdianhua2 == " ")
{
strdianhua2 = " ";
}
string strdizhi = dizhi.Text;
if(strdizhi == "" || strdizhi == " ")
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -