Esempio n. 1
0
        private void userUpdateButton_Click(object sender, EventArgs e)
        {
            if (userGridView.FocusedRowHandle < 0)
            {
                return;
            }

            UserDataSet  set  = Resource.Db.UserSet;
            FormUserEdit form = new FormUserEdit();

            form.Text      = "Modify";
            form.UserName  = set.Name;
            form.Authority = set.Authority;
            form.Password  = Encoding.ASCII.GetString(Convert.FromBase64String(set.Passwd));
            form.Memo      = set.Memo;

lbUserModifyRetry:
            form.ShowDialog();

            if (form.DialogResult == DialogResult.Cancel)
            {
                return;
            }

            if (form.UserName.Trim() == "")
            {
                MessageBox.Show("You must keyin User ID!",
                                Resource.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                goto lbUserModifyRetry;
            }

            if (form.Password.Length < 4)
            {
                MessageBox.Show("Password's length must be larger than 3bytes!",
                                Resource.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                goto lbUserModifyRetry;
            }

            set.Name      = form.UserName;
            set.Authority = form.Authority;
            set.Passwd    = Convert.ToBase64String(Encoding.ASCII.GetBytes(form.Password));
            set.Memo      = form.Memo;

            try
            {
                set.Update();
            }
            catch (Exception ex)
            {
                Resource.TLog.Log((int)ELogItem.Exception, ex.ToString());
            }
            finally
            {
                Resource.Db.UserSet.Select();
                userGrid.Refresh();
            }
        }
Esempio n. 2
0
        private void userAddButton_Click(object sender, EventArgs e)
        {
            FormUserEdit form = new FormUserEdit();

            form.Text      = "New";
            form.Authority = 3;

lbUserAddRetry:
            form.ShowDialog();

            if (form.DialogResult == DialogResult.Cancel)
            {
                return;
            }

            if (form.UserName.Trim() == "")
            {
                MessageBox.Show("You must keyin User ID!",
                                Resource.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                goto lbUserAddRetry;
            }

            if (form.Password.Length < 4)
            {
                MessageBox.Show("Password's length must be larger than 3bytes!",
                                Resource.Caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                goto lbUserAddRetry;
            }

            UserDataSet set = Resource.Db.UserSet;

            set.RecNo     = (int)Resource.Db.GetGenNo("GN_USER");
            set.Name      = form.UserName;
            set.Authority = form.Authority;
            set.Passwd    = Convert.ToBase64String(Encoding.ASCII.GetBytes(form.Password));
            set.Memo      = form.Memo;

            try
            {
                set.Insert();
            }
            catch (Exception ex)
            {
                Resource.TLog.Log((int)ELogItem.Exception, ex.ToString());
            }
            finally
            {
                Resource.Db.UserSet.Select();
                userGrid.Refresh();
            }
        }