Exemplo n.º 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            //【1】Determine if there is data
            if (dgvSysAdmins.Rows.Count < 0)
            {
                MessageBox.Show("There is no data in the table!", "System Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (dgvSysAdmins.CurrentRow.Cells[0].Value == null)
            {
                return;
            }

            //【2】encapsulation
            SysAdmins objSysAdmin = new SysAdmins()
            {
                LoginId  = Convert.ToInt32(dgvSysAdmins.CurrentRow.Cells[0].Value),
                UserName = dgvSysAdmins.CurrentRow.Cells[1].Value.ToString(),
            };

            if (dgvSysAdmins.CurrentRow.Cells[2].Value.ToString().Contains("Enable"))
            {
                objSysAdmin.IsDisable = false;
            }
            else
            {
                objSysAdmin.IsDisable = true;
            }
            if (dgvSysAdmins.CurrentRow.Cells[3].Value.ToString().Contains("Super"))
            {
                objSysAdmin.IsSuperUser = true;
            }
            else
            {
                objSysAdmin.IsSuperUser = false;
            }

            //【3】Initialization of Actionflag
            actionFlag = 3;

            //【4】Loading a form
            if (objFrmAdminDetail == null)
            {
                objFrmAdminDetail = new frmAdminDetail(actionFlag, objSysAdmin);
                DialogResult result = objFrmAdminDetail.ShowDialog();
                if (result == DialogResult.OK)
                {
                    LoadSysAdmins();
                }
            }
            else
            {
                objFrmAdminDetail.Activate();
                objFrmAdminDetail.WindowState = FormWindowState.Normal;
            }
        }
Exemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //Assign Value actionFlag
            actionFlag = 2;

            //Loading a form
            if (objFrmAdminDetail == null)
            {
                objFrmAdminDetail = new frmAdminDetail(actionFlag, null);
                DialogResult result = objFrmAdminDetail.ShowDialog();
                if (result == DialogResult.OK)
                {
                    LoadSysAdmins();
                }
            }
            else
            {
                objFrmAdminDetail.Activate();
                objFrmAdminDetail.WindowState = FormWindowState.Normal;
            }
        }