private void UpdateRfidMhs(string NIM, string prodi, string lastHeksa) { Int32 sequence = Int32.Parse(lastHeksa, System.Globalization.NumberStyles.HexNumber);//dari heksa terakir convert ke int sequence++; string heksa = String.Format("{0:X4}", sequence); //heksa selanjutnya DataTable dt = null; cKoneksi koneksi = new cKoneksi(); SqlConnection conn = new SqlConnection(koneksi.konekMsSql('2')); conn.Open(); try { string RFID = "1" + prodi + "" + heksa + ""; SqlCommand cmd = null; cQuery qr = new cQuery(); cmd = new SqlCommand(qr.qSelectNimByRfid(RFID), conn); SqlDataAdapter da = new SqlDataAdapter(cmd); dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { MessageBox.Show("Proses Generate Gagal"); return; } cmd = new SqlCommand(qr.qUpdateRfidMhsByNim(), conn); cmd.Parameters.AddWithValue("@RFID", RFID); cmd.Parameters.AddWithValue("@STUDENTID", NIM); cmd.ExecuteNonQuery(); } finally { conn.Close(); conn.Dispose(); dt.Clear(); dt.Dispose(); } }