private void 除订单_Click(object sender, EventArgs e) { int id_int = Convert.ToInt32(id); orderWinForm.Customer c = new orderWinForm.Customer(Convert.ToUInt32(customer_id), customer_name); orderWinForm.Goods goods = new orderWinForm.Goods(Convert.ToInt32(goods_id), goods_name, Convert.ToDouble(price)); orderWinForm.OrderDetail de = new orderWinForm.OrderDetail(goods, Convert.ToUInt32(amount)); if (service.GetById(id_int) == null) { orderWinForm.Order o = new orderWinForm.Order(id_int, c); service.AddOrder(o); o.AddDetails(de); } else { service.GetById(id_int).AddDetails(de); } MessageBox.Show("删除成功"); this.Close(); }
private void button1_Click(object sender, EventArgs e) { int id_int = Convert.ToInt32(id); orderWinForm.Customer c = new orderWinForm.Customer(Convert.ToUInt32(customer_id), customer_name); orderWinForm.Goods goods = new orderWinForm.Goods(Convert.ToInt32(goods_id), goods_name, Convert.ToDouble(price)); orderWinForm.OrderDetail de = new orderWinForm.OrderDetail(goods, Convert.ToUInt32(amount)); orderWinForm.Order o = service.GetById(id_int); var d = o.Details; foreach (var i in d) { if (i.Goods.Id == Convert.ToInt32(goods_id)) { i.Amount = Convert.ToUInt32(amount); i.Goods.Price = Convert.ToDouble(price); } } MessageBox.Show("修改成功"); this.Close(); }