scholastic/Form3_2.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 Form3_2 : Form
    {
        DataTable mytable;
        SqlConnection mycon;
        string pstr;
        public Form3_2()
        {
            InitializeComponent();
        }
        private void Showdata()
        {
            string constr = "server=.\\sql2005;database=mydata;uid=sa;pwd=sa";
            mycon = new SqlConnection(constr);
            string mysql = "select * from course";
            SqlDataAdapter myada = new SqlDataAdapter(mysql, mycon);
            mytable = new DataTable();
            myada.Fill(mytable);
            dataGridView1.DataSource = mytable.DefaultView;
            mycon.Close();
        }
        private void Form3_2_Load(object sender, EventArgs e)
        {
            Showdata();
            textBox1.Text = mytable.Rows[0][0].ToString();
            textBox2.Text = mytable.Rows[0][1].ToString();
            textBox3.Text = mytable.Rows[0][2].ToString();
            textBox4.Text = mytable.Rows[0][3].ToString();
        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            pstr = mytable.Rows[e.RowIndex][0].ToString();
            textBox1.Text = mytable.Rows[e.RowIndex][0].ToString();
            textBox2.Text = mytable.Rows[e.RowIndex][1].ToString();
            textBox3.Text = mytable.Rows[e.RowIndex][2].ToString();
            textBox4.Text = mytable.Rows[e.RowIndex][3].ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
            {
                MessageBox.Show("修改信息记录信息不完整,重新输入!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                mycon.Open();
                string myupdate = "update course set 课程号="+Convert.ToInt32(textBox1.Text)+",课程名='" + textBox2.Text + "',任课教师='"+textBox3.Text+"',专业='"+textBox4.Text+"' where 课程号=" + Convert.ToInt32(pstr);
后面还有 20 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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