I need to open Cash Drawer in my WPF application, this is the first time I deal with Cash Drawer, after some search I have knew that I'll use Microsoft Point of Services. So I have installed POSforDotNet V1.14 and start new project and added the reference, I have found this example :
CashDrawer myCashDrawer;
PosExplorer explorer;
public MainWindow()
{
InitializeComponent();
this.Loaded += MainWindow_Loaded;
}
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
explorer = new PosExplorer();
DeviceInfo ObjDevicesInfo = explorer.GetDevice("CashDrawer");
myCashDrawer = explorer.CreateInstance(ObjDevicesInfo);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
myCashDrawer.Open();
myCashDrawer.Claim(1000);
myCashDrawer.DeviceEnabled = true;
myCashDrawer.OpenDrawer();
myCashDrawer.DeviceEnabled = false;
myCashDrawer.Release();
myCashDrawer.Close();
}
You can download my test application HERE
I have tried but it dose not work :(
gave me error in myCashDrawer = explorer.CreateInstance(ObjDevicesInfo); line
Please can help me because I'm stuck with Microsoft Point of Services and I'm not fully understand it.
Besides the (CashDrawer) cast, I'd recommend to use
If you had more than one installed and you just use one parameter, it'll throw an error (and MSPOS v1.14 installs a phony cash drawer for testing, so you've got at least your physical and that one).
You need to typecast to
CashDrawer
. I updated your code now sure you will not get error.