📄 mainform.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;
using System.Data.SqlTypes;
using System.Drawing;
using System.IO;
namespace 个人通讯录
{
/// <summary>
/// Summary description for MainForm.
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.MainMenu myMainMenu;
private System.Windows.Forms.MenuItem mIUser;
private System.Windows.Forms.MenuItem mIchangeUser;
private System.Windows.Forms.MenuItem mIdeleteUser;
private System.Windows.Forms.MenuItem mIRecordSet;
private System.Windows.Forms.MenuItem mIAddRecord;
private System.Windows.Forms.MenuItem mISystem;
private System.Windows.Forms.MenuItem mIQuit;
private System.Windows.Forms.Label labelOicq;
private System.Windows.Forms.Label labelYear;
private System.Windows.Forms.Label labelAddress;
private System.Windows.Forms.Label labelPhone;
private System.Windows.Forms.Label labelSex;
private System.Windows.Forms.Label labelName;
private System.Windows.Forms.Label labelRec;
private System.Windows.Forms.Label labelTreeview;
private System.Windows.Forms.Label labelConstellation;
private System.Windows.Forms.Label labelBelong;
private System.Windows.Forms.Label labelMobile;
private System.Windows.Forms.Label labelEmail;
private System.Windows.Forms.Label labelDay;
private System.Windows.Forms.Label labelMonth;
private System.Windows.Forms.TextBox textBoxConstellation;
private System.Windows.Forms.TextBox textBoxBelong;
private System.Windows.Forms.TextBox textBoxEmail;
private System.Windows.Forms.TextBox textBoxMobile;
private System.Windows.Forms.TextBox textBoxOicq;
private System.Windows.Forms.TextBox textBoxPhone;
private System.Windows.Forms.TextBox textBoxYear;
private System.Windows.Forms.TextBox textBoxAddress;
private System.Windows.Forms.TextBox textBoxName;
private System.Windows.Forms.ComboBox comboBoxDay;
private System.Windows.Forms.ComboBox comboBoxMonth;
private System.Windows.Forms.ComboBox comboBoxSex;
private System.Windows.Forms.Panel panelMain;
private System.Windows.Forms.PictureBox pictureBoxLook;
private System.Windows.Forms.Button buttonSaveChange;
private System.Windows.Forms.Button buttonDelete;
private System.Windows.Forms.TreeView treeViewMain;
private System.Windows.Forms.StatusBar statusBarMain;
private System.Windows.Forms.OpenFileDialog openFileDialogPic;
private System.Windows.Forms.StatusBarPanel sBPanelUser;
private System.Windows.Forms.StatusBarPanel sBPanelCount;
private SqlCommandBuilder myComBuilder;
private SqlDataAdapter myDataAdapter;
public SqlConnection myConnection;
private DataSet myDataSet;
private LogForm formLogon;
private CUserForm formChangeUser;
private System.Windows.Forms.MenuItem menuItem1;
public string currentUser;
public MainForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
// 建立连接
string myConnectionString;
myConnectionString = "Initial Catalog=addresslist;Data Source=localhost;user id=sa;password=; Connect Timeout = 30";
myConnection = new SqlConnection(myConnectionString);
try
{
myConnection.Open();
}
catch (SqlException e)
{
}
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.myMainMenu = new System.Windows.Forms.MainMenu();
this.mISystem = new System.Windows.Forms.MenuItem();
this.mIQuit = new System.Windows.Forms.MenuItem();
this.mIRecordSet = new System.Windows.Forms.MenuItem();
this.mIAddRecord = new System.Windows.Forms.MenuItem();
this.mIUser = new System.Windows.Forms.MenuItem();
this.mIchangeUser = new System.Windows.Forms.MenuItem();
this.mIdeleteUser = new System.Windows.Forms.MenuItem();
this.labelRec = new System.Windows.Forms.Label();
this.labelTreeview = new System.Windows.Forms.Label();
this.panelMain = new System.Windows.Forms.Panel();
this.comboBoxDay = new System.Windows.Forms.ComboBox();
this.textBoxConstellation = new System.Windows.Forms.TextBox();
this.labelConstellation = new System.Windows.Forms.Label();
this.textBoxBelong = new System.Windows.Forms.TextBox();
this.labelBelong = new System.Windows.Forms.Label();
this.comboBoxMonth = new System.Windows.Forms.ComboBox();
this.textBoxEmail = new System.Windows.Forms.TextBox();
this.labelEmail = new System.Windows.Forms.Label();
this.buttonSaveChange = new System.Windows.Forms.Button();
this.buttonDelete = new System.Windows.Forms.Button();
this.pictureBoxLook = new System.Windows.Forms.PictureBox();
this.textBoxMobile = new System.Windows.Forms.TextBox();
this.labelMobile = new System.Windows.Forms.Label();
this.comboBoxSex = new System.Windows.Forms.ComboBox();
this.textBoxOicq = new System.Windows.Forms.TextBox();
this.textBoxPhone = new System.Windows.Forms.TextBox();
this.textBoxYear = new System.Windows.Forms.TextBox();
this.textBoxAddress = new System.Windows.Forms.TextBox();
this.textBoxName = new System.Windows.Forms.TextBox();
this.labelDay = new System.Windows.Forms.Label();
this.labelOicq = new System.Windows.Forms.Label();
this.labelYear = new System.Windows.Forms.Label();
this.labelAddress = new System.Windows.Forms.Label();
this.labelMonth = new System.Windows.Forms.Label();
this.labelPhone = new System.Windows.Forms.Label();
this.labelSex = new System.Windows.Forms.Label();
this.labelName = new System.Windows.Forms.Label();
this.treeViewMain = new System.Windows.Forms.TreeView();
this.statusBarMain = new System.Windows.Forms.StatusBar();
this.sBPanelUser = new System.Windows.Forms.StatusBarPanel();
this.sBPanelCount = new System.Windows.Forms.StatusBarPanel();
this.openFileDialogPic = new System.Windows.Forms.OpenFileDialog();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.panelMain.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.sBPanelUser)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.sBPanelCount)).BeginInit();
this.SuspendLayout();
//
// myMainMenu
//
this.myMainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mISystem,
this.mIRecordSet,
this.mIUser});
//
// mISystem
//
this.mISystem.Index = 0;
this.mISystem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mIQuit,
this.menuItem1});
this.mISystem.Text = "系统";
//
// mIQuit
//
this.mIQuit.Index = 0;
this.mIQuit.Text = "退出";
this.mIQuit.Click += new System.EventHandler(this.mIQuit_Click);
//
// mIRecordSet
//
this.mIRecordSet.Index = 1;
this.mIRecordSet.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mIAddRecord});
this.mIRecordSet.Text = "记录选项";
//
// mIAddRecord
//
this.mIAddRecord.Index = 0;
this.mIAddRecord.Text = "添加新记录";
this.mIAddRecord.Click += new System.EventHandler(this.mIAddRecord_Click);
//
// mIUser
//
this.mIUser.Index = 2;
this.mIUser.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mIchangeUser,
this.mIdeleteUser});
this.mIUser.Text = "用户设置";
//
// mIchangeUser
//
this.mIchangeUser.Index = 0;
this.mIchangeUser.Text = "修改用户信息";
this.mIchangeUser.Click += new System.EventHandler(this.mIchangeUser_Click);
//
// mIdeleteUser
//
this.mIdeleteUser.Index = 1;
this.mIdeleteUser.Text = "删除当前用户";
this.mIdeleteUser.Click += new System.EventHandler(this.mIdeleteUser_Click);
//
// labelRec
//
this.labelRec.BackColor = System.Drawing.Color.Transparent;
this.labelRec.Font = new System.Drawing.Font("SimSun", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.labelRec.Location = new System.Drawing.Point(169, 5);
this.labelRec.Name = "labelRec";
this.labelRec.Size = new System.Drawing.Size(119, 19);
this.labelRec.TabIndex = 26;
this.labelRec.Text = "记录内容";
this.labelRec.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// labelTreeview
//
this.labelTreeview.Font = new System.Drawing.Font("SimSun", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.labelTreeview.Location = new System.Drawing.Point(1, 5);
this.labelTreeview.Name = "labelTreeview";
this.labelTreeview.Size = new System.Drawing.Size(159, 19);
this.labelTreeview.TabIndex = 25;
this.labelTreeview.Text = "地址簿";
this.labelTreeview.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// panelMain
//
this.panelMain.BackColor = System.Drawing.SystemColors.Control;
this.panelMain.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panelMain.Controls.AddRange(new System.Windows.Forms.Control[] {
this.comboBoxDay,
this.textBoxConstellation,
this.labelConstellation,
this.textBoxBelong,
this.labelBelong,
this.comboBoxMonth,
this.textBoxEmail,
this.labelEmail,
this.buttonSaveChange,
this.buttonDelete,
this.pictureBoxLook,
this.textBoxMobile,
this.labelMobile,
this.comboBoxSex,
this.textBoxOicq,
this.textBoxPhone,
this.textBoxYear,
this.textBoxAddress,
this.textBoxName,
this.labelDay,
this.labelOicq,
this.labelYear,
this.labelAddress,
this.labelMonth,
this.labelPhone,
this.labelSex,
this.labelName});
this.panelMain.Location = new System.Drawing.Point(161, 29);
this.panelMain.Name = "panelMain";
this.panelMain.Size = new System.Drawing.Size(487, 323);
this.panelMain.TabIndex = 24;
//
// comboBoxDay
//
this.comboBoxDay.DisplayMember = "1";
this.comboBoxDay.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxDay.Items.AddRange(new object[] {
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"21",
"22",
"23",
"24",
"25",
"26",
"27",
"28",
"29",
"30",
"31"});
this.comboBoxDay.Location = new System.Drawing.Point(232, 56);
this.comboBoxDay.Name = "comboBoxDay";
this.comboBoxDay.Size = new System.Drawing.Size(40, 20);
this.comboBoxDay.TabIndex = 32;
//
// textBoxConstellation
//
this.textBoxConstellation.Location = new System.Drawing.Point(200, 88);
this.textBoxConstellation.Name = "textBoxConstellation";
this.textBoxConstellation.Size = new System.Drawing.Size(72, 21);
this.textBoxConstellation.TabIndex = 31;
this.textBoxConstellation.Text = "";
//
// labelConstellation
//
this.labelConstellation.BackColor = System.Drawing.Color.Transparent;
this.labelConstellation.Location = new System.Drawing.Point(152, 88);
this.labelConstellation.Name = "labelConstellation";
this.labelConstellation.Size = new System.Drawing.Size(32, 23);
this.labelConstellation.TabIndex = 30;
this.labelConstellation.Text = "星座";
this.labelConstellation.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// textBoxBelong
//
this.textBoxBelong.Location = new System.Drawing.Point(64, 88);
this.textBoxBelong.Name = "textBoxBelong";
this.textBoxBelong.Size = new System.Drawing.Size(64, 21);
this.textBoxBelong.TabIndex = 29;
this.textBoxBelong.Text = "";
//
// labelBelong
//
this.labelBelong.BackColor = System.Drawing.Color.Transparent;
this.labelBelong.Location = new System.Drawing.Point(16, 88);
this.labelBelong.Name = "labelBelong";
this.labelBelong.Size = new System.Drawing.Size(56, 23);
this.labelBelong.TabIndex = 28;
this.labelBelong.Text = "生肖";
this.labelBelong.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// comboBoxMonth
//
this.comboBoxMonth.DisplayMember = "1";
this.comboBoxMonth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxMonth.Items.AddRange(new object[] {
"1",
"2",
"3",
"4",
"5",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -