public ActionResult EditRepairRecord(WebRepairRecord webRepairRecord, List <string> delIDList) { RepairRecordBLL repairRecordBLL = new RepairRecordBLL(); var cResult = repairRecordBLL.UpdateRepairRecord(webRepairRecord, delIDList); return(JsonContentHelper.GetJsonContent(cResult)); }
public ActionResult AddRepairRecord(WebRepairRecord webRepairRecord, List <string> delIDList) { RepairRecordBLL repairRecord = new RepairRecordBLL(); webRepairRecord.CreateDate = DateTime.Now; webRepairRecord.CreateUserID = this.GetCurrentUserID(); webRepairRecord.ProjectID = this.GetCurrentProjectID(); var cResult = repairRecord.InsertRepairRecord(webRepairRecord); return(JsonContentHelper.GetJsonContent(cResult)); }
public CResult <WebRepairRecord> GetRepairRecordByID(string repairRecordID) { LogHelper.Info(MethodBase.GetCurrentMethod().ToString()); LogHelper.Info("repairRecordID", repairRecordID); if (string.IsNullOrEmpty(repairRecordID)) { return(new CResult <WebRepairRecord>(null, ErrorCode.ParameterError)); } using (var context = new DeviceMgmtEntities()) { var entity = context.RepairRecord.FirstOrDefault(t => t.ID == repairRecordID && t.IsValid); if (entity == null) { return(new CResult <WebRepairRecord>(null, ErrorCode.DataNoExist)); } var model = new WebRepairRecord() { ID = entity.ID, Note = entity.Note, DeviceID = entity.DeviceID, DeviceName = entity.Device.Name, Operator = entity.Operator, RepairDate = entity.RepairDate, CreateDate = entity.CreateDate, CreateUserID = entity.CreateUserID, CreateUserName = entity.User.Name, ProjectID = entity.ProjectID, Solution = entity.Solution, Describe = entity.Describe, }; var attachments = context.Attachment.Where(a => a.RelationID == entity.ID).ToList(); foreach (var attachment in attachments) { model.Attachments.Add(new WebAttachment() { DisplayName = attachment.DisplayName, FilePath = attachment.FilePath, ID = attachment.ID, Note = attachment.Note }); } LogHelper.Info("result", model); return(new CResult <WebRepairRecord>(model)); } }
public ActionResult AddRepairRecord(string deviceID, string deviceName, string returnUrl) { ViewBag.ReturnUrl = returnUrl; ViewBag.DeviceName = deviceName; ViewBag.DeviceID = deviceID; ViewBag.OperateAction = "Add"; ViewBag.LeftName = "设备信息"; ViewBag.IsAddRecord = "True"; ViewBag.TitleName = "添加维修记录"; WebRepairRecord webRepairRecord = new WebRepairRecord(); webRepairRecord.RepairDate = DateTime.Now.Date; return(View("RepairRecord/AddRepairRecord", webRepairRecord)); }
//public CResult<List<WebRepairRecord>> GetRepairRecordListByDeviceID(string deviceID, out int totalCount, string searchInfo, int pageIndex = 1, int pageSize = 10, string orderby = null, bool ascending = false) //{ // LogHelper.Info(MethodBase.GetCurrentMethod().ToString()); // LogHelper.Info("deviceID", deviceID); // using (DeviceMgmtEntities context = new DeviceMgmtEntities()) // { // Expression<Func<RepairRecord, bool>> filter = t => t.DeviceID == deviceID && t.IsValid == true; // if (string.IsNullOrWhiteSpace(searchInfo) == false) // { // searchInfo = searchInfo.Trim().ToUpper(); // filter = filter.And(t => t.Note.ToUpper().Contains(searchInfo)); // } // var temp = context.RepairRecord.Where(filter).Page(out totalCount, pageIndex, pageSize, orderby, ascending, true); // var result = temp.Select(t => new WebRepairRecord() // { // ID = t.ID, // Note = t.Note, // DeviceID = t.DeviceID, // DeviceName = t.Device.Name, // Operator = t.Operator, // RepairDate = t.RepairDate, // CreateDate = t.CreateDate, // CreateUserID = t.CreateUserID, // CreateUserName = t.User.Name, // ProjectID = t.ProjectID // }).ToList(); // LogHelper.Info("result", result); // return new CResult<List<WebRepairRecord>>(result); // } //} public CResult <string> InsertRepairRecord(WebRepairRecord model) { LogHelper.Info(MethodBase.GetCurrentMethod().ToString()); LogHelper.Info("model", model); if (string.IsNullOrEmpty(model.ProjectID)) { return(new CResult <string>(string.Empty, ErrorCode.ParameterError)); } using (var context = new DeviceMgmtEntities()) { if (context.Project.Any(t => t.IsValid && t.ID == model.ProjectID) == false) { return(new CResult <string>(string.Empty, ErrorCode.ProjectNotExist)); } if (context.Device.Any(t => t.ID == model.DeviceID) == false) { return(new CResult <string>(string.Empty, ErrorCode.DeviceNotExist)); } var entity = new RepairRecord(); entity.CreateDate = DateTime.Now; entity.CreateUserID = model.CreateUserID; entity.ID = Guid.NewGuid().ToString(); entity.RepairDate = model.RepairDate; entity.IsValid = true; entity.Note = model.Note; entity.ProjectID = model.ProjectID; entity.Operator = model.Operator; entity.DeviceID = model.DeviceID; entity.Solution = model.Solution; entity.Describe = model.Describe; context.RepairRecord.Add(entity); if (context.SaveChanges() > 0) { return(new CResult <string>(entity.ID)); } else { return(new CResult <string>("", ErrorCode.SaveDbChangesFailed)); } } }
public ActionResult EditRepairRecord(string repairRecordID, string deviceName, string returnUrl) { ViewBag.ReturnUrl = returnUrl; ViewBag.DeviceName = deviceName; ViewBag.DeviceID = ""; ViewBag.RepairRecordID = repairRecordID; ViewBag.OperateAction = "Update"; ViewBag.IsAddRecord = "False"; ViewBag.LeftName = "维修记录信息"; ViewBag.TitleName = "修改维修记录"; WebRepairRecord webRepairRecord = new WebRepairRecord(); RepairRecordBLL repairRecordBLL = new RepairRecordBLL(); webRepairRecord = repairRecordBLL.GetRepairRecordByID(repairRecordID).Data; return(View("RepairRecord/AddRepairRecord", webRepairRecord)); }
public CResult <bool> UpdateRepairRecord(WebRepairRecord model, List <string> deleteFiles) { LogHelper.Info(MethodBase.GetCurrentMethod().ToString()); LogHelper.Info("model", model); if (string.IsNullOrEmpty(model.ID)) { return(new CResult <bool>(false, ErrorCode.ParameterError)); } using (var context = new DeviceMgmtEntities()) { var entity = context.RepairRecord.FirstOrDefault(t => t.ID == model.ID && t.IsValid); if (entity == null) { return(new CResult <bool>(false, ErrorCode.DataNoExist)); } entity.Note = model.Note; entity.Operator = model.Operator; entity.RepairDate = model.RepairDate; entity.Solution = model.Solution; entity.Describe = model.Describe; context.Entry(entity).State = EntityState.Modified; if (deleteFiles != null && deleteFiles.Count() > 0) { var needDelete = context.Attachment.Where(t => deleteFiles.Contains(t.ID)).ToList(); foreach (var item in needDelete) { context.Attachment.Remove(item); FileHelper.DelFile(item.FilePath); } } return(context.Save()); } }