private bool savedata() { try { var pos = db.Pos.Local.First(); string coords = (pos.longitude.ToString().Replace(",", ".") + ", " + pos.attitude.ToString().Replace(",", ".")); if (pos.coordstextdata != coords) { pos.coordstextdata = coords; } db.SaveChanges(); SetXtraTabsVisible(); return(true); } catch (Exception ex) { Tools.showDbSaveExceptions(ex); return(false); } }
public static bool SaveDb(ref DbModel.tradeEntities db) { try { db.SaveChanges(); return(true); } catch (Exception ex) { showDbSaveExceptions(ex); return(false); } }
private void simpleButton1_Click(object sender, EventArgs e) { if (db.Sites.Local.Any(x => x.Dealers == null)) { foreach (var site in db.Sites.Local.Where(x => x.Dealers == null)) { site.Dealers = db.Dealers.First(); } } if (db.DealerLegalNames.Local.Any(x => x.Dealers == null)) { foreach (var legalName in db.DealerLegalNames.Local.Where(x => x.Dealers == null)) { legalName.Dealers = db.Dealers.First(); } } db.SaveChanges(); }
private void simpleButton9_Click(object sender, EventArgs e) { var frmSelectDealer = new Forms.FrmDealerChoose(); if (frmSelectDealer.ShowDialog(this) == DialogResult.OK) { try { var dbNew = new tradeEntities(DbModel.Tools.TradeConnectionString(Properties.Settings.Default.barcodeCS.ToString())); var pos2change = dbNew.Pos.Where(x => x.ID == posId).FirstOrDefault(); pos2change.dealer_ID = frmSelectDealer.DealerId; dbNew.SaveChanges(); this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); this.Close(); } } }