public ActionResult Create(long ID) { if (_session.IsLogin && !_session.IsStore) { ViewBag.IsEdit = true; IOrder _ord = new OrderBO(); Business.Model.ModelWeb.InvoiceModel model = new Business.Model.ModelWeb.InvoiceModel(); model = _ord.GetOrderByID(_session.StoreID, _session.CustomerID, ID); if (ID==-1) { ViewBag.IsNew = true; ViewBag.InvoiceDate = Utils.Utils.FormatDate(DateTime.Now); if (model.Invoice != null) { ViewBag.BillAddress = model.Invoice.Address; ViewBag.DeliveryAddress = model.Invoice.AddressAddr1S; ViewBag.City = model.Invoice.City ?? model.Customer.City; ViewBag.CityShip = model.Invoice.CityShip ?? model.Customer.City; ViewBag.ZipCode = model.Invoice.ZipCode ?? model.Customer.ZipCode; ViewBag.ZipCodeShip = model.Invoice.ZipCodeShip ?? model.Customer.ZipCode; ViewBag.State = model.Invoice.State ?? model.Customer.State; ViewBag.StateShip = model.Invoice.StateShip ?? model.Customer.State; } else { ViewBag.BillAddress = model.Customer.Address; ViewBag.DeliveryAddress = model.Customer.AddressAddr1S; ViewBag.City = model.Customer.City; ViewBag.CityShip = model.Customer.City; ViewBag.ZipCode = model.Customer.ZipCode; ViewBag.ZipCodeShip = model.Customer.ZipCode; ViewBag.State = model.Customer.State; ViewBag.StateShip = model.Customer.State; } ViewBag.InvoiceNo = _ord.GetRefNo(_session.StoreID, "INVOICE"); ViewBag.Amount = "0"; ViewBag.DiscountAmount = "0"; ViewBag.TaxAmount = "0"; ViewBag.TotalAmount = "0"; ViewBag.Description = ""; ViewBag.IsTemplate = false; } else { if (model.Invoice.InvoiceStatus == 0) ViewBag.IsEdit = true; else ViewBag.IsEdit = false; ViewBag.IsNew = false; ViewBag.BillAddress = model.Invoice.Address; ViewBag.DeliveryAddress = model.Invoice.AddressAddr1S; ViewBag.Description = model.Invoice.Notes; ViewBag.InvoiceDate = Utils.Utils.FormatDate(model.Invoice.InvoiceDate?? DateTime.Now); ViewBag.City = model.Invoice.City; ViewBag.CityShip = model.Invoice.CityShip; ViewBag.ZipCode = model.Invoice.ZipCode; ViewBag.ZipCodeShip = model.Invoice.ZipCodeShip; ViewBag.State = model.Invoice.State; ViewBag.StateShip = model.Invoice.StateShip; ViewBag.InvoiceNo = model.Invoice.InvoiceNo; ViewBag.Amount = string.Format("{0:#,###0}", model.Invoice.SubTotal); ViewBag.DiscountAmount = string.Format("{0:#,###0}", model.Invoice.Discount); ViewBag.TaxAmount = string.Format("{0:#,###0}", model.Invoice.SaleTax); ViewBag.TotalAmount = string.Format("{0:#,###0}", model.Invoice.Total); ViewBag.IsTemplate = model.Invoice.IsTemplate; } ViewBag.OrdID = ID; return View(); } else return RedirectToAction("Index", "Home"); }