private OrderDispatchModel TransformAuctionToOrdeDispatchModel(OrderDispatch od) { var odm = new OrderDispatchModel { DispatchId = od.DispatchId, OrderId = od.OrderId, ClientId = od.CarrierId, DispatchDate = od.DispatchDate, DispatchValue = od.DispatchValue, DispatchWeight = od.DispatchWeight, Observation = od.Observation, CompanyName = od.CompanyName, Destination = od.Destination, PhoneNumber = od.PhoneNumber, Status = od.Status, Products = od.Products }; return(odm); }
//============ public string PrintOrderData(OrderDispatchModel model, string Path) { int oulte = getOutletId(); var outletData = (from p in _entities.tblOutlets where p.OutletId == oulte select p).SingleOrDefault(); XDocument xd = XDocument.Load(Path); var result = from item in xd.Descendants("Items") where item.Element("UserId").Value == oulte.ToString() && item.Element("TableNo").Value == model.TableNo.ToString() select item; int counter = 1; StringBuilder sb = new StringBuilder(); var VatDetail = (from p in xd.Descendants("Items") where p.Element("UserId").Value == oulte.ToString() && p.Element("TableNo").Value == model.TableNo.ToString() group p by p.Element("VatAmt").Value into g select new { Vat = g.Key, amtCharges = g.Sum(a => Convert.ToDecimal(a.Element("VatAmountCharges").Value)) // xd.Descendants("Items").Sum(a => Convert.ToDecimal(a.Element("VatAmountCharges").Value)) }).ToList(); sb.Append("<div style='width:300px;height:auto;'>"); sb.Append("<div class='logo' style='border-bottom:1px dashed'>"); sb.Append("<b style='margin-left:90px;font-size:23px;'>Nibs Cafe</b></br>"); sb.Append("<strong style='margin-left:50px; font-size:17px;'>A Unit of KGC Enterprises</strong></br>"); sb.Append("<strong style='margin-left:50px; font-size:17px;'>TIN No:" + outletData.TinNo + "</strong></br>"); sb.Append("<strong style='margin-left:50px; font-size:17px;'>ServiceTax No:" + outletData.ServiceTaxNo + "</strong></br>"); sb.Append("<div>"); sb.Append("<b style='margin-left:50px; font-weight:100;font-size: 19px;'>" + outletData.Address + "</b><br />"); sb.Append("<b style='margin-left:50px; font-weight:100;font-size: 19px;'>Jaipur-302029</b><b style='margin-left:10px; font-weight:100'>PH:" + outletData.ContactA + "</b><br />"); //sb.Append("<b style='margin-left:50px; font-weight:100'>PH:9680625173</b><br />"); sb.Append("<b style='margin-left:90px;font-size: 19px;'>Sales Invoice</b></div></div>"); sb.Append("<div style='width: 300px; float:left; height: 35px; border-bottom: 1px dashed;font-size: 18px;'>"); sb.Append("<div style='width:200px;height:35px;float:left; padding-top:9px;'>Name:<b>" + model.CustomerName + "</b></div>"); sb.Append("<div style='width:100px;height:35px;float:left;padding-top:9px;'>Table No:<b>" + model.TableNo + "</b></div></div>"); sb.Append("<div style='width:350px;height:auto; float:left;'>"); sb.Append("<table style='width:350px;font-size: 19px;'>"); sb.Append(" <tr><th style='text-align:left'>Sr</th><th style='text-align:left'>Item</th><th style='text-align:left'>F</th><th style='text-align:left'>H</th><th style='text-align:left'>Amt</th></tr><tbody>"); foreach (var item in result) { int Itemid = Convert.ToInt32(item.Element("ItemId").Value); if (Itemid == 0) { var amount = item.Element("Amount").Value; decimal amt = Convert.ToDecimal(amount); sb.Append("<tr><td>" + counter + "</td> <td>" + item.Element("ItemName").Value + "</td><td>" + item.Element("FullQty") + "</td><td>" + item.Element("HalfQty") + "</td><td>" + Math.Round(amt, 2) + "</td></tr>"); } else { var Name = _entities.tblItems.Where(o => o.ItemId == Itemid).Select(x => x.Name).SingleOrDefault(); var amount = item.Element("Amount").Value; decimal amt = Convert.ToDecimal(amount); sb.Append("<tr><td>" + counter + "</td> <td>" + Name + "</td><td>" + item.Element("FullQty") + "</td><td>" + item.Element("HalfQty") + "</td><td>" + Math.Round(amt, 2) + "</td></tr>"); } } sb.Append("</tbody></table></div>"); sb.Append("<div style='width: 300px; border-top: 1px dashed; float:left;'>"); sb.Append("<div style='width:226px;float:left; height:auto; margin-top:20px;line-height:20px;font-size: 18px;'>"); foreach (var item in VatDetail) { sb.Append("<b>Vat Amount(" + item.Vat + "%)</b><br />"); } //sb.Append("<b>Service Tax(4.94)</b><br /><b>Total Amount</b><br /> <b>Discount Amount</b><br /><b>Net Amount</b><br /></div>"); sb.Append("<b>Service Tax(5.6)</b><br /><b>Total Amount</b><br /> <b>Discount Amount</b><br /><b>Net Amount</b><br /></div>"); sb.Append("<div style='width: 70px; margin-top: 20px; line-height: 20px; float: left; height: auto;font-size: 20px;'>"); foreach (var item in VatDetail) { sb.Append(Math.Round(item.amtCharges, 2) + "<br/>"); } sb.Append(model.ServiceCharge + "<br />" + model.TotalAmount + "<br /><b>" + model.DiscountAmount + "</b><br /><b>" + model.NetAmount + "</b>"); sb.Append("</div></div><div style='width:300px;text-align:center; height:20px; margin-top:15px;border-top:1px dashed; float:left'>" + DateTime.Now + "</div></div>"); //<tr><td>1</td> <td>Hot Pizza</td><td>2</td><td>0</td><td>240.0000</td></tr><tr><td>1</td> <td>Pizza 1</td><td>1</td><td>0</td><td>130.0000</td></tr> return(sb.ToString()); }