/// <summary> /// 根据关键字段的值获取记录 /// </summary> /// <param name="Id">关键字段的值</param> /// <returns>符合查询条件的记录</returns> public RsWorkSchedule GetRsWorkScheduleById(string Id) { using (IRsWorkScheduleBLL RsWorkScheduleBLL = BLLContainer.Resolve <IRsWorkScheduleBLL>()) { RsWorkSchedule model = RsWorkScheduleBLL.GetFirstOrDefault(Id); return(model); } }
/// <summary> /// 修改 /// </summary> /// <param name="mRsWorkSchedule">模型</param> /// <returns>是否成功</returns> public bool UpdateRsWorkSchedule(RsWorkSchedule mRsWorkSchedule) { if (mRsWorkSchedule == null) { return(false); } using (IRsWorkScheduleBLL RsWorkScheduleBLL = BLLContainer.Resolve <IRsWorkScheduleBLL>()) { return(RsWorkScheduleBLL.Update(mRsWorkSchedule)); } }
/// <summary> /// 按照关键字段删除 /// </summary> /// <param name="Id">关键字段</param> /// <returns>是否成功</returns> public bool DelRsWorkSchedule(string Id) { using (IRsWorkScheduleBLL RsWorkScheduleBLL = BLLContainer.Resolve <IRsWorkScheduleBLL>()) { try { RsWorkSchedule item = RsWorkScheduleBLL.GetFirstOrDefault(Id); return(RsWorkScheduleBLL.Delete(item)); } catch { return(false); } } }
private void button_Click(object sender, RoutedEventArgs e) { if (isvacation.IsChecked == true)//如果为休息日 { Dictionary <string, string> LinqWhere = new Dictionary <string, string>(); //LinqWhere.Add("MARK_DATE", this.txt_starttime.DateTime.ToString("yyyy-MM-dd")); string jsWhere = JsonSerializer.GetJsonString(LinqWhere);//todo:未考虑跨天业务 List <RsWorkSchedule> m_RsWorkSchedules = _SDMService.UseService(s => s.GetRsWorkSchedules("")); foreach (RsWorkSchedule item in m_RsWorkSchedules) { if (DateTime.Parse(item.MARK_DATE.ToString()).ToString("yyyy/MM/dd") == this.txt_starttime.DateTime.ToString("yyyy/MM/dd")) { item.WORK_FLAG = "0"; _SDMService.UseService(s => s.UpdateRsWorkSchedule(item)); } } } else { WeekDays a = chk_weekday.WeekDays; if (a != 0) { int count = 0; int.TryParse(this.txt_day.Text, out count); for (int i = 0; i < count; i++) { DateTime day = DateTime.Now.AddDays(i); if (chk_weekday.WeekDays.ToString().Contains(day.DayOfWeek.ToString())) { List <RsWorkSchedule> m_RsWorkSchedules = _SDMService.UseService(s => s.GetRsWorkSchedules($"MARK_DATE = '{this.txt_starttime.DateTime}'")); if (m_RsWorkSchedules.Count != 0) { m_RsWorkSchedules[0].MARK_DATE = day; m_RsWorkSchedules[0].MARK_STARTTIME = DateTime.Parse(day.Year.ToString() + "-" + day.Month.ToString() + "-" + day.Day.ToString() + " " + txt_starttime.DateTime.Hour.ToString() + ":" + txt_starttime.DateTime.Minute.ToString() + ":00"); m_RsWorkSchedules[0].MARK_ENDTIME = DateTime.Parse(day.Year.ToString() + "-" + day.Month.ToString() + "-" + day.Day.ToString() + " " + txt_endtime.DateTime.Hour.ToString() + ":" + txt_endtime.DateTime.Minute.ToString() + ":00"); m_RsWorkSchedules[0].WORK_FLAG = "1"; _SDMService.UseService(s => s.UpdateRsWorkSchedule(m_RsWorkSchedules[0])); } else { RsWorkSchedule m_RsWorkSchedule = new RsWorkSchedule(); m_RsWorkSchedule.PKNO = Guid.NewGuid().ToString("N"); m_RsWorkSchedule.MARK_DATE = day; m_RsWorkSchedule.MARK_STARTTIME = DateTime.Parse(day.Year.ToString() + "-" + day.Month.ToString() + "-" + day.Day.ToString() + " " + txt_starttime.DateTime.Hour.ToString() + ":" + txt_starttime.DateTime.Minute.ToString() + ":00"); m_RsWorkSchedule.MARK_ENDTIME = DateTime.Parse(day.Year.ToString() + "-" + day.Month.ToString() + "-" + day.Day.ToString() + " " + txt_endtime.DateTime.Hour.ToString() + ":" + txt_endtime.DateTime.Minute.ToString() + ":00"); m_RsWorkSchedule.WORK_FLAG = "1"; _SDMService.UseService(s => s.AddRsWorkSchedule(m_RsWorkSchedule)); } } } } } }
/// <summary> /// 按照关键字段删除 /// </summary> /// <param name="Ids">关键字段数组</param> /// <returns>是否成功</returns> public bool DelRsWorkSchedules(string[] Ids) { using (IRsWorkScheduleBLL RsWorkScheduleBLL = BLLContainer.Resolve <IRsWorkScheduleBLL>()) { try { List <RsWorkSchedule> entitys = new List <RsWorkSchedule>(); foreach (string id in Ids) { RsWorkSchedule item = RsWorkScheduleBLL.GetFirstOrDefault(id); entitys.Add(item); } return(RsWorkScheduleBLL.Delete(entitys)); } catch { return(false); } } }