public void Delete_Order(string orderid) { int count = 0; if (orderid.Contains(',')) { string[] str_id = orderid.Split(','); for (int i = 0; i < str_id.Length; i++) { int ids = Convert.ToInt32(str_id[i]); OrderFormInfo order = new OrderFormInfo() { OFI_ID = ids }; shop.Entry(order).State = System.Data.EntityState.Deleted; count = shop.SaveChanges(); } } else { int id = Convert.ToInt32(orderid); OrderFormInfo order = new OrderFormInfo() { OFI_ID = id }; shop.Entry(order).State = System.Data.EntityState.Deleted; count = shop.SaveChanges(); } Response.Write(count); }
/// <summary> /// 确认订单 /// </summary> /// <param name="orderid"></param> public void Decise_Order(string orderid, int?express_id) { int count = 0; //解析字符串转换成多个int值 if (orderid.Contains(',')) { string[] order_ID = orderid.Split(','); for (int i = 0; i < orderid.Length; i++) { int?id = Convert.ToInt32(order_ID[i]); //修改该订单的状态 OrderFormInfo order = shop.OrderFormInfo.Where(a => a.OFI_ID == id).FirstOrDefault(); order.OFI_States = 2; if (!string.IsNullOrEmpty(express_id.ToString())) { order.Express_ID = express_id; } count = shop.SaveChanges(); } } else { int?idS = Convert.ToInt32(orderid); //修改该订单的状态 OrderFormInfo order = shop.OrderFormInfo.Where(a => a.OFI_ID == idS).FirstOrDefault(); order.OFI_States = 2; if (!string.IsNullOrEmpty(express_id.ToString())) { order.Express_ID = express_id; } count = shop.SaveChanges(); } Response.Write(count); }
/// <summary> /// 修改订单信息 /// </summary> /// <param name="strjson">前台返回的json对象</param> public void Update_order(string strjson) { //反序列化(将json字符串转换成对象) Update_OrderInfo U_Order = new Update_OrderInfo(); U_Order = JsonConvert.DeserializeObject <Update_OrderInfo>(strjson); //修改数据库 //得到订单编号 int orderid = Convert.ToInt32(U_Order.OFI_ID); //修改订单信息 OrderFormInfo Order_update = shop.OrderFormInfo.Where(a => a.OFI_ID == orderid).FirstOrDefault(); Order_update.OFI_Number = Convert.ToInt32(U_Order.OFI_Number); Order_update.OFI_States = Convert.ToInt32(U_Order.IsState); //修改默认地址信息 MyAddressInfo Address_Update = shop.MyAddressInfo.Where(a => a.MAI_ID == Order_update.OFI_SAI_ID).FirstOrDefault(); Address_Update.MAI_Name = U_Order.GetName; Address_Update.MAI_Phone = U_Order.Phone; int count = shop.SaveChanges(); if (count > 0) { Response.Write("success"); } else { Response.Write("fail"); } }