Exemplo n.º 1
0
        private void Setup_grd_usergroup(string select_usergroup = "")
        {
            grd_usergroup.DataSource = Permission_ds.Select_usergroup();

            if (grd_usergroup.Rows.Count == 0)
            {
                return;
            }

            grd_usergroup.ClearSelection();

            if (select_usergroup == "")
            {
                grd_usergroup.Rows[0].Selected = true;
                grd_usergroup.CurrentCell      = grd_usergroup[0, 0];
            }
            else
            {
                select_usergroup = select_usergroup.ToUpper();
                foreach (DataGridViewRow grd_row in grd_usergroup.Rows)
                {
                    if (grd_row.Cells["usergroup"].Value.ToString().ToUpper() == select_usergroup)
                    {
                        grd_row.Selected          = true;
                        grd_usergroup.CurrentCell = grd_row.Cells["usergroup"];
                        break;
                    }
                }
            }

            grd_usergroup.AutoResizeColumns();
            Setup_grd_permission();
        }
Exemplo n.º 2
0
        private void Form_edit_users_Shown(object sender, EventArgs e)
        {
            if (!Program.System_user.Has_permission(Class_enum.User_permission.EDIT_USER))
            {
                MessageBox.Show("You do not have permission to edit users!", "ACCESS DENIED",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }

            Class_style.Grd_style.Common_style(grd_permission);
            Class_style.Grd_style.Common_style(grd_usergroup);

            grd_usergroup.DataSource = Permission_ds.Select_usergroup();
            grd_usergroup.ClearSelection();
            grd_usergroup.CurrentCell = null;

            txt_username.Text = Obj_user.Username;
            txt_name.Text     = Obj_user.Name;
            txt_ic_no.Text    = Obj_user.IcNo;
            dtp_join.Value    = Obj_user.JoinDate;

            if (Obj_user.LeaveDate != null)
            {
                dtp_leave.Value             = (DateTime)Obj_user.LeaveDate;
                dtp_leave.Enabled           = true;
                ch_empty_leave_date.Checked = false;
            }
            else
            {
                dtp_leave.Enabled           = false;
                ch_empty_leave_date.Checked = true;
            }
            if (Obj_user.UserImage != null)
            {
                picbox_image.Image = Image.FromStream(new MemoryStream(Obj_user.UserImage));
            }
            if (Obj_user.UserGroup != null)
            {
                foreach (DataGridViewRow grd_row in grd_usergroup.Rows)
                {
                    if (grd_row.Cells["usergroup"].Value.ToString() == Obj_user.UserGroup)
                    {
                        grd_usergroup.ClearSelection();
                        grd_row.Cells["usergroup"].Selected = true;
                        grd_usergroup.CurrentCell           = grd_row.Cells["usergroup"];
                        break;
                    }
                }
            }
            grd_usergroup.RowEnter += Grd_usergroup_RowEnter;
        }