Example #1
0
        /// <summary>
        /// 窗体登录事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e)
        {
            //初始化调用不规则窗体生成代码
            //此为生成不规则窗体和控件的类
            BitmapRegion BitmapRegion = new BitmapRegion();
            string       path         = Application.StartupPath + LibCommon.Const.LOGIN_BACKGROUND_BMP_PATH;

            BitmapRegion.CreateControlRegion(this, new Bitmap(path));

            try
            {
                ents = UserLogin.FindAll();
            }
            catch (Exception ex)
            {
                throw;
            }
            //获取所有用户信息


            //添加已记录的登录用户
            entsLogined = UserLogin.FindAllByIsLogined(0);
            foreach (UserLogin ent in entsLogined)
            {
                _cbxUserName.Items.Add(ent.LoginName);
            }

            //默认显示第一个用户,应改成默认选择最后一个登录用户。
            //可采用表中记录登录时间来实现。为减少修改量,未采用修改数据表结构。
            //采用读取配置文件的方法。记录信息在DefaultUser
            try
            {
                StreamReader sr  = new StreamReader(Application.StartupPath + "\\DefaultUser");
                string       str = sr.ReadLine();
                sr.Close();

                //赋值同时,触发_cbxUserName_SelectedIndexChanged事件,符合记住密码的用户名,自动赋值
                _cbxUserName.SelectedItem = (object)str;
            }
            catch (System.Exception ex)
            {
                Alert.alert(ex.Message);
            }
        }
Example #2
0
        /// <summary>
        /// 窗体登录事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e)
        {
            //初始化调用不规则窗体生成代码
            //此为生成不规则窗体和控件的类
            BitmapRegion BitmapRegion = new BitmapRegion();
            string path = Application.StartupPath + LibCommon.Const.LOGIN_BACKGROUND_BMP_PATH;
            BitmapRegion.CreateControlRegion(this, new Bitmap(path));

            try
            {
                ents = UserLogin.FindAll();
            }
            catch (Exception ex)
            {
                throw;
            }
            //获取所有用户信息

            //添加已记录的登录用户
            entsLogined = UserLogin.FindAllByIsLogined(0);
            foreach (UserLogin ent in entsLogined)
            {
                _cbxUserName.Items.Add(ent.LoginName);
            }

            //默认显示第一个用户,应改成默认选择最后一个登录用户。
            //可采用表中记录登录时间来实现。为减少修改量,未采用修改数据表结构。
            //采用读取配置文件的方法。记录信息在DefaultUser
            try
            {
                StreamReader sr = new StreamReader(Application.StartupPath + "\\DefaultUser");
                string str = sr.ReadLine();
                sr.Close();

                //赋值同时,触发_cbxUserName_SelectedIndexChanged事件,符合记住密码的用户名,自动赋值
                _cbxUserName.SelectedItem = (object)str;
            }
            catch (System.Exception ex)
            {
                Alert.alert(ex.Message);
            }
        }