public void AddCustomerandSaleHeader() { FFREntities ffrDb = new FFREntities(); Customer customer = new Customer(); customer.FirstName = "Nick"; customer.LastName = "Olsen"; customer.City = "Parker"; customer.State = "CO"; customer.Zip = "80134"; //Need to Add Street Name and Suite Fields customer.Address = customer.FirstName + " " + customer.LastName + "11321 Lovage Way " + customer.City + ", " + customer.State + " " + customer.Zip; customer.Phone = "3037181336"; customer.Email = "*****@*****.**"; ffrDb.Customers.Add(customer); ffrDb.SaveChanges(); SalesHeader salesHeader = new SalesHeader(); //salesHeader.CustomerId = 1; salesHeader.SalesStatus = "Open"; salesHeader.OrderSalesBalance = 50; salesHeader.OrderTaxAmount = 5; salesHeader.OrderTotal = salesHeader.OrderSalesBalance + salesHeader.OrderTaxAmount; ffrDb.SalesHeaders.Add(salesHeader); ffrDb.SaveChanges(); }
public void InstantiateCallerRequested(XmlWriter localXmlWriter, string xmlFileName) { customer = null; item = null; salesHeader= null; salesItem = null; employee = null; XmlReader xmlReader = XmlReader.Create(xmlFileName); while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "Customer") { customer = Activator.CreateInstance<Customer>(); break; } if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "Item") { item = Activator.CreateInstance<Item>(); break; } if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "SalesHeader") { salesHeader = Activator.CreateInstance<SalesHeader>(); break; } if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "SalesItem") { salesItem = Activator.CreateInstance<SalesItem>(); break; } if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "Employee") { employee = Activator.CreateInstance<Employee>(); break; } //throw Exception("No Caller Requested found in XML"); } xmlReader.Close(); }
public void CreateSalesHeaderUsingRepository() { var SalesHeaderRepo = new DataRepository<SalesHeader>(); SalesHeader createSalesHeader = new SalesHeader(); createSalesHeader.OrderSalesBalance = 800; createSalesHeader.OrderTaxAmount = 100; createSalesHeader.OrderTotal = 900; SalesHeaderRepo.Create(createSalesHeader); }
public int GetSalesId() { if (HttpContext.Current.Session[SalesIdSessionKey] == null) { /*if (!string.IsNullOrWhiteSpace(HttpContext.Current.User.Identity.Name)) { HttpContext.Current.Session[SalesIdSessionKey] = HttpContext.Current.User.Identity.Name; } else { // Generate a new random GUID using System.Guid class. Guid tempCartId = Guid.NewGuid(); HttpContext.Current.Session[SalesIdSessionKey] = tempCartId.ToString(); }*/ HttpContext.Current.Session[SalesIdSessionKey] = 1001; var shoppingCartHeader = new SalesHeader(); shoppingCartHeader.SalesId = Convert.ToInt16(HttpContext.Current.Session[SalesIdSessionKey]); shoppingCartHeader.CustomerId = 1; _db.SalesHeaders.Add(shoppingCartHeader); _db.SaveChanges(); } return 1;//Convert.ToInt16(HttpContext.Current.Session[SalesIdSessionKey]); }
public void UpdateSalesHeader() { FFREntities ffrDb = new FFREntities(); SalesHeader salesHeader = new SalesHeader(); salesHeader.CustomerId = 1; salesHeader.SalesStatus = "Update"; salesHeader.OrderSalesBalance = 50; salesHeader.OrderTaxAmount = 5; salesHeader.OrderTotal = salesHeader.OrderSalesBalance + salesHeader.OrderTaxAmount; ffrDb.SalesHeaders.Add(salesHeader); ffrDb.SaveChanges(); SalesHeader updateSalesHeader = (from d in ffrDb.SalesHeaders where d.SalesStatus == "Update" select d).Single(); updateSalesHeader.SalesStatus = "Record has been updated!"; ffrDb.SaveChanges(); }
public void DeleteSalesHeader() { FFREntities ffrDb = new FFREntities(); SalesHeader salesHeader = new SalesHeader(); salesHeader.SalesStatus = "Delete"; salesHeader.OrderSalesBalance = 50; salesHeader.OrderTaxAmount = 5; salesHeader.OrderTotal = salesHeader.OrderSalesBalance + salesHeader.OrderTaxAmount; ffrDb.SalesHeaders.Add(salesHeader); ffrDb.SaveChanges(); SalesHeader deleteSalesHeader = (from d in ffrDb.SalesHeaders where d.SalesId == 2 select d).Single(); ffrDb.SalesHeaders.Remove(deleteSalesHeader); ffrDb.SaveChanges(); }