Example #1
0
 public int InsertSpareUseHistory(SpareToolUseHistory spareToolUseHistory)
 {
     return(repoSpareToolService.inSertRepoSpareUseHistory(spareToolUseHistory));
 }
Example #2
0
 public string UpdateBreakToolInfo(MaintainManageInfo maintainManageInfo)
 {
     if (!new MaintainManageInfoService().IsNotFinishBreakToolExist(maintainManageInfo))
     {
         return("名称为" + maintainManageInfo.ToolSerialName + "的工具不存在!");
     }
     if (maintainManageInfo.UsedRepoSpareToolInfo == null)
     {
         maintainManageInfoService.UpdateMaintainStatus(maintainManageInfo);
         return("未使用任何零件");
     }
     foreach (var item in maintainManageInfo.UsedRepoSpareToolInfo)
     {
         RepoSpareTool repoSpareTool = repoSpareToolService.getOneRepoSpareToolFromDb(item.Key);
         if (repoSpareTool == null)
         {
             return("数据库中不包含型号为:" + item.Key + "的备件信息");
         }
         if (repoSpareTool.Num < item.Value)
         {
             return("数据库中型号为:" + item.Key + "的备件个数不足" + item.Value.ToString() + "个");
         }
     }
     try
     {
         maintainManageInfoService.UpdateMaintainManageInfo(maintainManageInfo);
         if (maintainManageInfo.Status != MaintainDeclare.Suspend)
         {
             foreach (var item in maintainManageInfo.UsedRepoSpareToolInfo)
             {
                 RepoSpareTool repoSpareTool = repoSpareToolService.getOneRepoSpareToolFromDb(item.Key);
                 int           num           = repoSpareTool.Num - item.Value;
                 Console.WriteLine("num is {0}", num);
                 int affectedRow = repoSpareToolService.updateRepoSpareToolNum(num, item.Key);
                 if (affectedRow < 1)
                 {
                     return("更新数据库失败!");
                 }
                 SpareToolUseHistory spareToolUseHistory = new SpareToolUseHistory();
                 spareToolUseHistory.SpareToolModel = item.Key;
                 spareToolUseHistory.Num            = item.Value;
                 spareToolUseHistory.UseTime        = DateTime.Now.ToString("yyyy-MM-dd");
                 affectedRow = repoSpareToolManage.InsertSpareUseHistory(spareToolUseHistory);
                 if (affectedRow < 1)
                 {
                     return("更新数据库失败!");
                 }
             }
             int affected = maintainManageInfoService.InsertOneRepairHistory(new RepairHistory
             {
                 ToolSerialName         = maintainManageInfo.ToolSerialName,
                 ToolModeName           = maintainManageInfo.ToolModeName,
                 SendFixTime            = maintainManageInfo.SendFixTime,
                 FinishFixTime          = maintainManageInfo.FinishFixTime,
                 Detail                 = maintainManageInfo.Detail,
                 UsedOtherSpareToolInfo = maintainManageInfo.UsedOtherSpareToolInfo,
                 UsedRepoSpareToolInfo  = maintainManageInfo.UsedRepoSpareToolInfo
             });
             if (affected < 1)
             {
                 return("更新数据库失败!");
             }
         }
         return("挂起");
     }
     catch
     {
         return("error");
     }
 }
Example #3
0
 public int inSertRepoSpareUseHistory(SpareToolUseHistory spareToolUseHistory)
 {
     return(SQLHelper.InsertValuesByStruct("SpareToolUseHistory", spareToolUseHistory));
 }