/// <summary> /// Prints receipt /// </summary> /// <param name="pay"> number that represents the method of payment</param> private void Receipt(int pay) { ReceiptPrinter r = new ReceiptPrinter(); StringBuilder sb = new StringBuilder(); sb.Append("\t Cowboy Cafe\n _________________________________________\n\nOrder #" + OrderNumber.ToString() + "\t\t\t" + DateTime.Now + "\n\n"); foreach (IOrderItem i in Items) { sb.Append(i.ToString() + "\t\t " + i.Price.ToString("C2")); foreach (string st in i.SpecialInstructions) { sb.Append("\n\t" + st); } sb.Append("\n"); } sb.Append("\nSubtotal: " + Subtotal.ToString("C2") + "\nTax: \t " + Tax.ToString("C2") + "\nTotal: \t " + Total.ToString("C2") + "\n"); if (pay == 0) { sb.Append("\nPaid: \t" + Paid.ToString("C2")); } else { sb.Append("\nCredit: \t " + Paid.ToString("C2")); } sb.Append("\nChange: \t " + Change.ToString("C2")); string s = sb.ToString(); MessageBox.Show(s); r.Print(s); s = "Contents of the Cash Drawer\n\n____________________________\n Coins\n____________________________\n\nPennies: " + cd.Pennies + "\nNickels: " + cd.Nickels + "\nDimes: " + cd.Dimes + "\nQuarters: " + cd.Quarters + "\nHalf Dollars: " + cd.HalfDollars + "\nDollars: " + cd.Dollars + "\n\n____________________________\n Bills\n____________________________\n\nOnes: " + cd.Ones + "\nTwos: " + cd.Twos + "\nFives: " + cd.Fives + "\nTens: " + cd.Tens + "\nTwenties: " + cd.Twenties + "\nFifties: " + cd.Fifties + "\nHundreds: " + cd.Hundreds + "\n\n____________________________\nCash Drawer Total: " + cd.TotalValue.ToString("C2") + "\n____________________________\n"; MessageBox.Show(s); NewOrder(); }
private string Validate(string propertyName) { // Return error message if there is error on else return empty or null string string validationMessage = string.Empty; if (_firstLoad) { return(validationMessage); } switch (propertyName) { case "Current": if (!double.TryParse(Current.ToString(), out uselessParse)) { validationMessage = "Only Digits Are Allowed"; } break; case "Paid": if (!double.TryParse(Paid.ToString(), out uselessParse)) { validationMessage = "Only Digits Are Allowed"; } break; } return(validationMessage); }
public override string ToString() { string res = $"{Date.ToString()} {Type.ToString()}\n"; res += $"Paid: {Paid.ToString()}\n"; res += $"Received: {Received.ToString()}\n"; res += $"Fees: {Fees.ToString()}\n"; res += $"XChange Rate: {XRate.ToString()}\n"; return(res); }
/// <summary> /// Creates the reciept to be sent to the printer /// </summary> /// <param name="cardOrCash">0 if card 1 if cash</param> private void PrintReceipt(int cardOrCash) { ReceiptPrinter rp = new ReceiptPrinter(); StringBuilder sb = new StringBuilder(); sb.Append("---------- COWBOY CAFE ----------\n"); sb.Append(DateTime.Now + "\n"); sb.Append("Order #: " + PrevOrderNumber + "\n"); /* Iterate over all items */ foreach (IOrderItem i in Items) { sb.Append(i.ToString() + "\t\t" + i.Price.ToString("C2") + "\n"); /* Iterate through the special instruction for the item i */ foreach (string s in i.SpecialInstructions) { sb.Append(s + "\n"); } sb.Append("\n"); } sb.Append("Subtotal: " + Subtotal.ToString("C2") + "\n"); sb.Append("Tax: " + Tax.ToString("C2") + "\n"); sb.Append("Total: " + TotalWithTax.ToString("C2") + "\n\n"); if (cardOrCash == 1) { sb.Append("Paid: " + Paid.ToString("C2") + "\n"); sb.Append("Change: " + Change.ToString("C2") + "\n"); } else { sb.Append("Credit Card was used!\n"); } string sr = sb.ToString(); MessageBox.Show(sr); rp.Print(sr); ShowDrawerContents(); SetNewOrder(); }
protected void Page_Load(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand("select AccountMaster.MemberID ,tblmembermaster.UserName,Sum(case when dateoftransaction>=getdate()then isnull(Credit,0) else 0 end) as Remaining, Sum(case when dateoftransaction<getdate()then isnull(Credit,0) else 0 end) as Paid,Sum(Credit) as Total from AccountMaster Inner Join tblMemberMaster on AccountMaster.MemberID=tblMemberMaster.UserCode WHERE TxnType=3 Group by AccountMaster.MemberID,tblmembermaster.UserName", con); SqlDataAdapter da = new SqlDataAdapter(cmd); using (DataTable dt = new DataTable()) { da.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); total = dt.AsEnumerable().Sum(row => row.Field <decimal>("Total")); Paid = dt.AsEnumerable().Sum(row => row.Field <decimal>("Paid")); Remaining = dt.AsEnumerable().Sum(row => row.Field <decimal>("Remaining")); GridView1.FooterRow.Cells[2].Text = "Total"; GridView1.FooterRow.Cells[3].Text = total.ToString(); GridView1.FooterRow.Cells[4].Text = Paid.ToString(); GridView1.FooterRow.Cells[5].Text = Remaining.ToString(); } }
public string PaidString() { return(Paid.ToString("c")); }
/// <summary> /// Vygeneruje z nákupního košíku XML účtenku /// </summary> public void GenerateXmlFile(string filename, List <ShoppingCartItem> ShoppingCart, DateTime time) { if (!Directory.Exists(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "PASS", "Bill"))) { Directory.CreateDirectory(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "PASS", "Bill")); } using (XmlWriter xmlWriter = XmlWriter.Create(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "PASS", "Bill", filename))) { xmlWriter.WriteRaw("<?xml-stylesheet type=\"text/xsl\" href=\"../CashRegister/Bill.xslt\"?>"); xmlWriter.WriteStartElement("bill"); foreach (ShoppingCartItem item in ShoppingCart) { xmlWriter.WriteStartElement("product"); xmlWriter.WriteElementString("name", item.AddedProduct.name.Trim()); xmlWriter.WriteElementString("quantity", item.Quantity.ToString()); xmlWriter.WriteElementString("unit", item.UnitName.Trim()); if (!item.AddedProduct.priceForUnit) { xmlWriter.WriteElementString("unitQuantity", item.AddedProduct.unitQuantity.ToString()); } xmlWriter.WriteElementString("expirationDate", ((DateTime)item.AddedProduct.expirationDate).ToString("dd.MM.yyyy")); xmlWriter.WriteElementString("code", item.AddedProduct.code.ToString()); xmlWriter.WriteElementString("totalPrice", item.TotalPrice.ToString()); xmlWriter.WriteElementString("priceForUnit", item.AddedProduct.priceForUnit.ToString()); xmlWriter.WriteElementString("priceForSingleUnit", item.AddedProduct.price.ToString()); xmlWriter.WriteElementString("vatType", item.AddedProduct.vatId.ToString()); xmlWriter.WriteEndElement(); } xmlWriter.WriteElementString("totalShoppingCartPrice", Sum.ToString()); xmlWriter.WriteElementString("paid", Paid.ToString()); xmlWriter.WriteElementString("change", Change.ToString()); xmlWriter.WriteElementString("staff", PASS.GeneralClasses.Authentification.AuthUser.Username); xmlWriter.WriteElementString("time", time.ToShortDateString() + " " + time.ToShortTimeString()); //DPH se počítá dohromady pro všechny výrobky dané kategorie (A,B,C,D) List <VAT> listOfVat = GetVat(); decimal? vatSum = GetVatSum(listOfVat); decimal? vatSumSingle = GetVatSumSingle(listOfVat); xmlWriter.WriteElementString("vatSum", string.Format("{0:0.00}", vatSum)); xmlWriter.WriteElementString("vatSumSingle", string.Format("{0:0.00}", vatSumSingle)); foreach (VAT singleVat in listOfVat) { xmlWriter.WriteStartElement(singleVat.id.ToString()); xmlWriter.WriteAttributeString("percentage", singleVat.percentage); xmlWriter.WriteAttributeString("totalPrice", string.Format("{0:0.00}", singleVat.vatValueProducts)); xmlWriter.WriteString(string.Format("{0:0.00}", singleVat.vatValue)); xmlWriter.WriteEndElement(); } //Informace do hlavičky Company company = CompanyInfo.GetCompanyInfo(); xmlWriter.WriteElementString("companyName", company.name.Trim()); // Name je vždy vyplněné //Další nepovinné údaje, pokud chybí, tak se to do XML nebude přidávat if (!string.IsNullOrEmpty(company.adress)) { xmlWriter.WriteElementString("companyAdress", company.adress.Trim()); } if (!string.IsNullOrEmpty(company.city)) { xmlWriter.WriteElementString("companyCity", company.city.Trim()); } if (company.postalCode != null) { xmlWriter.WriteElementString("companyPostalCode", company.postalCode.ToString()); } if (!string.IsNullOrEmpty(company.phone)) { xmlWriter.WriteElementString("companyPhone", company.phone.Trim()); } if (!string.IsNullOrEmpty(company.web)) { xmlWriter.WriteElementString("companyWeb", company.web.Trim()); } Bill billInfo = BillInfo.GetBillInfo(); if (!string.IsNullOrEmpty(billInfo.billText)) { xmlWriter.WriteElementString("billText", billInfo.billText.Trim()); } xmlWriter.WriteEndElement(); } }
public override string ToString() { return("[ ID = " + RentID + ". RentDate = " + RentDate.ToShortDateString() + ". DateGet = " + DateGet.ToShortDateString() + ". CarID = " + Car.CarID + ". ClientId = " + Client.Id + ". RentPrice = " + RentPrice + ". Paid = " + Paid.ToString() + ". WorkerFIO = " + WorkerFIO + ". ]"); }