/// <summary> /// UpdateInfo /// </summary> /// <param name="fields"></param> /// <param name="id"></param> /// <returns></returns> public bool UpdateInfo(string fields, long id) { TwdWindowTimeInfo info = dal.GetInfo(id); if (info == null) { throw new Exception("MC:0x00000084");///数据错误 } if (info.SendTimeStatus.GetValueOrDefault() != (int)SendTimeStatusConstants.NoSend) { throw new Exception("MC:0x00000311");///发单状态为未发单才允许被修改 } string partBoxCode = CommonBLL.GetFieldValue(fields, "PART_BOX_CODE"); string workDay = CommonBLL.GetFieldValue(fields, "WORK_DAY"); string windowTime = CommonBLL.GetFieldValue(fields, "WINDOW_TIME"); ///窗口时间 DateTime dateWindowTime = CommonBLL.TryParseDatetime(windowTime, "yyyy-MM-dd HH:mm:ss"); DateTime dateWorkDay = CommonBLL.TryParseDatetime(workDay, "yyyy-MM-dd HH:mm:ss"); dateWindowTime = new DateTime(dateWorkDay.Year, dateWorkDay.Month, dateWorkDay.Day, dateWindowTime.Hour, dateWindowTime.Minute, 0); int cnt = dal.GetCounts("[PART_BOX_CODE] = N'" + info.PartBoxCode + "' and [WINDOW_TIME] = N'" + info.WindowTime.GetValueOrDefault() + "' and [ID] <> " + id + ""); if (cnt > 0) { throw new Exception("MC:0x00000313");///相同零件类代码②、工作日⑧、窗口时间⑩的数据不允许重复 } fields = CommonBLL.SetFieldValue(fields, "WINDOW_TIME", dateWindowTime.ToString("yyyy-MM-dd HH:mm:ss")); TwdPartBoxInfo twdPartBoxInfo = new TwdPartBoxDAL().GetInfo(partBoxCode); if (twdPartBoxInfo == null) { throw new Exception("MC:0x00000225");///拉动零件类数据错误 } ///发单时间 = 工作日年月日 + 窗口时间时分秒 - 提前时间 int advanceTime = twdPartBoxInfo.RequirementAccumulateTime.GetValueOrDefault() + ///累积时间 twdPartBoxInfo.LoadTime.GetValueOrDefault() + ///装货时间 twdPartBoxInfo.TransportTime.GetValueOrDefault() + ///运输时间 twdPartBoxInfo.UnloadTime.GetValueOrDefault(); ///卸货时间 DateTime sendTime = dateWindowTime.AddMinutes(0 - advanceTime); fields = CommonBLL.SetFieldValue(fields, "SEND_TIME", sendTime.ToString("yyyy-MM-dd HH:mm:ss")); return(dal.UpdateInfo(fields, id) > 0 ? true : false); }