Beispiel #1
0
 public string OrderAdd()
 {
     string returnResult = String.Empty;
     var content = JObject.Parse(Request.Params[0]);
     string returnString = "添加失败!";
     if (content != null)
     {
         SysWorkOrder order = new SysWorkOrder();
         order.LastUpdateUserId = Int32.Parse(content.SelectToken("userid").ToString());
         order.CreateTime = DateTime.Now;
         order.LastUpdateTime = DateTime.Now;
         order.DeviceCode = content.SelectToken("devicecode").ToString();
         order.Device = content.SelectToken("device").ToString();
         order.Department = content.SelectToken("department").ToString();
         order.CurrentStatus = content.SelectToken("currentstatus").ToString();
         order.OrderTitle = content.SelectToken("ordertitle").ToString();
         order.Description = content.SelectToken("description").ToString();
         SysWorkOrderLog orderlog = new SysWorkOrderLog();
         orderlog.CreateTime = DateTime.Now;
         orderlog.Description = content.SelectToken("logdescription").ToString();
         orderlog.OperateUserId = Int32.Parse(content.SelectToken("userid").ToString());
         DbServices.InsertNewSysWorkOrder(order, orderlog);
         returnString = "添加成功!";
     }
     returnResult = JsonConvert.SerializeObject(new { msg = returnString });
     return returnResult;
 }
Beispiel #2
0
 public static void InsertNewSysWorkOrder(SysWorkOrder order, SysWorkOrderLog orderLog)
 {
     using (WeChatDbContext entity = new WeChatDbContext())
     {
         var oldorder = (from item in entity.SysWorkOrder where item.SysWorkOrderId == order.SysWorkOrderId select item).SingleOrDefault();
         if (oldorder == null)
         {
             var tempOrder = entity.SysWorkOrder.Add(order);
             entity.SaveChanges();
             orderLog.SysWorkOrderId = tempOrder.SysWorkOrderId;
             entity.SysWorkOrderLog.Add(orderLog);
             entity.SaveChanges();
         }
     }
 }
Beispiel #3
0
 public string OrderEdit()
 {
     string returnResult = String.Empty;
     var content = JObject.Parse(Request.Params[0]);
     string returnString = "更新失败!";
     if (content != null)
     {
         SysWorkOrder order = new SysWorkOrder();
         int orderid = Int32.Parse(content.SelectToken("orderid").ToString());
         order = DbServices.GetSysWorkOrder(orderid);
         order.CurrentStatus = content.SelectToken("status").ToString();
         order.LastUpdateTime = DateTime.Now;
         order.LastUpdateUserId = Int32.Parse(content.SelectToken("userid").ToString());
         SysWorkOrderLog swol = new SysWorkOrderLog();
         swol.CreateTime = DateTime.Now;
         swol.Description = content.SelectToken("logdesc").ToString();
         swol.SysWorkOrderId = orderid;
         swol.OperateUserId = order.LastUpdateUserId;
         DbServices.UpdateSysWorkOrder(order, swol);
         returnString = "更新成功!";
     }
     returnResult = JsonConvert.SerializeObject(new { msg = returnString });
     return returnResult;
 }
Beispiel #4
0
 public static void UpdateSysWorkOrder(SysWorkOrder order, SysWorkOrderLog orderLog)
 {
     using (WeChatDbContext entity = new WeChatDbContext())
     {
         var oldorder = (from item in entity.SysWorkOrder where item.SysWorkOrderId == order.SysWorkOrderId select item).SingleOrDefault();
         if (oldorder != null)
         {
             entity.Entry(oldorder).State = System.Data.Entity.EntityState.Modified;
             oldorder.OrderTitle = order.OrderTitle;
             oldorder.LastUpdateTime = DateTime.Now;
             oldorder.Device = order.Device;
             oldorder.DeviceCode = order.DeviceCode;
             oldorder.Description = order.Description;
             oldorder.Department = order.Department;
             oldorder.CurrentStatus = order.CurrentStatus;
             oldorder.LastUpdateUserId = order.LastUpdateUserId;
             entity.SysWorkOrderLog.Add(orderLog);
             entity.SaveChanges();
         }
     }
 }