예제 #1
0
        private void LbxUsername_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (LbxUsername.SelectedItem.ToString() != null)
            {
                string username = LbxUsername.SelectedItem.ToString();

                cDatabase db = new cDatabase();
                cQuery    qr = new cQuery();

                DataTable dtUser = db.selectData(qr.qSelectUserWhereUsername(username), '1');

                if (dtUser.Rows.Count != 0)
                {
                    foreach (DataRow row in dtUser.Rows)
                    {
                        txt_username.Text       = row["username"].ToString();
                        txt_fullname.Text       = row["fullname"].ToString();
                        txt_password.Text       = row["password"].ToString();
                        combo_role.SelectedItem = row["role"].ToString();

                        if (row["aplication"].ToString() == "Biro Umum")
                        {
                            rbKantor.Checked = true;
                        }
                        else if (row["aplication"].ToString() == "Gate")
                        {
                            rbGate.Checked = true;
                        }
                    }
                }
            }
        }
예제 #2
0
        private void deleteOperator()
        {
            cQuery    qr = new cQuery();
            cDatabase db = new cDatabase();

            db.insertDataSqlite(qr.qDeleteOperator());
        }
예제 #3
0
        private void isiListBox()
        {
            LbxUsername.Items.Clear();

            cDatabase db = new cDatabase();
            cQuery    qr = new cQuery();

            string queryUse = string.Empty;

            if (rbBiroUmum.Checked == true)
            {
                queryUse = qr.qSelectUserOpBu();
            }
            else if (rbAkademik.Checked == true)
            {
                queryUse = qr.qSelectUserOpAkademik();
            }

            DataTable dtUser = db.selectData(queryUse, '1');


            if (dtUser.Rows.Count != 0)
            {
                foreach (DataRow row in dtUser.Rows)
                {
                    LbxUsername.Items.Add(row["username"]);
                }
            }
            dtUser.Clear();
            dtUser.Dispose();
        }
예제 #4
0
        private void deleteKendaraan()
        {
            cQuery    qr = new cQuery();
            cDatabase db = new cDatabase();

            db.insertDataSqlite(qr.qDeleteKendaraan());
        }
예제 #5
0
        private void deleteMahasiswaTmp()
        {
            cQuery    qr = new cQuery();
            cDatabase db = new cDatabase();

            //string query = "delete from penggunaTmp where kategori = 1"; //kategori 1=mahasiwa
            db.insertDataSqlite(qr.qDeleteMhsTmp());
        }
예제 #6
0
        private DataTable selectFrHistoryRfidMhsTerakirbyProdi(string prodi)
        {
            DataTable dt = null;
            cDatabase db = new cDatabase();
            cQuery    qr = new cQuery();

            dt = db.selectData(qr.qSelectLastHistoryRfidByProdi(prodi), '3');//konek ke tabel history_rfid
            return(dt);
        }
예제 #7
0
        private DataTable selectRfidPegTerakir()
        {
            DataTable dt = null;
            cDatabase db = new cDatabase();
            cQuery    qr = new cQuery();

            dt = db.selectData(qr.qSelectLastRfidPegawai(), '4'); //4 = konek ke payroll_web
            return(dt);
        }
예제 #8
0
        private DataTable selectHistoryRfidTerakirPegawai()
        {
            DataTable dt = null;
            cDatabase db = new cDatabase();
            cQuery    qr = new cQuery();

            dt = db.selectData(qr.qSelectLastHistoryRfidPegawai(), '3');//konek ke tabel history_rfid
            return(dt);
        }
예제 #9
0
        private DataTable selectRfidMhsTerakirByProdi(string prodi)
        {
            DataTable dt = null;
            cDatabase db = new cDatabase();
            cQuery    qr = new cQuery();

            dt = db.selectData(qr.qSelectLastRfidMhsByProdi(prodi), '2');
            return(dt);
        }
예제 #10
0
        private DataTable cekTransaksiMhs(string nim)
        {
            cDatabase db = new cDatabase();
            cQuery    qr = new cQuery();

            DataTable dtStatusMhs = null;

            //Cek dulu data yang mau diUpload apakah sudah ada atau belum
            dtStatusMhs = db.selectData(qr.qSelectTop1StatusMhsWhereStudId(nim), '2'); //2 = user ktm

            return(dtStatusMhs);
        }
