public DeviceOrderingViewModel() { Device = new List <DeviceModel>(); orderInfo = new DeviceOrderInfo(); orderDetail = new DeviceOrderDetail(); orderDetailList = new List <DeviceOrderDetail>(); }
public ActionResult Edit(string DeviceName) { var model = new DeviceOrderDetail(); if (DeviceName != null) { for (int i = 0; i < deviceOrderData.orderDetailList.Count; ++i) { if (deviceOrderData.orderDetailList[i].DeviceName == DeviceName) { model = deviceOrderData.orderDetailList[i]; } } } return(View(model)); }
public ActionResult AddOrder(FormCollection collection) { try { var model = new DeviceOrderDetail(); model.ProjectNumber = collection["orderInfo.ProjectNumber"]; model.DeviceName = collection["DeviceName"]; if ((DateTime.TryParse(collection["OrderDate"], out orderDate)) && (orderDate.CompareTo(DateTime.Today) > 0)) { model.OrderDate = orderDate; int number; if ((int.TryParse(collection["orderDetail.OrderNumber"], out number)) && (number > 0)) { model.OrderNumber = number; } if (!IsExitOrderDevice(model.DeviceName)) { if (IsDeviceNumEnough(model.DeviceName, orderDate, model.OrderNumber)) { deviceOrderData.orderInfo.ProjectNumber = model.ProjectNumber; deviceOrderData.orderInfo.OrderDate = orderDate; deviceOrderData.orderDetailList.Add(model); var devices = this.IDKLManagerService.GetDeviceList().Select(c => new { Name = c.DeivceName }).Distinct(); ViewData.Add("DeviceName", new SelectList(devices, "Name", "Name")); return(View("Create", deviceOrderData)); } else { return(Back(GlobalData.warningInfo3)); } } else { return(Back(GlobalData.warningInfo2)); } } else { return(Back(GlobalData.warningInfo5)); } } catch (Exception e) { return(Back(GlobalData.warningInfo4 + e.Message)); } }