private void OpenCashDrawer() { //<<<step1>>>--Start //When outputting to a printer,a mouse cursor becomes like a hourglass. Cursor.Current = Cursors.WaitCursor; //btnOpen.Enabled = false; try { //Open the drawer by using the "OpenDrawer" method. m_Drawer.OpenDrawer(); // Wait during open drawer. while (m_Drawer.DrawerOpened == false) { System.Threading.Thread.Sleep(100); } //When the drawer is not closed in ten seconds after opening, beep until it is closed. //If that method is executed, the value is not returned until the drawer is closed. m_Drawer.WaitForDrawerClose(10000, 2000, 100, 1000); //btnOpen.Enabled = true; Cursor.Current = Cursors.Default; } catch (PosControlException) { } catch (NullReferenceException) { } //<<<step1>>>---End }
public void OpenCashDrawer(bool IsWaited = false) { try { string strLogicalName = "CashDrawer"; //PosExplorerを生成します。 PosExplorer posExplorer = new PosExplorer(); DeviceInfo deviceInfo = null; deviceInfo = posExplorer.GetDevice(DeviceType.CashDrawer, strLogicalName); m_Drawer = (CashDrawer)posExplorer.CreateInstance(deviceInfo); try { // m_Drawer.DeviceEnabled = true; } catch { } m_Drawer.Open(); m_Drawer.Claim(1000); //デバイスを使用可能(動作できる状態)にします。 m_Drawer.DeviceEnabled = true; } catch (PosControlException) { } m_Drawer.OpenDrawer(); // ドロワーが開いている間、待ちます。 while (m_Drawer.DrawerOpened == false) { System.Threading.Thread.Sleep(100); } //開いてから10秒間経っても閉じられない場合はビープ音を断続的に鳴らします。 //このメソッドを実行すると、ドロワーが閉じられるまで処理が戻ってこないので注意してください。 if (IsWaited) { m_Drawer.WaitForDrawerClose(10000, 2000, 100, 1000); } try { CloseCashDrawer(); } catch { try { m_Drawer = null; } catch { } } }
/// <summary> /// Finalizes the sale and takes user money and gives user change /// </summary> public void FinalizeSale() { CashDrawer.OpenDrawer(); Pennies += uPennies; Nickels += uNickels; Dimes += uDimes; Quarters += uQuarters; HalfDollars += uHalfDollars; Dollars += uDollars; Ones += uOnes; Twos += uTwos; Fives += uFives; Tens += uTens; Twenties += uTwenties; Fifties += uFifties; Hundreds += uHundreds; Pennies -= changePennies; Nickels -= changeNickels; Dimes -= changeDimes; Quarters -= changeQuarters; HalfDollars -= changeHalfDollars; Dollars -= changeDollars; Ones -= changeOnes; Twos -= changeTwos; Fives -= changeFives; Tens -= changeTens; Twenties -= changeTwenties; Fifties -= changeFifties; Hundreds -= changeHundreds; }
private void openDrawer() { if (m_Drawer != null) { try { //Open the device //Use a Logical Device Name which has been set on the SetupPOS. m_Drawer.Open(); //Get the exclusive control right for the opened device. //Then the device is disable from other application. m_Drawer.Claim(1000); //Enable the device. m_Drawer.DeviceEnabled = true; //Open the drawer by using the "OpenDrawer" method. m_Drawer.OpenDrawer(); m_Drawer.DeviceEnabled = false; m_Drawer.Release(); m_Drawer.Close(); } catch (Exception) { useNativePrinter(); } } else { useNativePrinter(); } }
public void QuarterShouldBeQuater() { CashDrawer.OpenDrawer(); RegisterFunction register = new RegisterFunction(new Order()); Assert.Equal(register.Quarters, CashDrawer.Quarters); CashDrawer.ResetDrawer(); }
public void HalfCoinShouldBeHalfCoins() { CashDrawer.OpenDrawer(); RegisterFunction register = new RegisterFunction(new Order()); Assert.Equal(register.HalfDollars, CashDrawer.HalfDollars); CashDrawer.ResetDrawer(); }
public void OnesShouldBeOnes() { CashDrawer.OpenDrawer(); RegisterFunction register = new RegisterFunction(new Order()); Assert.Equal(register.Ones, CashDrawer.Ones); CashDrawer.ResetDrawer(); }
public void HundredsShouldBeHundreds() { CashDrawer.OpenDrawer(); RegisterFunction register = new RegisterFunction(new Order()); Assert.Equal(register.Hundreds, CashDrawer.Hundreds); CashDrawer.ResetDrawer(); }
public void DollarCoinShouldBeDollarCoin() { CashDrawer.OpenDrawer(); RegisterFunction register = new RegisterFunction(new Order()); Assert.Equal(register.DollarCoin, CashDrawer.Dollars); CashDrawer.ResetDrawer(); }
public void OpenCashDrawer() { myCashDrawer.Open(); myCashDrawer.Claim(1000); myCashDrawer.DeviceEnabled = true; myCashDrawer.OpenDrawer(); myCashDrawer.DeviceEnabled = false; myCashDrawer.Release(); myCashDrawer.Close(); }
public void ChangeOwedIsCorrect() { CashDrawer.OpenDrawer(); Order order = new Order(); order.Add(new AretinoAppleJuice()); RegisterFunction register = new RegisterFunction(order); Assert.Equal(0, register.AmountOwe); CashDrawer.ResetDrawer(); }
private void OpenDrawerButton_Click(object sender, System.EventArgs e) { try { drawer.OpenDrawer(); } catch (Exception ae) { ShowException(ae); } }
public void openCashDrawer2() { myCashDrawer.Open(); myCashDrawer.Claim(1000); myCashDrawer.DeviceEnabled = true; myCashDrawer.OpenDrawer(); myCashDrawer.DeviceEnabled = false; myCashDrawer.Release(); myCashDrawer.Close(); //myCashDrawer.CapStatus }
public void AmountDueIsCorrect() { CashDrawer.OpenDrawer(); Order order = new Order(); order.Add(new AretinoAppleJuice()); RegisterFunction register = new RegisterFunction(order); Assert.Equal(register.AmountDue, register.Total); CashDrawer.ResetDrawer(); }
public static void OpenCashDrawer2() { #if !DEMO if ((activeCashDrawer2 != null) && (activeCashDrawer2.State == ControlState.Idle)) { #if DEBUG ShowActiveCashDrawerWindow(); #endif activeCashDrawer2.OpenDrawer(); } #endif }
public void OpenCashDrawerCase() { try { if (_CashDrawer != null) { _CashDrawer.OpenDrawer(); } } catch (Exception ex) { sMessengeError = ex.Message; } }
public void OpenCashDrawer() { try { myCashDrawer.Open(); myCashDrawer.Claim(1000); myCashDrawer.DeviceEnabled = true; myCashDrawer.OpenDrawer(); myCashDrawer.DeviceEnabled = false; myCashDrawer.Release(); myCashDrawer.Close(); } catch (Exception ex) { } }
private void button3_Click(object sender, EventArgs e) { if (Configuration.UseCashDrawer) { CashDrawer.InitializeDrawer(); CashDrawer.CashDrawerEvent += CashDrawer_CashDrawerEvent; CashDrawer.OpenDrawer(); drawer = new Popups.PopupTellCashDrawer(this, () => { ChoosePrint(); }); Pop(this, drawer); } else { ChoosePrint(); } }
public bool Open() { try { if (_cashDrawer != null && _cashDrawer.Claimed) { _cashDrawer.OpenDrawer(); return(true); } return(true); } catch (Exception ex) { return(true); } }
public void StoreCash() { CashDrawer.OpenDrawer(); DrawerHundredsQuantity += CustomerHundredsQuantity; DrawerFiftiesQuantity += CustomerFiftiesQuantity; DrawerTwentiesQuantity += CustomerTwentiesQuantity; DrawerTensQuantity += CustomerTensQuantity; DrawerFivesQuantity += CustomerFivesQuantity; DrawerTwosQuantity += CustomerTwosQuantity; DrawerOnesQuantity += CustomerOnesQuantity; DrawerHalfDollarsQuantity += CustomerHalfDollarsQuantity; DrawerQuartersQuantity += CustomerQuartersQuantity; DrawerDimesQuantity += CustomerDimesQuantity; DrawerNickelsQuantity += CustomerNickelsQuantity; DrawerPenniesQuantity += CustomerPenniesQuantity; }
public void ChangeShouldStartAtZero() { CashDrawer.OpenDrawer(); RegisterFunction register = new RegisterFunction(new Order()); Assert.Equal(0, register.ChangeDimes); Assert.Equal(0, register.ChangeDollarCoin); Assert.Equal(0, register.ChangeFifties); Assert.Equal(0, register.ChangeFives); Assert.Equal(0, register.ChangeHalfDollars); Assert.Equal(0, register.ChangeHundreds); Assert.Equal(0, register.ChangeNickles); Assert.Equal(0, register.ChangeOnes); Assert.Equal(0, register.ChangePennies); Assert.Equal(0, register.ChangeQuarters); Assert.Equal(0, register.ChangeTens); Assert.Equal(0, register.ChangeTwenties); Assert.Equal(0, register.ChangeTwos); CashDrawer.ResetDrawer(); }
}//end UpdateToCust() /// <summary> /// adds coins in FromCust back into CashDrawer /// </summary> public void AddToDrawer() { CashDrawer.OpenDrawer(); FieldInfo[] allFields = typeof(CashDrawer).GetFields(); List<FieldInfo> allCurrencies = new List<FieldInfo>(); for(int i = 0; i < allFields.Length; i++) { if (allFields[i].Name != "Total") allCurrencies.Add(allFields[i]); }//end looping for each field in all fields of CashDrawer for(int i = 0; i < FromCust.Count; i++) { //supposedly null can be used to set the value of static classes //gets the current number of this i-th currency int cur = (int)allCurrencies[i].GetValue(null); int soon = cur + FromCust[i].Number; //actually sets the property to the value allCurrencies[i].SetValue(null, soon); }//end looping for each type of currency in CashDrawer }//end AddToDrawer
private void button1_Click(object sender, EventArgs e) { if (!Turno.shiftActive) { return; } DarkForm darkForm = new DarkForm(); Form_Login formLogin = new Form_Login(string.Format("Verificación De\nUsuario")); FormShiftAddMoney formShiftAddMoney = new FormShiftAddMoney(); darkForm.Show(); formLogin.ShowDialog(); Empleado empleado = new Empleado(formLogin.ID); if (formLogin.DialogResult == DialogResult.OK && empleado.isAdmin) { if (formShiftAddMoney.ShowDialog() == DialogResult.OK) { //<<< step1 >>> --Start //When outputting to a printer,a mouse cursor becomes like a hourglass. try { if (m_Drawer != null) { //Open the device //Use a Logical Device Name which has been set on the SetupPOS. m_Drawer.Open(); //Get the exclusive control right for the opened device. //Then the device is disable from other application. m_Drawer.Claim(1000); //Enable the device. m_Drawer.DeviceEnabled = true; //Open the drawer by using the "OpenDrawer" method. m_Drawer.OpenDrawer(); m_Drawer.DeviceEnabled = false; m_Drawer.Release(); m_Drawer.Close(); } else { useDefaultPrinter(); } } catch (Exception) { if (m_Drawer != null) { m_Drawer.Release(); m_Drawer.Close(); } useDefaultPrinter(); } //<<<step1>>>--End Turno.AddCashToDrawer(empleado.ID, formShiftAddMoney.cash, formShiftAddMoney.reason); MessageBox.Show("Se realizó correctamente"); this.setGroupBoxInfo(); } } else if (formLogin.DialogResult == DialogResult.OK && !empleado.isAdmin && formLogin.ID > -1) { MessageBox.Show("No tiene los permisos necesarios para realizar esta acción"); } darkForm.Close(); }
/// <summary> /// Method to print the receipt to receipts.txt /// </summary> /// <param name="isCash">Boolean representing whether the method of payment was cash or not</param> /// <param name="thisOrder">The order whose receipt we want to print</param> public void PrintReceipt(bool isCash, Order thisOrder) { CashDrawer.OpenDrawer(); List <string> receipt = new List <string>(); string addLine = ""; StringBuilder sb = new StringBuilder(); int index = 0; receipt.Add("Order #" + thisOrder.Number.ToString()); receipt.Add(DateTime.Now.ToString()); while (index != addLine.Length) { if (sb.Length == 40) { receipt.Add(sb.ToString()); sb.Clear(); } else { sb.Append(addLine[index]); } index++; } receipt.Add(sb.ToString()); foreach (IOrderItem item in thisOrder) { sb.Clear(); index = 0; if (item is ComboMeal comboItem) { receipt.Add("Combo Meal - $" + comboItem.Price.ToString()); receipt.Add(comboItem.Entree.ToString()); foreach (string instruction in comboItem.Entree.SpecialInstructions) { receipt.Add(" -" + instruction); } receipt.Add(comboItem.Drink.ToString()); foreach (string instruction in comboItem.Drink.SpecialInstructions) { receipt.Add(" -" + instruction); } receipt.Add(comboItem.Side.ToString()); foreach (string instruction in comboItem.Side.SpecialInstructions) { receipt.Add(" -" + instruction); } } else { index = 0; addLine = item.ToString(); addLine += " - $" + item.Price; receipt.Add(addLine); foreach (string instruction in item.SpecialInstructions) { addLine = " -" + instruction; receipt.Add(addLine); } } } receipt.Add(""); addLine = "Subtotal: $" + thisOrder.Subtotal; receipt.Add(addLine); addLine = "Tax: $" + thisOrder.Tax; receipt.Add(addLine); addLine = "Total: $" + thisOrder.Total; receipt.Add(addLine); if (isCash) { addLine = "Payment Method: Cash"; receipt.Add(addLine); } else { addLine = "Payment Method: Card"; receipt.Add(addLine); } addLine = "Change Owed: $" + ChangeOwed; receipt.Add(addLine); File.WriteAllLines(@"D:\K-State Computer Science\Semester 5\CIS 400 - OO Design, Implementation, Testing\CIS400\bleakwind-buffet\Debug\receipts.txt", receipt); RoundRegister.RecieptPrinter.CutTape(); }
private void PayBtn_Click(object sender, EventArgs e) { if (this.PO.delivered) { FormPagar formPagar = new FormPagar(this.PO.total - this.PO.pay, true); DarkForm darkForm = new DarkForm(); darkForm.Show(); if (formPagar.ShowDialog() == DialogResult.OK) { this.PO.MakePayment(Convert.ToDouble(formPagar.Pay), this.CurrentEmployeeID); this.updateValues(); if (m_Drawer != null) { try { //Open the device //Use a Logical Device Name which has been set on the SetupPOS. m_Drawer.Open(); //Get the exclusive control right for the opened device. //Then the device is disable from other application. m_Drawer.Claim(1000); //Enable the device. m_Drawer.DeviceEnabled = true; //Open the drawer by using the "OpenDrawer" method. m_Drawer.OpenDrawer(); m_Drawer.DeviceEnabled = false; m_Drawer.Release(); m_Drawer.Close(); } catch (PosControlException) { useNativePrinter(); } } else { useNativePrinter(); } //<<<step1>>>--End MessageBox.Show("Se realizó abono con exito"); if (this.PO.paid) { if (inASearch) { searchPO(); } else { this.loadPurchases(); } } } darkForm.Close(); } else { MessageBox.Show("Primero debe confirmar el pedido para realizar un abono", "No se puede realizar un abono", MessageBoxButtons.OK); } }
public void ShouldNotifyPropertyChange() { CashDrawer.OpenDrawer(); RegisterFunction register = new RegisterFunction(new Order()); Assert.PropertyChanged(register, "CustomerDimes", () => { register.CustomerDimes++; } ); Assert.PropertyChanged(register, "ChangeDimes", () => { register.ChangeDimes++; } ); Assert.PropertyChanged(register, "CustomerDollarCoin", () => { register.CustomerDollarCoin++; } ); Assert.PropertyChanged(register, "ChangeDollarCoin", () => { register.ChangeDollarCoin++; } ); Assert.PropertyChanged(register, "CustomerFifties", () => { register.CustomerFifties++; } ); Assert.PropertyChanged(register, "ChangeFifties", () => { register.ChangeFifties++; } ); Assert.PropertyChanged(register, "CustomerFives", () => { register.CustomerFives++; } ); Assert.PropertyChanged(register, "ChangeFives", () => { register.ChangeFives++; } ); Assert.PropertyChanged(register, "CustomerHalfDollars", () => { register.CustomerHalfDollars++; } ); Assert.PropertyChanged(register, "ChangeHalfDollars", () => { register.ChangeHalfDollars++; } ); Assert.PropertyChanged(register, "CustomerHundreds", () => { register.CustomerHundreds++; } ); Assert.PropertyChanged(register, "ChangeHundreds", () => { register.ChangeHundreds++; } ); Assert.PropertyChanged(register, "CustomerNickles", () => { register.CustomerNickles++; } ); Assert.PropertyChanged(register, "ChangeNickles", () => { register.ChangeNickles++; } ); Assert.PropertyChanged(register, "CustomerOnes", () => { register.CustomerOnes++; } ); Assert.PropertyChanged(register, "ChangeOnes", () => { register.ChangeOnes++; } ); Assert.PropertyChanged(register, "CustomerPennies", () => { register.CustomerPennies++; } ); Assert.PropertyChanged(register, "ChangePennies", () => { register.ChangePennies++; } ); Assert.PropertyChanged(register, "CustomerQuarters", () => { register.CustomerQuarters++; } ); Assert.PropertyChanged(register, "ChangeQuarters", () => { register.ChangeQuarters++; } ); Assert.PropertyChanged(register, "CustomerTens", () => { register.CustomerTens++; } ); Assert.PropertyChanged(register, "ChangeTens", () => { register.ChangeTens++; } ); Assert.PropertyChanged(register, "CustomerTwenties", () => { register.CustomerTwenties++; } ); Assert.PropertyChanged(register, "ChangeTwenties", () => { register.ChangeTwenties++; } ); Assert.PropertyChanged(register, "CustomerTwos", () => { register.CustomerTwos++; } ); Assert.PropertyChanged(register, "ChangeTwos", () => { register.ChangeTwos++; } ); CashDrawer.ResetDrawer(); }
public void OpenDrawer() { _drawer.OpenDrawer(); }