📄 insert_man.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.IO;
namespace 图书
{
/// <summary>
/// insert_man 的摘要说明。
/// </summary>
public class insert_man : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox txt_bz;
private System.Windows.Forms.TextBox txt_qy;
private System.Windows.Forms.TextBox txtname;
private System.Windows.Forms.TextBox txtID;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Button btn_cancel;
private System.Windows.Forms.Button btn_sure;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox cb_sl;
private System.Windows.Forms.ComboBox cb_sex;
private System.Windows.Forms.ComboBox cb_lx;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public insert_man()
{
//
// 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.label8 = new System.Windows.Forms.Label();
this.txt_bz = new System.Windows.Forms.TextBox();
this.txt_qy = new System.Windows.Forms.TextBox();
this.txtname = new System.Windows.Forms.TextBox();
this.txtID = new System.Windows.Forms.TextBox();
this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.btn_cancel = new System.Windows.Forms.Button();
this.btn_sure = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.cb_sl = new System.Windows.Forms.ComboBox();
this.cb_sex = new System.Windows.Forms.ComboBox();
this.cb_lx = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// label8
//
this.label8.Dock = System.Windows.Forms.DockStyle.Top;
this.label8.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label8.ForeColor = System.Drawing.Color.RoyalBlue;
this.label8.Location = new System.Drawing.Point(0, 0);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(496, 24);
this.label8.TabIndex = 49;
this.label8.Text = "读者信息添加";
this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// txt_bz
//
this.txt_bz.Location = new System.Drawing.Point(104, 171);
this.txt_bz.Multiline = true;
this.txt_bz.Name = "txt_bz";
this.txt_bz.Size = new System.Drawing.Size(344, 88);
this.txt_bz.TabIndex = 48;
this.txt_bz.Text = "";
//
// txt_qy
//
this.txt_qy.Location = new System.Drawing.Point(344, 83);
this.txt_qy.Name = "txt_qy";
this.txt_qy.Size = new System.Drawing.Size(104, 21);
this.txt_qy.TabIndex = 46;
this.txt_qy.Text = "";
//
// txtname
//
this.txtname.Location = new System.Drawing.Point(112, 83);
this.txtname.Name = "txtname";
this.txtname.Size = new System.Drawing.Size(112, 21);
this.txtname.TabIndex = 39;
this.txtname.Text = "";
//
// txtID
//
this.txtID.Location = new System.Drawing.Point(112, 43);
this.txtID.Name = "txtID";
this.txtID.Size = new System.Drawing.Size(112, 21);
this.txtID.TabIndex = 38;
this.txtID.Text = "";
//
// label7
//
this.label7.Location = new System.Drawing.Point(48, 163);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(56, 24);
this.label7.TabIndex = 43;
this.label7.Text = "备注:";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label6
//
this.label6.Location = new System.Drawing.Point(256, 123);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(80, 24);
this.label6.TabIndex = 42;
this.label6.Text = "读者类型:";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label5
//
this.label5.Location = new System.Drawing.Point(256, 83);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(80, 23);
this.label5.TabIndex = 41;
this.label5.Text = "借书期限:";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// btn_cancel
//
this.btn_cancel.Location = new System.Drawing.Point(304, 275);
this.btn_cancel.Name = "btn_cancel";
this.btn_cancel.Size = new System.Drawing.Size(72, 23);
this.btn_cancel.TabIndex = 40;
this.btn_cancel.Text = "取消(&C)";
this.btn_cancel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.btn_cancel.Click += new System.EventHandler(this.btn_cancel_Click);
//
// btn_sure
//
this.btn_sure.Location = new System.Drawing.Point(152, 275);
this.btn_sure.Name = "btn_sure";
this.btn_sure.Size = new System.Drawing.Size(72, 23);
this.btn_sure.TabIndex = 37;
this.btn_sure.Text = "确定(&S)";
this.btn_sure.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.btn_sure.Click += new System.EventHandler(this.btn_sure_Click);
//
// label4
//
this.label4.Location = new System.Drawing.Point(256, 43);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(80, 24);
this.label4.TabIndex = 36;
this.label4.Text = "借书数量:";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label3
//
this.label3.Location = new System.Drawing.Point(40, 123);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(64, 24);
this.label3.TabIndex = 35;
this.label3.Text = "性别:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label2
//
this.label2.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
this.label2.Location = new System.Drawing.Point(32, 83);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 24);
this.label2.TabIndex = 34;
this.label2.Text = "姓名:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label1
//
this.label1.Location = new System.Drawing.Point(24, 43);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(80, 24);
this.label1.TabIndex = 33;
this.label1.Text = "读者编号:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// cb_sl
//
this.cb_sl.Items.AddRange(new object[] {
"1",
"2",
"3",
"4",
"5",
"6"});
this.cb_sl.Location = new System.Drawing.Point(344, 48);
this.cb_sl.Name = "cb_sl";
this.cb_sl.Size = new System.Drawing.Size(104, 20);
this.cb_sl.TabIndex = 50;
//
// cb_sex
//
this.cb_sex.Items.AddRange(new object[] {
"女",
"男"});
this.cb_sex.Location = new System.Drawing.Point(128, 128);
this.cb_sex.Name = "cb_sex";
this.cb_sex.Size = new System.Drawing.Size(104, 20);
this.cb_sex.TabIndex = 51;
//
// cb_lx
//
this.cb_lx.Items.AddRange(new object[] {
"管理员",
"普通用户"});
this.cb_lx.Location = new System.Drawing.Point(344, 128);
this.cb_lx.Name = "cb_lx";
this.cb_lx.Size = new System.Drawing.Size(104, 20);
this.cb_lx.TabIndex = 52;
//
// insert_man
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.Aquamarine;
this.ClientSize = new System.Drawing.Size(496, 301);
this.Controls.Add(this.cb_lx);
this.Controls.Add(this.cb_sex);
this.Controls.Add(this.cb_sl);
this.Controls.Add(this.label8);
this.Controls.Add(this.txt_bz);
this.Controls.Add(this.txt_qy);
this.Controls.Add(this.txtname);
this.Controls.Add(this.txtID);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.btn_cancel);
this.Controls.Add(this.btn_sure);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.ForeColor = System.Drawing.Color.Blue;
this.Name = "insert_man";
this.Text = "读者信息添加界面";
this.Load += new System.EventHandler(this.insert_man_Load);
this.ResumeLayout(false);
}
#endregion
private void btn_sure_Click(object sender, System.EventArgs e)
{
int i=0;
StreamReader sr=new StreamReader("ts.ini",System.Text.Encoding.Default);
string sn=sr.ReadLine();
SqlConnection conn=new SqlConnection(sn);
SqlCommand comm=new SqlCommand("Insert_dzxxb",conn);
comm.CommandType=CommandType.StoredProcedure;
comm.Parameters.Add("@dzbh",this.txtID.Text);
comm.Parameters.Add("@xm",this.txtname.Text);
comm.Parameters.Add("@xb",this.cb_sex.Text);
comm.Parameters.Add("@dzlb",this.cb_lx.Text);
comm.Parameters.Add("@jssl",this.cb_sl.Text);
comm.Parameters.Add("@jsqx",this.txt_qy.Text);
comm.Parameters.Add("@bz",this.txt_bz.Text);
try
{
conn.Open();
i=comm.ExecuteNonQuery();
if(i==1)
{
MessageBox.Show("添加成功!");
this.Hide();
}
else
{
MessageBox.Show("已插入,不能再添加!");
}
}
catch
{
MessageBox.Show("添加失败!");
}
finally
{
conn.Close();
}
}
private void btn_cancel_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void insert_man_Load(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -