终于来到了最后一次的进度报告,其实在我写这篇博客的时候,我的演示视频已经上传到了b站。
演示视频
虽然程序已经完成,但是我还是想把最后这段时间所做的工作写出来,方便以后的内容参考,也使得这次大作业有始有终。
具体的代码展示我会再单独做一篇博客出来,下面就开始这次的内容。
菜单栏
其中,修改信息功能本质上是把注册的信息读取后再重新写入账户表中,因此“修改信息”的代码中几乎包含了“个人信息”的全部代码,为了简洁,这里只放出“修改信息”的代码:
主窗体:
private void 修改信息ToolStripMenuItem_Click(object sender, EventArgs e)
{
Updateinformation Form = new Updateinformation();//新建一个主窗体
Form.Show();//显示主窗体
}
子窗体:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Updateinformation : Form
{
private string Scode;
private static char[] constant =
{
'0','1','2','3','4','5','6','7','8','9',
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
};
public Byte[] mybyte = new byte[0];
public Updateinformation()
{
InitializeComponent();
string str = "Data Source =.; Initial Catalog = test; Persist Security Info = True; User ID = sa; Password = ****************";
SqlConnection con = new SqlConnection(str);
con.Open();
string sql = "select * from usertable where userid='" + Program.user + "'";
SqlCommand com = new SqlCommand(sql, con);
SqlDataReader read = com.ExecuteReader(); //用com(变量名)点上ExecuteReader()方法,该方法的类型是SqlDataReader类型
read.Read();
textBox3.Text = read["userid"].ToString();//查询列名1的数据,方法为: read(变量名)["列名"]; 该方法返回的是object类型
textBox4.Text = read["number"].ToString(); //如上
textBox1.Text = read["phone"].ToString();
dateTimePicker1.Value = Convert.ToDateTime(read["birthday"])