登陆页面代码如下。主页为Fmain。求解答。using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using pubclass;
using System.Data.Sql;
using System.Data.SqlClient;
using Infowindow;
using System.Drawing.Drawing2D;
namespace ypgspgl
{
    public partial class Login : Form
    {
        public string bh;        public Login()
        {
            InitializeComponent();
        }        
        private void Login_Load(object sender, EventArgs e)
        {
            ///?
            this.panel1.BackColor = Color.FromArgb(50,208,220,238);
            this.pictureBox1.BackColor = Color.FromArgb(100);
            this.pictureBox2.BackColor = Color.FromArgb(100);
            this.label7.BackColor = Color.FromArgb(100);
            ///?
            
            //GraphicsPath mypath = new GraphicsPath();
            //mypath.AddEllipse(0, 30, this.Width - 30, this.Height);
            //this.Region = new Region(mypath);
            this.ShowUnitCode();
        }        private void pictureBox2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }        private void pictureBox1_Click(object sender, EventArgs e)
        {
            int ret = CheckPassword();
            switch (ret)
            {
                case 1:
                    this.DialogResult = DialogResult.OK;
                    bh = this.textBox1.Text;
                    break;
                case -1:
                    MessageBox.Show("用户名不能为空!");                    
                    break;
                case -2:
                    MessageBox.Show("密码不能为空!");
                    break;
                case -3:
                    MessageBox.Show("查无此用户!请确认你的用户名是否正确!");
                    break;
                case -4:
                    MessageBox.Show("密码错误!请确认你的密码是否正确!");
                    this.textBox2.Text = "";
                    break;
            }
            this.Hide();
            //FrmInfowindows infowin = new FrmInfowindows();            //infowin.ShowDialog();
            //infowin.WindowState = FormWindowState.Normal;
            if (InfoComm.iLONG == 1)
            {
                pubclass.pubc.cstr = pubclass.pubc.getcstr();
                Login login = new Login();
                if (login.ShowDialog() == DialogResult.OK)
                {
                    string bh = login.bh;  //取工号
                    Fmain fmain = new Fmain(bh);
                    fmain.Show();
                }
            }            this.WindowState = FormWindowState.Minimized;            this.Show();
            
        }      
        
        private void ChangImage(PictureBox pictureBox,Size size, string ImagePath)
        {
            pictureBox.Size = size;
            pictureBox.BackgroundImageLayout = ImageLayout.Zoom;
            pictureBox.BackgroundImage = Image.FromFile(ImagePath);
        }        private int CheckPassword()
        {
            string sqlstr = "";
            if ("" == this.textBox1.Text) return -1;   //用户名为空
            string useid = this.textBox1.Text;  
            if ("" == this.textBox2.Text) return -2;   //密码为空
            string password = this.textBox2.Text;
            ////
            sqlstr = "select USEID,pwd from US_UseSz where USEID = '" + useid + "'";
            DataTable dt = pubc.GetDTable(sqlstr);
            if (dt.Rows.Count <= 0) return -3;          //用户名不存在
            if (password != dt.Rows[0][1].ToString()) return -4;//密码不比配
            return 1;
        }        private void ShowUnitCode()
        {
            string sqlstr = "select distinct cUnitName from us_unitinfo";
            DataTable dt = pubc.GetDTable(sqlstr);
            if (dt.Rows.Count <= 0) return;
            this.label7.Text = dt.Rows[0][0].ToString();
        }        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                textBox2.Focus();
            }
        }        private void textBox1_Leave(object sender, EventArgs e)
        {
            string sqlstr = "";
            if ("" == this.textBox1.Text)
            {
                this.errorProvider1.SetError((Control)textBox1, "用户名为空");
                return;
            }
            string useid = this.textBox1.Text;
            sqlstr = "select USEID,pwd from US_UseSz where USEID = '" + useid + "'";
            DataTable dt = pubc.GetDTable(sqlstr);
            if (dt.Rows.Count <= 0) this.errorProvider1.SetError((Control)textBox1, "用户名不存在");
            else this.errorProvider1.Clear();
            return;
        }        private void textBox2_Leave(object sender, EventArgs e)
        {
            string sqlstr = "";
            if ("" == this.textBox2.Text)
            {
                this.errorProvider1.SetError((Control)textBox2, "密码为空");
                return;
            }
            string useid = this.textBox1.Text;
            string password = this.textBox2.Text;
            sqlstr = "select USEID,pwd from US_UseSz where USEID = '" + useid + "'";
            DataTable dt = pubc.GetDTable(sqlstr);
            if (dt.Rows.Count > 0)
            {
                if (password != dt.Rows[0][1].ToString()) this.errorProvider1.SetError((Control)textBox2, "密码不比配");
                else this.errorProvider1.Clear();
                return;
            }
           
        }        
        private void textBox2_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                this.pictureBox1_Click((object)pictureBox1, e);
            }
        }
        private void pictureBox2_MouseDown(object sender, MouseEventArgs e)
        {
            //Size imagesize = new Size(64, 64);
            //ChangImage(this.pictureBox2, imagesize, "Resources\\aqua_3_button_power1.png");
        }        private void pictureBox2_MouseUp(object sender, MouseEventArgs e)
        {
            //Size imagesize = new Size(64, 64);
            //ChangImage(this.pictureBox2, imagesize, "Resources\\00.png");
        }        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            //ChangImage(pictureBox1, new Size(64, 64), "Resources\\11.png");
        }        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            //ChangImage(pictureBox1, new Size(64, 64), "Resources\\aqua_1_button_login.png");
        }
    }
}