最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#實(shí)現(xiàn)學(xué)員信息管理系統(tǒng)

 更新時(shí)間:2019年06月12日 08:34:02   作者:zxh...  
這篇文章主要為大家詳細(xì)介紹了C#實(shí)現(xiàn)學(xué)員信息管理系統(tǒng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

新手寫(xiě)一段學(xué)員信息管理系統(tǒng),有代碼冗余的情況請(qǐng)諒解,代碼如下,請(qǐng)大神指點(diǎn)

//登陸入口頁(yè)面
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.Threading.Tasks;
using System.Windows.Forms;

namespace 學(xué)員管理系統(tǒng)
{
 public partial class Lo : Form
 {
 public Lo()
 {
  InitializeComponent();
 }
  string sql= "Data Source=LAPTOP-PCMBBB0N;Initial Catalog=DB_Student;Trusted_Connection=true;";
  private void Log_Load(object sender, EventArgs e)
 {
  this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
  this.Location = new Point(Screen.PrimaryScreen.Bounds.Width / 2 - this.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2 - this.Height / 2);
 }
 Main main;
  private void button1_Click(object sender, EventArgs e)
 {
  try
  {
  string pwd =txtpwd.Text;
  if (pwd.ToString() == "")
  {
   label2.Visible = true;
   label2.Text = "密碼不能為空!";
  }
  else
  {
   if (pwd.Equals((table.Rows[0]["Pwd"]).ToString()))
   {
   label2.Visible = false;
   main = new Main();
   main.Show();
   this.Visible = false;
   }
   else
   {
   label2.Text = "密碼不正確!";
   label2.Visible = true;
   }
  }
  }
  catch (Exception)
  {
  throw;
  }
 }
 DataTable table = new DataTable();
 private void txtid_Leave(object sender, EventArgs e)
 {
  try
  {
  int id = int.Parse(txtid.Text);
   //1.鏈接數(shù)據(jù)庫(kù)對(duì)象
   SqlConnection sqlcon = new SqlConnection(sql);
  //3.創(chuàng)建數(shù)據(jù)庫(kù)命令對(duì)象
  SqlCommand cmd = new SqlCommand();
  cmd.Connection = sqlcon;
   cmd.CommandText = "SELECT * FROM Student WHERE ID=" + id;
   //5.數(shù)據(jù)適配器對(duì)象
  SqlDataAdapter sda = new SqlDataAdapter();
  sda.SelectCommand = cmd;
  //6.這個(gè)table可以用來(lái)接受適配的最終結(jié)果
  sda.Fill(table);
   if (table.Rows.Count > 0)
  {
   label1.Visible = false;
  }
  else
  {
   label1.Visible = true;
   label1.Text = "輸入ID不存在!";
  }
  }
  catch (Exception)
  {
  
  label1.Visible = true;
  label1.Text = "請(qǐng)輸入純數(shù)字ID!";
  txtid.Focus();
  txtid.Text = "";
  }
 }
 private void button2_Click_1(object sender, EventArgs e)
 {
  Register register = new Register();
  register.ShowDialog();
  this.Visible = true;
  label1.Visible = false;
 }
 }
}


//注冊(cè)頁(yè)面
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;

