コード例 #1
0
        private void InsertIP()
        {
            bool err = false;

            string query = "INSERT INTO IpHistory (IpAddress, LastModified, port) values (@IpAddress, @LastModified, @port)";

            cKoneksi koneksi = new cKoneksi();

            cControl cnt = new cControl();

            using (SQLiteConnection sqlCon = new SQLiteConnection(koneksi.LokasiSqlite()))//insert ke local Sqlite
            {
                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);
                    DataTable         dt = new DataTable();

                    try
                    {
                        //---------------------------------
                        cmd.CommandText = query;
                        cmd.Parameters.AddWithValue("@IpAddress", getIpAdr);
                        cmd.Parameters.AddWithValue("@LastModified", cnt.getDateTimeNow());
                        cmd.Parameters.AddWithValue("@port", txtNewPort.Text.ToString().Trim());
                        //---------------------------------
                        cmd.Connection = sqlCon;
                        sqlCon.Open();

                        da.Fill(dt);
                        //---------------------
                    }
                    catch (Exception ex)
                    {
                        err = true;
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        sqlCon.Close();
                        sqlCon.Dispose();

                        dt.Clear();
                        dt.Dispose();
                    }
                }
            }

            if (err == false)
            {
                refresh(); //jika tidak ada error refresh
            }
        }
コード例 #2
0
        private void refresh()
        {
            clearIP();
            txtNewPort.Text = string.Empty;

            cControl cnt = new cControl();

            txtLastIp.Text     = cnt.getLastIp();
            txtLastIp.ReadOnly = true;

            txtLastPort.Text     = cnt.getLastPort();
            txtLastPort.ReadOnly = true;
        }
コード例 #3
0
        private void SearchAmbilKtm()
        {
            cQuery    qr = new cQuery();
            cDatabase db = new cDatabase();

            DataTable dtSearch = null;

            if (rbMahasiswa.Checked == true)
            {
                dtSearch = db.selectData(qr.qSearchMhsByNImNama(txt_cari_nik.Text, txt_cari_nama.Text), '2');
            }
            else
            {
                dtSearch = db.selectData(qr.qSearchPegByNikNama(txt_cari_nik.Text, txt_cari_nama.Text), '4');
            }

            cControl cnt = new cControl();

            foreach (DataRow rowSearch in dtSearch.Rows)
            {
                string[] row = null;

                if (rbMahasiswa.Checked == true)
                {
                    row = new string[] { rowSearch["STUDENTID"].ToString(), rowSearch["STUDENTID"].ToString(), rowSearch["FULLNAME"].ToString(), rowSearch["RFID"].ToString() };
                }
                else
                {
                    row = new string[] { rowSearch["id_pegawai"].ToString(), rowSearch["nik"].ToString(), rowSearch["nama"].ToString(), rowSearch["rfid"].ToString() };
                }

                DGList.Rows.Add(row);
            }

            dtSearch.Clear();
            dtSearch.Dispose();
        }
コード例 #4
0
        private void cariMhs()
        {
            cQuery    qr       = new cQuery();
            cDatabase db       = new cDatabase();
            DataTable dtSearch = db.selectData(qr.qSearchMhsByNImNama(txt_cari_nim.Text, txt_cari_nama.Text), '2');
            cControl  cnt      = new cControl();

            foreach (DataRow rowSearch in dtSearch.Rows)
            {
                string status    = string.Empty;
                String TglBlokir = string.Empty;
                //jika kode rfid kososng, cek dari table history blokir
                if (rowSearch["RFID"].ToString().Trim() == string.Empty)
                {
                    DataTable dtHistory = db.selectData(qr.qSearchHistoryByIdPenggunaTop1(rowSearch["STUDENTID"].ToString()), '3');
                    if (dtHistory.Rows.Count != 0)//jika ada data di dlm history blokir = terblokir
                    {
                        status = "Terblokir";
                    }
                    else
                    {//jika tidak ada data di dlm history blokir = Tidak Aktif
                        status = "Tidak Aktif";
                    }
                }
                else
                {//jika ada data rfidnya = akif
                    status = "Aktif";
                }

                string[] row = new string[] { rowSearch["STUDENTID"].ToString(), rowSearch["STUDENTID"].ToString(), rowSearch["FULLNAME"].ToString(), rowSearch["RFID"].ToString(), status };
                DGList.Rows.Add(row);
            }

            dtSearch.Clear();
            dtSearch.Dispose();
        }