예제 #11
0
        //true = ada data
        //false = tidak ada data
        private bool cekTransaksiUploadMhs()
        {
            DataTable dt = null;
            cQuery    qr = new cQuery();
            cDatabase db = new cDatabase();

            dt = db.selectDataSqlite(qr.qSelectTransaksiMhsStatus0Limit1()); // ambil data dari sqlite
            if (dt.Rows.Count != 0)                                          //jika ada data
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #12
0
        private void tampilMhs(string NIM)
        {
            cDatabase db = new cDatabase();
            cQuery    qr = new cQuery();

            DataTable dt = db.selectData(qr.qSelectNamaRfidMhsByNim(NIM), '2');

            if (dt.Rows.Count != 0)
            {
                foreach (DataRow rowMhs in dt.Rows)
                {
                    txt_nik.Text  = rowMhs["STUDENTID"].ToString();
                    txt_nama.Text = rowMhs["FULLNAME"].ToString();
                    txtRfid.Text  = rowMhs["RFID"].ToString();
                }
            }
            dt.Clear();
            dt.Dispose();
        }
예제 #13
0
        private void tampilPeg(string ID_PEG)
        {
            cDatabase db = new cDatabase();
            cQuery    qr = new cQuery();

            DataTable dt = db.selectData(qr.qSelectNamaRfidPegByIdPeg(ID_PEG), '4');//4 = konek ke 10.0.1.64 db payroll_web

            if (dt.Rows.Count != 0)
            {
                foreach (DataRow rowMhs in dt.Rows)
                {
                    txt_nik.Text     = rowMhs["nik"].ToString();
                    txt_nama.Text    = rowMhs["nama"].ToString();
                    txtRfid.Text     = rowMhs["rfid"].ToString();
                    lbIdPegawai.Text = rowMhs["id_pegawai"].ToString();
                }
            }
            dt.Clear();
            dt.Dispose();
        }
예제 #14
0
        public string getLastIp()
        {
            string IpAddress = string.Empty;
            string qr        = "SELECT IpAddress FROM IpHistory order by LastModified desc limit 1";

            cDatabase db = new cDatabase();
            DataTable dt = db.selectDataSqlite(qr);

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    IpAddress = row["IpAddress"].ToString();
                }
            }

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

            return(IpAddress);
        }
예제 #15
0
        public string getLastPort()
        {
            string port = string.Empty;
            string qr   = "SELECT port FROM IpHistory order by LastModified desc limit 1";

            cDatabase db = new cDatabase();
            DataTable dt = db.selectDataSqlite(qr);

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    port = row["port"].ToString();
                }
            }

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

            return(port);
        }
예제 #16
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();
        }
예제 #17
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();
        }
