private IList <ICategory> GetAllCategoriesToBon(IReceipt bon) { string sql = "SELECT kat.Kategorie, kat.ID FROM [BonKategorien] zuordnung join[Kategorien] kat on zuordnung.ID_Kategorie = kat.ID WHERE zuordnung.ID_Bon = " + bon.ID.ToString(); IList <ICategory> retval = new List <ICategory>(); SqlDataReader reader; try { var cmd = new SqlCommand(sql, con); reader = cmd.ExecuteReader(); while (reader.Read()) { var b = reader["Kategorie"]; string name = b as string; var id = reader["ID"]; int idAlsInt = (int)id; retval.Add(_categories.Where(x => x.ID.Equals(idAlsInt)).FirstOrDefault()); } reader.Close(); } catch (Exception ex) { throw new Exception("Fail", ex); } retval = retval.OrderBy(x => x.Name).ToList(); return(retval); }
/// <summary> /// Removes the given item from the collection /// </summary> /// <returns>True, if the item was removed, otherwise False</returns> /// <param name="item">The item that should be removed</param> public override bool Remove(IModelElement item) { IReceipt receiptItem = item.As <IReceipt>(); if (((receiptItem != null) && this._parent.Receipts.Remove(receiptItem))) { return(true); } if ((this._parent.Vendor == item)) { this._parent.Vendor = null; return(true); } ITransaction transactionItem = item.As <ITransaction>(); if (((transactionItem != null) && this._parent.Transactions.Remove(transactionItem))) { return(true); } if ((this._parent.MerchantAccount == item)) { this._parent.MerchantAccount = null; return(true); } return(false); }
public void GenerateRecipt() { recipt = ReciptFactory.ReciptFact(ReciptType.duplicate.ToString()); payment = PaymentFactory.PaymentFact("agent"); Console.WriteLine(recipt.GenerateRecipt()); Console.WriteLine(payment.GenerateComission()); }
private void SaveCategoriesToBon(IReceipt bon) { // Delete: string delCat = "DELETE FROM BonKategorien WHERE ID_Bon = " + bon.ID.ToString(); // SqlDataReader reader; try { SqlCommand cmd = new SqlCommand(delCat, con); cmd.ExecuteNonQuery(); } catch { throw new Exception("Fehler beim LÖschen der Kategorien zu Bon Nr. " + bon.ID.ToString()); } // Insert: string insertSQL; foreach (ICategory cat in bon.Categories) { insertSQL = "INSERT INTO BonKategorien ([ID_Bon] ,[ID_Kategorie]) Values (" + bon.ID.ToString() + ", " + cat.ID.ToString() + ")"; try { var cmd = new SqlCommand(insertSQL, con); cmd.ExecuteNonQuery(); } catch { throw new Exception("Fehler beim Hinzufügen der Kategorien zu Bon Nr. " + bon.ID.ToString()); } } }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { IReceipt receiptsCasted = item.As <IReceipt>(); if ((receiptsCasted != null)) { this._parent.Receipts.Add(receiptsCasted); } if ((this._parent.Vendor == null)) { IVendor vendorCasted = item.As <IVendor>(); if ((vendorCasted != null)) { this._parent.Vendor = vendorCasted; return; } } ITransaction transactionsCasted = item.As <ITransaction>(); if ((transactionsCasted != null)) { this._parent.Transactions.Add(transactionsCasted); } if ((this._parent.MerchantAccount == null)) { IMerchantAccount merchantAccountCasted = item.As <IMerchantAccount>(); if ((merchantAccountCasted != null)) { this._parent.MerchantAccount = merchantAccountCasted; return; } } }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.Cashier == null)) { ICashier cashierCasted = item.As <ICashier>(); if ((cashierCasted != null)) { this._parent.Cashier = cashierCasted; return; } } if ((this._parent.PointOfSale == null)) { IPointOfSale pointOfSaleCasted = item.As <IPointOfSale>(); if ((pointOfSaleCasted != null)) { this._parent.PointOfSale = pointOfSaleCasted; return; } } IReceipt receiptsCasted = item.As <IReceipt>(); if ((receiptsCasted != null)) { this._parent.Receipts.Add(receiptsCasted); } ITransaction transactionsCasted = item.As <ITransaction>(); if ((transactionsCasted != null)) { this._parent.Transactions.Add(transactionsCasted); } }
/// <summary> /// Removes the given item from the collection /// </summary> /// <returns>True, if the item was removed, otherwise False</returns> /// <param name="item">The item that should be removed</param> public override bool Remove(IModelElement item) { if ((this._parent.Cashier == item)) { this._parent.Cashier = null; return(true); } if ((this._parent.PointOfSale == item)) { this._parent.PointOfSale = null; return(true); } IReceipt receiptItem = item.As <IReceipt>(); if (((receiptItem != null) && this._parent.Receipts.Remove(receiptItem))) { return(true); } ITransaction transactionItem = item.As <ITransaction>(); if (((transactionItem != null) && this._parent.Transactions.Remove(transactionItem))) { return(true); } return(false); }
public void ManyYieldsSingleReceiveDelete() { IQueue q = _queue; List <Message> sm = new List <Message>(); for (int i = 0; i < ManyYeildCount; i++) { sm.AddRange(YieldMessages()); } sm.ForEach((m) => q.Send(m)); List <Message> rm = new List <Message>(); for (int i = 0; i < sm.Count * 2; i++) { IReceipt rt = q.Receive(); if (rt != null) { rm.Add(rt.GetMessage <Message>()); rt.Delete(); } } AssertSentReceivedMessages( sm, rm); }
public void SetOSAgainstReceiptItem(IReceipt pyi) { double qtyAmount = pyi.GET_AMOUNT; if (qtyAmount <= 0) { return; } if (AGAINST_RECEIPT_STATUS == AgainstStatus.Close) { throw new Exception("Invoice Item Allready Close :" + this.INVOICE_NO); } if (qtyAmount > OUTSTANDING_AMOUNT) { throw new Exception("Receipt Item Amount exceed SIJ Outstanding Item Amount :" + this.INVOICE_NO); } OUTSTANDING_AMOUNT = OUTSTANDING_AMOUNT - qtyAmount; RECEIPT_AMOUNT = RECEIPT_AMOUNT + qtyAmount; if (isValidToClose()) { AGAINST_RECEIPT_STATUS = AgainstStatus.Close; } else { AGAINST_RECEIPT_STATUS = AgainstStatus.Outstanding; } ((CustomerInvoiceJournal)EVENT_JOURNAL).UpdateAgainstReceiptStatusSIJ(); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.Receipt == null)) { IReceipt receiptCasted = item.As <IReceipt>(); if ((receiptCasted != null)) { this._parent.Receipt = receiptCasted; return; } } if ((this._parent.Cheque == null)) { ICheque chequeCasted = item.As <ICheque>(); if ((chequeCasted != null)) { this._parent.Cheque = chequeCasted; return; } } if ((this._parent.Card == null)) { ICard cardCasted = item.As <ICard>(); if ((cardCasted != null)) { this._parent.Card = cardCasted; return; } } }
public static T GetMessage <T>(this IReceipt receipt) where T : IDictionary <string, string>, new() { using (XmlReader reader = XmlReader.Create(new StringReader(receipt.Message))) { return(reader.ReadMessage <T>()); } }
public BonViewModel(IReceipt bon, DBConnector dbConnection) { _DBConnection = dbConnection; _bon = bon; _user = _bon.User; _payDate = _bon.PayDate; _details = _bon.Details; _amount = bon.Amount; _settlementDate = _bon.SettlementDate; _id = _bon.ID; _settled = _bon.Settled; _paymentType = _bon.PaymentType; _payments = _bon.Payments; _categoryAdapter = new CategoryAdapter(bon.Categories, dbConnection); Balance = false; LoadPaymentViewModels(); NewPaymentCommand = new ActionCommand(NewPayment, null); SaveBonCommand = new ActionCommand(SaveBon, CanSaveBon); EditBonCommand = new ActionCommand(EditBon, CanEditBon); LiftPayDateCommand = new ActionCommand(LiftPayDate, null); ReducePayDateCommand = new ActionCommand(ReducePayDate, null); CanBeEdited = false; }
private void SaveCurrentBon() { //CurrentBon.Save(); IReceipt bon = CurrentBon.Bon; int id = _DBConnection.SaveBon(bon); // CurrentBon = null; }
public IReceipt Buy() { NotifyObservers(); IReceipt receipt = _payStationFactory.CreateReceipt(_minutes); Reset(); return(receipt); }
private static IReceipt ToCancelReceipt(IReceipt existingReceipt, CancelReceipt request) { var receipt = ((Receipt.Repository.OrmLite.Receipt)existingReceipt).CreateCopy(); receipt.Status = (int)ReceiptStatusConstant.Cancelled; receipt.Note = request.Note; return(receipt); }
private IReceipt ToPayReceipt(IReceipt existingReceipt, PayReceipt request) { var receipt = ((Repository.Receipt)existingReceipt).CreateCopy(); receipt.Status = (int)ReceiptStatusConstant.Paid; receipt.Note = request.Note; return(receipt); }
public string BuildHtmlReceipt(IReceipt receipt)///(IHeader header, IList<IBody> body, IFooter footer) { return(_builder.Init() .BuildHeader(receipt.Header) .BuildBody(receipt.Groceries) .BuildFooter(receipt.Footer) .BuildTemplate() .GetResult()); }
public IReceiptBuilder Init() { _receipt = new Receipt(); _groceries = new List <IBody>(); _header = new StringBuilder(); _body = new StringBuilder(); _footer = new StringBuilder(); return(this); }
public ReceiptCalculatorTests() { _container = Bootstrapper.Bootstrap(); var shoppingCartsRepository = _container.GetService <IShoppingCartsRepository>(); var shoppingCart = shoppingCartsRepository.GetShoppingCart(Ids.ShoppingCartId); var receiptCalculator = _container.GetService <IReceiptCalculator>(); _receipt = receiptCalculator.CalculateReceipt(shoppingCart); }
public void ShouldResetDisplayWhenBuying() { _ps.AddPayment(25); Assert.That(_ps.ReadDisplay(), Is.EqualTo(1010)); IReceipt receipt = _ps.Buy(); Assert.That(_ps.ReadDisplay(), Is.EqualTo(1000)); Assert.That(receipt.Value(), Is.EqualTo(10)); }
public BusinessLogic(ILogger logger, IReceipt receipt, IDataAccess dataAccess, IShoppingCart shoppingCart) { if (logger == null || receipt == null || dataAccess == null || shoppingCart == null) { throw new ArgumentNullException(); } _logger = logger; _receipt = receipt; _dataAccess = dataAccess; _shoppingCart = shoppingCart; }
public void ShouldProduceValidReceiptWhenBuying(int[] coins, int minutes) { foreach (var coin in coins) { _ps.AddPayment(coin); } IReceipt receipt = _ps.Buy(); Assert.That(receipt, Is.Not.Null); Assert.That(receipt.Value(), Is.EqualTo(minutes)); }
public void UnSetOSAgainstReceiptItem(IReceipt grni) { double qtyAmount = grni.GET_AMOUNT; if (qtyAmount > this.AMOUNT || OUTSTANDING_AMOUNT + qtyAmount > this.AMOUNT) { throw new Exception("Receipt Item revise Amount exceed SIJ Item Amount :" + this.INVOICE_NO); } OUTSTANDING_AMOUNT = OUTSTANDING_AMOUNT + qtyAmount; RECEIPT_AMOUNT = RECEIPT_AMOUNT - qtyAmount; if (OUTSTANDING_AMOUNT > 0) { AGAINST_RECEIPT_STATUS = AgainstStatus.Outstanding; } ((CustomerInvoiceJournal)EVENT_JOURNAL).UpdateAgainstReceiptStatusSIJ(); }
private void CalculateTotals(IReceipt receipt) { var productTotal = 0m; var taxTotal = 0m; foreach (var item in receipt.ShoppingCart.Items) { productTotal += item.Product.Price * item.Quantity; foreach (var tax in item.Taxes) { taxTotal += tax.Value; } } receipt.Total = productTotal + taxTotal; receipt.TaxTotal = receipt.Total - productTotal; }
public ChatWindow(IInputManager inputManager, IGuiFrame chatFrame) { if (inputManager == null) { throw new ArgumentNullException("inputManager"); } SetupSlashCommands(); mChatFrame = chatFrame; mChatEntryBox = mChatFrame.SelectSingleElement <Textbox>("ChatEntryTextbox"); //mChatLogFrame = (mChatFrame.SelectSingleElement<TabButton>("BottomLeftTabView/ButtonsFrame/ChatLogTab")).Frame; //mLocalChatPrototype = mChatLogFrame.SelectSingleElement<Textbox>("**/MyMessages"); //mChatLogFrame.RemoveChildWidget(mLocalChatPrototype); Hangout.Shared.Action chatSend = delegate() { // Get chat from text entry box, and clear it String chatText = mChatEntryBox.Text; mChatEntryBox.Text = ""; Hangout.Shared.Action slashCommand; if (mSlashCommands.TryGetValue(chatText, out slashCommand)) { slashCommand(); } else { // Filter out empty string if (chatText != "") { // Dispatch chat event. This will get picked up by SendChatCommand object[] args = { chatText }; GameFacade.Instance.SendNotification(GameFacade.SEND_CHAT, args); } } }; mInputReceiptReturn = inputManager.RegisterForButtonDown(KeyCode.Return, chatSend); // If numlock is down, some laptops send this event instead mInputReceiptEnter = inputManager.RegisterForButtonDown(KeyCode.KeypadEnter, chatSend); }
// Make an immediate call to Javascript that bypasses our list of allowed functions // and will never be deferred until later. Use this only if the call needs to // occur before mAllowedCalls is populated. private IReceipt MakeForcedJSCall(string func, List <object> argList, Action <string> callbackFunc) { bool forcedKey = false; if (!mAllowedCalls.ContainsKey(func)) { forcedKey = true; mAllowedCalls.Add(func, true); } IReceipt rec = MakeJSCall(func, argList, callbackFunc); if (forcedKey) { mAllowedCalls.Remove(func); } return(rec); }
public void StartListeningForInput() { if (!mInputStarted) { mInputStarted = true; mInputManager.StartInput(); mRegisterForMouseDownReceipt = mInputManager.RegisterForButtonDown(KeyCode.Mouse0, MouseDown); mRegisterForMouseUpReceipt = mInputManager.RegisterForButtonUp(KeyCode.Mouse0, MouseUp); mRegisterForMousePositionReceipt = mInputManager.RegisterForMousePosition(MousePosition); if (Application.isEditor) { mInputManager.RegisterForButtonDown(KeyCode.Semicolon, delegate() { GameFacade.Instance.RetrieveMediator <FashionLevel>().ReloadStationPositions(); }); } } }
public Motor(LocalAvatarEntity localAvatarEntity) { mLocalAvatarEntity = localAvatarEntity; GameObject gameObjectToMotorize = localAvatarEntity.UnityGameObject; if (gameObjectToMotorize == null) { throw new ArgumentNullException("gameObjectToMotorize"); } mRigidBody = gameObjectToMotorize.GetComponent(typeof(Rigidbody)) as Rigidbody; if (mRigidBody == null) { mRigidBody = gameObjectToMotorize.AddComponent(typeof(Rigidbody)) as Rigidbody; } mScheduler = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler; mCollisionReceipt = CollisionUtility.ListenForCollisions(mRigidBody, StopMovingWhenHitGround); }
/// <summary> /// Schliesst die Zahlung ab, sofern genug Geld eingeworfen wurde. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _btnFertig_Click(object sender, RoutedEventArgs e) { GasPump selectedGasPump = (GasPump)GasPumpComboBox.SelectedItem; int[] outputCoins = new int[1]; try { outputCoins = Context.FinishInput(selectedGasPump); if (outputCoins[0] == -1) { _tbxAnzeige.Text += $"\r\nEs wurde noch zu wenig Geld eingeworfen. Es fehlen noch {selectedGasPump.ToPayValue - decimal.Parse(Context.GetValueInput().ToString()) / 100} Franken."; } else { _tbxAnzeige.Text += "\r\nAusgabe:\r\n"; RenderNumberOfCoins(outputCoins); DisableButtons(); IReceipt receipt = Context.CreateReceipt(selectedGasPump); selectedGasPump.ToPayValue = 0; ReceiptDisplay receiptDisplay = new ReceiptDisplay(); receiptDisplay.Context = receipt; receiptDisplay.Show(); } } catch (Exception ex) { if (ex.Message.StartsWith("Es kann leider kein Rückgeld gegeben werden.")) { MessageService.AddWarningMessage("Fehler", $"{ex.Message}\r\n{ex.Source}\r\n{ex.StackTrace}"); } else { MessageService.AddErrorMessage("Fehler", ex.Message); } return; } }
private IList <IPayment> GetAllPaymentsToBon(IReceipt bon) { string strSQL = "SELECT z.* from Zahlungen z join Bon b on b.ID = z.idBon WHERE z.idBon = " + bon.ID.ToString(); IList <IPayment> retval = new List <IPayment>(); SqlDataReader reader; try { var cmd = new SqlCommand(strSQL, con); reader = cmd.ExecuteReader(); while (reader.Read()) { var id = reader["ID"]; int idAlsInt = (int)id; var c = reader["Zahlungstyp"]; string paymentType = c as string; double amount = Convert.ToDouble(reader["Betrag"]); string details = reader["Details"] as string; IPayment payment = new Payment(idAlsInt, amount, details, paymentType); retval.Add(payment); } reader.Close(); } catch (Exception ex) { throw new Exception("Fail", ex); } foreach (IPayment payment in retval) { payment.Categories = GetAllCategoriesToPayment(payment); } return(retval); }