可视化程序设计-个人记账本(课程设计)_第1页
可视化程序设计-个人记账本(课程设计)_第2页
可视化程序设计-个人记账本(课程设计)_第3页
可视化程序设计-个人记账本(课程设计)_第4页
可视化程序设计-个人记账本(课程设计)_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、可视化程序设计实验报告学 号:2143214姓 名:李子厚提交日期:2016-11-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 Window

2、sFormsApplication1 public partial class Form1 : Form double outValue = 0; bool c = false; string d; bool f = true; int x = 0; int y = 0; public Form1() InitializeComponent(); private void button1_Click(object sender, EventArgs e) caculate(1); private void button2_Click(object sender, EventArgs e) ca

3、culate(2); private void button3_Click(object sender, EventArgs e) caculate(3); private void button4_Click(object sender, EventArgs e) caculate(4); private void button5_Click(object sender, EventArgs e) caculate(5); private void button6_Click(object sender, EventArgs e) caculate(6); private void butt

4、on7_Click(object sender, EventArgs e) caculate(7); private void button8_Click(object sender, EventArgs e) caculate(8); private void button9_Click(object sender, EventArgs e) caculate(9); private void button14_Click(object sender, EventArgs e) caculate(0); private void button10_Click(object sender, E

5、ventArgs e) c = true; d = "+" textBox1.Text += "+" private void button11_Click(object sender, EventArgs e) c = true; d = "-" textBox1.Text += "-" private void button12_Click(object sender, EventArgs e) switch (d) case "+": outValue = x + y; break; ca

6、se "-": outValue = x - y; break; case "*": outValue = x * y; break; case "/": outValue = x /y; break; textBox1.Text = outValue + "" c = false; f = false; x = 0; y = 0; private void button13_Click(object sender, EventArgs e) textBox1.Text = "" c = fal

7、se; f = false; x = 0; y = 0; public void caculate(int z) if (f = false) textBox1.Text = "" f = true; if (c = true) textBox1.Text += z; y = 10 * y + z; else textBox1.Text += z; x = 10 * x + z; private void button15_Click(object sender, EventArgs e) if (c = true) y = 0; textBox1.Text = x + d

8、; else x = 0; textBox1.Text = "" private void button17_Click(object sender, EventArgs e) c = true; d = "*" textBox1.Text += "*" private void button16_Click(object sender, EventArgs e) c = true; d = "/" textBox1.Text += "/" private void button18_Click

9、(object sender, EventArgs e) /除法功能只能算整除,由于不知道int换成double怎么改所以没能实现【程序截图】实验二 目录与文件【实验内容】做一个简单的记事本,有打开和保存功能【关键代码】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

10、.Windows.Forms;using System.IO;namespace test2 public partial class Form1 : Form public Form1() InitializeComponent(); string filename; private void 打开ToolStripMenuItem_Click(object sender, EventArgs e) OpenFileDialog open = new OpenFileDialog(); filename = open.FileName; open.Filter = "txt fil

11、es (*.txt)|*.txt|All files (*.*)|*.*" open.FilterIndex = 2; open.RestoreDirectory = true; if (open.ShowDialog()=DialogResult.OK) StreamReader reader = new StreamReader(open.FileName, System.Text.Encoding.Default); richTextBox1.Text = reader.ReadToEnd(); reader.Close(); private void 保存ToolStripM

12、enuItem_Click(object sender, EventArgs e) SaveFileDialog save = new SaveFileDialog(); StreamWriter writer; save.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" save.FilterIndex = 2; save.RestoreDirectory = true; if (save.ShowDialog() = DialogResult.OK) writer = new StreamWriter(save

13、.FileName); writer.Write(richTextBox1.Text); /写入 writer.Close();/关闭流 【程序截图】实验三 图形图像处理【实验内容】做一个程序,可以读取一个位图并显示,通过点击上下左右按钮,可以调整图片的位置,通过点击放大缩小,可以缩放图片。【关键代码】using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text

14、;using System.Windows.Forms;namespace WindowsFormsApplication3 public partial class Form1 : Form Graphics g; int width, height; int x, y; const int per = 5; float rit = 1; public Form1() InitializeComponent(); width = pictureBox1.Width; height = pictureBox1.Height; g = this.pictureBox1.CreateGraphic

15、s(); x = y = 0; private void draw() g = this.pictureBox1.CreateGraphics(); g.Clear(this.BackColor); g.TranslateTransform(x, y); g.ScaleTransform(rit, rit); g.DrawImage(pictureBox1.Image, 0, 0, width, height); private void 读取ToolStripMenuItem_Click(object sender, EventArgs e) OpenFileDialog open = ne

16、w OpenFileDialog(); open.Filter = "image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*" if (open.ShowDialog() = DialogResult.OK) pictureBox1.Image = Image.FromFile(open.FileName); private void pictureBox1_Click(object sender, EventArgs e) private void button1_Click(object

17、sender, EventArgs e) y = y - per; draw(); private void button2_Click(object sender, EventArgs e) y = y + per; draw(); private void button3_Click(object sender, EventArgs e) x = x - per; draw(); private void button4_Click(object sender, EventArgs e) x = x + per; draw(); private void button5_Click(obj

18、ect sender, EventArgs e) rit = (float)(rit + 0.1); draw(); private void button6_Click(object sender, EventArgs e) if (rit > 0) rit = (float)(rit - 0.1); draw(); 【程序截图】 实验四 数据操作【实验内容】制作一个程序,输入一个姓名,点击查询。【关键代码】using System;using System.Collections.Generic;using System.ComponentModel;using System.Dat

19、a;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Data.SqlClient;namespace DBOperate public partial class Form1 : Form SqlDataAdapter adapter; DataTable table; DataSet dataset1; public Form1() InitializeComponent(); privat

20、e void Form1_Load(object sender, EventArgs e) string connStr = Properties.Settings.Default.Database2ConnectionString;/连接字符串 SqlConnection conn = new SqlConnection(connStr);/建立到数据库的连接 adapter = new SqlDataAdapter("select * from Table", conn); SqlCommandBuilder builder = new SqlCommandBuilde

21、r(adapter); adapter.InsertCommand = builder.GetInsertCommand(); adapter.DeleteCommand = builder.GetDeleteCommand(); adapter.UpdateCommand = builder.GetUpdateCommand(); table = new DataTable(); adapter.Fill(table); dataGridView1.DataSource = table; private void button2_Click(object sender, EventArgs

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论