addstu.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
// edit by gjh
namespace LoginFrame
{
public partial class addstu : Form
{
public addstu()
{
InitializeComponent();
}
private void addstu_Load(object sender, EventArgs e)
{
}
private void txtname_TextChanged(object sender, EventArgs e)
{
}
private void btnadd_Click(object sender, EventArgs e)
{ // 给定年龄范围 0-100
if (int.Parse(txtage.Text) < 0 || int.Parse(txtage.Text) > 100)
{
if (int.Parse(txtage.Text) > 100)
MessageBox.Show("年龄请不要超过100");
else
MessageBox.Show("年龄请不要小于0");
}
else
{
SqlConnection conn = new SqlConnection(DbHelper.connString);
try
{
conn.Open();
// 插入学生信息
string sql = string.Format("insert into stuinfo (Name,sex,Age,phone,myclass,loginid,loginpwd) values ('{0}','{1}',{2},'{3}','{4}','{5}','{6}')", txtname.Text, cbosex.Text, int.Parse(txtage.Text),phone.Text,myclass.Text,loginid.Text,password.Text);
SqlCommand comm = new SqlCommand(sql, conn);
int a = comm.ExecuteNonQuery();
if (a == 1)
{
MessageBox.Show("插入成功!");
}
else
{
MessageBox.Show("插入失败!");
}
}
catch (Exception ex)
后面还有 44 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
