//批次修改(一次一件) public String EditEvent(int mID, int cID, String uid, EventEditViewModel editValue) { String ret = "false"; String eventNum = ""; String errorStr = ""; Boolean Chg = false; WBSEventM wBSEventM = db.WBSEventM.Find(mID); WBSEventC wBSEventC = db.WBSEventC.Find(cID); eventNum = wBSEventM.CaseClass + wBSEventM.CaseDate + "-"; if (wBSEventM.CaseCode < 10) eventNum += "0000" + wBSEventM.CaseCode.ToString(); else if (wBSEventM.CaseCode < 100 && wBSEventM.CaseCode >= 10) eventNum += "000" + wBSEventM.CaseCode.ToString(); else if (wBSEventM.CaseCode < 1000 && wBSEventM.CaseCode >= 100) eventNum += "00" + wBSEventM.CaseCode.ToString(); else if (wBSEventM.CaseCode < 10000 && wBSEventM.CaseCode >= 1000) eventNum += "0" + wBSEventM.CaseCode.ToString(); else eventNum += wBSEventM.CaseCode.ToString(); eventNum += "-" + ((wBSEventC.ChildCaseID < 10) ? ("0" + wBSEventC.ChildCaseID.ToString()) : wBSEventC.ChildCaseID.ToString()); try { if (editValue.SArriveDTStr != null) { if (wBSEventC.EventStatus < 41) errorStr += "案件尚未到達,無法修改到達時間。\n\r"; else { wBSEventC.ServiceArriveDT = DateTime.Parse(editValue.SArriveDTStr); Chg = true; } } if (editValue.SLeaveDTStr != null) { if (wBSEventC.EventStatus < 42) errorStr += "案件尚未離開,無法修改離開時間。\n\r"; else { wBSEventC.ServiceLeaveDT = DateTime.Parse(editValue.SLeaveDTStr); Chg = true; } } if (editValue.QFinishDTStr != null) { if (wBSEventC.EventStatus < 50) errorStr += "案件尚未解決,無法修改解決時間。\n\r"; else { wBSEventC.QuestionFinishDT = DateTime.Parse(editValue.QFinishDTStr); Chg = true; } } if (Chg) { wBSEventC.AbnormalModifySW = "Y"; //異常修改SW wBSEventC.ModifyDateTime = DateTime.Now; wBSEventC.ModifyUserID = uid; db.SaveChanges(); if (errorStr == "") return wBSEventM.Customer1.ShortName + "-" + wBSEventC.ProductClass1.Note + "-修改成功,單號:" + eventNum + "。\n\r"; //return "案件" + eventNum + "修改成功。\n\r"; else return wBSEventM.Customer1.ShortName + "-" + wBSEventC.ProductClass1.Note + "-部分修改成功,失敗部分原因如下:\n\r" + errorStr + "單號:" + eventNum + "。\n\r"; //return "案件" + eventNum + "修改部分成功。失敗部分原因如下:\n\r" + errorStr; } else { return wBSEventM.Customer1.ShortName + "-" + wBSEventC.ProductClass1.Note + "-修改失敗,失敗原因如下:\n\r" + errorStr + "單號:" + eventNum + "。\n\r"; //return "案件" + eventNum + "修改失敗。失敗原因如下:\n\r" + errorStr; } } catch { return wBSEventM.Customer1.ShortName + "-" + wBSEventC.ProductClass1.Note + "-修改失敗,失敗原因如下:\n\r" + errorStr + "單號:" + eventNum + "。\n\r"; //return "案件" + eventNum + "修改失敗。失敗原因如下:\n\r" + errorStr; } }
//保養強制解決(一次一件) public String CloseMEvent(int mID, int cID, String uid, EventEditViewModel editValue) { String ret = "false"; String eventNum = ""; String errorStr = ""; Boolean Chg = false; WBSEventM wBSEventM = db.WBSEventM.Find(mID); WBSEventC wBSEventC = db.WBSEventC.Find(cID); eventNum = wBSEventM.CaseClass + wBSEventM.CaseDate + "-"; if (wBSEventM.CaseCode < 10) eventNum += "0000" + wBSEventM.CaseCode.ToString(); else if (wBSEventM.CaseCode < 100 && wBSEventM.CaseCode >= 10) eventNum += "000" + wBSEventM.CaseCode.ToString(); else if (wBSEventM.CaseCode < 1000 && wBSEventM.CaseCode >= 100) eventNum += "00" + wBSEventM.CaseCode.ToString(); else if (wBSEventM.CaseCode < 10000 && wBSEventM.CaseCode >= 1000) eventNum += "0" + wBSEventM.CaseCode.ToString(); else eventNum += wBSEventM.CaseCode.ToString(); eventNum += "-" + ((wBSEventC.ChildCaseID < 10) ? ("0" + wBSEventC.ChildCaseID.ToString()) : wBSEventC.ChildCaseID.ToString()); try { if (wBSEventC.EventClass=="M01") { if (wBSEventC.EventStatus != 0) { if (wBSEventC.EventStatus <= 11) {//11 wBSEventC.AssignUserID = uid; wBSEventC.AssignDT = DateTime.Parse("1900/01/01"); wBSEventC.ResponsibleID = 1093; //SYS01(楊經理) wBSEventC.AssignCreateDT = DateTime.Parse("1900/01/01"); wBSEventC.AssignCreateUserID = uid; wBSEventC.AssignModifyDT = DateTime.Parse("1900/01/01"); wBSEventC.AssignModifyUserID = uid; } if (wBSEventC.EventStatus <= 30) {//20. 21. 30 if (wBSEventC.EventStatus == 21) { wBSEventC.RespondSW = "Y"; wBSEventC.RespondDT = DateTime.Parse("1900/01/01"); wBSEventC.RespondReason = ""; } wBSEventC.ScheduleStartDT = DateTime.Parse("1900/01/01"); wBSEventC.ScheduleEndDT = DateTime.Parse("1900/01/01"); wBSEventC.ScheduleServiceHours = 0; } if (wBSEventC.EventStatus <= 31) { wBSEventC.ServiceArriveDT = DateTime.Parse(editValue.SArriveDTStr); wBSEventC.ServiceArriveSysDT = DateTime.Parse(editValue.SArriveDTStr); wBSEventC.ServiceCreateDT = DateTime.Parse("1900/01/01"); wBSEventC.ServiceCreateUserID = uid; wBSEventC.ServiceModifyDT = DateTime.Parse("1900/01/01"); wBSEventC.ServiceModifyUserID = uid; } if (wBSEventC.EventStatus <= 41) { wBSEventC.ServiceLeaveDT = DateTime.Parse(editValue.SLeaveDTStr); wBSEventC.ServiceLeaveSysDT = DateTime.Parse(editValue.SLeaveDTStr); wBSEventC.ServiceTakeHours = 0; } if (wBSEventC.EventStatus <= 42) { wBSEventC.ServiceReport = ""; } if (wBSEventC.EventStatus <= 43) { if (wBSEventC.ProvideSpareMach == null) wBSEventC.ProvideSpareMach = "F"; if (wBSEventC.RetrieveSpareMach == null) wBSEventC.RetrieveSpareMach = "F"; if (wBSEventC.RetrieveUserMach == null) wBSEventC.RetrieveUserMach = "F"; if (wBSEventC.ReturnUserMach == null) wBSEventC.ReturnUserMach = "F"; wBSEventC.MachMemo = ""; wBSEventC.EventStatus = 46; wBSEventC.QuestionFinishDT = DateTime.Parse(editValue.QFinishDTStr); wBSEventC.QuestionFinishSysDT = DateTime.Parse(editValue.QFinishDTStr); wBSEventC.QuestionFinishSW = "Y"; wBSEventC.ModifyDateTime = DateTime.Now; wBSEventC.ModifyUserID = uid; wBSEventC.AbnormalModifySW = "Y"; } if (wBSEventC.ServiceReport == null || wBSEventC.ServiceReport == "") wBSEventC.ServiceReport += "已解決待審核。"; else wBSEventC.ServiceReport += "\r\n已解決待審核。"; //if (wBSEventC.RetrieveSpareMach == "T") //先判斷本case是否取回備機,若有,表示之前的全取回 // wBSEventM.SpareMach = "R"; ; //if (wBSEventC.ReturnUserMach == "T") //先判斷本case是否歸還客戶機器,若有,表示之前的全歸還 // wBSEventM.UserMach = "R"; ; //if (wBSEventC.ProvideSpareMach == "T") //再判斷本次是否借出備機 // wBSEventM.SpareMach = "L"; //if (wBSEventC.RetrieveUserMach == "T") //再判斷本次是否取回客戶機器 // wBSEventM.UserMach = "L"; wBSEventM.CaseMStatus = "6"; db.SaveChanges(); //ret = "案件" + eventNum + "已解決。"; ret = wBSEventM.Customer1.ShortName + "-" + wBSEventC.ProductClass1.Note + "-M01保養單已解決待審核,單號:" + eventNum + "。\n\r"; //ret = eventNum + "結案成功。"; } } else { ret = wBSEventM.Customer1.ShortName + "-" + wBSEventC.ProductClass1.Note + "-非「M01保養單」不做處理,單號:" + eventNum + "。\n\r"; } return ret; } catch { return wBSEventM.Customer1.ShortName + "-" + wBSEventC.ProductClass1.Note + "-保養強制解決失敗,單號:" + eventNum + "。\n\r"; } }