namespace 學(xué)員管理系統(tǒng)
{
 public partial class Register : Form
 {
 public Register()
 {
  InitializeComponent();
 }
 string sql = "Data Source=LAPTOP-PCMBBB0N;Initial Catalog=DB_Student;Trusted_Connection=true;";
  private void button1_Click(object sender, EventArgs e)
 {
  try
  {
  SqlConnection sqlCon = new SqlConnection(sql);
  string sqltxt = string.Format("INSERT INTO Student VALUES('{0}','{1}','{2}','{3}','{4}')", textBox2.Text, textBox1.Text, textBox3.Text, textBox4.Text, textBox5.Text);
  SqlCommand cmd = new SqlCommand(sqltxt, sqlCon);
  sqlCon.Open();
  int res = cmd.ExecuteNonQuery();
  if (res > 0)
  {
   MessageBox.Show("注冊(cè)成功");
   textBox1.Text = "";
   textBox2.Text = "";
   textBox3.Text = "";
   textBox4.Text = "";
   textBox5.Text = "";
   textBox1.Focus();
  }
  }
  catch (Exception)
  {
  throw;
  }
 }

     

//信息頁(yè)面(可以進(jìn)行數(shù)據(jù)庫(kù)信息更改,刪除,查看 以及翻頁(yè)操作)
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;
namespace 學(xué)員管理系統(tǒng)
{
 public partial class Main : Form
 {
 public Main()
 {
  InitializeComponent();
 } 
  string strcon = "Data Source=LAPTOP-PCMBBB0N;Initial Catalog=DB_Student;Trusted_Connection=true;";
 int countPage;
 int nowPage = 1;
 SqlConnection sqlCon;
  private void Main_Load(object sender, EventArgs e)
 {
  sqlCon = new SqlConnection(strcon);
  //綁定頁(yè)碼信息
  try
  {
  string sql = "SELECT COUNT(*) FROM Student";
  SqlCommand cmdl = new SqlCommand(sql, sqlCon);
  sqlCon.Open();
  object res = cmdl.ExecuteScalar();
  if (res != null)
  {
   if ((int)res % 6 > 0)
   {
   countPage = ((int)res / 6) + 1;
   }
   else
   {
   countPage = (int)res / 6;
   }
  }
  }
  catch (Exception)
  {
  throw;
  }
  finally
  {
  sqlCon.Close();
  }
  //初始信息綁定
  try
  {
  SetPage(sqlCon);
  dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
  dataGridView1.RowHeadersVisible = false;
  foreach (DataGridViewColumn dc in dataGridView1.Columns)
  {
   dc.SortMode = DataGridViewColumnSortMode.Programmatic;
  }
  dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  dataGridView1.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  dataGridView1.ScrollBars = ScrollBars.None;
  dataGridView1.MultiSelect = false;
  dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  dataGridView1.AllowUserToResizeRows = false;
  dataGridView1.AllowUserToResizeColumns = false;   
  dataGridView1.ScrollBars = ScrollBars.None;
  dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
  dataGridView1.AllowUserToAddRows = false;
  dataGridView1.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  foreach (DataGridViewColumn item in dataGridView1.Columns)
  {
   item.SortMode = DataGridViewColumnSortMode.NotSortable;
  }
  dataGridView1.ReadOnly = true;
  dataGridView1.CellMouseDown += DataGridView1_CellMouseDown;
  }
  catch (Exception ex)
  {
  throw;
  }
  finally
  {
  sqlCon.Close();
  }
 }
 private void SetPage(SqlConnection sqlCon)
 {
  string sql = string.Format("SELECT ID AS '賬號(hào)',NAME AS '姓名',Sex AS '性別',Age AS '年齡',Zhanli AS '電話' FROM Student WHERE ID IN(SELECT TOP(6) ID FROM Student WHERE ID NOT IN (SELECT TOP({0}) ID FROM Student ORDER BY ID)ORDER BY ID ) ORDER BY ID", (nowPage - 1) * 6);
  SqlCommand cmd = new SqlCommand(sql, sqlCon);
  SqlDataAdapter sda = new SqlDataAdapter(cmd);
  DataSet ds = new DataSet();
  sda.Fill(ds);
  dataGridView1.DataSource = ds.Tables[0];
  label1.Text = nowPage.ToString();
  label3.Text = countPage.ToString();
 }
  private void DataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
 {
  if (e.Button == MouseButtons.Right && dataGridView1.SelectedRows.Count > 0)
  {
  dataGridView1.ClearSelection();
  dataGridView1.Rows[e.RowIndex].Selected = true;
  ID.Idd = (int)dataGridView1.SelectedCells[0].Value;
  contextMenuStrip1.Show();
  }
 }
 private void 刪除ToolStripMenuItem1_Click(object sender, EventArgs e)
 {
  try
  {
  SqlConnection sqlCon = new SqlConnection(strcon);
  string sqltxt = "DELETE FROM Student WHERE ID=" + ID.Idd;
  SqlCommand cmd = new SqlCommand(sqltxt, sqlCon);
  sqlCon.Open();
  int res = cmd.ExecuteNonQuery();
  if (res > 0)
  {
   MessageBox.Show("刪除成功!");
   Main ma = new 學(xué)員管理系統(tǒng).Main();
   ma.Show();
   this.Visible = false;
  }
  }
  catch (Exception)
  {
  throw;
  }
 }
 private void 修改密碼ToolStripMenuItem_Click(object sender, EventArgs e)
 {
  xiugai xiu = new xiugai();
  xiu.ShowDialog();
  this.Visible = false;
 }
 private void 查看詳細(xì)信息ToolStripMenuItem_Click(object sender, EventArgs e)
 {
  chakan cha = new chakan();
  cha.ShowDialog();
  this.Visible = false;
 }
 private void 下一頁(yè)ToolStripMenuItem_Click(object sender, EventArgs e)
 {
  
  if (nowPage >= countPage)
  {
  return;
  }
  else
  {
  nowPage++;
  SetPage(sqlCon);
  }
 }
  private void 上一頁(yè)ToolStripMenuItem_Click(object sender, EventArgs e)
 {
  if (nowPage <= 1)
  {
  return;
  }
  else
  {
  nowPage--;
  SetPage(sqlCon);
  }
 }
 }
}

/查看詳細(xì)信息
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.Threading.Tasks;
using System.Windows.Forms;

namespace 學(xué)員管理系統(tǒng)
{
 public partial class chakan : Form
 {
 public chakan()
 {
  InitializeComponent();
 }
  private void button1_Click(object sender, EventArgs e)
 {
  Main ma = new 學(xué)員管理系統(tǒng).Main();
  ma.Show();
  this.Visible = false; 
 }
 string sql = "Data Source=LAPTOP-PCMBBB0N;Initial Catalog=DB_Student;Trusted_Connection=true;";
 private void chakan_Load(object sender, EventArgs e)
 {
  try
  {
  SqlConnection sqlcon = new SqlConnection(sql);
  string sqltxt = "SELECT * FROM Student WHERE ID="+ID.Idd; 
  SqlCommand cmd = new SqlCommand(sqltxt, sqlcon);
  sqlcon.Open();
  SqlDataAdapter sda = new SqlDataAdapter(cmd);
  DataTable table = new DataTable();
  sda.Fill(table);
  Name1.Text = (table.Rows[0]["NAME"]).ToString();
  ID1.Text = (table.Rows[0]["ID"]).ToString();
  Pwd.Text = (table.Rows[0]["Pwd"]).ToString();
  Sex.Text = (table.Rows[0]["Sex"]).ToString();
  Age.Text = (table.Rows[0]["Age"]).ToString();
  Zhanli.Text = (table.Rows[0]["Zhanli"]).ToString();
  }
  catch (Exception)
  {
  throw;
  }
 }
 }
}

//創(chuàng)建一個(gè)類(lèi)用來(lái)存儲(chǔ)用戶(hù)賬號(hào)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 學(xué)員管理系統(tǒng)
{
 public class ID
 {
 public static int idd;
 public static int Idd
 {
  get
  {
  return idd;
  }
  set
  {
  idd = value;
  }
 }
 }
}
//修改密碼
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 學(xué)員管理系統(tǒng)
{
 public partial class xiugai : Form
 {
 public xiugai()
 {
  InitializeComponent();
 }
 string sql = "Data Source=LAPTOP-PCMBBB0N;Initial Catalog=DB_Student;Trusted_Connection=true;";
 private void button1_Click(object sender, EventArgs e)
 {
  string yuan = textBox1.Text;
  string New = textBox2.Text;
  string New2 = textBox3.Text;
  if (yuan=="")
  {
  label4.Visible = true;
  textBox1.Focus();
  }
  else
  {
  if (New=="")
  {
   label5.Visible = true;
   textBox2.Focus();
  }
  else
  {
   if (New2==""||New2!=New)
   {
   label6.Visible = true;
   textBox3.Focus();
   }
   else
   {
   try
   {
    int num = int.Parse(yuan);
    SqlConnection sqlcon = new SqlConnection(sql);
    string sqltext = "UPDATE Student SET Pwd=" + New2 + "WHERE ID="+ID.Idd;
    //string sqltext = "UPDATE StudentInfor SET Pwd=" + New2 + "WHERE ID="+ID.Idd;
    SqlCommand cmd = new SqlCommand(sqltext,sqlcon);
    sqlcon.Open();
    int res = cmd.ExecuteNonQuery();
    if (res>0)
    {
    MessageBox.Show("修改成功");
    }
   }
   catch (Exception)
   {
    throw;
   }
   }
  }
  }
 }
 }
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • C#使用符號(hào)表實(shí)現(xiàn)查找算法

    C#使用符號(hào)表實(shí)現(xiàn)查找算法

    本文詳細(xì)講解了C#使用符號(hào)表實(shí)現(xiàn)查找算法,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-04-04
  • DOTNETBAR制作圓角窗體和圓角控件代碼實(shí)例

    DOTNETBAR制作圓角窗體和圓角控件代碼實(shí)例

    這篇文章主要介紹了DOTNETBAR制作圓角窗體和圓角控件的方法,大家參考使用吧
    2013-11-11
  • 簡(jiǎn)單學(xué)習(xí)C#中的泛型方法使用

    簡(jiǎn)單學(xué)習(xí)C#中的泛型方法使用

    這篇文章主要介紹了C#中的泛型方法使用,需要的朋友可以參考下
    2016-02-02
  • 淺談C#中ListView類(lèi)的用法

    淺談C#中ListView類(lèi)的用法

    這篇文章主要介紹了淺談C#中ListView的用法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • 基于WPF繪制一個(gè)點(diǎn)贊大拇指動(dòng)畫(huà)

    基于WPF繪制一個(gè)點(diǎn)贊大拇指動(dòng)畫(huà)

    這篇文章主要為大家詳細(xì)介紹了WPF實(shí)現(xiàn)繪制一個(gè)點(diǎn)贊大拇指動(dòng)畫(huà),文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)或工作有一定幫助,感興趣的小伙伴可以了解一下
    2023-02-02
  • 解答“60k”大佬的19道C#面試題(上)

