Ejemplo n.º 1
0
        private string SyncKendaraan(bool firstSync)
        {
            string err = string.Empty;    //tampungan error message

            deleteKendaraanTmp();         //hapus tmp

            err = downloadKendaraanTmp(); //insert tmp

            //cek fisrtSync
            if (firstSync == true)
            {
                if (err != string.Empty)
                { //jika terjadi error
                    return(err);
                }
            }

            cQuery qr = new cQuery();

            //string qrTmp = "SELECT last_update FROM kendaraanTmp order by last_update desc LIMIT 1";//cek data di tmp
            if (cekDataSqlLIte(qr.qSelectKendaraanTmpLimit1(), false) == true) //cek tabel tmp
            {                                                                  //jika ada datanya
               //pindah tabel tmp ke kendaraan

                deleteKendaraan();
                copyTmpToKendaraan();

                if (ProgressBarSinkron.Value == ProgressBarSinkron.Maximum)//jika sudah selesai tampilkan download complete
                {
                    if (LbDownload.InvokeRequired)
                    {
                        LbDownload.BeginInvoke(
                            new Action(() =>
                        {
                            LbDownload.Text = "Download Complete";
                        }
                                       ));
                    }
                }

                //cek firstSync
                if (firstSync == false)
                {
                    MessageBox.Show("" + ProgressBarSinkron.Value + " Data Berhasil di Download", "BSI UMY", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                if (LbDownload.InvokeRequired)
                {
                    LbDownload.BeginInvoke(
                        new Action(() =>
                    {
                        LbDownload.Text = string.Empty;
                    }
                                   ));
                }
            }
            else
            {
                MessageBox.Show("Synchronize Failed", "BSI UMY", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            return(err);
        }