public static List <StoreSiteInfo> GetStoreSites() { List <StoreSiteInfo> storeSites = new List <StoreSiteInfo>(); OracleConnection connection = new OracleConnection(ConnectionFactory.ActiveConnection.PawnSecConnectionString); connection.Open(); OracleCommand command = new OracleCommand(); command.Connection = connection; command.CommandText = "Select ID,storenumber,appversionid FROM pawnsec.storesiteinfo order by storenumber"; command.CommandType = CommandType.Text; OracleDataReader dr = command.ExecuteReader(); while (dr.Read()) { StoreSiteInfo s = new StoreSiteInfo(); s.Id = Conversion.ToInt32(dr["id"]); s.StoreNumber = Conversion.ToString(dr["storenumber"]); s.AppVersionId = Conversion.ToInt32(dr["appversionid"]); storeSites.Add(s); } connection.Dispose(); return(storeSites); }
private void btnChangeStore_Click(object sender, EventArgs e) { AppVersion appVersion = ddlApplication.SelectedItem as AppVersion; ClientRegistry cr = ddlClientRegistries.SelectedItem as ClientRegistry; StoreSiteInfo si = ddlStoreSites.SelectedItem as StoreSiteInfo; Store store = Stores.ContainsKey(si.StoreNumber) ? Stores[si.StoreNumber] : null; if (appVersion == null || cr == null || si == null || store == null) { MessageBox.Show("Cannot change the store."); return; } if (string.IsNullOrEmpty(cr.MachineName)) { MessageBox.Show("Invalid machine name"); return; } if (Db.ChangeStore(cr, si, store, appVersion)) { MessageBox.Show("Store Changed", "Change Store", MessageBoxButtons.OK); UpdateDatabaseSelected(); } else { MessageBox.Show("Error while changing store."); } }
public static bool ChangeStore(ClientRegistry cr, StoreSiteInfo si, Store store, AppVersion appVersion) { bool success = false; OracleTransaction pawnSecTransaction = null; OracleTransaction cdOwnerTransaction = null; try { int result = UpdatePawnSec(cr, si, out pawnSecTransaction); if (result == 0) { pawnSecTransaction.Rollback(); return(false); } if (appVersion.UsesCashDrawer) { result = UpdateCdOwner(cr, store, out cdOwnerTransaction); if (result == 0) { cdOwnerTransaction.Rollback(); return(false); } } pawnSecTransaction.Commit(); if (appVersion.UsesCashDrawer) { cdOwnerTransaction.Commit(); } success = true; } catch (Exception) { if (pawnSecTransaction != null) { pawnSecTransaction.Rollback(); } if (cdOwnerTransaction != null) { cdOwnerTransaction.Rollback(); } success = false; } return(success); }
private static int UpdatePawnSec(ClientRegistry cr, StoreSiteInfo si, out OracleTransaction transaction) { OracleConnection connection = new OracleConnection(ConnectionFactory.ActiveConnection.PawnSecConnectionString); connection.Open(); transaction = connection.BeginTransaction(); OracleCommand command = new OracleCommand(); command.Connection = connection; command.CommandText = string.Format("UPDATE pawnsec.clientstoremap SET storesiteid = {0} WHERE clientregistryid = {1} and storesiteid = {2}", si.Id, cr.Id, cr.CurrentStoreId); command.CommandType = CommandType.Text; command.Transaction = transaction; return(command.ExecuteNonQuery()); }
private void ddlStoreSites_SelectedIndexChanged(object sender, EventArgs e) { StoreSiteInfo si = ddlStoreSites.SelectedItem as StoreSiteInfo; if (si == null) { return; } if (Stores.ContainsKey(si.StoreNumber)) { txtStoreId.Text = Stores[si.StoreNumber].StoreId; } }
private void ddlClientRegistries_SelectedIndexChanged(object sender, EventArgs e) { ClientRegistry cr = ddlClientRegistries.SelectedItem as ClientRegistry; if (cr == null) { return; } txtClientId.Text = cr.Id.ToString(); StoreSiteInfo si = StoreSites.Find(s => s.Id.Equals(cr.CurrentStoreId)); if (si != null) { ddlStoreSites.SelectedItem = si; } }