예제 #18
0
        private string uploadTransaksiKartuMhs()
        {
            cSyncRun.isSync = true;    //tandai proses sync

            string err = string.Empty; //tampungan error message

            try
            {
                DataTable dt = null;
                cQuery    qr = new cQuery();
                cDatabase db = new cDatabase();

                dt = db.selectDataSqlite(qr.qSelectTransaksiMhsStatus0()); // ambil data dari sqlite
                if (dt.Rows.Count != 0)                                    //jika ada data
                {
                    cKoneksi koneksi = new cKoneksi();

                    SqlConnection    conn     = new SqlConnection(koneksi.konekMsSql('2'));   //konek ke sql server user ktm = 2
                    SQLiteConnection connLite = new SQLiteConnection(koneksi.LokasiSqlite()); //koneksi ke sqlite
                    try
                    {
                        conn.Open();     //open sql server
                        connLite.Open(); //open sqlite

                        //===inisialisasi progres bar======
                        if (PbUpload.InvokeRequired)
                        {
                            PbUpload.BeginInvoke(
                                new Action(() =>
                            {
                                PbUpload.Style   = ProgressBarStyle.Blocks;
                                PbUpload.Value   = 0;
                                PbUpload.Minimum = 0;
                                PbUpload.Maximum = dt.Rows.Count;
                            }
                                           ));
                        }
                        //=================================

                        SQLiteTransaction transactionSqlite = connLite.BeginTransaction();

                        DataTable dtTrMhs = null;
                        foreach (DataRow row in dt.Rows)
                        {
                            SqlCommand myCommand = null;

                            dtTrMhs = cekTransaksiMhs(row["nim"].ToString()); //cek data sebelumnya
                            if (dtTrMhs.Rows.Count == 0)                      //jika tidak ada data sebelumnya langung di insert
                            {
                                myCommand = new SqlCommand(qr.qInsertStatusMhs(), conn);

                                myCommand.Parameters.AddWithValue("@STUDENTID", row["nim"]);
                                myCommand.Parameters.AddWithValue("@TGL_AMBIL_KTM", row["lastModified"]);
                                myCommand.Parameters.AddWithValue("@PTGS_KTM_AMBIL", row["operator"]);
                            }
                            else //hanya di update
                            {
                                //==cek dulu status ktm diambil==
                                Int32  AMBIL_KTM_KE;
                                string tmpAMBIL_KTM_KE = "";
                                foreach (DataRow rowTrMhs in dtTrMhs.Rows)
                                {
                                    tmpAMBIL_KTM_KE = rowTrMhs["AMBIL_KTM_KE"].ToString().Trim();
                                }
                                //===============================

                                myCommand = new SqlCommand(qr.qUpdateStatusMhs(), conn);

                                if (Int32.TryParse(tmpAMBIL_KTM_KE, out AMBIL_KTM_KE))
                                {//jika sudah pernah diambil, urutan pengambilan ditambah 1
                                    myCommand.Parameters.AddWithValue("@AMBIL_KTM_KE", AMBIL_KTM_KE + 1);
                                }
                                else
                                {//jika urutan bukan int, set jadi 0
                                    myCommand.Parameters.AddWithValue("@AMBIL_KTM_KE", 1);
                                }
                                myCommand.Parameters.AddWithValue("@TGL_AMBIL_KTM", row["lastModified"]);
                                myCommand.Parameters.AddWithValue("@STUDENTID", row["nim"]);
                                myCommand.Parameters.AddWithValue("@PTGS_KTM_AMBIL", row["operator"]);
                            }

                            SQLiteCommand cmdSqlite = new SQLiteCommand(qr.qUpdateStatusUpload1(), connLite);
                            cmdSqlite.Parameters.AddWithValue("@idTransaksi", row["idTransaksi"]);

                            ////cek perintah thread close
                            if (cSyncRun.closingThread == true)
                            {
                                transactionSqlite.Commit(); //jika ada perintah thread close, maka di sqlite langsung di commit

                                conn.Close();               //tutup koneksi
                                conn.Dispose();
                                connLite.Close();
                                connLite.Dispose();

                                return("Thread Closed By User");
                            }

                            try
                            {
                                myCommand.ExecuteNonQuery();//insert ke sql
                            }
                            catch
                            {
                                transactionSqlite.Commit();//jika proses insert di sql gagal, di sqlite langsung di commit
                            }

                            cmdSqlite.ExecuteNonQuery();//update status ke sqlite

                            //===proses progres bar======
                            if (PbUpload.InvokeRequired)
                            {
                                PbUpload.BeginInvoke(
                                    new Action(() =>
                                {
                                    PbUpload.Increment(1);
                                }
                                               ));
                            }
                            //===========================

                            dtTrMhs.Clear();
                        }
                        transactionSqlite.Commit();
                    }
                    catch (Exception ex)
                    {
                        err = ex.Message;
                        //MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        conn.Close(); //tutup koneksi
                        conn.Dispose();
                        connLite.Close();
                        connLite.Dispose();
                    }
                }

                //clear datatable
                dt.Clear();
                dt.Dispose();
                //================
            }
            catch (Exception ex)
            {
                err = ex.Message;
            }

            cSyncRun.isSync = false;

            return(err);
        }
