scholastic/Form4_1.cs

(开头部分) 3KB

这里只显示每个文件的开头 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 Form4_1 : Form
    {
        string sno;
        string sname;
        string ssex;
        string sage;
        string ssalary;
        string scs;
        string sedu;
        string scourse;
        public Form4_1()
        {
            InitializeComponent();
        }

        private void Form4_1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "" || textBox7.Text == "" || textBox8.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 teacher(职工号,姓名,性别,年龄,工资,所在系,学历,课程) values(" + Convert.ToInt32(textBox1.Text) + ",'" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "')";
                SqlCommand mycom = new SqlCommand(myinsert, mycon);
                mycom.ExecuteNonQuery();
                mycon.Close();
                mycon.Dispose();
                MessageBox.Show("已成功向数据库表中插入一条记录!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                sno = textBox1.Text;
                sname = textBox2.Text;
                ssex = textBox3.Text;
                sage = textBox4.Text;
                ssalary = textBox5.Text;
                scs = textBox6.Text;
                sedu = textBox7.Text;
                scourse = textBox8.Text;
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
后面还有 26 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读 AI

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。