/// <summary> /// 更新出库状态 /// </summary> /// <param name="childjson">出库单出库商品json</param> private void GetDeliveryState(IList <string> strList, string paids) { string db = ConfigurationManager.AppSettings["ExamineDB"]; Dictionary <string, object> dic = null; OrdersPart op = null; for (int i = 0; i < strList.Count; i++) { dic = FromJson(strList[i]) as Dictionary <string, object>; if (dic != null) { op = OrdersPart.TryFind(dic["PId"]); if (op != null) { op.OutCount = (op.OutCount == null ? 0 : Convert.ToInt32(op.OutCount)) + Convert.ToInt32(dic["OutCount"]); op.DoSave(); } else { //throw new Exception("PId未在OrdersPart的Id中"); } } } //更新销售单状态 string[] oids = paids.Split(','); SaleOrder order = null; string count = "0";//待出库数量 string state = ""; OrdersPart[] ops = null; string jsons = ""; foreach (string str in oids) { if (string.IsNullOrEmpty(str)) { continue; } count = DataHelper.QueryValue("select count(1) from " + db + "..OrdersPart where OId='" + str + "' and (OutCount is null or OutCount<>[Count])") + ""; if (count == "0") { //已出库state //state = "已出库"; state = "已全部生成出库单"; } else { //state = "部分出库"; state = "部分生成出库单"; } order = SaleOrder.TryFind(str); if (order != null) { jsons = ""; order.DeliveryState = state; //更新order的json ops = OrdersPart.FindAllByProperty("OId", str); //拼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 += "},"; } order.Child = "[" + jsons.Substring(0, jsons.Length - 1) + "]"; order.DoSave(); } } }
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()); } }