学习记录

学习了用VS2012制作了程序的登陆界面

代码块

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 shaochao2017270402
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.comboBox1.SelectedIndex = 1;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (this.textBox2.Text == "" || this.textBox1.Text == "")
            {
                MessageBox.Show("用户名密码不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (this.comboBox1.SelectedItem.ToString() == "收银员")
                {
                    if (this.textBox1.Text == "111111" && this.textBox1.Text == "111111"
                        || this.textBox1.Text == "123456" && this.textBox2.Text == "123456")
                    {
                        //MessageBox.Show("收银员登录成功");
                        this.Hide();
                        Form2 fm2 = new Form2();
                        fm2.userName = this.textBox1.Text.ToString();
                        //fm2.MdiParent = this;
                        fm2.Show();
                    }
                    else
                    {
                        MessageBox.Show("用户名或者密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (this.comboBox1.SelectedItem.ToString() == "库管员")
                {
                    if (this.textBox1.Text == "1" && this.textBox2.Text == "1")
                    {
                        //MessageBox.Show("库管员登录成功");
                        this.Hide();
                        Form3 fm2 = new Form3();
                        fm2.userName = this.textBox1.Text.ToString();
                        //fm2.MdiParent = this;
                        fm2.Show();
                        
                    }
                    else
                    {
                        MessageBox.Show("用户名或者密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                
            }
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            MessageBox.Show("请联系管理员", "提示", MessageBoxButtons.OK);
        }

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

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                SendKeys.Send("{tab}");
            }
        }

        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                this.button1_Click(sender, e);
            }
        }

        private void textBox1_Enter(object sender, EventArgs e)
        {
            ((TextBox)sender).SelectAll();
        }

        private void textBox2_Enter(object sender, EventArgs e)
        {
            ((TextBox)sender).SelectAll();
        }
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,219评论 25 708
  • 用两张图告诉你,为什么你的 App 会卡顿? - Android - 掘金 Cover 有什么料? 从这篇文章中你...
    hw1212阅读 12,913评论 2 59
  • 夜色冰凉如水, 心似夜色清冷 越来越觉得, 可以倚靠的人, 仿佛只有自己, N, N, D。 都七老八十了 难不成...
    画堂韶光久阅读 259评论 33 27
  • 太太前段时间休息不规律,加上前天照顾孩子着凉了,结果昨天感冒发热去挂水了,晚上回家后就听到母子俩在厨房的一段对话。...
    乐爸分享阅读 858评论 0 0
  • 因为高中学校全部都是女生的原因,导致我现在还没谈过一场恋爱。 做为一名大学生,估计5个里面有3个谈过一次恋爱,而我...
    卓别林_ccc9阅读 144评论 0 0