| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3743 人关注过本帖
标题:c#学生信息管理系统
取消只看楼主 加入收藏
软件二叔
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-9-20
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
c#学生信息管理系统
1! 注册的信息无法进入数据库!!!
2! 管理员对数据库内的学生信息的修改和查询代码!!!
/*------------------注册代码-----------------------*/
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;


namespace WindowsFormsApplication1
{
    public partial class Formregister : Form
    {
        public Formregister()
        {
            InitializeComponent();
        }

        private void Formregister_Load(object sender, EventArgs e)
        {

        }
        public bool bbool;

        private void buttonconform_Click(object sender, EventArgs e)
        {
            Formlog f2 = new Formlog();
            string User, Pwd;

            string StrConnection = @"Data Source=JIAOWOERYE-PC;Initial Catalog=mydatabase;Integrated Security=True";
            SqlConnection con = new SqlConnection(StrConnection);
            con.Open();
            string str= "select * from TableStudent";

            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
             = str;
             = CommandType.Text;
            cmd.ExecuteNonQuery();
            SqlDataReader reader = cmd.ExecuteReader();
            while(reader.Read())
            {
                User = reader["studentName"].ToString();
                Pwd = reader["mima"].ToString();
            
             if (textBoxname.Text.Trim () == reader["studentName"].ToString().Trim())
            {
                MessageBox.Show("用户存在");
                bbool =true;
                return;                 }
            else
            if (textBoxname.Text.Trim() != reader["studentName"].ToString().Trim())
            {
                MessageBox.Show("恭喜,该用户名可以使用");
                bbool = false;
            }
            }
            if (bbool == false)
            {
                = "insert into TableStudent values('" + textBoxnum.Text + "','" + textBoxname.Text + "','" + textBoxclass.Text + "','" + textBoxmima.Text + "','" + textBoxrealname.Text + "')";

                con.Close();
                MessageBox.Show("注册成功!");
               
                f2.Show();//运行登陆程序
                this.Hide();

            }


            
               
            }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Formlog f2 = new Formlog();
            f2.Show();
        }
    }
}


/*---------------------------------------管理员管理代码------------------------*/
//有错误,要求读取后可以选中一项修改,求大神更改
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFormsApplication1
{
    public partial class Formcontrol : Form
    {
        public Formcontrol()
        {
            InitializeComponent();
        }

        private void comboBoxnumber_SelectedIndexChanged(object sender, EventArgs e)
        {
            string StrConnection = @"Data Source=JIAOWOERYE-PC;Initial Catalog=mydatabase;Integrated Security=True";
            SqlConnection con = new SqlConnection(StrConnection);
            con.Open();


            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
             = CommandType.Text;

             = "select studentNumber from TableStudent where studentNumber =" + comboBoxnumber.Text;
            SqlDataReader reader = cmd.ExecuteReader();


            reader.Read();

            textBoxnum.Text = reader.GetValue(reader.GetOrdinal("studentNumber")).ToString().Trim();
            textBoxrealname.Text = reader.GetValue(reader.GetOrdinal("studentName")).ToString().Trim();
            textBoxmima.Text = reader.GetValue(reader.GetOrdinal("male")).ToString().Trim();
            textBoxname.Text = reader.GetValue(reader.GetOrdinal("age")).ToString().Trim();
            //textBoxdepart.Text = reader.GetValue(reader.GetOrdinal("deparement")).ToString().Trim();
            textBoxclass.Text = reader.GetValue(reader.GetOrdinal("class")).ToString().Trim();


        }

        private void buttonchange_Click(object sender, EventArgs e)
        {

        }
    }
    }
//}
搜索更多相关主题的帖子: 管理系统 public 管理员 数据库 信息 
2016-01-13 20:37
软件二叔
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-9-20
收藏
得分:0 
2016-02-13 14:45
快速回复:c#学生信息管理系统
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020218 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved