private void DoBatchDelete() { IList <object> idList = RequestData.GetList <object>("IdList"); if (idList != null && idList.Count > 0) { DeliveryOrder.DoBatchDelete(idList.ToArray()); } }
private void DoBatchDelete() { IList <object> idList = RequestData.GetList <object>("IdList"); string db = ConfigurationManager.AppSettings["ExamineDB"]; if (idList != null && idList.Count > 0) { OrdersPart op = null; OrdersPart[] ops = null; DelieryOrderPart[] dops = null; DeliveryOrder dorder = null; SaleOrder order = null; string count = ""; //更新订单状态,同时删除DeliveryOrderPart表数据 foreach (object obj in idList) { dorder = DeliveryOrder.TryFind(obj); if (dorder == null) { DelieryOrderPart.DeleteAll("DId='" + obj + "'"); //删除DeliveryOrderPart continue; } dops = DelieryOrderPart.FindAllByProperty("DId", obj); foreach (DelieryOrderPart dop in dops) { //更新订单状态 op = OrdersPart.TryFind(dop.PId); if (op != null) { op.OutCount = (op.OutCount == null ? 0 : Convert.ToInt32(op.OutCount)) - Convert.ToInt32(dop.Count); op.DoSave(); } } //更新order的json string jsons = ""; order = SaleOrder.FindAllByProperty("Id", dorder.PId).FirstOrDefault <SaleOrder>(); if (order == null) { DelieryOrderPart.DeleteAll("DId='" + obj + "'"); //删除DeliveryOrderPart continue; } ops = OrdersPart.FindAllByProperty("OId", order.Id); //拼json foreach (OrdersPart opt in ops) { jsons += "{"; jsons += "Id:'" + opt.PId + "',"; jsons += "Isbn:'" + opt.Isbn + "',"; jsons += "Code:'" + opt.PCode + "',"; jsons += "Name:'" + opt.PName + "',"; jsons += "Unit:'" + opt.Unit + "',"; jsons += "MinSalePrice:'" + opt.MinSalePrice + "',"; jsons += "Price:'" + opt.SalePrice + "',"; jsons += "Amount:'" + opt.Amount + "',"; jsons += "Count:'" + opt.Count + "',"; jsons += "OutCount:'" + opt.OutCount + "',"; jsons += "Remark:'" + opt.Remark + "'"; jsons += "},"; } count = DataHelper.QueryValue("select count(1) from " + db + "..OrdersPart where OId='" + order.Id + "' and OutCount=[Count]") + ""; if (count == "0") { order.DeliveryState = ""; } else { order.DeliveryState = "部分生成出库单"; } order.Child = "[" + jsons.Substring(0, jsons.Length - 1) + "]"; order.DoSave(); DelieryOrderPart.DeleteAll("DId='" + obj + "'"); //删除DeliveryOrderPart } DeliveryOrder.DoBatchDelete(idList.ToArray()); } }