//已解決案件修改手機(20160317-增加到達時間及離開時間的修改) public String[] EditClosedCase(EditCloseCaseViewModel editCase) { String[] ret = new String[3]; ret[0] = "false"; //回饋訊息 ret[1] = ""; //案號 ret[2] = ""; //mid try { int tempCid = Int32.Parse(editCase.Cid); WBSEventC wBSEventC = db.WBSEventC.Find(tempCid); WBSEventM wBSEventM = db.WBSEventM.Find(wBSEventC.MomCaseID); String caseNum = ""; ret[2] = wBSEventC.MomCaseID.ToString(); caseNum = wBSEventM.CaseClass + wBSEventM.CaseDate + "-"; if (wBSEventM.CaseCode < 10) caseNum += "0000" + wBSEventM.CaseCode.ToString(); else if (wBSEventM.CaseCode < 100 && wBSEventM.CaseCode >= 10) caseNum += "00" + wBSEventM.CaseCode.ToString(); else if (wBSEventM.CaseCode < 10000 && wBSEventM.CaseCode >= 1000) caseNum += "0" + wBSEventM.CaseCode.ToString(); else caseNum += wBSEventM.CaseCode.ToString(); caseNum += "-" + ((wBSEventC.ChildCaseID < 10) ? ("0" + wBSEventC.ChildCaseID.ToString()) : wBSEventC.ChildCaseID.ToString()); if (wBSEventC.ServiceArriveDT != editCase.ArriveDate || wBSEventC.ServiceLeaveDT != editCase.LeaveDate) wBSEventC.AbnormalModifySW = "Y"; wBSEventC.ServiceArriveDT = editCase.ArriveDate; wBSEventC.ServiceLeaveDT = editCase.LeaveDate; wBSEventC.ModifyDateTime = DateTime.Now; wBSEventC.ModifyUserID = editCase.UserID; wBSEventC.ServiceModifyDT = DateTime.Now; wBSEventC.ServiceModifyUserID = editCase.UserID; wBSEventC.ProvideSpareMach = editCase.ProvideSpareMach; wBSEventC.RetrieveSpareMach = editCase.RetrieveSpareMach; wBSEventC.RetrieveUserMach = editCase.RetrieveUserMach; wBSEventC.ReturnUserMach = editCase.ReturnUserMach; wBSEventC.MachMemo = editCase.MachMemo; wBSEventC.ServiceReport = editCase.ServiceReport; //20150825新增-Hsiuyang-SugProduct實際更換削除部分 JArray SugProduct = JsonConvert.DeserializeObject<JArray>(editCase.MaterialJson); for (int i = 0; i < SugProduct.Count; i++) { SugProduct sugProduct = new SugProduct(); sugProduct.CID = wBSEventC.Num; sugProduct.Class = Int32.Parse(SugProduct[i]["Class"].ToString()); if (SugProduct[i]["ProductNum"].ToString() == "") sugProduct.ProductName = SugProduct[i]["ProductName"].ToString(); else sugProduct.ProductNum = Int32.Parse(SugProduct[i]["ProductNum"].ToString()); db.SugProduct.Add(sugProduct); } ////20160201新增-Hsiuyang-刪除已上傳服務報告附件 //JArray DeleteFile = JsonConvert.DeserializeObject<JArray>(editCase.DeleteFileJson); //for (int i = 0; i < DeleteFile.Count; i++) //{ // SugProduct sugProduct = new SugProduct(); // sugProduct.CID = wBSEventC.Num; // sugProduct.Class = Int32.Parse(SugProduct[i]["Class"].ToString()); // if (SugProduct[i]["ProductNum"].ToString() == "") // sugProduct.ProductName = SugProduct[i]["ProductName"].ToString(); // else // sugProduct.ProductNum = Int32.Parse(SugProduct[i]["ProductNum"].ToString()); // db.SugProduct.Add(sugProduct); //} //20160201新增-Hsiuyang-刪除已設定實際/銷除零件列表 JArray DeleteUsedProduct = JsonConvert.DeserializeObject<JArray>(editCase.DeleteUsedProductJson); for (int i = 0; i < DeleteUsedProduct.Count; i++) { int t = Int32.Parse(DeleteUsedProduct[i]["ID"].ToString()); SugProduct sugProduct = db.SugProduct.Find(t); db.SugProduct.Remove(sugProduct); } db.SaveChanges(); ret[0] = wBSEventM.Customer1.ShortName + "-" + wBSEventC.ProductClass1.Note + "-修改成功,單號:" + caseNum + "。"; //ret[0] = "修改成功"; ret[1] = caseNum; } catch { ret[0] = "false"; } return ret; }
public ActionResult EditServiceData(string cid, string materialJson, string editArriveTime, string editLeaveTime, string deleteFileJson, string deleteUsedProductJson, string note, string provideSpareMach, string retrieveSpareMach, string retrieveUserMach, string returnUserMach, string machMemo, IEnumerable<HttpPostedFileBase> files) { if (!User.Identity.IsAuthenticated) return RedirectToAction("Logon", "Mobile"); // 先取得該使用者的 FormsIdentity FormsIdentity id = (FormsIdentity)User.Identity; // 再取出使用者的 FormsAuthenticationTicket FormsAuthenticationTicket ticket = id.Ticket; string[] ret; String msg = "修改失敗。"; EditCloseCaseViewModel editCase = new EditCloseCaseViewModel(); editCase.Cid = cid; editCase.MaterialJson = materialJson; editCase.DeleteFileJson = deleteFileJson; editCase.DeleteUsedProductJson = deleteUsedProductJson; editCase.ServiceReport = note; editCase.ProvideSpareMach = provideSpareMach; editCase.MachMemo = machMemo; editCase.RetrieveSpareMach = retrieveSpareMach; editCase.RetrieveUserMach = retrieveUserMach; editCase.ReturnUserMach = returnUserMach; editCase.UserID = ticket.Name; editCase.ArriveDate = DateTime.ParseExact(editArriveTime, "yyyyMMdd HH:mm", CultureInfo.InvariantCulture);; editCase.LeaveDate = DateTime.ParseExact(editLeaveTime, "yyyyMMdd HH:mm", CultureInfo.InvariantCulture); ; ret = wBSEventRepository.EditClosedCase(editCase); if (ret[0] != "false") { string filePath = System.Configuration.ConfigurationManager.AppSettings["FilePath"]; JArray DeleteFile = JsonConvert.DeserializeObject<JArray>(editCase.DeleteFileJson); for (int i = 0; i < DeleteFile.Count; i++) { filesRepository.DeleteFile(DeleteFile[i]["FID"].ToString(), filePath); } if (files != null) { Save(files, ret[1], cid, 4); } msg = ret[0]; } else { msg = "修改失敗。"; } return RedirectToAction("EventList", "Mobile", new { data = msg, type = "3" }); }