📄 insert_book.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_book 的摘要说明。
/// </summary>
public class insert_book : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txt_lx;
private System.Windows.Forms.Label lbl_lx;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox txt_bz;
private System.Windows.Forms.TextBox txt_gjc;
private System.Windows.Forms.TextBox txt_zs;
private System.Windows.Forms.TextBox txtID;
private System.Windows.Forms.Label label7;
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 label3;
private System.Windows.Forms.Label label1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public insert_book()
{
//
// 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.txt_lx = new System.Windows.Forms.TextBox();
this.lbl_lx = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.txt_bz = new System.Windows.Forms.TextBox();
this.txt_gjc = new System.Windows.Forms.TextBox();
this.txt_zs = new System.Windows.Forms.TextBox();
this.txtID = new System.Windows.Forms.TextBox();
this.label7 = 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.label3 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// txt_lx
//
this.txt_lx.Location = new System.Drawing.Point(352, 40);
this.txt_lx.Name = "txt_lx";
this.txt_lx.Size = new System.Drawing.Size(88, 21);
this.txt_lx.TabIndex = 65;
this.txt_lx.Text = "";
//
// lbl_lx
//
this.lbl_lx.Location = new System.Drawing.Point(264, 40);
this.lbl_lx.Name = "lbl_lx";
this.lbl_lx.Size = new System.Drawing.Size(80, 32);
this.lbl_lx.TabIndex = 64;
this.lbl_lx.Text = "书籍类型:";
this.lbl_lx.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// 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.Blue;
this.label8.Location = new System.Drawing.Point(0, 0);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(520, 24);
this.label8.TabIndex = 63;
this.label8.Text = "书籍信息添加";
this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// txt_bz
//
this.txt_bz.Location = new System.Drawing.Point(128, 120);
this.txt_bz.Multiline = true;
this.txt_bz.Name = "txt_bz";
this.txt_bz.Size = new System.Drawing.Size(288, 104);
this.txt_bz.TabIndex = 62;
this.txt_bz.Text = "";
//
// txt_gjc
//
this.txt_gjc.Location = new System.Drawing.Point(352, 80);
this.txt_gjc.Name = "txt_gjc";
this.txt_gjc.Size = new System.Drawing.Size(88, 21);
this.txt_gjc.TabIndex = 61;
this.txt_gjc.Text = "";
//
// txt_zs
//
this.txt_zs.Location = new System.Drawing.Point(128, 80);
this.txt_zs.Name = "txt_zs";
this.txt_zs.Size = new System.Drawing.Size(112, 21);
this.txt_zs.TabIndex = 60;
this.txt_zs.Text = "";
//
// txtID
//
this.txtID.Location = new System.Drawing.Point(128, 40);
this.txtID.Name = "txtID";
this.txtID.Size = new System.Drawing.Size(112, 21);
this.txtID.TabIndex = 56;
this.txtID.Text = "";
//
// label7
//
this.label7.Location = new System.Drawing.Point(80, 112);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(48, 32);
this.label7.TabIndex = 59;
this.label7.Text = "备注:";
this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label5
//
this.label5.Location = new System.Drawing.Point(272, 80);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(72, 23);
this.label5.TabIndex = 58;
this.label5.Text = "关键词:";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// btn_cancel
//
this.btn_cancel.Location = new System.Drawing.Point(312, 248);
this.btn_cancel.Name = "btn_cancel";
this.btn_cancel.Size = new System.Drawing.Size(72, 24);
this.btn_cancel.TabIndex = 57;
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(136, 248);
this.btn_sure.Name = "btn_sure";
this.btn_sure.Size = new System.Drawing.Size(72, 23);
this.btn_sure.TabIndex = 55;
this.btn_sure.Text = "确定(&S)";
this.btn_sure.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.btn_sure.Click += new System.EventHandler(this.btn_sure_Click);
//
// label3
//
this.label3.Location = new System.Drawing.Point(48, 80);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 24);
this.label3.TabIndex = 54;
this.label3.Text = "书籍总数:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(112, 24);
this.label1.TabIndex = 53;
this.label1.Text = "书籍编号:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// insert_book
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.Turquoise;
this.ClientSize = new System.Drawing.Size(520, 301);
this.Controls.Add(this.txt_lx);
this.Controls.Add(this.lbl_lx);
this.Controls.Add(this.label8);
this.Controls.Add(this.txt_bz);
this.Controls.Add(this.txt_gjc);
this.Controls.Add(this.txt_zs);
this.Controls.Add(this.txtID);
this.Controls.Add(this.label7);
this.Controls.Add(this.label5);
this.Controls.Add(this.btn_cancel);
this.Controls.Add(this.btn_sure);
this.Controls.Add(this.label3);
this.Controls.Add(this.label1);
this.ForeColor = System.Drawing.Color.Blue;
this.MaximizeBox = false;
this.Name = "insert_book";
this.Text = "书籍信息添加界面";
this.Load += new System.EventHandler(this.insert_book_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_sjxxb",conn);
comm.CommandType=CommandType.StoredProcedure;
comm.Parameters.Add("@sjbh",this.txtID.Text);
comm.Parameters.Add("@sjlx",this.txt_lx.Text);
comm.Parameters.Add("@gjc",this.txt_gjc.Text);
comm.Parameters.Add("@sjzs",this.txt_zs.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_book_Load(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -