public object CreateOrder(Orderdetail orderdetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } orderdetail.IsConfirmed = false; orderdetail.OrderDate = DateTime.Now; orderdetail.Status = "Placed"; db.Orderdetails.Add(orderdetail); int y = db.SaveChanges(); //db.Orderdetails.Add(new Orderdetail() //{ // CustomerId = orderdetail.CustomerId, // CustomerName = orderdetail.CustomerName, // DeliveryAddress = orderdetail.DeliveryAddress, // Phone = orderdetail.Phone, // OrderDate = DateTime.Now, // OrderPayMethod = orderdetail.OrderPayMethod, // PaymentReferenceId = orderdetail.PaymentReferenceId, // IsConfirmed = true, // Status = "Placed" //}); //return CreatedAtRoute("DefaultApi", new { id = orderDetail.OrderID }, orderDetail); return(y); }
public async Task<ActionResult<Orderdetail>> PostOrderdetail(Orderdetail orderdetail) { _context.Orderdetails.Add(orderdetail); await _context.SaveChangesAsync(); return CreatedAtAction("GetOrderdetail", new { id = orderdetail.ID }, orderdetail); }
public ActionResult <Orderdetail> Get(int id) { Orderdetail orderdetail = new Orderdetail(); string userapi = (Environment.GetEnvironmentVariable("userapi") != null ? Environment.GetEnvironmentVariable("userapi"): "https://localhost:1234/"); string orderapi = (Environment.GetEnvironmentVariable("orderapi") != null ? Environment.GetEnvironmentVariable("orderapi"): "https://localhost:2345/"); using (var client = new HttpClient()) { client.BaseAddress = new Uri(userapi); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.GetAsync("user/1").Result; if (response.IsSuccessStatusCode) { string responseString = response.Content.ReadAsStringAsync().Result; orderdetail.UserDetails = response.Content.ReadAsAsync <User>().Result; } } using (var client = new HttpClient()) { client.BaseAddress = new Uri(orderapi); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.GetAsync("orders/1").Result; if (response.IsSuccessStatusCode) { string responseString = response.Content.ReadAsStringAsync().Result; orderdetail.Orders = response.Content.ReadAsAsync <IEnumerable <Order> >().Result; } } return(Ok(orderdetail)); }
public async Task <IActionResult> PutOrderdetail(int id, Orderdetail orderdetail) { if (id != orderdetail.DetailId) { return(BadRequest()); } _context.Entry(orderdetail).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException e) { if (!OrderdetailExists(id)) { return(NotFound()); } else { throw e; } } return(NoContent()); }
public async Task <IActionResult> Edit(int id, [Bind("OrderNumber,ProductCode,QuantityOrdered,PriceEach,OrderLineNumber")] Orderdetail orderdetail) { if (id != orderdetail.OrderNumber) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(orderdetail); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderdetailExists(orderdetail.OrderNumber)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["OrderNumber"] = new SelectList(_context.Orders, "OrderNumber", "Status", orderdetail.OrderNumber); ViewData["ProductCode"] = new SelectList(_context.Products, "ProductCode", "ProductCode", orderdetail.ProductCode); return(View(orderdetail)); }
public IHttpActionResult PutOrderdetail(int id, Orderdetail orderdetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != orderdetail.OrderId) { return(BadRequest()); } db.Entry(orderdetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OrderdetailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult NewOrder(OrderView orderview) { orderview = Session["OrderView"] as OrderView; int idcustomers = Convert.ToInt32(Request["Customerid"]); DateTime dateorder = Convert.ToDateTime(Request["Customer.Orderdate"]); Order neworder = new Order() { Customerid = idcustomers, OrderDate = dateorder }; db.Orders.Add(neworder); db.SaveChanges(); int lastorderid = db.Orders.ToList().Select(o => o.Orderid).Max(); foreach (ProductOrder Item in orderview.Products) { var detail = new Orderdetail() { Orderid = lastorderid, Productid = Item.Productid, Quantity = Item.quantity, unitprice = Item.unitprice }; db.Orderdetails.Add(detail); } db.SaveChanges(); orderview = Session["OrderView"] as OrderView; var list = db.Customers.ToList(); ViewBag.Customerid = new SelectList(list, "Customerid", "CompanyName"); return(View(orderview)); }
public async Task <IActionResult> PutOrderdetail([FromRoute] int id, [FromBody] Orderdetail orderdetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != orderdetail.Id) { return(BadRequest()); } _context.Entry(orderdetail).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderdetailExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Insert(Orderdetail orderdetail) { using (var entities = new toysforboysEntities()) { entities.orderdetails.Add(orderdetail); entities.SaveChanges(); } }
public ActionResult DeleteConfirmed(int id) { Orderdetail orderdetail = db.Orderdetails.Find(id); db.Orderdetails.Remove(orderdetail); db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Index() { Store MyStore = new Store { Name = "Walmart", Email = "*****@*****.**", Phone = 999999999, Location = "Tampa" }; Product MyProduct1 = new Product { Name = "StrawBerries", Description = "StrawBerries", Price = 15, Seller = "Kirkland", Store = MyStore }; Product MyProduct2 = new Product { Name = "BlueBerries", Description = "BlueBerries", Price = 10, Seller = "Kirkland", Store = MyStore, }; Order MyOrder = new Order { OrderDate = System.DateTime.Now, OrderMessage = "Mounika's Order", OrderTotal = 100 }; Orderdetail MyOrderDetail1 = new Orderdetail { Quantity = 5, Product = MyProduct1, Order = MyOrder }; Orderdetail MyOrderDetail2 = new Orderdetail { Quantity = 3, Product = MyProduct2, Order = MyOrder }; dbContext.Stores.Add(MyStore); dbContext.Products.Add(MyProduct1); dbContext.Products.Add(MyProduct2); dbContext.Orders.Add(MyOrder); dbContext.Orderdetails.Add(MyOrderDetail1); dbContext.Orderdetails.Add(MyOrderDetail2); dbContext.SaveChanges(); return(View()); }
public void Delete(Orderdetail orderdetail) { using (var entities = new toysforboysEntities()) { entities.orderdetails.Attach(orderdetail); entities.orderdetails.Remove(orderdetail); entities.SaveChanges(); } }
public int AddOrderOne(OrderInfo order, Orderdetail orderdetail) { string sql = $"insert into OrderInfo values('{order.OrderId}','{order.UserId}','{order.Orderdate}','{order.Orderamount}','{order.Message}','{order.Postmethod}','{order.Paymethod}','{order.Recevername}','{order.Receveraddr}','{order.Recevertel}','{order.Memo}','{order.Totalprice}') "; sql += $"insert into Orderdetail values('{orderdetail.OrderDetailId}','{orderdetail.OrderId}','{orderdetail.ProductId}','{orderdetail.Orderamount}','{orderdetail.Poststatus}','{orderdetail.Recevstatus}','{orderdetail.Saletotalprice}') "; return(_data.AddOrder(sql)); }
public int BuyShop(string token, int goodId, int buycount, string mess = "") { int userId = 0; JWTHelper jWT = new JWTHelper(); string json = jWT.GetPayload(token); Customer model = JsonConvert.DeserializeObject <Customer>(json); if (model != null) { userId = model.UserId; } else { return(0); } Random random = new Random(); ProductInfo list = _goodsList.GetProductinfo(goodId); OrderInfo order = new OrderInfo(); order.OrderId = random.Next(1, 1000000).ToString(); order.UserId = userId; order.Orderdate = DateTime.Now; order.Orderamount = buycount; order.Message = mess; order.Postmethod = "中通"; order.Paymethod = "支付宝"; order.Recevername = model.UserName; order.Receveraddr = model.UserAddress; order.Recevertel = model.UserTel; order.Memo = "_"; order.Totalprice = list.ProductDPrice * buycount; Orderdetail orderdetail = new Orderdetail(); orderdetail.OrderDetailId = random.Next(1, 100000); orderdetail.OrderId = order.OrderId; orderdetail.ProductId = list.ProductId; orderdetail.Orderamount = buycount; orderdetail.Poststatus = "未发货"; orderdetail.Recevstatus = "未收货"; orderdetail.Saletotalprice = (list.ProductDPrice * list.ProductAmount).ToString(); _goodsList.UptKuCunOne(goodId, buycount); if (_goodsList.AddOrderOne(order, orderdetail) > 0) { return(1); } return(0); }
public IHttpActionResult GetOrderdetail(int id) { Orderdetail orderdetail = db.Orderdetails.Find(id); if (orderdetail == null) { return(NotFound()); } return(Ok(orderdetail)); }
public RptOrderItem(Orderdetail item, int no, int div) { this.ItemName = item.Item.Itemname; this.ItemType = item.Item.Itemtype; this.Color = item.Item.Colorname; this.iQuantity = (int)item.Orderqty; this.Quantity = this.iQuantity.ToString(); this.UnitPrice = (int)(item.Unitprice / div); this.TotalAmount = (int)(this.iQuantity * this.UnitPrice); this.No = no.ToString().PadLeft(2, '0'); }
private Orderdetail InputOrderDetail(int orderId, int productId, int quantity, double SellPrice, int DiscountPercent) { Orderdetail orderdetail = new Orderdetail(); orderdetail.OrderId = orderId; orderdetail.ProductId = productId; orderdetail.Quantity = quantity; orderdetail.Price = (SellPrice / 100) * (100 - DiscountPercent); return(orderdetail); }
public ActionResult DatHang(Customer cus) { if (Session["cart"] == null) { return(RedirectToAction("Index", "Trangchu")); } Customer kh = new Customer(); if (Session["UserName"] == null) { kh = cus; db.Customers.Add(kh); db.SaveChanges(); } else { User user = Session["UserName"] as User; kh.UserId = user.Id; kh.FullName = cus.FullName; kh.Email = user.Email; kh.Address = cus.Address; kh.Phone = cus.Phone; db.Customers.Add(kh); db.SaveChanges(); } Order ddh = new Order(); ddh.CustemerId = kh.Id; ddh.CreateDate = DateTime.Now; ddh.ExportDate = DateTime.Now; ddh.Status = 0; ddh.DeliveryAddress = kh.Address; ddh.DeliveryName = ""; db.Orders.Add(ddh); db.SaveChanges(); List <Cart> lstCart = Laygiohang(); foreach (var item in lstCart) { Orderdetail ctdh = new Orderdetail(); ctdh.OrderId = ddh.Id; ctdh.ProductId = item.Id; ctdh.ProductName = item.Name; ctdh.Quantity = item.Quantity; ctdh.Price = item.Price; ctdh.Amount = item.Amount; db.Orderdetails.Add(ctdh); } db.SaveChanges(); Session["cart"] = null; return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "orderdetailid,Orderid,Productid,Quantity,unitprice")] Orderdetail orderdetail) { if (ModelState.IsValid) { db.Entry(orderdetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Orderid = new SelectList(db.Orders, "Orderid", "Orderid", orderdetail.Orderid); ViewBag.Productid = new SelectList(db.Products, "Productid", "productname", orderdetail.Productid); return(View(orderdetail)); }
public async Task <IActionResult> PostOrderdetail([FromBody] Orderdetail orderdetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Orderdetail.Add(orderdetail); await _context.SaveChangesAsync(); return(CreatedAtAction("GetOrderdetail", new { id = orderdetail.Id }, orderdetail)); }
public async Task <IActionResult> Create([Bind("OrderNumber,ProductCode,QuantityOrdered,PriceEach,OrderLineNumber")] Orderdetail orderdetail) { if (ModelState.IsValid) { _context.Add(orderdetail); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["OrderNumber"] = new SelectList(_context.Orders, "OrderNumber", "Status", orderdetail.OrderNumber); ViewData["ProductCode"] = new SelectList(_context.Products, "ProductCode", "ProductCode", orderdetail.ProductCode); return(View(orderdetail)); }
public async Task <ActionResult <Orderdetail> > PostOrderdetail(Orderdetail orderdetail) { try { _context.Orderdetail.Add(orderdetail); await _context.SaveChangesAsync(); return(CreatedAtAction("GetOrderdetail", new { id = orderdetail.DetailId }, orderdetail)); } catch (Exception e) { throw e; }; }
public IHttpActionResult DeleteOrderdetail(int id) { Orderdetail orderdetail = db.Orderdetails.Find(id); if (orderdetail == null) { return(NotFound()); } db.Orderdetails.Remove(orderdetail); db.SaveChanges(); return(Ok(orderdetail)); }
// GET: Orderdetails/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Orderdetail orderdetail = db.Orderdetails.Find(id); if (orderdetail == null) { return(HttpNotFound()); } return(View(orderdetail)); }
// GET: Orderdetails/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Orderdetail orderdetail = db.Orderdetails.Find(id); if (orderdetail == null) { return(HttpNotFound()); } ViewBag.Orderid = new SelectList(db.Orders, "Orderid", "Orderid", orderdetail.Orderid); ViewBag.Productid = new SelectList(db.Products, "Productid", "productname", orderdetail.Productid); return(View(orderdetail)); }
public IEnumerable <Orderdetail> CreateOrderDetails(Order order, List <OrderedProduct> orderedProducts) { var orderdetails = new List <Orderdetail>(); foreach (var op in orderedProducts) { var orderdetail = new Orderdetail(); orderdetail.orderId = order.id; orderdetail.productId = op.id; orderdetail.quantityOrdered = op.quantityOrdered; orderdetail.priceEach = op.priceEach; orderdetails.Add(orderdetail); } return(orderdetails); }
public async Task <IActionResult> Finish(string Email, string Firstname, string Middlename, string Lastname, string Addres, string Housenr, string Zipcode, string City, string Phonenr, string Toevoeging) { string id = GetOrderId(); string Userid = CheckId(); if (Userid == "" || String.IsNullOrEmpty(Userid)) { Userid = "Not Reg " + Guid.NewGuid().ToString();; } ShoppingCart cart = UserLogin(); var viewModel = new ShoppingCartViewModel { CartItems = await cart.GetCartItems() }; ViewBag.BovensteAuto = viewModel.CartItems[0].Car.color; Orderdetail detail = new Orderdetail { Orderid = id, Email = Email, Lastname = Lastname, Phonenumber = Phonenr, Address = Addres, Housenumber = Housenr + Toevoeging, Firstname = Firstname, Zipcode = Zipcode, City = City, Middlename = Middlename, Userid = Userid }; DbContext.orderdetail.Add(detail); DbContext.SaveChanges(); await cart.AddToHistory(viewModel.CartItems, id, Userid); foreach (var item in viewModel.CartItems) { cart.RemoveFromCart(item.CartItemId); } await cart.CountDecrease(viewModel.CartItems); return(View()); }
public ActionResult PlaceOrder(string amount, string firstname, string lastname, string clinicname, string address, string city, string number) { Order order = new Order(); order.Firstname = firstname; order.Lastname = lastname; order.Clinicname = clinicname; order.Address = address; order.City = city; order.Phone = number; order.Date = DateTime.Now; order.Amount = double.Parse(amount); db.Orders.Add(order); db.SaveChanges(); int moid = db.Orders.Select(o => o.Id).DefaultIfEmpty(0).Max(); var pro = from prod in ShoppingCart.Items join od in db.Products on prod.Id equals od.Id select new { PNAME = od.SuppliedProduct.ProductName, PID = od.SuppliedProductId, PRICE = od.Price, PQTY = prod.Count }; Orderdetail odt = new Orderdetail(); foreach (var item in pro) { odt.Orderid = moid; odt.Productid = item.PID; odt.ProductName = item.PNAME; odt.Productprice = item.PRICE; odt.Productqty = item.PQTY; odt.Productamount = item.PQTY * item.PRICE; db.Orderdetails.Add(odt); db.SaveChanges(); var spidt = db.SuppliedProducts.FirstOrDefault(s => s.Id == item.PID); spidt.AvailableQuantity -= item.PQTY; db.SaveChanges(); } TempData["Message"] = "Your Order has been placed !"; return(Redirect(Request.UrlReferrer.ToString())); }
public static bool IdCheck(List <Orderdetail> l, Orderdetail o) { bool b = false; foreach (Orderdetail orderdetail in l) { if (o.orderId == orderdetail.orderId && o.productId == orderdetail.productId) { b = true; if (o.priceEach == orderdetail.priceEach && o.quantityOrdered == orderdetail.quantityOrdered) { throw new ArgumentException(); } break; } } return(b); }
public async Task <ActionResult <Order> > PostOrder([FromForm] Order order) { order.Date = DateTime.Now; _context.Orders.Add(order); await _context.SaveChangesAsync(); var cart = await _context.Carts.FirstAsync(c => c.Userid == order.Userid); var id_cart = cart.Id; var Cartdetails = await _context.Cartdetails .Where(cd => cd.Cartid == id_cart) .Select(x => new Cartdetail() { Id = x.Id, Quanity = x.Quanity, Cartid = x.Cartid, Productid = x.Productid, }).ToListAsync(); var oder_id = await _context.Orders.OrderByDescending(p => p.Id).FirstAsync(); foreach (var item in Cartdetails) { Orderdetail orderdetail = new Orderdetail(); orderdetail.Productid = item.Productid; orderdetail.Orderid = oder_id.Id; orderdetail.Quantity = item.Quanity; _context.Orderdetails.Add(orderdetail); await _context.SaveChangesAsync(); } foreach (var item in Cartdetails) { var cartdetail = await _context.Cartdetails.FirstAsync(c => c.Id == item.Id); if (cartdetail != null) { _context.Cartdetails.Remove(cartdetail); await _context.SaveChangesAsync(); } } return(NoContent()); }
public async Task <IActionResult> Buy([Bind("cusName,cusPhone,cusAddress")] UserInfoOrderDto infouser) { var userIdsession = HttpContext.Session.GetInt32("userId"); var cart = _context.Carts.ToList().Where(c => c.UserId == userIdsession); var user = await _context.Users.FindAsync(userIdsession); Order order = new Order(); order = InputOrder(user.Id, 1, infouser); //order.UserId = user.Id; //order.CreateTime = DateTime.Now; //order.StatusCode = 1; _context.Add(order); await _context.SaveChangesAsync(); var lastorder = _repository.GetLastOrderByUserId((int)userIdsession); foreach (var item in cart) { Orderdetail orderdetail = new Orderdetail(); var product = await _context.Products.FindAsync(item.ProductId); var promotion = await _context.Promotions.FindAsync(product.PromoId); if (product != null && product.StatusCode != 0 && product.Quantity >= item.Quantity) { orderdetail = InputOrderDetail(lastorder.Id, item.ProductId, item.Quantity, product.SellPrice, promotion.DiscountPercent); //orderdetail.Price = (product.SellPrice / 100) * (100 - promotion.DiscountPercent); //orderdetail.Quantity = item.Quantity; //orderdetail.ProductId = item.ProductId; //orderdetail.OrderId = lastorder.Id; product.Quantity -= item.Quantity; _context.Add(orderdetail); await _context.SaveChangesAsync(); _context.Products.Update(product); await _context.SaveChangesAsync(); _context.Carts.Remove(item); await _context.SaveChangesAsync(); } } return(RedirectToAction("Index", "Home")); }
// tach truoc khi confirmed protected void cmdDoSplit_Click(object sender, EventArgs e) { int count1 = 0, count2 = 0; foreach (GridViewRow row in gvSplit.Rows) { count1 += int.Parse((row.Cells[2].Controls[1] as TextBox).Text); count2 += int.Parse((row.Cells[3].Controls[1] as TextBox).Text); } if (count1 == count2 || count2 == 0) { lblResult.Text = (string)GetLocalResourceObject("_EmptyOrderError"); return; } IDao<Orderheader, long> ohDao = DaoFactory.GetDao<Orderheader, long>(); IDao<Orderdetail, long> odDao = DaoFactory.GetDao<Orderdetail, long>(); using (TransactionBlock tran = new TransactionBlock()) { //get current order Orderheader oh = CurrentOrderHeader; // and mark current order to deleted oh.Status = (int)VDMS.I.Vehicle.OrderStatus.Deleted; oh.Lasteditedby = UserHelper.Username; oh.Lastediteddate = DateTime.Now; ohDao.SaveOrUpdate(oh); // get detail of this order odDao.SetCriteria(new ICriterion[] { Expression.Eq("Orderheader", oh) }); List<Orderdetail> listOd = odDao.GetAll(); // create two new orders Orderheader oh1 = new Orderheader(), oh2 = new Orderheader(); oh1.Createddate = oh2.Createddate = DateTime.Now; oh1.Createdby = oh2.Createdby = UserHelper.Username; oh1.Lastediteddate = oh2.Lastediteddate = DateTime.Now; oh1.Lasteditedby = oh2.Lasteditedby = UserHelper.Username; oh1.Ordernumber = oh2.Ordernumber = oh.Ordernumber; // set order date of two orders header DateTime oh1Date, oh2Date; DateTime.TryParse(txtOrder1Date.Text, new CultureInfo(UserHelper.Language), DateTimeStyles.AllowWhiteSpaces, out oh1Date); DateTime.TryParse(txtOrder2Date.Text, new CultureInfo(UserHelper.Language), DateTimeStyles.AllowWhiteSpaces, out oh2Date); oh1.Orderdate = oh1Date; oh2.Orderdate = oh2Date; oh1.Ordertimes = oh2.Ordertimes = 1; // TODO oh1.Shippingdate = oh2.Shippingdate = oh.Shippingdate; oh1.Shippingto = oh2.Shippingto = oh.Shippingto; oh1.Status = oh2.Status = (int)VDMS.I.Vehicle.OrderStatus.Sent; oh1.Dealercode = oh2.Dealercode = oh.Dealercode; oh1.Subtotal = oh2.Subtotal = 0; // TODO oh1.Taxamt = oh2.Taxamt = oh.Taxamt; oh1.Freight = oh2.Freight = oh.Freight; oh1.Dealercomment = oh2.Dealercomment = oh.Dealercomment; oh1.Vmepcomment = oh2.Vmepcomment = oh.Vmepcomment; oh1.Referenceorderid = oh2.Referenceorderid = (int)oh.Id; oh1.Databasecode = oh2.Databasecode = oh.Databasecode; oh1.Areacode = oh2.Areacode = oh.Areacode; // new on substore mgr oh1.Secondaryshippingcode = oh2.Secondaryshippingcode = oh.Secondaryshippingcode; oh1.Secondaryshippingto = oh2.Secondaryshippingto = oh.Secondaryshippingto; // save three orders ohDao.SaveOrUpdate(oh1); ohDao.SaveOrUpdate(oh2); int index = 0; foreach (GridViewRow row in gvSplit.Rows) { int total = int.Parse((row.Cells[2].Controls[1] as TextBox).Text); int q2 = int.Parse((row.Cells[3].Controls[1] as TextBox).Text); int q1 = total - q2; Orderdetail od1 = new Orderdetail(), od2 = new Orderdetail(); od1.Createddate = od2.Createddate = DateTime.Now; od1.Createdby = od2.Createdby = UserHelper.Username; od1.Lastediteddate = od2.Lastediteddate = DateTime.Now; od1.Lasteditedby = od2.Lasteditedby = UserHelper.Username; //od1.Unitprice = od2.Unitprice = listOd[index].Unitprice; //od1.Unitpricediscount = od2.Unitpricediscount = listOd[index].Unitpricediscount; //od1.Orderpriority = od2.Orderpriority = listOd[index].Orderpriority; //Orderdetail od = listOd.Find(delegate(Orderdetail d) { return d.Item.Id == row.Cells[0].Text; }); Orderdetail od = listOd.Find(d => d.Item.Id == row.Cells[0].Text); od1.Unitprice = od2.Unitprice = od.Unitprice; od1.Unitpricediscount = od2.Unitpricediscount = od.Unitpricediscount; od1.Orderpriority = od2.Orderpriority = od.Orderpriority; od1.Item = od2.Item = od.Item; od1.Orderheader = oh1; od2.Orderheader = oh2; if (q1 > 0) { od1.Orderqty = q1; odDao.SaveOrUpdate(od1); } if (q2 > 0) { od2.Orderqty = q2; odDao.SaveOrUpdate(od2); } index++; } tran.IsValid = true; } lblResult.Text = (string)GetLocalResourceObject("_ProcessComplete"); phGoback.Visible = true; DisableButton(); }
public OrderDetailEx(Orderdetail oBase, DataObjectState objectState) : base(oBase.Createddate, oBase.Createdby, oBase.Lastediteddate, oBase.Lasteditedby, oBase.Orderqty, oBase.Unitprice, oBase.Unitpricediscount, oBase.Orderpriority, oBase.Item, oBase.Orderheader, oBase.Specialoffer) { Id = oBase.Id; ObjectState = objectState; }
bool SynchronizeOrderDetail(string OrderNumber, IDao<Orderheader, long> ohDao, IDao<Orderdetail, long> odDao, Orderheader oh) { DataSet ds = VDMS.Data.TipTop.Order.GetOrderDetail(OrderNumber); long total = 0; foreach (DataRow row in ds.Tables[0].Rows) { if (!ItemDataSource.IsExistItem((string)row["ItemCode"], NEED_ITEM_AVAILABLE_ON_CONFIRM)) return false; Orderdetail od = new Orderdetail() { Createddate = DateTime.Now, Createdby = UserHelper.Username, Lastediteddate = DateTime.Now, Lasteditedby = UserHelper.Username, Unitprice = long.Parse(row["Price"].ToString()), Unitpricediscount = 0, Orderpriority = int.Parse((string)row["Priority"]), Orderqty = (int)((decimal)row["Quantity"]) }; total += (od.Unitprice * od.Orderqty); Item item = new Item() { Id = (string)row["ItemCode"] }; od.Item = item; od.Orderheader = oh; odDao.SaveOrUpdate(od); } oh.Subtotal = total; ohDao.SaveOrUpdate(oh); return true; }
public static Orderdetail CreateNewOrderDetailDefault() { Orderdetail res = new Orderdetail(); res.Createddate = res.Lastediteddate = DateTime.Now; res.Createdby = res.Lasteditedby = UserHelper.Username; res.Unitpricediscount = 0; return res; }
public ItemOrder(Orderdetail od, int? index) : base(od.Createddate, od.Createdby, od.Lastediteddate, od.Lasteditedby, od.Orderqty, od.Unitprice, od.Unitpricediscount, od.Orderpriority, od.Item, od.Orderheader, od.Specialoffer) { if (index != null) this.Index = (int)index; }
public ItemOrder(Orderdetail od) : this(od, null) { }
public RptOrderItem(Orderdetail item, int no) : this(item, no, 1000) { }