• 大小: 1.27MB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2023-10-01
  • 语言: C#
  • 标签: C#  

资源简介

应用SQL server,仅供新手学习参考

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace DianMing
{
    public partial class AddStudent : Form
    {
        public AddStudent()
        {
            InitializeComponent();
        }
        //信息完整性
        private bool Integrality()
        {
            if (this.txtName.Text.Trim().Equals(““) || this.txtName.Text.Trim() == null)
            {
                MessageBox.Show(“请输入学生姓名!“);
                this.txtName.Focus();
                return false;
            }
            return true;
        }

        #region//确定 事件
        private void btnOk_Click(object sender EventArgs e)
        {
            //去掉姓名两边的空格
            this.txtName.Text = this.txtName.Text.Trim();
            if (this.Integrality()&&this.EqualName())
            { 
                //向info表中插入这条数据
                try
                {
                    //建插入命令
                    string strSQL = string.Format(“ insert into info values ( ‘{0} ‘ ‘{1}‘1 )“this.txtName.Textthis.cboxSex.Text);
                    DBHelper.conn.Open();
                    SqlCommand cmd = new SqlCommand(strSQLDBHelper.conn);
                    if (cmd.ExecuteNonQuery() > 0)
                    {
                        MessageBox.Show(“添加成功!“);
                        //判断是否要继续插入
                        if (this.cboxContinue.Checked)
                        {
                            this.txtName.Text = ““;
                            this.txtName.Focus();
                        }
                        else
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show(“添加失败!“);
                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    DBHelper.CloseData();
                }
            }
        }
        #endregion

        #region//判断是否有 同名 记录
        private bool EqualName()
        {
            try
            {
                DBHelper.CloseData();
                string strSql = string.Format(“select count(*) from info where Name=‘{0}‘ “this.txtName.Text.Trim());
                DBHelper.conn.Open();
                SqlCommand cmd = new SqlCommand(strSqlDBHelper.conn);
                int index =Convert.ToInt32( cmd.ExecuteScalar().ToString());
                if (index > 0)
                {
                    if (MessageBox.Show(“该名字已存在继续添加吗?“ “请确认“ MessageBoxButtons.YesNo
                         MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        retu

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4170  2011-05-16 16:48  陈年-点名系统(sql server版)\DianMing\DianMing\AddStudent.cs

     文件       5982  2011-05-16 16:18  陈年-点名系统(sql server版)\DianMing\DianMing\AddStudent.Designer.cs

     文件       9474  2011-05-16 16:18  陈年-点名系统(sql server版)\DianMing\DianMing\AddStudent.resx

     文件    1458688  2011-05-19 15:22  陈年-点名系统(sql server版)\DianMing\DianMing\bin\Debug\DianMing.exe

     文件     116224  2011-05-19 15:22  陈年-点名系统(sql server版)\DianMing\DianMing\bin\Debug\DianMing.pdb

     文件      14328  2011-05-19 15:25  陈年-点名系统(sql server版)\DianMing\DianMing\bin\Debug\DianMing.vshost.exe

     文件        490  2009-06-11 05:14  陈年-点名系统(sql server版)\DianMing\DianMing\bin\Debug\DianMing.vshost.exe.manifest

     文件       5216  2011-05-21 17:57  陈年-点名系统(sql server版)\DianMing\DianMing\DBHelper.cs

     文件       3837  2011-05-16 16:49  陈年-点名系统(sql server版)\DianMing\DianMing\DeleteStusent.cs

     文件       5060  2011-05-16 16:20  陈年-点名系统(sql server版)\DianMing\DianMing\DeleteStusent.Designer.cs

     文件       9474  2011-05-16 16:20  陈年-点名系统(sql server版)\DianMing\DianMing\DeleteStusent.resx

     文件       7409  2011-05-19 13:50  陈年-点名系统(sql server版)\DianMing\DianMing\DianMing.csproj

     文件       2724  2011-05-17 13:12  陈年-点名系统(sql server版)\DianMing\DianMing\frmChange.cs

     文件       5226  2011-05-17 13:12  陈年-点名系统(sql server版)\DianMing\DianMing\frmChange.Designer.cs

     文件       9474  2011-05-17 13:12  陈年-点名系统(sql server版)\DianMing\DianMing\frmChange.resx

     文件      22638  2011-05-19 15:25  陈年-点名系统(sql server版)\DianMing\DianMing\frmMian.cs

     文件      31396  2011-05-19 15:22  陈年-点名系统(sql server版)\DianMing\DianMing\frmMian.Designer.cs

     文件      13987  2011-05-19 15:22  陈年-点名系统(sql server版)\DianMing\DianMing\frmMian.resx

     文件        362  2011-05-19 13:50  陈年-点名系统(sql server版)\DianMing\DianMing\frmMode.cs

     文件       1852  2011-05-19 13:50  陈年-点名系统(sql server版)\DianMing\DianMing\frmMode.Designer.cs

     文件       9474  2011-05-19 13:50  陈年-点名系统(sql server版)\DianMing\DianMing\frmMode.resx

     文件        378  2011-05-11 15:31  陈年-点名系统(sql server版)\DianMing\DianMing\frmModification.cs

     文件       1188  2011-05-11 15:31  陈年-点名系统(sql server版)\DianMing\DianMing\frmModification.Designer.cs

     文件       5814  2011-05-11 15:31  陈年-点名系统(sql server版)\DianMing\DianMing\frmModification.resx

     文件        964  2011-05-18 13:43  陈年-点名系统(sql server版)\DianMing\DianMing\frmResult.cs

     文件       4928  2011-05-18 13:42  陈年-点名系统(sql server版)\DianMing\DianMing\frmResult.Designer.cs

     文件       9841  2011-05-18 13:42  陈年-点名系统(sql server版)\DianMing\DianMing\frmResult.resx

     文件       1729  2011-05-16 16:51  陈年-点名系统(sql server版)\DianMing\DianMing\LookInfo.cs

     文件       4231  2011-05-16 16:18  陈年-点名系统(sql server版)\DianMing\DianMing\LookInfo.Designer.cs

     文件       9474  2011-05-16 16:18  陈年-点名系统(sql server版)\DianMing\DianMing\LookInfo.resx

............此处省略59个文件信息

评论

共有 条评论