예제 #1
0
        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);
        }
예제 #2
0
        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.");
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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());
        }
예제 #5
0
        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;
            }
        }
예제 #6
0
        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;
            }
        }