Winform學(xué)生信息管理系統(tǒng)各子窗體剖析(3)
先來補充一下學(xué)生信息管理系統(tǒng)登錄窗體,在完成的過程中總是遇到各種各樣的問題,對于登錄窗體的設(shè)計還是存在著一些弊端,那就是需要登錄學(xué)生信息管理系統(tǒng)時如果輸入的數(shù)據(jù)出錯不必一個個刪除,就需要在窗體上再添加一個清空寫入數(shù)據(jù)的button控件,將其屬性Text改為重置。還有一個與登錄窗口設(shè)計的屬性AcceptButton將其改為確定按鈕的唯一名字(也就是button1),因此在按下回車鍵后我們也能登錄到學(xué)生信息管理系統(tǒng)主頁面相對應(yīng)的CancelButton將其改為取消按鈕的唯一名字(也就是button2),因此在按下退出鍵后也能退出登錄窗口。
需要在重置的button按鈕控件添加的Click事件的代碼為:
<span style="font-size:18px;">private void button3_Click(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text = ""; }</span>
完成改動后的登錄窗口為:
下面就來設(shè)計一些需要都用到的子窗體。
一、學(xué)生信息添加窗體
學(xué)生信息添加窗體窗體主要是用來添加學(xué)生信息或者修改學(xué)生信息,輸入學(xué)號、姓名、性別、出生日期、家庭住址、家庭電話和所在班級,點擊“保存”按鈕即可錄入或者修改學(xué)生信息記錄,點擊“取消”按鈕,退出學(xué)生信息添加窗體。這個窗體需要用到的控件有Label控件,TextBox控件,Button控件,Panel控件和ComboBox控件。在學(xué)生信息管理系統(tǒng)主頁面中的菜單選項中找到學(xué)生管理,再次單擊學(xué)生信息就會出現(xiàn)學(xué)生信息添加的窗口。
二、用戶信息添加窗體
用戶信息添加窗體主要是實現(xiàn)登錄用戶的添加操作。該窗體中包含了用戶名、密碼、確認密碼和用戶權(quán)限這些信息。當點擊“保存”按鈕時,即可以將用戶的這些信息添加到數(shù)據(jù)庫中。點擊“取消”按鈕,可以退出用戶信息添加窗體。這個窗體需要用到的控件有Label控件,TextBox控件,Button控件,Panel控件和ComboBox控件。在學(xué)生信息管理系統(tǒng)主頁面中的菜單選項中找到系統(tǒng)管理,再次單擊用戶信息就會出現(xiàn)用戶信息添加的窗口。
三、用戶修改密碼窗體
用戶修改密碼窗體主要是實現(xiàn)用戶修改密碼的功能。該窗體中,可以通過輸入用戶名和原密碼,然后輸入新密碼和確認新密碼,來修改用戶的登錄密碼。這個窗體需要用到的控件有Label控件,TextBox控件,Button控件,Panel控件。在學(xué)生信息管理系統(tǒng)主頁面中的菜單選項中找到系統(tǒng)管理,再次單擊用戶修改密碼就會出現(xiàn)用戶修改密碼添加的窗口。
上述三個子窗體中的取消按鈕都是一樣的代碼寫入:
<span style="font-size:18px;">private void button2_Click(object sender, EventArgs e) { Close(); }</span>
經(jīng)過上述的改動和子窗體的添加后的完整的Form1(學(xué)生信息管理系統(tǒng)登錄窗口)的代碼為:
<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);//創(chuàng)建一個學(xué)生信息管理系統(tǒng)主界面的對象 ad.Show();//點擊確定后進入學(xué)生信息管理系統(tǒng)主界面 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(學(xué)生信息管理系統(tǒng)主頁面)的代碼為:
<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輸入的信息傳遞給狀態(tài)欄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();//創(chuàng)建一個子窗體的實例 qq.MdiParent = this;//要求子窗體的父窗體是MDI窗體 qq.Show(); } private void 學(xué)生信息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(學(xué)生信息添加窗體)的代碼為:
<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>
在登錄學(xué)生信息管理系統(tǒng)主頁面打開子窗體的界面為:
在文件中找到你所編寫的程序,打開exe運行學(xué)生信息管理系統(tǒng),檢驗是否與自己設(shè)計想象的有什么不同,不同的話進行修改調(diào)試,直到與自己預(yù)想的結(jié)果相吻合就可以了。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習有所幫助。
相關(guān)文章
C#編程實現(xiàn)Excel文檔中搜索文本內(nèi)容的方法及思路
有了在Word文檔中編程實現(xiàn)搜索文本的經(jīng)驗,在Excel中實現(xiàn)這個功能也并非難事。2013-07-07淺談C#在網(wǎng)絡(luò)波動時防重復(fù)提交的方法
這篇文章主要介紹了淺談C#在網(wǎng)絡(luò)波動時防重復(fù)提交的方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習或者工作具有一定的參考學(xué)習價值,需要的朋友們下面隨著小編來一起學(xué)習學(xué)習吧2019-04-04經(jīng)典排序算法之冒泡排序(Bubble sort)代碼
這篇文章主要介紹了經(jīng)典排序算法之冒泡排序(Bubble sort)代碼的相關(guān)資料,非常不錯具有參考借鑒價值,需要的朋友可以參考下2016-06-06