partial void UpdateDS_Orders(DS_Orders instance);
partial void DeleteDS_Orders(DS_Orders instance);
partial void InsertDS_Orders(DS_Orders instance);
partial void DeleteDS_Orders(DS_Orders instance);
partial void UpdateDS_Orders(DS_Orders instance);
partial void InsertDS_Orders(DS_Orders instance);
/// <summary> /// 加入进货单 /// </summary> /// <param name="ProductID">产品ID</param> /// <param name="ProNum">产品数量</param> /// <param name="ProTotalCount">添加商品后反回进货单中的总商品数</param> /// <param name="ProTotalAmount">添加商品后反回进货单中的总金额</param> /// <param name="CurrentProAmount">当前产品ID的总金额</param> public OrderInfo Add(int ProductID, int ProNum) { var odinfo = new OrderInfo(); var orderDetail = CreateOrderDetail(ProductID,ProNum); odinfo.CrtPriceRang=orderDetail.PriceRang; var productbl = new DS_ProductsDataContext(DBUtility.DbHelperSQL.Connection); var memberbl = new View_MembersDataContext(DBUtility.DbHelperSQL.Connection); var product = productbl.DS_Products.Single(a=>a.ID.Equals(orderDetail.ProductID)); var existod=Orders.Where(a=>a.MemberID.Equals(product.MemberID)); if (existod.Count().Equals(0))//检查订单中是否存在相同公司 { var order = new DS_Orders(); order.MemberID = product.MemberID; var member = memberbl.View_Members.Single(a=>a.ID.Equals(product.MemberID)); order.CompanyName = member.CompanyName; order.QQ = member.QQ; order.ProNum = orderDetail.ProNum; order.PurchaseID = 0; order.Amount = orderDetail.Amount; order.CreateDate = DateTime.Now; order.ID = id++; odinfo.ID = order.ID; Orders.Add(order); orderDetail.OrderID = order.ID; orderDetail.MemberID = order.MemberID; orderDetail.OrderNum = DS_Orders_Br.GetSerial(); OrderDetail.Add(orderDetail); } else { var order = existod.Single(); orderDetail.OrderID = order.ID; orderDetail.MemberID = order.MemberID; odinfo.ID = order.ID; //检查购物车中是否已存在相同商品 var existoddt = OrderDetail.Where(a=>a.ProductID.Equals(orderDetail.ProductID)); if (existoddt.Count().Equals(0)) { order.Amount += orderDetail.Amount; order.ProNum += orderDetail.ProNum; orderDetail.OrderNum = DS_Orders_Br.GetSerial(); OrderDetail.Add(orderDetail); } else { var oddt = existoddt.Single(); order.Amount -= Math.Round(double.Parse(oddt.ProNum.ToString()) * oddt.Price); oddt.ProNum += orderDetail.ProNum; oddt.Price = GetPrice(product.PriceRang,oddt.ProNum); oddt.PriceRang = GetPriceRang(product.PriceRang,oddt.ProNum); odinfo.CrtPriceRang=oddt.PriceRang; oddt.Amount = Math.Round(double.Parse(oddt.ProNum.ToString()) * oddt.Price); order.Amount += oddt.Amount; order.ProNum += orderDetail.ProNum; } } odinfo.PurTotalCount = Orders.Sum(a=>a.ProNum); odinfo.CrtProAmount= OrderDetail.Where(a=>a.ProductID.Equals(ProductID)).Sum(a=>a.Amount); odinfo.PurTotalAmount = Orders.Sum(a=>a.Amount); odinfo.CrtOrderAmount = Orders.Where(a=>a.ID.Equals(orderDetail.OrderID)).Sum(a=>a.Amount); return odinfo; }