Skip to content

Instantly share code, notes, and snippets.

@ChrisMoney
Created September 28, 2016 20:01
Show Gist options
  • Save ChrisMoney/6b77d64e518be09081482f8c25939865 to your computer and use it in GitHub Desktop.
Save ChrisMoney/6b77d64e518be09081482f8c25939865 to your computer and use it in GitHub Desktop.
WPF Navigation App - Desktop app with page navigation that functions like web app
using System;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Navigation;
using System.Windows.Threading;
using SocketSender;
using IntercardLogging;
namespace RegistrationKiosk
{
/// <summary>
/// Interaction logic for CardSwipe.xaml
/// </summary>
public partial class CardSwipe : Page
{
public CardSwipe()
{
InitializeComponent();
TbCardNumber.Focus();
//Helper.MainGrid = MainGrid;
InputManager.Current.PreProcessInput += Helper.OnActivity;
Helper.ActivityTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(20), IsEnabled = true };
Helper.ActivityTimer.Tick += Helper.OnInactivity;
Helper.Page = this;
Helper.AtAttractionPage = false;
}
private void Next_Click(object sender, RoutedEventArgs e)
{
NavigationService nav = NavigationService.GetNavigationService(this);
nav.Navigate(new Uri("AcctHistoryRegistration.xaml", UriKind.RelativeOrAbsolute));
}
private void TbCardNumber_OnTextChanged(object sender, TextChangedEventArgs e)
{
IntercardLogger ILog = new IntercardLogger();
TextBox tbx = (TextBox)sender;
string text = tbx.Text;
// capture second instance of ?, which represents the end of track data
int index = text.IndexOf('?', text.IndexOf('?') + 1);
// call FormatAcctNumber once we have read all of the track data
if (index > 0)
{
string siteCode = string.Empty;
TbAcct.Text = Helper.FormatAcctNumber(tbx.Text, out siteCode);
TbSiteCode.Text = siteCode;
// check if account exists
TransActionServerIO transaction = new TransActionServerIO();
ClassLibrary_Accounts.Account acctBalance = transaction.GetCardHoldersBalance(Convert.ToInt64(TbAcct.Text));
// Initialize static account class with values from Transaction Server acct response
if (acctBalance != null)
{
Account.FirstName = acctBalance.FirstName;
Account.LastName = acctBalance.LastName;
Account.AccountNumber = acctBalance.AccountNumber;
Account.CashBalance = acctBalance.CashBalance;
Account.CashBonusBalance = acctBalance.CashBonusBalance;
Account.CashIn = acctBalance.CashIn;
Account.Discount = acctBalance.Discount;
Account.EmpCredits = acctBalance.EmpCredits;
Account.EmpStatus = acctBalance.EmpStatus;
Account.NewCard = acctBalance.NewCard;
Account.PointBalance = acctBalance.PointBalance;
Account.TokenBalance = acctBalance.TokenBalance;
Account.TokenBonusBalance = acctBalance.TokenBonusBalance;
Account.TpDuration = acctBalance.TP_Duration;
Account.TpStartTime = acctBalance.TP_StartTime;
Account.TpEndTime = acctBalance.TP_EndTime;
//Account.Cell;
//Account.Birthday;
//Account.Email;
//Account.Postal;
}
else
{
Account.FirstName = "";
Account.LastName = "";
Account.AccountNumber = Convert.ToInt64(TbAcct.Text);
Account.CashBalance = 0;
Account.CashBonusBalance = 0;
Account.CashIn = 0;
Account.Discount = 0;
Account.EmpCredits = 0;
Account.EmpStatus = 0;
Account.NewCard = true;
Account.PointBalance = 0;
Account.TokenBalance = 0;
Account.TpDuration = 0;
Account.TpStartTime = default(DateTime);
Account.TpEndTime = default(DateTime);
//Account.Cell;
//Account.Birthday;
//Account.Email;
//Account.Postal;
}
string[] macIds = TransActionServerIO.GetLocalMACs().ToArray();
string firstName = string.Empty;
string lastName = string.Empty;
string phone = string.Empty;
int sex = 0;
string email = string.Empty;
string postalCode = string.Empty;
DateTime dateOfBirth = DateTime.MinValue;
byte[] photo = null;
bool digitalTickets;
if (transaction.GetMemberByAccountNumber(
macIds,
Convert.ToInt64(TbAcct.Text),
out firstName,
out lastName,
out phone,
out sex,
out email,
out postalCode,
out dateOfBirth,
out photo,
out digitalTickets) == 0)
{
// assign cust macIds
try {Customer.MacIds = macIds;}
catch (Exception ex) { ILog.IntercardLog().Debug(ex.Message); }
// assign cust first name
try { Customer.FirstName = firstName; }
catch (Exception ex) { ILog.IntercardLog().Debug(ex.Message);}
// assign last name
try { Customer.LastName = lastName; }
catch (Exception ex) { ILog.IntercardLog().Debug(ex.Message);}
// assign phone
try { Customer.Phone = phone; }
catch (Exception ex) { ILog.IntercardLog().Debug(ex.Message);}
// assign sex
try { Customer.Sex = sex; }
catch (Exception ex) { ILog.IntercardLog().Debug(ex.Message);}
// assign postal code
try { Customer.PostalCode = postalCode; }
catch (Exception ex) { ILog.IntercardLog().Debug(ex.Message);}
// assign date of birth
try { Customer.DateOfBirth = dateOfBirth; }
catch (Exception ex) { ILog.IntercardLog().Debug(ex.Message);}
// assign photo
try { Customer.Photo = photo; }
catch (Exception ex) { ILog.IntercardLog().Debug(ex.Message);}
// assign digital tickets
try { Customer.DigitalTickets = digitalTickets; }
catch (Exception ex) { ILog.IntercardLog().Debug(ex.Message);}
} ;
NavigationService nav = NavigationService.GetNavigationService(this);
nav.Navigate(new Uri("AcctHistoryRegistration.xaml", UriKind.RelativeOrAbsolute));
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
NavigationService nav = NavigationService.GetNavigationService(this);
nav.Navigate(new Uri("MainWindow.xaml", UriKind.RelativeOrAbsolute));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment