public ActionResult SaveOrder_templateList(int CtrOrderId, t_PM_Order order, FormCollection collection) { //string content = collection["OrderContent"].ToString(); string result = "OK"; try { if (order.OrderID > 0) { t_PM_Order orderinfo = bll.t_PM_Order.Where(o => o.OrderID == order.OrderID).First(); orderinfo.OrderContent = Common.ReplaceEnter(order.OrderContent); orderinfo.OrderNO = order.OrderNO; orderinfo.PID = order.PID; orderinfo.PlanDate = order.PlanDate; orderinfo.CtrPlanDate = order.CtrPlanDate; orderinfo.PName = order.PName; orderinfo.Priority = order.Priority; orderinfo.Remarks = Common.ReplaceEnter(order.Remarks); orderinfo.UserID = order.UserID; orderinfo.OrderState = 0; if (orderinfo.UserName != order.UserName) { UtilsSms.smsOrderCancel(orderinfo.UserName, orderinfo.OrderName, bll); } orderinfo.UserName = order.UserName; orderinfo.BugID = order.BugID; orderinfo.BugInfo = order.BugInfo; orderinfo.OrderType = order.OrderType; orderinfo.OrderName = order.OrderName; orderinfo.DressCodeID = order.DressCodeID; bll.ObjectStateManager.ChangeObjectState(orderinfo, EntityState.Modified); bll.SaveChanges(); //发送短信; UtilsSms.smsOrderAdd(order.UserName, order.OrderName, bll); // if (orderinfo.sTemplateIDs != order.sTemplateIDs || orderinfo.sTemplateCount != order.sTemplateCount) { //delete date //删除工单 string strsql = "delete from t_PM_Order_Info where OrderID = " + order.OrderID; int docount = bll.ExecuteStoreCommand(strsql, null); // if (!string.IsNullOrEmpty(order.sTemplateIDs) && !string.IsNullOrEmpty(order.sTemplateCount)) { string[] sTemplateIDsArry = order.sTemplateIDs.Split(','); string[] sTemplateCountArry = order.sTemplateCount.Split(','); if (sTemplateIDsArry.Length > 0 && sTemplateIDsArry.Length == sTemplateCountArry.Length) { for (int i = 0; i < sTemplateIDsArry.Length; i++) { //result = DeleteInfo(int.Parse(sTemplateIDsArry[i].Trim())); t_PM_Order_Info Order_Info = new t_PM_Order_Info(); Order_Info.orderId = order.OrderID; Order_Info.templateId = int.Parse((sTemplateIDsArry[i])); Order_Info.deviceCount = int.Parse((sTemplateCountArry[i])); Order_Info.unCount = Order_Info.deviceCount; bll.t_PM_Order_Info.AddObject(Order_Info); bll.SaveChanges(); } } } } Common.InsertLog("工单管理", CurrentUser.UserName, "编辑工单信息[" + order.OrderNO + "]");//log } else { order.OrderState = 0; //0待接收 1已受理 2已完成 order.IsQualified = -1; //-1 未检查 0不合格 1合格 order.CreateDate = DateTime.Now; order.Creater = CurrentUser.UserName; order.OrderContent = order.OrderContent.Replace("\n", "<br>"); int iOrderTypeId = 1; if (order.OrderType.Equals("日常巡检")) { iOrderTypeId = 3; } if (order.OrderType.Equals("检修试验")) { iOrderTypeId = 2; } if (order.OrderType.Equals("应急抢修")) { iOrderTypeId = 1; } order.OrderTypeId = iOrderTypeId; bll.t_PM_Order.AddObject(order); bll.SaveChanges(); if (CtrOrderId > 0) { t_PM_Order order2 = bll.t_PM_Order.ToList().Last(); updateCstrOrder(CtrOrderId, order2.OrderID); } if (!string.IsNullOrEmpty(order.sTemplateIDs) && !string.IsNullOrEmpty(order.sTemplateCount)) { string[] sTemplateIDsArry = order.sTemplateIDs.Split(','); string[] sTemplateCountArry = order.sTemplateCount.Split(','); if (sTemplateIDsArry.Length > 0 && sTemplateIDsArry.Length == sTemplateCountArry.Length) { t_PM_Order orderNew = null; List <t_PM_Order> list = bll.t_PM_Order.Where(o => o.OrderNO == order.OrderNO).ToList(); if (list.Count > 0) { orderNew = list[0]; if (orderNew == null) { return(Content("添加工单错误!")); } for (int i = 0; i < sTemplateIDsArry.Length; i++) { //result = DeleteInfo(int.Parse(sTemplateIDsArry[i].Trim())); t_PM_Order_Info Order_Info = new t_PM_Order_Info(); Order_Info.orderId = orderNew.OrderID; Order_Info.templateId = int.Parse((sTemplateIDsArry[i])); Order_Info.deviceCount = int.Parse((sTemplateCountArry[i])); Order_Info.unCount = Order_Info.deviceCount; bll.t_PM_Order_Info.AddObject(Order_Info); bll.SaveChanges(); } } } } Common.InsertLog("工单管理", CurrentUser.UserName, "新增工单信息[" + order.OrderNO + "]");//log //发送短信; UtilsSms.smsOrderAdd(order.UserName, order.OrderName, bll); Console.WriteLine(result); } } catch (Exception ex) { result = ex.ToString(); } return(Content(result)); }
public ActionResult SaveOrder(t_PM_Order order, FormCollection collection) { //string content = collection["OrderContent"].ToString(); string result = "OK"; try { if (order.OrderID > 0) { t_PM_Order orderinfo = bll.t_PM_Order.Where(o => o.OrderID == order.OrderID).First(); orderinfo.OrderContent = Common.ReplaceEnter(order.OrderContent); orderinfo.OrderNO = order.OrderNO; orderinfo.PID = order.PID; orderinfo.PlanDate = order.PlanDate; orderinfo.PName = order.PName; orderinfo.Priority = order.Priority; orderinfo.Remarks = Common.ReplaceEnter(order.Remarks); orderinfo.UserID = order.UserID; orderinfo.OrderState = 0; if (orderinfo.UserName != order.UserName) { UtilsSms.smsOrderCancel(orderinfo.UserName, orderinfo.OrderName, bll); } orderinfo.UserName = order.UserName; orderinfo.BugID = order.BugID; orderinfo.BugInfo = order.BugInfo; orderinfo.OrderType = order.OrderType; orderinfo.OrderName = order.OrderName; orderinfo.DressCodeID = order.DressCodeID; bll.ObjectStateManager.ChangeObjectState(orderinfo, EntityState.Modified); bll.SaveChanges(); Common.InsertLog("工单管理", CurrentUser.UserName, "编辑工单信息[" + order.OrderNO + "]");//log } else { order.OrderState = 0; //0待接收 1已受理 2已完成 order.IsQualified = -1; //-1 未检查 0不合格 1合格 order.CreateDate = DateTime.Now; order.Creater = CurrentUser.UserName; order.OrderContent = order.OrderContent.Replace("\n", "<br>"); int iOrderTypeId = 1; if (order.OrderType.Equals("日常巡检")) { iOrderTypeId = 3; } if (order.OrderType.Equals("检修试验")) { iOrderTypeId = 2; } if (order.OrderType.Equals("应急抢修")) { iOrderTypeId = 1; } order.OrderTypeId = iOrderTypeId; bll.t_PM_Order.AddObject(order); bll.SaveChanges(); Common.InsertLog("工单管理", CurrentUser.UserName, "新增工单信息[" + order.OrderNO + "]");//log } //发送短信; UtilsSms.smsOrderAdd(order.UserName, order.OrderName, bll); Console.WriteLine(result); } catch (Exception ex) { result = ex.ToString(); } return(Content(result)); }