⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tbookinfo.cs

📁 图书馆管理系统为方便读者
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.label8.Text = "图书关键字:";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(272, 24);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(100, 16);
			this.label6.TabIndex = 6;
			this.label6.Text = "出版日期:";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(24, 152);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(80, 23);
			this.label5.TabIndex = 5;
			this.label5.Text = "图书出版社:";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(24, 120);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(72, 23);
			this.label4.TabIndex = 4;
			this.label4.Text = "图书作者:";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(24, 88);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(72, 23);
			this.label3.TabIndex = 3;
			this.label3.Text = "图书类型:";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(24, 56);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(80, 23);
			this.label2.TabIndex = 2;
			this.label2.Text = "图书名称:";
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(120, 24);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(120, 21);
			this.textBox1.TabIndex = 1;
			this.textBox1.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(24, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(72, 16);
			this.label1.TabIndex = 0;
			this.label1.Text = "图书编号:";
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.textBox9);
			this.groupBox2.Location = new System.Drawing.Point(8, 200);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(504, 120);
			this.groupBox2.TabIndex = 1;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "备注";
			// 
			// textBox9
			// 
			this.textBox9.Location = new System.Drawing.Point(8, 16);
			this.textBox9.Multiline = true;
			this.textBox9.Name = "textBox9";
			this.textBox9.Size = new System.Drawing.Size(488, 96);
			this.textBox9.TabIndex = 18;
			this.textBox9.Text = "";
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(320, 336);
			this.button1.Name = "button1";
			this.button1.TabIndex = 2;
			this.button1.Text = "确定";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(432, 336);
			this.button2.Name = "button2";
			this.button2.TabIndex = 3;
			this.button2.Text = "取消";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// sqlDataAdapter1
			// 
			this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
			this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
			this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
			this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																									  new System.Data.Common.DataTableMapping("Table", "Tbookclass", new System.Data.Common.DataColumnMapping[] {
																																																					new System.Data.Common.DataColumnMapping("classno", "classno")})});
			this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
			// 
			// sqlDeleteCommand1
			// 
			this.sqlDeleteCommand1.CommandText = "DELETE FROM Tbookclass WHERE (classno = @Original_classno)";
			this.sqlDeleteCommand1.Connection = this.sqlConnection1;
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_classno", System.Data.SqlDbType.NVarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "classno", System.Data.DataRowVersion.Original, null));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "data source =222.20.54.54;initial catalog =yuan;user id =sa;password =0517;";
			// 
			// sqlInsertCommand1
			// 
			this.sqlInsertCommand1.CommandText = "INSERT INTO Tbookclass(classno) VALUES (@classno); SELECT classno FROM Tbookclass" +
				" WHERE (classno = @classno)";
			this.sqlInsertCommand1.Connection = this.sqlConnection1;
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@classno", System.Data.SqlDbType.NVarChar, 50, "classno"));
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT classno FROM Tbookclass";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			// 
			// sqlUpdateCommand1
			// 
			this.sqlUpdateCommand1.CommandText = "UPDATE Tbookclass SET classno = @classno WHERE (classno = @Original_classno); SEL" +
				"ECT classno FROM Tbookclass WHERE (classno = @classno)";
			this.sqlUpdateCommand1.Connection = this.sqlConnection1;
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@classno", System.Data.SqlDbType.NVarChar, 50, "classno"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_classno", System.Data.SqlDbType.NVarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "classno", System.Data.DataRowVersion.Original, null));
			// 
			// TbookInfo
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(520, 374);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.Name = "TbookInfo";
			this.Text = "添加图书信息";
			this.Load += new System.EventHandler(this.TbookInfo_Load);
			this.groupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.booktypeinfo1)).EndInit();
			this.groupBox2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void TbookInfo_Load(object sender, System.EventArgs e)
		{
			sqlDataAdapter1.Fill (booktypeinfo1);

		}

		private void sqlConnection2_InfoMessage(object sender, System.Data.SqlClient.SqlInfoMessageEventArgs e)
		{
		
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
		   //sqlConnection1.ConnectionString ="data source =222.20.54.54;initial catalog =yuan;user id =sa;password =0517;";
			if(textBox1.Text !=""&&textBox2.Text !="")
			{
				//string cstring="data source =222.20.54.54;initial catalog =yuan;user id =sa ;password=0517";
				//SqlConnection conn=new SqlConnection ();
				//conn.ConnectionString =cstring;
			    
				string cmdstring="insert Tbookinfo values(";
				cmdstring+="'"+textBox1.Text+"'," ;
				cmdstring+="'"+textBox2.Text+"'," ;
				cmdstring+="'"+comboBox1.SelectedText +"'," ;
				cmdstring+="'"+textBox3.Text+"'," ;
				cmdstring+="'"+textBox4.Text+"'," ;
				cmdstring+="'"+textBox5.Text+"'," ;
				cmdstring+="'"+textBox6.Text+"'," ;
				cmdstring+="'"+textBox7.Text+"'," ;
				cmdstring+="'"+textBox8.Text+"'," ;
				cmdstring+="'"+textBox9.Text+"')" ;
				
				
				SqlCommand cmd=new SqlCommand ();
				cmd.CommandText =cmdstring;
				cmd.Connection =sqlConnection1;
				sqlConnection1.Open ();
               
				SqlCommand cmd2=new SqlCommand ();
				cmd2.CommandText ="select * from Tbookinfo where bookid="+"'"+textBox1.Text +"'";
				cmd2.Connection =sqlConnection1;
                
				int i=0;
				//conn.Open ();
				SqlDataReader rdr =cmd2.ExecuteReader ();
				if(rdr.Read ())
				{
					i+=1;
				}
				
				if(i>=1)
				{
					MessageBox.Show ("对不起,您输入的书籍编号已经存在!","错误",MessageBoxButtons.OKCancel ,MessageBoxIcon.Error );
					textBox1.Text ="";
					
				}
				else
				{   
					sqlConnection1.Close ();
					sqlConnection1.Open ();
					cmd.ExecuteNonQuery ();
					MessageBox.Show ("已经写入到数据库中!","完成!",MessageBoxButtons.OKCancel ,MessageBoxIcon.Information );
				}
				
				//cmd.ExecuteNonQuery ();
				sqlConnection1.Close ();
			}
			else
			{
				MessageBox.Show ("第一项和第二项不能为空!请将其填满","错误!",MessageBoxButtons.OKCancel ,MessageBoxIcon.Error );
			}

		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			this.Close ();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -