国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

Winform學生信息管理系統各子窗體剖析(3)

2020-01-24 01:08:48
字體:
來源:轉載
供稿:網友

先來補充一下學生信息管理系統登錄窗體,在完成的過程中總是遇到各種各樣的問題,對于登錄窗體的設計還是存在著一些弊端,那就是需要登錄學生信息管理系統時如果輸入的數據出錯不必一個個刪除,就需要在窗體上再添加一個清空寫入數據的button控件,將其屬性Text改為重置。還有一個與登錄窗口設計的屬性AcceptButton將其改為確定按鈕的唯一名字(也就是button1),因此在按下回車鍵后我們也能登錄到學生信息管理系統主頁面相對應的CancelButton將其改為取消按鈕的唯一名字(也就是button2),因此在按下退出鍵后也能退出登錄窗口。
需要在重置的button按鈕控件添加的Click事件的代碼為:

<span style="font-size:18px;">private void button3_Click(object sender, EventArgs e) {  textBox1.Text = "";  textBox2.Text = ""; }</span> 

完成改動后的登錄窗口為:

 下面就來設計一些需要都用到的子窗體。

一、學生信息添加窗體

        學生信息添加窗體窗體主要是用來添加學生信息或者修改學生信息,輸入學號、姓名、性別、出生日期、家庭住址、家庭電話和所在班級,點擊“保存”按鈕即可錄入或者修改學生信息記錄,點擊“取消”按鈕,退出學生信息添加窗體。這個窗體需要用到的控件有Label控件,TextBox控件,Button控件,Panel控件和ComboBox控件。在學生信息管理系統主頁面中的菜單選項中找到學生管理,再次單擊學生信息就會出現學生信息添加的窗口。

 二、用戶信息添加窗體

         用戶信息添加窗體主要是實現登錄用戶的添加操作。該窗體中包含了用戶名、密碼、確認密碼和用戶權限這些信息。當點擊“保存”按鈕時,即可以將用戶的這些信息添加到數據庫中。點擊“取消”按鈕,可以退出用戶信息添加窗體。這個窗體需要用到的控件有Label控件,TextBox控件,Button控件,Panel控件和ComboBox控件。在學生信息管理系統主頁面中的菜單選項中找到系統管理,再次單擊用戶信息就會出現用戶信息添加的窗口。

 三、用戶修改密碼窗體

        用戶修改密碼窗體主要是實現用戶修改密碼的功能。該窗體中,可以通過輸入用戶名和原密碼,然后輸入新密碼和確認新密碼,來修改用戶的登錄密碼。這個窗體需要用到的控件有Label控件,TextBox控件,Button控件,Panel控件。在學生信息管理系統主頁面中的菜單選項中找到系統管理,再次單擊用戶修改密碼就會出現用戶修改密碼添加的窗口。

上述三個子窗體中的取消按鈕都是一樣的代碼寫入:

<span style="font-size:18px;">private void button2_Click(object sender, EventArgs e) {   Close(); }</span> 

經過上述的改動和子窗體的添加后的完整的Form1(學生信息管理系統登錄窗口)的代碼為:

<span style="font-size:18px;">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;  namespace WindowsForms {   public partial class Form1 : Form   {     public Form1()     {       InitializeComponent();     }      private void button1_Click(object sender, EventArgs e)     {       string str = textBox1.Text;//獲取你在textBox1中輸入的信息       Form2 ad = new Form2(str);//創建一個學生信息管理系統主界面的對象       ad.Show();//點擊確定后進入學生信息管理系統主界面       this.Hide();//單擊確定后隱藏登錄窗口     }      private void button2_Click(object sender, EventArgs e)     {       Application.Exit();//點擊取消退出整個程序     }      private void button3_Click(object sender, EventArgs e)     {       textBox1.Text = "";//這是清空你寫入的用戶名稱       textBox2.Text = "";//這是清空你寫入的用戶密碼     }   } }</span></span> 

完整的Form2(學生信息管理系統主頁面)的代碼為:

<span style="font-size:18px;"><span style="font-size:18px;">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;  namespace WindowsForms {   public partial class Form2 : Form   {     public Form2(string s)     {       InitializeComponent();       tssl_name.Text = s;//將登陸窗口textBox1輸入的信息傳遞給狀態欄Text屬性     }      private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)     {       Application.Exit();//單擊主菜單中的退出我們退出整個程序     }      private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)     {      }      private void toolStripButton1_Click(object sender, EventArgs e)     {       Children qq = new Children();//創建一個子窗體的實例       qq.MdiParent = this;//要求子窗體的父窗體是MDI窗體       qq.Show();     }      private void 學生信息ToolStripMenuItem_Click(object sender, EventArgs e)     {       Children1 c1 = new Children1();       c1.MdiParent = this;       c1.Show();     }      private void 用戶信息ToolStripMenuItem_Click(object sender, EventArgs e)     {       Children2 c2 = new Children2();       c2.MdiParent = this;       c2.Show();     }      private void 用戶密碼修改ToolStripMenuItem_Click(object sender, EventArgs e)     {       Children3 c3 = new Children3();       c3.MdiParent = this;       c3.Show();     }   } }</span> 

完整的子窗體Children1(學生信息添加窗體)的代碼為:

<span style="font-size:18px;">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;  namespace WindowsForms {   public partial class Children1 : Form   {     public Children1()     {       InitializeComponent();     }      private void button2_Click(object sender, EventArgs e)     {       Close();     }   } }</span> 

完整的子窗體Children2(用戶信息添加窗體)的代碼為:

<span style="font-size:18px;">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;  namespace WindowsForms {   public partial class Children2 : Form   {     public Children2()     {       InitializeComponent();     }      private void button2_Click(object sender, EventArgs e)     {       Close();     }      private void s(object sender, EventArgs e)     {     }   } }</span> 

完整的子窗體Children2(用戶密碼修改窗體)的代碼為:

<span style="font-size:18px;">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;  namespace WindowsForms {   public partial class Children3 : Form   {     public Children3()     {       InitializeComponent();     }      private void button2_Click(object sender, EventArgs e)     {       Close();     }   } }</span> 

在登錄學生信息管理系統主頁面打開子窗體的界面為:

在文件中找到你所編寫的程序,打開exe運行學生信息管理系統,檢驗是否與自己設計想象的有什么不同,不同的話進行修改調試,直到與自己預想的結果相吻合就可以了。

以上就是本文的全部內容,希望對大家的學習有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 永吉县| 迁西县| 平凉市| 陵水| 泌阳县| 红安县| 淄博市| 新平| 巴彦县| 正宁县| 蒙自县| 新源县| 双江| 沁阳市| 鄂尔多斯市| 天峻县| 屯门区| 云梦县| 泽州县| 隆安县| 太谷县| 巴东县| 桓仁| 绥芬河市| 斗六市| 凤阳县| 宜城市| 江津市| 眉山市| 雷波县| 施甸县| 平昌县| 于都县| 朔州市| 怀化市| 黎城县| 巩留县| 青川县| 简阳市| 永城市| 永城市|