    解答“60k”大佬的19道C#面試題(上)

    這篇文章主要解答了“60k”大佬的19道C#面試題中的10道,文中的面試題比較小眾,作者給了不錯(cuò)的答案,相信對(duì)你以后的面試有所幫助,感興趣就來(lái)了解下
    2020-06-06
  • c# 實(shí)現(xiàn)語(yǔ)音合成

    c# 實(shí)現(xiàn)語(yǔ)音合成

    這篇文章主要介紹了c# 實(shí)現(xiàn)語(yǔ)音合成的方法,幫助大家更好的理解和使用c#,感興趣的朋友可以了解下
    2020-12-12
  • Question:基于C#連續(xù)賦值的面試題介紹

    Question:基于C#連續(xù)賦值的面試題介紹

    本篇文章是關(guān)于C#中連續(xù)賦值的面試題介紹,需要的朋友參考下
    2013-05-05
  • WPF實(shí)現(xiàn)3D粒子波浪效果

    WPF實(shí)現(xiàn)3D粒子波浪效果

    這篇文章主要為大家詳細(xì)介紹了WPF實(shí)現(xiàn)3D粒子波浪效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-09-09
  • 如何使用Dapper處理多個(gè)結(jié)果集與多重映射實(shí)例教程

    如何使用Dapper處理多個(gè)結(jié)果集與多重映射實(shí)例教程

    Dapper類(lèi)是一個(gè)開(kāi)源的數(shù)據(jù)庫(kù)操作類(lèi),下面這篇文章主要給大家介紹了關(guān)于如何使用Dapper處理多個(gè)結(jié)果集與多重映射的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2018-09-09

最新評(píng)論

景德镇市| 英吉沙县| 虹口区| 炎陵县| 嵊州市| 金川县| 班玛县| 康保县| 建平县| 枞阳县| 郧西县| 民县| 木兰县| 米易县| 海原县| 铜山县| 开原市| 如东县| 通化县| 大洼县| 阳东县| 汾阳市| 特克斯县| 阜阳市| 襄城县| 四子王旗| 治多县| 新乡市| 凤山市| 马边| 花莲县| 丽水市| 阳信县| 芮城县| 瑞金市| 平山县| 小金县| 桃园县| 共和县| 嘉荫县| 磴口县|