深入.NET平台和C#编程 第一章 概念+上机

本文介绍了一个基于.NET框架的登录系统实现案例,通过面向对象编程(OOP)的方式组织代码,包括登录信息类的设计与使用,以及登录界面和注册界面的具体实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

OOP:面向对象编程  S2
S1:语法基础++++++逻辑思维
S2:面向对象思维+创新思维++++项目驱动
Y2:框架++++源码++++++对整个真正的项目,全局的把控

1.封装:类(属性++方法)  私有字段封装成共有的属性
2.泛型集合++++++重点
3.xml解析技术
4.IO流  +++++++

--------------------------------------------------------------
预习检查:
1.   .NET 框架的两个主要组件是什么?
   解析:
   
2.任何人    在任何地方      使用任何终端设备     服务

3.前惠普ceo  卡莉·菲奥莉娜  艰难的抉择
hp   康柏合并


李纳斯  写的Linux  Unix   Minux


Ghost  安装版

FCL(Framework Class Library 框架类型)



4.CLR=========CLS(Common Language  Specfication  公共语言规范)+CTS(Common Type System 通用类型系统)
 基本框架类::线程类
 

5.WF:Work Flow :工作流

  WCF:底层通信   HTTp    Ftp  
  
  
  WPF:更酷炫
  
  Linq:是一种类似于数据的能获取数据的语言 from c in db.xxxx
  
6.类库
一堆类的集合  10个  dll

神器:Reflector


7.类图
作用:清晰的反馈出类结构  :字段      属性   方法

  





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 WindowsFormsApplication4
{
    public partial class denglu : Form
    {
        public denglu()
        {
            InitializeComponent();
        }
        public LoginInfo[] persons = new LoginInfo[10];
      
        public void LoadData()
        {
            persons[0] = new LoginInfo();
            persons[0].Name = "李小龙";
            persons[0].Password = "1";
            persons[0].Email = "lxl";
            persons[0].Id = "001";

            persons[1] = new LoginInfo();
            persons[1].Name = "李小龙2";
            persons[1].Password = "2";
            persons[1].Email = "lxl2";
            persons[1].Id = "002";


            persons[2] = new LoginInfo();
            persons[2].Name = "巩俐";
            persons[2].Password = "3";
            persons[2].Email = "gl";
            persons[2].Id = "003";

        }
        private void label3_Click(object sender, EventArgs e)
        { zhuce frm = new zhuce();
            frm.mylogin = this;
            frm.Show();
            this.Visible = false;
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //if(textBox1.Text.Trim().Equals(null)||textBox2.Text.Trim().Equals(null)){
            //    MessageBox.Show("用户名或密码不能为空", "提示");
            //}
            //LoadData();
            //01.用户会输入用户名和密码
            string email = textBox1.Text;
            string pwd = textBox2.Text;
            //02.将用户输入内容与数组中的每一项对比,如果有匹配项目,登陆成功
            bool flag = false;//登陆状态,默认为失败
            foreach (LoginInfo item in persons)
            {
                if (item != null)
                {
                    //参与比较
                    if (email.Equals(item.Email) && pwd.Equals(item.Password))
                    /// if (email == item.Email && pwd == item.Password)
                    {
                        //证明用户输入的信息均正确,登陆成功
                        flag = true;
                        zhujiemian frm = new zhujiemian();
                        frm.name = email;
                        frm.textBox1.Text = "欢迎," + item.Name;
                        frm.Show();
                        break;

                    }

      } else if(email.Equals("") && pwd.Equals("")){
                MessageBox.Show("用户名或密码不能为空","提示");
            }

     }
       
            if (!flag)
            {
                MessageBox.Show("用户名或者密码错误!");
            }
           


            //03.写一个方法来给数组中前三项赋值

            
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            LoadData();
        }
    }
}

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;
using System.Data.SqlClient;

namespace WindowsFormsApplication4
{
    public partial class zhuce : Form
    {
        public zhuce()
        {
            InitializeComponent();
        }
        public denglu mylogin;
        private void button1_Click(object sender, EventArgs e)
        {

            //01.非空验证自己判定下
            //02.先构造出一个LoginInfo对象  然后将LoginInfo对象添加到persons数组中
            LoginInfo info = new LoginInfo();
            info.Name = textBox1.Text;
            info.Email = textBox3.Text;
            info.Password = textBox4.Text;
            info.Id = textBox2.Text;

            //就是将info天际到数组中
            //数组有10个位置,要把info扔到什么位置
            for (int i = 0; i < mylogin.persons.Length; i++)
            {
                if (mylogin.persons[i] == null)
                {
                    mylogin.persons[i] = info;
                    MessageBox.Show("注册成功");
                    mylogin.Visible = true;
                    this.Close();
                    break;
                }
            }
        }

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

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 WindowsFormsApplication4
{
    public partial class zhujiemian : Form
    {
        public string name;
        public zhujiemian()
        {
            InitializeComponent();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            this.Text = name;
        }

        private void Form3_Load(object sender, EventArgs e)
        {

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApplication4
{
   public class LoginInfo
    {
        //private string _email;
        //private string _id;
        //private string _name;
        //private string _password;

        //public string Email
        //{
        //    get
        //    {
        //        throw new System.NotImplementedException();
        //    }
        //    set
        //    {
        //    }
        //}

        //public string Id
        //{
        //    get
        //    {
        //        throw new System.NotImplementedException();
        //    }
        //    set
        //    {
        //    }
        //}

        //public string Name
        //{
        //    get
        //    {
        //        throw new System.NotImplementedException();
        //    }
        //    set
        //    {
        //    }
        //}

        //public string Password
        //{
        //    get
        //    {
        //        throw new System.NotImplementedException();
        //    }
        //    set
        //    {
        //    }
        //}

        public string Name { get; set; }
        public string Id { get; set; }
        public string Email { get; set; }
        public string Password { get; set; }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值