public ActionResult AddTempRuleByOrder() { Response resp = new Response(); CWTariff cwtrff = new CWTariff(); List <TempChargingRule> ruleList = cwtrff.GetTempChgRuleList(); if (ruleList.Count > 0) { resp.Code = 0; resp.Message = "系统故障,存在临时类记录,无法完成新增工作!"; return(Json(resp)); } string preID = Request.Form["PreID"]; string tType = Request.Form["TType"]; //计费类型 string freetime = Request.Form["FreeTime"]; string fee = Request.Form["OrderFee"]; TempChargingRule rule = new TempChargingRule() { ICType = EnmICCardType.Temp, TempChgType = (EnmTempChargeType)Convert.ToInt16(tType), PreChgID = Convert.ToInt32(preID) }; resp = cwtrff.AddTempChgRule(rule); if (resp.Code == 1) { //先删除原来的记录 List <OrderChargeDetail> orderdetailLst = cwtrff.GetOrderDetailList(); foreach (OrderChargeDetail order in orderdetailLst) { cwtrff.DeleteOrderDetail(order.ID); } //添加新的 OrderChargeDetail odetail = new OrderChargeDetail() { TempChgID = rule.ID, OrderFreeTime = freetime, Fee = Convert.ToSingle(fee) }; resp = cwtrff.AddOrderDetail(odetail); resp.Data = null; if (resp.Code == 1) { var da = new { mainID = rule.ID, orderID = odetail.ID }; resp.Data = da; } } return(Json(resp)); }