scholastic/Form5_1.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace scholastic
{
public partial class Form5_1 : Form
{
string sdept, smajor, snum, stea;
public Form5_1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == ""|| textBox4.Text == "")
{
MessageBox.Show("输入的信息不完整,请重新输入!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
string constr = "server=.\\sql2005;database=mydata;uid=sa;pwd=sa";
SqlConnection mycon = new SqlConnection(constr);
mycon.Open();
string myinsert = "insert into major(所在系,专业,人数,辅导员) values('" + textBox1.Text + "','" + textBox2.Text + "'," + Convert.ToInt32(textBox3.Text) + ",'" + textBox4.Text + "')"; //insert插入语句
SqlCommand mycom = new SqlCommand(myinsert, mycon); //定义SqlCommand对象,并连接数据库
mycom.ExecuteNonQuery();
mycon.Close();
mycon.Dispose();
MessageBox.Show("已成功向数据库表中插入一条记录!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
sdept = textBox1.Text;
smajor = textBox2.Text;
snum = textBox3.Text;
stea = textBox4.Text;
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
}
}
private void button2_Click(object sender, EventArgs e)
{
Form5_1_1 myf = new Form5_1_1();
myf.toolStripStatusLabel1.Text = "成功插入一条记录--> 所在系: " + sdept + ",专业:" + smajor + ",人数:" + snum + ",辅导员:" + stea ;
myf.ShowDialog();
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
后面还有 6 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
