上机实验6

  • 格式:doc
  • 大小:222.50 KB
  • 文档页数:8

攀枝花学院实验报告 实验课程: Visual C#,NET程序设计 实验项目: 上机实验10 实验日期:2015年6月9日 系:数学与计算机学院 班级: 2013级计算机科学与技术 姓名: 学号: 同组人: 指导教师:罗明刚 成绩: 实验目的: 初步掌握windows窗体应用程序的设计方法,包括对话框的设计方法,掌握常用窗体控件的使用方法. 实验仪器设备,药品,器材:Microsoft visual studio 2010 实验要求: 1.熟悉visual studio.net 2010的基本操作方法. 1.认真阅读本章相关内容,尤其是案例. 2.实验前进行程序设计,完成源程序的编写任务. 3.反复操作,直到不需要参考教材,能熟练操作为止. 实验步骤: 对于一个windows版的个人理财系统来说,他具有用户登陆,收支情况管理和基本资料管理等功能,如图所示:

1.请设计一个简单的用户登陆界面,当输入正确的用户名和密码时,系统将给出正确的提示,否则给出错误的提示. 2.请设计一个关于我们的窗体. 3.添加一个新窗体,用于添加个人收支明细.特别注意,勤俭节约是中华名族的传统美德是滚动显示的文字. 4.添加一个新窗体,用于添加收支项目信息. 5.修改”添加收支项”对话框的”确定信息”选项卡,使用通用对话框动态设置收支信息. 6.添加一个新窗体,用作个人理财系统的主窗体,并为其创建主菜单,工具栏以及状态栏..其中,工具栏的个按钮分别对应菜单命令:添加收支,统计查询,添加收支项目,收支明细查询. 7.设置个人理财软件为MDI应用程序,并在主窗体中通过菜单命令或工具栏按钮打开各个窗体.注意,将”关于我们”显示为模式对话框. 1.其代码如下: 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;

namespace _1 { public partial class Login : Form { public Login() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { string userName = textBox1.Text; string password = textBox2.Text; if (userName == "admin" && password == "1234") { MessageBox.Show("欢迎进入成绩管理系统!", "登陆成功", MessageBoxButtons.OK, MessageBoxIcon.Information);

} else { MessageBox.Show("你输入的用户名或密码错误!", "登陆失败", MessageBoxButtons.OK, MessageBoxIcon.Information); }

} private void button2_Click(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text = ""; textBox1.Focus(); } } } using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace _1 { static class Program { /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Login()); } } } 编译并运行程序,输入用户名和密码,单击“确定”按钮后的运行效果如图所示。

2. 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; namespace _1 { public partial class AboutForm : Form { public AboutForm() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { this.Close(); } } }

using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace _1 { static class Program { /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new AboutForm()); } } } 编译并运行程序,运行效果如图所示。 3.using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace _1 { static class Program { /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new shouru()); } } }编译并运行程序,运行效果如图所示。

. 4. using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace _1 { static class Program { /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new s()); } } } 编译并运行程序,运行效果如图所示。

5.using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace _1 { static class Program { /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new 个人理财()); } } } 编译并运行程序,运行效果如图所示。

,