1、using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Text.RegularExpressions;namespace myString class myString public String str; public int length get return str.Length; public myString(String str) this.str = str; /判断是否为数字 public bool isNumber() try int.Par
2、se(str); catch(Exception) return false; return true; /判断是否含有字母、数字、下划线 public bool isContainIdentifier() bool character=false, number=false, underline=false; for (int i = 0; i = a & c AZ) character = true; else if (c 09 number = true; else if (c = _) underline = true; if (character | number | underli
3、ne) else /判断是否为有效的日期格式 public bool isValidDate() string pattern = d4-0-10-9-0-30-9; return Regex.IsMatch(this.str, pattern); /判断是否为有效的身份证号 public bool isValidID()d619d20,11-90-30-9d30-9,x /产生随机六位字符串(包含数字或大小写字母) public static String randomString() StringBuilder sb = new StringBuilder(); StringBuilder
4、 sb1 = new StringBuilder(); Random r = new Random(); 10; sb.Append(i); 26; sb.Append(char)(i + ); 6; sb1.Append(sb.ToString().ElementAt(int)(r.NextDouble() * (sb.Length + 1); return sb1.ToString();Program.cs class Program static void Main(string args) /*/Console.ForegroundColor = ConsoleColor.Green;
5、 Console.BackgroundColor = ConsoleColor.Red; myString m1 = new myString(13266a4); Console.WriteLine(m1.str+ 是纯数字?t+m1.isNumber(); m1 = new myString(1326614 Console.WriteLine(m1.str + + m1.isNumber(); myString m2 = new myString(我们_ Console.WriteLine(m2.str + 包含字母数字下划线? + m2.isContainIdentifier(); m2
6、= new myString(我们 Console.WriteLine(m2.str+m2.isContainIdentifier(); myString m3 = new myString(2008-12-15 Console.WriteLine(m3.str+ 是有效日期?+m3.isValidDate(); m3 = new myString(2008-12-45 Console.WriteLine(m3.str + + m3.isValidDate(); myString m4 = new myString(513030199409284315 Console.WriteLine(m4
7、.str+ 是有效身份证号?+m4.isValidID(); m4 = new myString(51303019940928431x Console.WriteLine(m4.str + + m4.isValidID();51303019940928431a Console.WriteLine(随机六位字符串:+myString.randomString();Result:设计一个简单的基于C/S结构的学生信息管理系统实验目的:2. 掌握设计对象类的数据成员及服务的方法。3. 学会运用面向对象程序设计的思想设计一个简单的信息系统。实验要求:设计一个简单的基于C/S结构的学生个人信息管理系统,
8、该系统具有录入,查询,修改三项基本功能。要求如下:1. 具有简单的录入,查询和修改的GUI2. 系统使用的GUI组件不得少于5种,越全面越好,但要合适(和谐界面) 3. 存储数据的媒介可选择text文档或者数据库,推荐第一种4. 学生个人信息必须包括:编号,姓名,性别,出生日期,是否已婚,身份证号,自我简介,其余可自行丰富。5. 具有对姓名,出生日期和身份证号进行简单效验的功能6. 学生编号随机产生数据的存储媒介必须选择其中一种,也可以结合使用。3实验报告40%;using System.Windows.Forms;namespace studentSystem static class Pr
9、ogram / / 应用程序的主入口点。/summary STAThread static void Main() Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); login f1 = new login(); DialogResult r = f1.ShowDialog(); if (r = DialogResult.OK) Application.Run(new welcome();Login.csusing System.ComponentModel;using
10、 System.Data;using System.Drawing; public partial class login : Form public login() InitializeComponent(); private void button2_Click(object sender, EventArgs e) if (textBox1.Text = admin textBox2.Text = this.DialogResult = DialogResult.OK; MessageBox.Show(用户名或密码不正确, 错误提示 private void pictureBox1_Cl
11、ick(object sender, EventArgs e) private void button3_Click(object sender, EventArgs e)此功能正在开发中.温馨提醒,MessageBoxButtons.OK,MessageBoxIcon.Warning);Welcome.cs public partial class welcome : public welcome() private void button3_click(object sender, EventArgs e) Form1 f1=new Form1(); f1.ShowDialog(); pr
12、ivate void button4_Click(object sender, EventArgs e) Form2 f2 = new Form2(); f2.ShowDialog(); private void button5_Click(object sender, EventArgs e) Form3 f3 = new Form3(); f3.ShowDialog(); private void button6_Click(object sender, EventArgs e) if (MessageBox.Show(你确定要退出吗?确认, MessageBoxButtons.YesNo
13、, MessageBoxIcon.Question) = DialogResult.Yes) Application.Exit(); private void welcome_Load(object sender, EventArgs e)Form1.csusing System.IO; public partial class Form1 : public Form1() private void label1_Click(object sender, EventArgs e) private void Form1_Load(object sender, EventArgs e) priva
14、te void pictureBox1_Click_1(object sender, EventArgs e) private void label7_Click(object sender, EventArgs e) private void textBox4_TextChanged(object sender, EventArgs e) private void textBox5_TextChanged(object sender, EventArgs e) if(!this.isValidID(textBox7.Text)请输入正确的身份证号提示, MessageBoxButtons.O
15、K, MessageBoxIcon.Error); else if (this.isNumber(textBox1.Text) & textBox2.Text != textBox3.Text ! textBox4.Text ! textBox5.Text ! textBox6.Text ! textBox8.Text ! textBox9.Text ! FileStream fs = File.Open(d:info.txt, FileMode.OpenOrCreate); sb.Append(textBox1.Text + + textBox2.Text + + textBox3.Text
16、 + + textBox4.Text + + textBox5.Text + + textBox6.Text + + textBox7.Text + + textBox8.Text + + textBox9.Text+dateTimePicker1.Text+richTextBox1.Text); sb.Length; fs.WriteByte(byte)(sb.ToString()i); fs.Close();保存成功,请查看文件D:/info.txt else 请输入完整信息,MessageBoxButtons.OK,MessageBoxIcon.Error); public bool i
17、sNumber(string str) try catch (Exception) public bool isValidID(string str) return Regex.IsMatch(str, pattern); private void textBox2_TextChanged(object sender, EventArgs e) private void label9_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e) textBox1.Text = t
18、extBox2.Text = textBox3.Text = textBox4.Text = textBox5.Text = textBox6.Text = textBox7.Text = textBox8.Text = textBox9.Text = richTextBox2.Text = private void textBox9_TextChanged(object sender, EventArgs e) private void label2_Click(object sender, EventArgs e) private void textBox8_TextChanged(obj
19、ect sender, EventArgs e) private void textBox3_TextChanged(object sender, EventArgs e) private void label4_Click(object sender, EventArgs e) private void label3_Click(object sender, EventArgs e) private void dateTimePicker1_ValueChanged(object sender, EventArgs e) private void label6_Click(object se
20、nder, EventArgs e) private void richTextBox1_TextChanged(object sender, EventArgs e) private void textBox1_TextChanged(object sender, EventArgs e) private void label5_Click(object sender, EventArgs e) private void label11_Click(object sender, EventArgs e) private void label8_Click(object sender, EventArgs e) private void label10_Click(object sender, EventArgs e) private void textBox7_TextChanged(object sender, EventArgs e) private void richTextBox2_TextChanged(object sender, EventArgs e)
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1