⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logon.cs

📁 微软的行业应用解决方案实例!非常优秀的Windows Mobile开发案例
💻 CS
字号:
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace HardwareDistributor.UI
{
    /// <summary>
    /// UI Layer form that allows user to login and choose a role
    /// </summary>
    public partial class Logon : Form
    {

        public Logon()
        {
            InitializeComponent();
        }


        /// <summary>
        /// Shutdown application
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemExit_Click(object sender, EventArgs e)
        {
            //Exit app
            Application.Exit();
        }

       
        /// <summary>
        /// This menu logs you on to the system
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemLogon_Click(object sender, EventArgs e)
        {
            try
            {
                Application.DoEvents();
                Cursor.Current = Cursors.WaitCursor;
                Application.DoEvents();

                //Ensure that a User name has been entered
                if (txtUserName.Text != "")
                {
                    //Ensure that a Password has been entered
                    if (txtPassword.Text != "")
                    {
                        //Verify correct credentials
                        bool authorized = Business.Services.VerifyCredentials(txtUserName.Text.Trim(), txtPassword.Text.Trim());

                        if (authorized)
                        {
                            Application.DoEvents();
                            Cursor.Current = Cursors.Default;
                            Application.DoEvents();

                            //Take user to appropriate screen based on Role
                            switch ((int)cboRole.SelectedValue)
                            {
                                //Launch Customer Service screen
                                case 2:
                                    CustomerService customerService = new CustomerService();
                                    customerService.ShowDialog();
                                    customerService.Dispose();
                                    break;
                                //Launch Warehouse screen
                                case 3:
                                    Warehouse warehouse = new Warehouse();
                                    warehouse.ShowDialog();
                                    warehouse.Dispose();
                                    break;
                                //Launch Deliveries screen
                                case 4:
                                    Deliveries deliveries = new Deliveries();
                                    deliveries.ShowDialog();
                                    deliveries.Dispose();
                                    break;
                            }
                        }
                        else
                        {
                            MessageBox.Show("Your logon credentials are invalid", "Logon Error");
                            txtUserName.Text = "";
                            txtPassword.Text = "";
                            txtUserName.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("You must enter a valid password", "Input Error");
                        txtPassword.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("You must enter a valid user name", "Input Error");
                    txtUserName.Focus();
                }
            }
            catch (Exception ex)
            {
                Business.Services.LogErrors(ex);
                MessageBox.Show("Error verifying logon credentials", "System Error");
            }
        }


        /// <summary>
        /// Load the Logon form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Logon_Load(object sender, EventArgs e)
        {
            try
            {
                //Set combo box display and value 
                //menbers to Role properties
                cboRole.DisplayMember = "RoleName";
                cboRole.ValueMember = "RoleId";
                //Retrieve and data bind the RoleCollection
                cboRole.DataSource = Business.Services.GetRoles();
            }
            catch (Exception ex)
            {
                Business.Services.LogErrors(ex);
                MessageBox.Show("Error displaying Roles", "System Error");
            }
        }


        /// <summary>
        /// Launch Help
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void linkLabelHelp_Click(object sender, EventArgs e)
        {
            try
            {
                //Show Logon Help
                Help.ShowHelp(this, @Business.GlobalCache.Instance.AppPath + "HardwareHelp.htm#overview");
            }
            catch (Exception ex)
            {
                Business.Services.LogErrors(ex);
                MessageBox.Show("Error displaying Help", "System Error");
            }
        }

        


    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -