?? 副本 addlevelform.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Data;
namespace KTMIS
{
/// <summary>
/// AddLevel 的摘要說明。
/// </summary>
public class AddLevel : System.Windows.Forms.Form
{
internal System.Windows.Forms.TextBox LevelCoTextBox;
private System.Windows.Forms.Button returnBtn;
internal System.Windows.Forms.Button add_updateLevelBtn;
internal System.Windows.Forms.TextBox LevelSNPYtextBox;
private System.Windows.Forms.Label LevelSNPYlabel;
internal System.Windows.Forms.TextBox LevelSNtextBox;
private System.Windows.Forms.Label LevelSNlabel;
private SqlConnection LevelConnection = null;
private SqlCommand LevelCommand = null;
private ArrayList arrayList = null;
/// <summary>
/// 必需的設計器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public AddLevel()
{
//
// 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.LevelCoTextBox = new System.Windows.Forms.TextBox();
this.returnBtn = new System.Windows.Forms.Button();
this.add_updateLevelBtn = new System.Windows.Forms.Button();
this.LevelSNPYtextBox = new System.Windows.Forms.TextBox();
this.LevelSNPYlabel = new System.Windows.Forms.Label();
this.LevelSNtextBox = new System.Windows.Forms.TextBox();
this.LevelSNlabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// LevelCoTextBox
//
this.LevelCoTextBox.Location = new System.Drawing.Point(472, 72);
this.LevelCoTextBox.Name = "LevelCoTextBox";
this.LevelCoTextBox.Size = new System.Drawing.Size(88, 30);
this.LevelCoTextBox.TabIndex = 19;
this.LevelCoTextBox.Text = "";
this.LevelCoTextBox.Visible = false;
//
// returnBtn
//
this.returnBtn.Location = new System.Drawing.Point(376, 256);
this.returnBtn.Name = "returnBtn";
this.returnBtn.Size = new System.Drawing.Size(144, 56);
this.returnBtn.TabIndex = 18;
this.returnBtn.Text = "返回";
this.returnBtn.Click += new System.EventHandler(this.returnBtn_Click);
//
// add_updateLevelBtn
//
this.add_updateLevelBtn.Location = new System.Drawing.Point(144, 256);
this.add_updateLevelBtn.Name = "add_updateLevelBtn";
this.add_updateLevelBtn.Size = new System.Drawing.Size(144, 56);
this.add_updateLevelBtn.TabIndex = 17;
this.add_updateLevelBtn.Text = "添加";
this.add_updateLevelBtn.Click += new System.EventHandler(this.add_updateLevelBtn_Click);
//
// LevelSNPYtextBox
//
this.LevelSNPYtextBox.Location = new System.Drawing.Point(296, 128);
this.LevelSNPYtextBox.Name = "LevelSNPYtextBox";
this.LevelSNPYtextBox.Size = new System.Drawing.Size(200, 30);
this.LevelSNPYtextBox.TabIndex = 16;
this.LevelSNPYtextBox.Text = "";
//
// LevelSNPYlabel
//
this.LevelSNPYlabel.Location = new System.Drawing.Point(24, 112);
this.LevelSNPYlabel.Name = "LevelSNPYlabel";
this.LevelSNPYlabel.Size = new System.Drawing.Size(224, 96);
this.LevelSNPYlabel.TabIndex = 15;
this.LevelSNPYlabel.Text = "請輸入級別名稱的拼音的縮寫(如:每個字拼音的第一個字母大寫組合):";
//
// LevelSNtextBox
//
this.LevelSNtextBox.Location = new System.Drawing.Point(296, 16);
this.LevelSNtextBox.Name = "LevelSNtextBox";
this.LevelSNtextBox.Size = new System.Drawing.Size(200, 30);
this.LevelSNtextBox.TabIndex = 14;
this.LevelSNtextBox.Text = "";
//
// LevelSNlabel
//
this.LevelSNlabel.Location = new System.Drawing.Point(32, 16);
this.LevelSNlabel.Name = "LevelSNlabel";
this.LevelSNlabel.Size = new System.Drawing.Size(216, 40);
this.LevelSNlabel.TabIndex = 13;
this.LevelSNlabel.Text = "請輸入級別的名稱:";
//
// AddLevel
//
this.AutoScaleBaseSize = new System.Drawing.Size(11, 23);
this.ClientSize = new System.Drawing.Size(608, 350);
this.Controls.Add(this.LevelCoTextBox);
this.Controls.Add(this.returnBtn);
this.Controls.Add(this.add_updateLevelBtn);
this.Controls.Add(this.LevelSNPYtextBox);
this.Controls.Add(this.LevelSNPYlabel);
this.Controls.Add(this.LevelSNtextBox);
this.Controls.Add(this.LevelSNlabel);
this.Font = new System.Drawing.Font("宋體", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.Name = "AddLevel";
this.Text = "添加級別";
this.ResumeLayout(false);
}
#endregion
private void add_updateLevelBtn_Click(object sender, System.EventArgs e)
{
//string connString = "user id=sa;data source=\".\";initial catalog=KTMIS";
//LevelConnection = new SqlConnection(connString);
if(add_updateLevelBtn.Text == "添加")
{
LevelCommand = new SqlCommand("InsertLevel",LevelConnection);
LevelCommand.CommandType = CommandType.StoredProcedure;
LevelCommand.Parameters.Add("@LevelCo",SqlDbType.Int);
LevelCommand.Parameters.Add("@LevelNa",SqlDbType.VarChar,10);
LevelCommand.Parameters.Add("@LevelPY",SqlDbType.VarChar,5);
LevelCommand.Parameters["@LevelCo"].Direction = System.Data.ParameterDirection.Output;
LevelCommand.Parameters["@LevelNa"].Value = LevelSNtextBox.Text.ToString().Trim();
LevelCommand.Parameters["@LevelPY"].Value = LevelSNPYtextBox.Text.ToString().Trim();
try
{
LevelConnection.Open();
LevelCommand.ExecuteNonQuery();
arrayList = new ArrayList();
arrayList.Add(LevelCommand.Parameters["@LevelCo"].Value);
arrayList.Add(LevelSNtextBox.Text.ToString().Trim());
MessageBox.Show("添加成功!","系統提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
catch(Exception ex)
{
MessageBox.Show("添加失敗,原因是:"+ex.ToString(),"系統提示",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
}
finally
{
LevelConnection.Close();
}
}
else if(add_updateLevelBtn.Text == "修改")
{
LevelCommand = new SqlCommand("UpdateLevel",LevelConnection);
LevelCommand.CommandType = CommandType.StoredProcedure;
LevelCommand.Parameters.Add("@LevelCo",SqlDbType.Int);
LevelCommand.Parameters.Add("@LevelNa",SqlDbType.VarChar,10);
LevelCommand.Parameters.Add("@LevelPY",SqlDbType.VarChar,5);
LevelCommand.Parameters["@LevelCo"].Value = Convert.ToInt16(LevelCoTextBox.Text.ToString().Trim());
LevelCommand.Parameters["@LevelNa"].Value = LevelSNtextBox.Text.ToString().Trim();
LevelCommand.Parameters["@LevelPY"].Value = LevelSNPYtextBox.Text.ToString().Trim();
try
{
LevelConnection.Open();
LevelCommand.ExecuteNonQuery();
MessageBox.Show("修改成功!","系統提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
catch(Exception ex)
{
MessageBox.Show("修改失敗,原因是:"+ex.ToString(),"系統提示",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
}
finally
{
LevelConnection.Close();
}
}
}
public ArrayList GetArrayList()
{
return arrayList;
}
public void SetLevelSNText(string text)
{
LevelSNtextBox.Text = text;
}
public void SetLevelCoText(string text)
{
LevelCoTextBox.Text = text;
}
public void SetLevelSNPYText(string text)
{
LevelSNPYtextBox.Text = text;
}
public void SetFormTital(string tital)
{
this.Text = tital;
}
public void SetLevelBtnText(string text)
{
add_updateLevelBtn.Text = text;
}
private void returnBtn_Click(object sender, System.EventArgs e)
{
this.Close();
}
public System.Data.SqlClient.SqlConnection Connection
{
set
{
this.LevelConnection = value;
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -