login.cs 2.96 KB
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 HcgClientExport
{
    public partial class login : Form
    {
        public login()
        {
            InitializeComponent();
            this.textBox1.GotFocus += new EventHandler(textBox1_GotFocus);
            this.textBox2.GotFocus += new EventHandler(textBox2_GotFocus);
            textBox1.MouseUp += new MouseEventHandler(textBox1_MouseUp);
            textBox2.MouseUp += new MouseEventHandler(textBox2_MouseUp);
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.Icon=((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
        }
        // private string titie = "xhcx";
        private void button1_Click(object sender, EventArgs e)
        {

            Form1 f = new Form1();
            string ss = new DataControl().GetLogin(this.textBox1.Text, En.GenerateMD5(this.textBox2.Text),f );
            if (ss.Equals("1"))
            {

                this.Hide();
             
                f.uid = this.textBox1.Text;
                f.ShowDialog();
                Application.Exit();
            }
            else if (ss.Equals("-1"))
            {
                MessageBox.Show("登陆失败");
            }
            else
            {
                MessageBox.Show(ss);
            }
        }

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

        private void textBox1_Click(object sender, EventArgs e)
        {
            //   this.textBox1.
        }
        void textBox1_MouseUp(object sender, MouseEventArgs e)
        {
            //如果鼠标左键操作并且标记存在,则执行全选             
            if (e.Button == MouseButtons.Left && (bool)textBox1.Tag == true)
            {
                textBox1.SelectAll();
            }

            //取消全选标记              
            textBox1.Tag = false;
        }
        void textBox2_MouseUp(object sender, MouseEventArgs e)
        {
            //如果鼠标左键操作并且标记存在,则执行全选             
            if (e.Button == MouseButtons.Left && (bool)textBox2.Tag == true)
            {
                textBox2.SelectAll();
            }

            //取消全选标记              
            textBox2.Tag = false;
        }
        void textBox2_GotFocus(object sender, EventArgs e)
        {
            textBox2.Tag = true;    //设置标记              
            textBox2.SelectAll();   //注意1         
        }
        void textBox1_GotFocus(object sender, EventArgs e)
        {
            textBox1.Tag = true;    //设置标记              
            textBox1.SelectAll();   //注意1         
        }

    }
}