private void button2_Click(object sender, EventArgs e) { if (dtOperator.CurrentCell.RowIndex > -1) { try { string[] baru = new string[3]; using (SqlConnection myConnection = new SqlConnection()) { string oString = "SELECT * FROM operator WHERE NIK = @NIK"; SqlCommand oCmd = new SqlCommand(oString, myConnection); oCmd.Parameters.Add("@NIK", SqlDbType.VarChar).Value = dtOperator.Rows[dtOperator.CurrentCell.RowIndex].Cells[0].Value; myConnection.ConnectionString = @"Data Source=" + Properties.Settings.Default.Server + "; Initial Catalog=" + Properties.Settings.Default.DBName + "; Integrated Security=True"; myConnection.Open(); using (SqlDataReader oReader = oCmd.ExecuteReader()) { while (oReader.Read()) { baru[0] = oReader["NIK"].ToString(); baru[1] = oReader["nama"].ToString(); baru[2] = oReader["level"].ToString(); } myConnection.Close(); } } frm = new frmFormulirOperator(this, baru[0], baru[1], baru[2]); frm.username = this.username; frm.ShowDialog(this); } catch (Exception ex) { MessageBox.Show(this, "ERR: " + ex.ToString()); } } else { MessageBox.Show(this, "Pilih operator yang akan Anda ubah!", "Exist", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void button3_Click(object sender, EventArgs e) { frm = new frmFormulirOperator(this); frm.username = this.username; frm.ShowDialog(this); }