Exemplo n.º 1
0
 public Login()
 {
     doInitilization();
     InitializeComponent();
     ents = UserLogin.FindAll();
     //doSecuritySetting(false);
 }
Exemplo n.º 2
0
 public LoginPopup(string title)
 {
     InitializeComponent();
     ents         = UserLogin.FindAll();
     DialogResult = DialogResult.None;
     Text         = title;
 }
Exemplo n.º 3
0
        /// <summary>
        /// 确定登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonOk_Click(object sender, EventArgs e)
        {
            bool status = false;

            string userName = this._cbxUserName.Text;
            string password = this._txtPassword.Text;

            UserLogin[] ents = UserLogin.FindAll();
            //数据库中无用户名及密码信息
            if (ents == null)
            {
                LibCommon.Const.FIRST_TIME_LOGIN = true;
                status = false;
                Alert.alert(Const.ADD_USER_INFO, Const.LOGIN_FAILED_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);

                UserLogin ent = new UserLogin();
                ent.LoginName = _cbxUserName.Text.ToString();
                ent.PassWord  = _txtPassword.Text;

                //显示添加用户信息界面,确定后将新创建的用户名及密码自动填写到相应控件上
                UserLoginInformationInput ulii = new UserLoginInformationInput(ent, true);
                ulii.ShowDialog();
                if (LibCommon.Const.FIRST_LOGIN_NAME != "")
                {
                    _cbxUserName.Text = LibCommon.Const.FIRST_LOGIN_NAME;
                    _txtPassword.Text = LibCommon.Const.FIRST_LOGIN_PASSWORD;
                    LibCommon.Const.FIRST_TIME_LOGIN = false;
                    //buttonOk_Click(sender, e);//添加成功用户后,自动登陆系统
                }
            }
            else
            {
                //验证帐号密码是否正确
                if (LoginSuccess(userName, password))
                {
                    status = true;
                }
                else
                {
                    Alert.alert(Const.USER_NAME_OR_PWD_ERROR_MSG, Const.LOGIN_FAILED_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (status)
            {
                this.Hide();
                _showForm.WindowState = FormWindowState.Maximized;
                _showForm.ShowDialog();
            }
        }
        /// <summary>
        /// 获取所有登录用户信息
        /// </summary>
        private void GetUserLoginInfo()
        {
            //sql语句,从数据库中获取数据
            UserLogin[] ents = UserLogin.FindAll();
            if (ents == null)
            {
                return;
            }
            //获取记录条数
            int rowsCount = ents.Length;

            fpUserLoginInformation.ActiveSheet.Rows.Count    = rowsCount + _fpTitleRowCount;
            fpUserLoginInformation.ActiveSheet.Columns.Count = _columnsCount;

            for (int i = 0; i < rowsCount; i++)
            {
                //选择
                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 0].CellType            = new FarPoint.Win.Spread.CellType.CheckBoxCellType();
                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 0].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 0].VerticalAlignment   = FarPoint.Win.Spread.CellVerticalAlignment.Center;
                //登录名
                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 1].Text = ents[i].LoginName;
                //密码,让密码显示为“******”
                //this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 2].Text = ents[i].PassWord;
                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 2].Text = new string(LibCommon.Const.PASSWORD_CHAR, 6);
                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 2].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 2].VerticalAlignment   = FarPoint.Win.Spread.CellVerticalAlignment.Center;
                //权限
                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 3].Text = ents[i].Permission;
                //所属用户组
                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 4].Text = ents[i].GroupName;
                //记住密码,“√”为True
                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 5].Text = ents[i].IsSavePassWord.ToString();
                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 5].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 5].VerticalAlignment   = FarPoint.Win.Spread.CellVerticalAlignment.Center;

                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 6].Text = ents[i].IsLogined.ToString();
                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 6].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 6].VerticalAlignment   = FarPoint.Win.Spread.CellVerticalAlignment.Center;
                //备注
                this.fpUserLoginInformation.ActiveSheet.Cells[i + 2, 7].Text = ents[i].Remarks;
            }
            //设置焦点
            this.fpUserLoginInformation.ActiveSheet.SetActiveCell(1, 0);
            //记录当前farpoint的记录条数
            _fpRowsCount = this.fpUserLoginInformation.ActiveSheet.Rows.Count;
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 确定登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonOk_Click(object sender, EventArgs e)
        {
            bool status = false;

            string userName = this._cbxUserName.Text;
            string password = this._txtPassword.Text;

            UserLogin[] ents = UserLogin.FindAll();
            //数据库中无用户名及密码信息
            if (ents == null)
            {
                LibCommon.Const.FIRST_TIME_LOGIN = true;
                status = false;
                Alert.alert(Const.ADD_USER_INFO, Const.LOGIN_FAILED_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);

                UserLogin ent = new UserLogin();
                ent.LoginName = _cbxUserName.Text.ToString();
                ent.PassWord  = _txtPassword.Text;
            }
            else
            {
                //验证帐号密码是否正确
                if (LoginSuccess(userName, password))
                {
                    status = true;
                }
                else
                {
                    Alert.alert(Const.USER_NAME_OR_PWD_ERROR_MSG, Const.LOGIN_FAILED_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            if (status)
            {
                this.Hide();
                _showForm.WindowState = FormWindowState.Maximized;
                _showForm.ShowDialog();
            }
        }