📄 frmadd.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Text;
using System.IO;
namespace ShInfo
{
/// <summary>
/// frmAdd 的摘要说明。
/// </summary>
public class frmAdd : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblName2;
private System.Windows.Forms.Label lblTel2;
private System.Windows.Forms.TextBox txtName2;
private System.Windows.Forms.TextBox txtTel2;
private System.Windows.Forms.Button btnAdd;
private System.Windows.Forms.Button btnEixt2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private Sunisoft.IrisSkin.SkinEngine skinEngine1;
private ArrayList AL;
public frmAdd(ArrayList al)
{
InitializeComponent();
this.skinEngine1.SkinFile = "WaveColor2.ssk";
AL=al;
}
/// <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.skinEngine1 = new Sunisoft.IrisSkin.SkinEngine(((System.ComponentModel.Component)(this)));
this.lblName2 = new System.Windows.Forms.Label();
this.lblTel2 = new System.Windows.Forms.Label();
this.btnAdd = new System.Windows.Forms.Button();
this.btnEixt2 = new System.Windows.Forms.Button();
this.txtName2 = new System.Windows.Forms.TextBox();
this.txtTel2 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// skinEngine1
//
this.skinEngine1.SerialNumber = "";
this.skinEngine1.SkinFile = null;
//
// lblName2
//
this.lblName2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.lblName2.Location = new System.Drawing.Point(32, 16);
this.lblName2.Name = "lblName2";
this.lblName2.TabIndex = 0;
this.lblName2.Text = "姓名:";
this.lblName2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblTel2
//
this.lblTel2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.lblTel2.Location = new System.Drawing.Point(32, 72);
this.lblTel2.Name = "lblTel2";
this.lblTel2.TabIndex = 1;
this.lblTel2.Text = "手机号码: ";
this.lblTel2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// btnAdd
//
this.btnAdd.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.btnAdd.Location = new System.Drawing.Point(80, 144);
this.btnAdd.Name = "btnAdd";
this.btnAdd.TabIndex = 2;
this.btnAdd.Text = "添加(&A)";
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
//
// btnEixt2
//
this.btnEixt2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.btnEixt2.Location = new System.Drawing.Point(192, 144);
this.btnEixt2.Name = "btnEixt2";
this.btnEixt2.TabIndex = 3;
this.btnEixt2.Text = "取消(&Q)";
this.btnEixt2.Click += new System.EventHandler(this.btnEixt2_Click);
//
// txtName2
//
this.txtName2.AutoSize = false;
this.txtName2.Location = new System.Drawing.Point(144, 16);
this.txtName2.MaxLength = 6;
this.txtName2.Name = "txtName2";
this.txtName2.Size = new System.Drawing.Size(152, 24);
this.txtName2.TabIndex = 4;
this.txtName2.Text = "";
this.txtName2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtName2_KeyPress);
this.txtName2.TextChanged += new System.EventHandler(this.txtName2_TextChanged);
//
// txtTel2
//
this.txtTel2.AutoSize = false;
this.txtTel2.HideSelection = false;
this.txtTel2.Location = new System.Drawing.Point(144, 72);
this.txtTel2.MaxLength = 11;
this.txtTel2.Name = "txtTel2";
this.txtTel2.Size = new System.Drawing.Size(152, 24);
this.txtTel2.TabIndex = 5;
this.txtTel2.Text = "";
this.txtTel2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtTel2_KeyPress);
this.txtTel2.TextChanged += new System.EventHandler(this.txtTel2_TextChanged);
this.txtTel2.Leave += new System.EventHandler(this.txtTel2_Leave);
//
// frmAdd
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(338, 202);
this.Controls.Add(this.txtTel2);
this.Controls.Add(this.txtName2);
this.Controls.Add(this.btnEixt2);
this.Controls.Add(this.btnAdd);
this.Controls.Add(this.lblTel2);
this.Controls.Add(this.lblName2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "frmAdd";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "添加通讯录";
this.Load += new System.EventHandler(this.frmAdd_Load);
this.ResumeLayout(false);
}
#endregion
private void btnEixt2_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void frmAdd_Load(object sender, System.EventArgs e)
{
}
private void btnAdd_Click(object sender, System.EventArgs e)
{
if(this.txtName2.Text.Length!=0&&this.txtTel2.Text.Length!=0)
{
string bb=this.txtTel2.Text;
if(bb.Substring(0,2)=="13"||
bb.Substring(0,3)=="150"||
bb.Substring(0,3)=="156"||
bb.Substring(0,3)=="158"||
bb.Substring(0,3)=="159")
{
AddressBookRecord AA=new AddressBookRecord(this.txtName2.Text,this.txtTel2.Text);
Managerbookrecord M=new Managerbookrecord();
M.AddAddress(AA);
MessageBox.Show("添加成功!","提示:",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.txtTel2.Clear();
this.txtName2.Clear();
this.txtName2.Focus();
}
else
{
MessageBox.Show("手机号码输入错误","提示:");
this.txtTel2.Clear();
this.txtName2.Focus();
}
}
else
{
MessageBox.Show("姓名和号码不能为空","提示:");
}
}
private void txtName2_TextChanged(object sender, System.EventArgs e)
{
}
private void txtName2_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
e.Handled=e.KeyChar<'a'||e.KeyChar>'z';
if(e.KeyChar==(char)8)
e.Handled=false;
}
private void txtTel2_TextChanged(object sender, System.EventArgs e)
{
}
private void txtTel2_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
e.Handled=e.KeyChar<'0'||e.KeyChar>'9';
if(e.KeyChar==(char)8)
e.Handled=false;
}
private void txtTel2_Leave(object sender, System.EventArgs e)
{
if(this.txtTel2.Text.Length<11)
{
MessageBox.Show("手机号码输入错误","提示:");
this.txtTel2.Clear();
this.txtTel2.Focus();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -