Exemple #1
0
        private void Dgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string colName = dgv.Columns[e.ColumnIndex].Name;

            if (colName == "Ubah")
            {
                tmbUsers frm = new tmbUsers(this);
                frm.lblJudul.Text     = "Ubah Data User";
                frm.btnSimpan.Visible = false;
                frm.lblId.Text        = dgv[0, e.RowIndex].Value.ToString();
                frm.txtNama.Text      = dgv[1, e.RowIndex].Value.ToString();
                frm.txtUsername.Text  = dgv[2, e.RowIndex].Value.ToString();
                frm.txtPassword.Text  = dgv[3, e.RowIndex].Value.ToString();
                frm.cmbRole.Text      = dgv[4, e.RowIndex].Value.ToString();
                frm.ShowDialog();
            }
            else if (colName == "Hapus")
            {
                if (MessageBox.Show("Apakah Anda yakin ingin menghapus data ini?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    cn.Open();
                    cm = new SqlCommand("delete from Users where id ='" + dgv[0, e.RowIndex].Value.ToString() + "'", cn);
                    cm.ExecuteNonQuery();
                    cn.Close();
                    load();
                    lblSukses.Visible = false;
                    lblUbah.Visible   = false;
                    lblHapus.Visible  = true;
                }
            }
        }
Exemple #2
0
        private void BtnTambah_Click(object sender, EventArgs e)
        {
            tmbUsers frm = new tmbUsers(this);

            frm.btnUbah.Visible = false;
            frm.ShowDialog();
        }