예제 #19
0
        private string downloadOperatorTmp()
        {
            string err = string.Empty;

            try
            {
                cQuery    qr = new cQuery();
                cDatabase db = new cDatabase();
                DataTable dt = null;
                dt = db.selectData(qr.qSelectUserOpAkdk(), '1'); // ambil data dari mssql
                if (dt.Rows.Count != 0)                          //jika ada data
                {
                    //===inisialisasi progres bar======
                    if (ProgressBarSinkron.InvokeRequired)
                    {
                        ProgressBarSinkron.BeginInvoke(
                            new Action(() =>
                        {
                            ProgressBarSinkron.Style   = ProgressBarStyle.Blocks;
                            ProgressBarSinkron.Value   = 0;
                            ProgressBarSinkron.Minimum = 0;
                            ProgressBarSinkron.Maximum = dt.Rows.Count;
                        }
                                       ));
                    }

                    //=================================

                    cKoneksi koneksi = new cKoneksi();

                    using (var conn = new SQLiteConnection(koneksi.LokasiSqlite()))//koneksi ke sqlite
                    {
                        try
                        {
                            conn.Open();//buka koneksi
                            using (var cmd = new SQLiteCommand(conn))
                            {
                                using (var transaction = conn.BeginTransaction())
                                {
                                    //looping insert
                                    foreach (DataRow row in dt.Rows)
                                    {
                                        cmd.CommandText = qr.qInsertUserTmp();//" INSERT INTO userTmp (username, fullname, password, role) values(@username, @fullname, @password, @role)";
                                        cmd.Parameters.Clear();
                                        cmd.Prepare();
                                        cmd.Parameters.AddWithValue("@username", row["username"]);
                                        cmd.Parameters.AddWithValue("@fullname", row["fullname"]);
                                        cmd.Parameters.AddWithValue("@password", row["password"]);
                                        cmd.Parameters.AddWithValue("@aplication", row["aplication"]);
                                        cmd.Parameters.AddWithValue("@role", row["role"]);
                                        cmd.ExecuteNonQuery();

                                        //===proses progres bar======
                                        if (ProgressBarSinkron.InvokeRequired)
                                        {
                                            ProgressBarSinkron.BeginInvoke(
                                                new Action(() =>
                                            {
                                                ProgressBarSinkron.Increment(1);
                                            }
                                                           ));
                                        }

                                        //ProgressBarSinkron.Increment(1);
                                        //===========================
                                    }

                                    transaction.Commit();
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                        finally
                        {
                            conn.Close(); //tutup koneksi
                            conn.Dispose();
                        }
                    }

                    ////===tutup progres bar======
                    //if (ProgressBarSinkron.Value == ProgressBarSinkron.Maximum)//jika sudah selesai tampilkan download complete
                    //{ LblProgressBar.Text = "Download Complete"; }
                    //MessageBox.Show("" + ProgressBarSinkron.Value + " Data Berhasil di Download");
                    //panelProgressBar.Visible = false;// hiden panel progressbar
                    ////==========================
                }

                //clear datatable
                dt.Clear();
                dt.Dispose();
                //================
            }
            catch (Exception ex)
            {
                err = ex.Message;
                //ProgressBarSinkron.Visible = false;
                MessageBox.Show(ex.Message);
            }
            return(err);
        }
예제 #20
0
        private string downloadKendaraanTmp()
        {
            string err = string.Empty;

            try
            {
                cQuery    qr = new cQuery();
                cDatabase db = new cDatabase();
                DataTable dt = null;
                dt = db.selectData(qr.qSelectKendaraan(), '1'); // ambil data dari mssql
                if (dt.Rows.Count != 0)                         //jika ada data
                {
                    //===inisialisasi progres bar======
                    if (ProgressBarSinkron.InvokeRequired)
                    {
                        ProgressBarSinkron.BeginInvoke(
                            new Action(() =>
                        {
                            ProgressBarSinkron.Style   = ProgressBarStyle.Blocks;
                            ProgressBarSinkron.Value   = 0;
                            ProgressBarSinkron.Minimum = 0;
                            ProgressBarSinkron.Maximum = dt.Rows.Count;
                        }
                                       ));
                    }
                    //=================================

                    cKoneksi koneksi = new cKoneksi();

                    using (var conn = new SQLiteConnection(koneksi.LokasiSqlite()))//koneksi ke sqlite
                    {
                        try
                        {
                            conn.Open();//buka koneksi
                            using (var cmd = new SQLiteCommand(conn))
                            {
                                using (var transaction = conn.BeginTransaction())
                                {
                                    //looping insert
                                    foreach (DataRow row in dt.Rows)
                                    {
                                        cmd.CommandText = qr.qInsertKendaraanTmp();
                                        cmd.Parameters.Clear();
                                        cmd.Prepare();
                                        cmd.Parameters.AddWithValue("@id", row["id_kendaraan"]);
                                        cmd.Parameters.AddWithValue("@id_pengguna", row["pengguna"]);
                                        cmd.Parameters.AddWithValue("@no_kendaraan", row["tnkb"]);
                                        cmd.Parameters.AddWithValue("@pemilik", row["pemilik"]);
                                        cmd.Parameters.AddWithValue("@merek", row["merek"]);
                                        cmd.Parameters.AddWithValue("@jenis", row["id_jenis_kendaraan"]); //jenis dilangsung aja
                                        cmd.Parameters.AddWithValue("@last_update", row["last_update"]);  //last Update
                                        cmd.ExecuteNonQuery();

                                        //===proses progres bar======
                                        if (ProgressBarSinkron.InvokeRequired)
                                        {
                                            ProgressBarSinkron.BeginInvoke(
                                                new Action(() =>
                                            {
                                                ProgressBarSinkron.Increment(1);
                                            }
                                                           ));
                                        }
                                        //===========================
                                    }

                                    transaction.Commit();
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                        finally
                        {
                            conn.Close(); //tutup koneksi
                            conn.Dispose();
                        }
                    }

                    ////===tutup progres bar======
                    //if (ProgressBarSinkron.Value == ProgressBarSinkron.Maximum)//jika sudah selesai tampilkan download complete
                    //{ LblProgressBar.Text = "Download Complete"; }
                    //MessageBox.Show("" + ProgressBarSinkron.Value + " Data Berhasil di Download");
                    //panelProgressBar.Visible = false;// hiden panel progressbar
                    ////==========================
                }

                //clear datatable
                dt.Clear();
                dt.Dispose();
                //================
            }
            catch (Exception ex)
            {
                err = ex.Message;
                //ProgressBarSinkron.Visible = false;
                MessageBox.Show(ex.Message);
            }
            return(err);
        }
예제 #21
0
        private string downloadMahasiswaTmp()
        {
            string err = string.Empty;

            try
            {
                cQuery    qr = new cQuery();
                cDatabase db = new cDatabase();
                DataTable dt = null;
                dt = db.selectData(qr.qSelectMhs(), '2'); // '2' = ambil data dari 10.0.1.61 db s1makumyny4
                if (dt.Rows.Count != 0)                   //jika ada data
                {
                    //===inisialisasi progres bar======
                    if (ProgressBarSinkron.InvokeRequired)
                    {
                        ProgressBarSinkron.BeginInvoke(
                            new Action(() =>
                        {
                            ProgressBarSinkron.Value   = 0;
                            ProgressBarSinkron.Minimum = 0;
                            ProgressBarSinkron.Maximum = dt.Rows.Count;
                        }
                                       ));
                    }
                    //=================================

                    cKoneksi koneksi = new cKoneksi();
                    using (var conn = new SQLiteConnection(koneksi.LokasiSqlite()))//koneksi ke sqlite
                    {
                        try
                        {
                            conn.Open();//buka koneksi
                            using (var cmd = new SQLiteCommand(conn))
                            {
                                using (var transaction = conn.BeginTransaction())
                                {
                                    //looping insert
                                    foreach (DataRow row in dt.Rows)
                                    {
                                        cmd.CommandText = qr.qInsertPenggunaTmp();//"insert into penggunaTmp (id,nik,nama,rfid,kategori) values (@id,@nik,@nama,@rfid,@kategori)";
                                        cmd.Parameters.Clear();
                                        cmd.Prepare();
                                        cmd.Parameters.AddWithValue("@id", row["StudentID"]);  //kenapa ID diisi sama kayak nik??
                                        cmd.Parameters.AddWithValue("@nik", row["StudentID"]); //kenapa ID diisi sama kayak nik??
                                        cmd.Parameters.AddWithValue("@nama", row["fullname"]);
                                        cmd.Parameters.AddWithValue("@rfid", row["rfid"]);
                                        cmd.Parameters.AddWithValue("@kategori", 1); // 1 = kategori mahasiswa
                                        cmd.ExecuteNonQuery();

                                        //===proses progres bar======
                                        if (ProgressBarSinkron.InvokeRequired)
                                        {
                                            ProgressBarSinkron.BeginInvoke(
                                                new Action(() =>
                                            {
                                                ProgressBarSinkron.Increment(1);
                                            }
                                                           ));
                                        }
                                        //===========================
                                    }

                                    transaction.Commit();
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                        finally
                        {
                            conn.Close(); //tutup koneksi
                            conn.Dispose();
                        }
                    }

                    ////===tutup progres bar======
                    //if (ProgressBarSinkron.Value == ProgressBarSinkron.Maximum)//jika sudah selesai tampilkan download complete
                    //{ LblProgressBar.Text = "Download Complete"; }
                    //MessageBox.Show("" + ProgressBarSinkron.Value + " Data Berhasil di Download");
                    //panelProgressBar.Visible = false;// hiden panel progressbar
                    ////==========================
                }

                //clear datatable
                dt.Clear();
                dt.Dispose();
                //================
            }
            catch (Exception ex)
            {
                err = ex.Message;
                //ProgressBarSinkron.Visible = false;
                MessageBox.Show(ex.Message);
            }
            return(err);
        }
예제 #22
0
        private void generateRfidPegawai() //harusnya bukan nik tapi id_pegawai CEK LAGI DARI PROSES SEARCH!!!!!!!!!!!!!!!!!!!!
        {
            string idPegawai = lbIdPegawai.Text.Replace("'", "''");

            DataTable dtRfid = null;
            cDatabase db     = new cDatabase();
            cQuery    qr     = new cQuery();

            dtRfid = db.selectData(qr.qSelectRfidByIdPeg(idPegawai), '4');
            if (dtRfid.Rows.Count != 0)
            {
                string cekRfid = string.Empty;
                foreach (DataRow rowProdi in dtRfid.Rows)
                {
                    cekRfid = rowProdi["rfid"].ToString();
                }

                //jika ternyata sudah ada rfidnya, proses stop
                if (cekRfid != string.Empty)
                {
                    clearTampilan();
                    tampilPeg(idPegawai);

                    //txt_cari_nama.Text = string.Empty;
                    //txt_cari_nik.Text = string.Empty;

                    return;
                }

                //cek dari tabel pegawai
                DataTable lastHeksa = selectRfidPegTerakir(); //ambil heksa terakir dari pegawai
                string    heksa     = string.Empty;
                if (lastHeksa.Rows.Count != 0)
                {
                    foreach (DataRow rowHeksa in lastHeksa.Rows)
                    {
                        heksa = rowHeksa["heksa"].ToString();
                    }
                }

                //cek dari tabel history_rfid
                DataTable lastHeksaHis = selectHistoryRfidTerakirPegawai(); //ambil heksa terakir pegawai dari history
                string    heksaHis     = string.Empty;
                if (lastHeksaHis.Rows.Count != 0)
                {
                    foreach (DataRow rowHeksaHis in lastHeksaHis.Rows)
                    {
                        heksaHis = rowHeksaHis["heksa"].ToString();
                    }
                }

                string heksaUse = string.Empty;                        //heksa yang akan dipakai

                if (heksa != string.Empty && heksaHis != string.Empty) //jika di kedua tabel ditemukan heksa sebelumnya
                {
                    //bandingkan heksa dari tabel mhs dan history, nilainya paling tinggi yang dipakai
                    Int32 iheksa    = Int32.Parse(heksa, System.Globalization.NumberStyles.HexNumber);    //dari heksa terakir convert ke int
                    Int32 iheksaHis = Int32.Parse(heksaHis, System.Globalization.NumberStyles.HexNumber); //dari heksa terakir convert ke int

                    if (iheksa > iheksaHis)
                    {
                        heksaUse = heksa;
                    }
                    else if (iheksaHis > iheksa)
                    {
                        heksaUse = heksaHis;
                    }
                }
                else if (heksa != string.Empty && heksaHis == string.Empty) //jika hanya ditemukan dari tabel pegawai
                {
                    heksaUse = heksa;
                }
                else if (heksa == string.Empty && heksaHis != string.Empty) //jika hanya ditemukan dari tabel history_rfid
                {
                    heksaUse = heksaHis;
                }

                //=======================================================================
                if (heksaUse != string.Empty)//jika sudah ditemukan kode rfid terakir, lanjutkan sequence-nya
                {
                    UpdateRfidPegawai(idPegawai, heksaUse);
                }
                else
                { //jika belum ditemukan kode rfid sebelumnya, generate dari awal
                    UpdateRfidPegawai(idPegawai, "0000");
                }

                lastHeksa.Clear();
                lastHeksa.Dispose();
                lastHeksaHis.Clear();
                lastHeksaHis.Dispose();
            }

            clearTampilan();

            //txt_cari_nama.Text = string.Empty;
            //txt_cari_nik.Text = string.Empty;
            //DGList.Rows.Clear();
            //jmlRow.Text = string.Empty;

            tampilPeg(idPegawai);
        }
예제 #23
0
        private void generateRfidMhs()
        {
            string NIM = txt_nik.Text.Replace("'", "''");

            string prodi = string.Empty;

            DataTable dtProdi = null;
            cDatabase db      = new cDatabase();
            cQuery    qr      = new cQuery();

            dtProdi = db.selectData(qr.qSelectKodeProdiByNim(NIM), '2');
            if (dtProdi.Rows.Count != 0)
            {
                string cekRfid = string.Empty;
                foreach (DataRow rowProdi in dtProdi.Rows)//ambil kode prodi sesuai nim
                {
                    cekRfid = rowProdi["RFID"].ToString();
                    prodi   = rowProdi["prodi"].ToString();
                }

                //jika ternyata sudah ada rfidnya, proses stop
                if (cekRfid != string.Empty)
                {
                    clearTampilan();

                    tampilMhs(NIM);

                    //txt_cari_nama.Text = string.Empty;
                    //txt_cari_nik.Text = string.Empty;

                    return;
                }

                //cek dari tabel mahasiswa
                DataTable lastHeksa = selectRfidMhsTerakirByProdi(prodi); //ambil heksa terakir dari mahasiswa, sesuai prodinya
                string    heksa     = string.Empty;
                if (lastHeksa.Rows.Count != 0)
                {
                    foreach (DataRow rowHeksa in lastHeksa.Rows)
                    {
                        heksa = rowHeksa["heksa"].ToString();
                    }
                }

                //cek dari tabel history_rfid
                DataTable lastHeksaHis = selectFrHistoryRfidMhsTerakirbyProdi(prodi); //ambil heksa terakir dari history, sesuai prodinya
                string    heksaHis     = string.Empty;
                if (lastHeksaHis.Rows.Count != 0)
                {
                    foreach (DataRow rowHeksaHis in lastHeksaHis.Rows)
                    {
                        heksaHis = rowHeksaHis["heksa"].ToString();
                    }
                }

                string heksaUse = string.Empty;                        //heksa yang akan dipakai

                if (heksa != string.Empty && heksaHis != string.Empty) //jika di kedua tabel ditemukan heksa sebelumnya
                {
                    //bandingkan heksa dari tabel mhs dan history, nilainya paling tinggi yang dipakai
                    Int32 iheksa    = Int32.Parse(heksa, System.Globalization.NumberStyles.HexNumber);    //dari heksa terakir convert ke int
                    Int32 iheksaHis = Int32.Parse(heksaHis, System.Globalization.NumberStyles.HexNumber); //dari heksa terakir convert ke int

                    if (iheksa > iheksaHis)
                    {
                        heksaUse = heksa;
                    }
                    else if (iheksaHis > iheksa)
                    {
                        heksaUse = heksaHis;
                    }
                }
                else if (heksa != string.Empty && heksaHis == string.Empty) //jika hanya ditemukan dari tabel mahasiswa
                {
                    heksaUse = heksa;
                }
                else if (heksa == string.Empty && heksaHis != string.Empty) //jika hanya ditemukan dari tabel history_rfid
                {
                    heksaUse = heksaHis;
                }

                //=======================================================================
                if (heksaUse != string.Empty)//jika sudah ditemukan kode rfid terakir, lanjutkan sequence-nya
                {
                    UpdateRfidMhs(NIM, prodi, heksaUse);
                }
                else
                { //jika belum ditemukan kode rfid sebelumnya, generate dari awal
                    UpdateRfidMhs(NIM, prodi, "0000");
                }

                lastHeksa.Clear();
                lastHeksa.Dispose();
                lastHeksaHis.Clear();
                lastHeksaHis.Dispose();
            }

            clearTampilan();

            //txt_cari_nama.Text = string.Empty;
            //txt_cari_nik.Text = string.Empty;
            //DGList.Rows.Clear();
            //jmlRow.Text = string.Empty;

            tampilMhs(NIM);
        }