Пример #1
0
        private void ucUser_Load(object sender, EventArgs e)
        {
            initable();
            //用户不能编辑单元格
            CheckDatas.EditMode = DataGridViewEditMode.EditProgrammatically;
            try
            {
                string        err = string.Empty;
                StringBuilder sb  = new StringBuilder();
                displaytable.Clear();
                sb.Append("order by ID");

                DataTable dt = sql.GetUser(sb.ToString(), out err);
                if (dt != null)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        AddItemToTable(dt.Rows[i][0].ToString(), dt.Rows[i][1].ToString(), dt.Rows[i][2].ToString());
                    }
                }
                CheckDatas.DataSource       = displaytable;
                CheckDatas.Columns[0].Width = 180;
                CheckDatas.Columns[1].Width = 180;
                CheckDatas.Columns[2].Width = 180;
            }
            catch (Exception ex)
            {
                dy.savediary(DateTime.Now.ToString(), "用户管理错误:" + ex.Message, "错误");
                MessageBox.Show(ex.Message, "用户管理");
            }
            dy.savediary(DateTime.Now.ToString(), "用户管理", "成功");
        }
Пример #2
0
        private void panel1_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                if (tbx_user.Text == string.Empty)
                {
                    MessageBox.Show("用户名不能为空", "提示");
                    return;
                }
                if (Txt_Password.Text == string.Empty)
                {
                    MessageBox.Show("密码不能为空", "提示");
                    return;
                }

                //超级用户
                if (tbx_user.Text.Trim() != "sakj")
                {
                    //根据输入的用户名查询
                    //string err = string.Empty;
                    //StringBuilder sb = new StringBuilder();
                    //displaytable.Clear();
                    sb.Clear();
                    sb.Append("where userlog=");
                    sb.Append("'");
                    sb.Append(tbx_user.Text.Trim());
                    sb.Append("'");
                    sb.Append(" order by ID");

                    DataTable dt = sql.GetUser(sb.ToString(), out err);
                    if (dt != null && dt.Rows.Count < 1)
                    {
                        MessageBox.Show("此用户不存在,请输入正确用户!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.tbx_user.Select(0, this.tbx_user.Text.Length);
                        this.tbx_user.Focus();
                        return;
                    }
                    else if (dt != null && dt.Rows.Count > 0)
                    {
                        if (!dt.Rows[0][1].ToString().Equals(Txt_Password.Text.Trim()))
                        {
                            MessageBox.Show("密码错误,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Txt_Password.Text = "";
                            this.Txt_Password.Focus();
                            return;
                        }
                    }

                    Global.userlog = tbx_user.Text.Trim();
                    this.Hide();
                    this.ShowIcon = false;
                    MainForm window = new MainForm();
                    //dy.savediary(DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss"), "系统登录", "成功");
                    window.Show();
                }
                else if (tbx_user.Text.Trim() == "sakj")
                {
                    if (Txt_Password.Text != "sakj8888")
                    {
                        MessageBox.Show("密码错误");
                        return;
                    }
                    Global.userlog = tbx_user.Text.Trim();
                    this.Hide();
                    this.ShowIcon = false;
                    MainForm window = new MainForm();
                    window.Show();
                }
            }
            catch (Exception ex)
            {
                dy.savediary(DateTime.Now.ToString(), "登录窗口登录错误:" + ex.Message, "错误");
                MessageBox.Show(ex.Message);
            }
        }