/// <summary> /// Process Makkebun & Lawatan /// </summary> public static void SyncToServerForMakKebun() { IAppInfoRepo AppInfoRepo = new AppInfoRepo(); IMakkebunRepo MakkebunRepo = new MakkebunRepo(); ISemakTapakRepo SemakTapakRepo = new SemakTapakRepo(); IList <makkebun> lstMakKebun = MakkebunRepo.GetAllToSync(); for (int i = 0; i < lstMakKebun.Count; i++) { makkebun makkebunsqlite = lstMakKebun[i]; using (IDbTransaction sqlTrans = MakkebunRepo.MySQLBeginTransaction()) { // INSERT MAKKEBUN TO MYSQL int iSaveMakkebun = MakkebunRepo.CreateMySQL(makkebunsqlite, sqlTrans); if (iSaveMakkebun > 0) { makkebun lastmakkebun = MakkebunRepo.GetLastMakkebunBy(makkebunsqlite.appinfo_id); makkebunsqlite.newid_makkebun = lastmakkebun.id_makkebun; makkebunsqlite.syncdate = DateTime.Now; // UPDATE MAKKEBUN SQLITE MakkebunRepo.UpdateSync(makkebunsqlite); // GET LAWATAN SQLITE DATA semak_tapak semak_tapakSqlite = SemakTapakRepo.GetBy(makkebunsqlite.appinfo_id, makkebunsqlite.id_makkebun); semak_tapakSqlite.newmakkebun_id = makkebunsqlite.newid_makkebun; // INSERT LAWATAN TO MYSQL int iSaveSemakTapak = SemakTapakRepo.CreateMySQL(semak_tapakSqlite, sqlTrans); if (iSaveSemakTapak > 0) { semak_tapak lastsemak_tapak = SemakTapakRepo.GetLastSemakTapakBy(makkebunsqlite.appinfo_id, semak_tapakSqlite.newmakkebun_id); semak_tapakSqlite.newid = lastsemak_tapak.id; semak_tapakSqlite.syncdate = DateTime.Now; // UPDATE MAKKEBUN SQLITE int iSemakTapakUpdateSync = SemakTapakRepo.UpdateSync(semak_tapakSqlite); } } sqlTrans.Commit(); } AppInfoRepo.CloseMySQLDB(); } }
private void SetupFormMakKebun(int appinfo_id, int id_makkebun) { this.appinfo_id = appinfo_id; this.id_makkebun = id_makkebun; makkebun makkebun = MakkebunRepo.GetBy(id_makkebun); txtaddr1.Text = makkebun.addr1; txtaddr2.Text = makkebun.addr2; txtaddr3.Text = makkebun.addr3; txtcatatan.Text = makkebun.catatan; txtluaslesen.Text = makkebun.luaslesen.ToString("#.##"); txtluasmatang.Text = makkebun.luasmatang.ToString("#.##"); txtnolesen.Text = makkebun.nolesen; txtnolot.Text = makkebun.nolot; if (makkebun.tebang == "SUDAH") { rbSudah.Checked = true; DateTime dttarikhtebang = DateTime.ParseExact(makkebun.tarikhtebang, "dd-MM-yyyy", CultureInfo.InvariantCulture); txttarikhtebang.Text = dttarikhtebang.ToString(); txttarikhtebang.Value = dttarikhtebang; } else if (makkebun.tebang == "BELUM") { rbBelum.Checked = true; } else { rbBelum.Checked = false; rbSudah.Checked = false; } cbnegeri.SelectedValue = makkebun.negeri; cbdaerah.SelectedValue = makkebun.daerah; cbdun.SelectedValue = makkebun.dun; cbparlimen.SelectedValue = makkebun.parlimen; cbsyarattanah.SelectedValue = makkebun.syarattanah; cbjenishakmiliktanah.SelectedValue = makkebun.hakmiliktanah; cbpemilikan.SelectedValue = makkebun.pemilikan; cbpengurusan.SelectedValue = makkebun.pengurusan; cbtncr.SelectedValue = makkebun.tncr; }
/// <summary> /// Process Normal /// </summary> public static void SyncToServer() { try { IAppInfoRepo AppInfoRepo = new AppInfoRepo(); AppInfoRepo.ResetMySQLConnection(true); IMakkebunRepo MakkebunRepo = new MakkebunRepo(); ISemakTapakRepo SemakTapakRepo = new SemakTapakRepo(); IList <appinfo> lstAppInfoToSync = AppInfoRepo.GetAllWithoutSync(); for (int i = 0; i < lstAppInfoToSync.Count; i++) { appinfo appinfoSqlite = lstAppInfoToSync[i]; AppInfoRepo.OpenMySQLDB(); WriteLog("MySQLBeginTransaction"); using (IDbTransaction sqlTrans = AppInfoRepo.MySQLBeginTransaction()) { string newrefno = GenerateRefNo(appinfoSqlite.negeri, null); appinfoSqlite.newrefno = newrefno; // Insert To MySQL Server - AppInfo WriteLog("AppInfoRepo.CreateMySQL"); try { if (AppInfoRepo.CreateMySQL(appinfoSqlite, sqlTrans) > 0) { // Update data local sqlite appinfoSqlite.syncdate = DateTime.Now; AppInfoRepo.UpdateSync(appinfoSqlite); WriteLog(string.Format("AppInfoRepo.CreateMySQL & Update SQLite - {0} - {1} - {2}", appinfoSqlite.id, appinfoSqlite.refno_new, appinfoSqlite.newrefno)); IList <makkebun> lstMakkebunSqlite = MakkebunRepo.GetAllByAppInfo(appinfoSqlite.id); for (int j = 0; j < lstMakkebunSqlite.Count; j++) { makkebun makkebunSqlite = lstMakkebunSqlite[j]; // INSERT MAKKEBUN TO MYSQL WriteLog("MakkebunRepo.CreateMySQL"); try { int iSaveMakkebun = MakkebunRepo.CreateMySQL(makkebunSqlite, sqlTrans); if (iSaveMakkebun > 0) { makkebun lastmakkebun = MakkebunRepo.GetLastMakkebunBy(appinfoSqlite.id); makkebunSqlite.newid_makkebun = lastmakkebun.id_makkebun; makkebunSqlite.syncdate = DateTime.Now; // UPDATE MAKKEBUN SQLITE MakkebunRepo.UpdateSync(makkebunSqlite); WriteLog(string.Format("MakkebunRepo.CreateMySQL & Update SQLite - {0} - {1} - {2}", appinfoSqlite.id, makkebunSqlite.id_makkebun, makkebunSqlite.newid_makkebun)); // GET LAWATAN SQLITE DATA semak_tapak semak_tapakSqlite = SemakTapakRepo.GetBy(appinfoSqlite.id, makkebunSqlite.id_makkebun); if (semak_tapakSqlite != null) { semak_tapakSqlite.newmakkebun_id = makkebunSqlite.newid_makkebun; // INSERT LAWATAN TO MYSQL WriteLog("SemakTapakRepo.CreateMySQL"); try { int iSaveSemakTapak = SemakTapakRepo.CreateMySQL(semak_tapakSqlite, sqlTrans); if (iSaveSemakTapak > 0) { semak_tapak lastsemak_tapak = SemakTapakRepo.GetLastSemakTapakBy(appinfoSqlite.id, semak_tapakSqlite.newmakkebun_id); semak_tapakSqlite.newid = lastsemak_tapak.id; semak_tapakSqlite.syncdate = DateTime.Now; // UPDATE MAKKEBUN SQLITE int iSemakTapakUpdateSync = SemakTapakRepo.UpdateSync(semak_tapakSqlite); WriteLog(string.Format("SemakTapakRepo.CreateMySQL & Update SQLite - {0} - {1} - {2}", appinfoSqlite.id, semak_tapakSqlite.id, semak_tapakSqlite.newid)); } } catch (Exception ex) { WriteLog(string.Format("ERROR-SemakTapakRepo.CreateMySQL-{0}", ex.GetFullMessage())); } } else { WriteLog(string.Format("Maklumat Kebun Belum Lawat - {0}", makkebunSqlite.id_makkebun)); } } } catch (Exception ex) { WriteLog(string.Format("ERROR-MakkebunRepo.CreateMySQL-{0}", ex.GetFullMessage())); } } } } catch (Exception ex) { WriteLog(string.Format("ERROR-AppInfoRepo.CreateMySQL-appinfo:{0}-refno_new:{1}-MESSAGE:{2}", appinfoSqlite.id, appinfoSqlite.refno_new, ex.GetFullMessage())); } sqlTrans.Commit(); } AppInfoRepo.CloseMySQLDB(); } } catch (Exception ex) { MessageBox.Show(ex.GetFullMessage()); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (appinfo_id <= 0) { MessageBox.Show("Harap masukan data dari Maklumat Pemohon."); return; } IList <Control> lstCtrlEmptyCheck = new List <Control>(); lstCtrlEmptyCheck.Add(txtaddr1); lstCtrlEmptyCheck.Add(txtaddr2); lstCtrlEmptyCheck.Add(cbnegeri); //lstCtrlEmptyCheck.Add(cbdaerah); //lstCtrlEmptyCheck.Add(cbdun); //lstCtrlEmptyCheck.Add(cbparlimen); lstCtrlEmptyCheck.Add(txtnolot); lstCtrlEmptyCheck.Add(txtluasmatang); lstCtrlEmptyCheck.Add(cbsyarattanah); lstCtrlEmptyCheck.Add(txtnolesen); lstCtrlEmptyCheck.Add(cbjenishakmiliktanah); lstCtrlEmptyCheck.Add(cbpengurusan); lstCtrlEmptyCheck.Add(cbpemilikan); if (WFUtils.CheckControllCollectionEmpty(lstCtrlEmptyCheck)) { return; } bool IsNew = false; makkebun makkebun = MakkebunRepo.GetBy(id_makkebun); if (makkebun == null) { makkebun = new makkebun(); IsNew = true; } makkebun.appinfo_id = appinfo_id; makkebun.addr1 = txtaddr1.Text; makkebun.addr2 = txtaddr2.Text; makkebun.addr3 = txtaddr3.Text; makkebun.catatan = txtcatatan.Text; makkebun.luaslesen = Convert.ToDouble(string.IsNullOrEmpty(txtluaslesen.Text) ? 0 : Convert.ToDouble(txtluaslesen.Text)); makkebun.luasmatang = Convert.ToDouble(txtluasmatang.Text); makkebun.nolesen = txtnolesen.Text; makkebun.nolot = txtnolot.Text; makkebun.tarikhtebang = txttarikhtebang.Text; makkebun.negeri = cbnegeri.SelectedValue.ToString(); makkebun.daerah = cbdaerah.SelectedValue == null ? "" : cbdaerah.SelectedValue.ToString(); makkebun.dun = cbdun.SelectedValue == null ? "" : cbdun.SelectedValue.ToString(); makkebun.parlimen = ParlimenRepo.GetParlimenIDBy(cbparlimen.SelectedValue.ToString()); makkebun.syarattanah = cbsyarattanah.SelectedValue.ToString(); makkebun.hakmiliktanah = cbjenishakmiliktanah.SelectedValue.ToString(); makkebun.pemilikan = cbpemilikan.SelectedValue.ToString(); makkebun.pengurusan = cbpengurusan.SelectedValue.ToString(); makkebun.tncr = cbtncr.SelectedValue.ToString(); makkebun.tebang = rbSudah.Checked ? "SUDAH" : rbBelum.Checked ? "BELUM" : ""; if (IsNew) { try { makkebun.created = DateTime.Now; makkebun.createdby = VariableSettingRepo.GetBy("UserKeyIn").Value; MakkebunRepo.Create(makkebun); MessageBox.Show("Data berhasil disimpan [" + refno_new + " | " + txtnolot.Text + "]"); } catch (Exception ex) { MessageBox.Show(ex.GetFullMessage()); } } else { try { MakkebunRepo.Edit(makkebun); MessageBox.Show("Data berhasil disimpan [" + refno_new + " | " + txtnolot.Text + "]"); } catch (Exception ex) { MessageBox.Show(ex.GetFullMessage()); } } } catch (Exception ex) { MessageBox.Show(ex.GetFullMessage() + " - Harap periksa data input kembali"); return; } BindGrid(page); btnReset.PerformClick(); }