Beispiel #1
0
        public static void AddNewWorkCalendar(WorkCalendar.DTO headDTO, List <WorkCalendarRule.DTO> lineDTOs)
        {
            DakkaLinqDataContext db = DBHelper.GetDakkaLinqDataContext();

            WorkCalendar workCalendar = new WorkCalendar
            {
                Code        = headDTO.Code,
                Name        = headDTO.Name,
                Description = headDTO.Description,
                //FromDate = DateTime.Parse(headDTO.FromDate),
                //ToDate = DateTime.Parse(headDTO.ToDate)
            };

            if (headDTO.FromDate != null)
            {
                workCalendar.FromDate = DateTime.Parse(headDTO.FromDate);
            }
            if (headDTO.ToDate != null)
            {
                workCalendar.ToDate = DateTime.Parse(headDTO.ToDate);
            }

            foreach (var line in lineDTOs)
            {
                WorkCalendarRule workCalendarRule = new WorkCalendarRule()
                {
                    RuleType  = new RuleTypeEnum(line.RuleType).Value,
                    IsWorkDay = new IsWorkDayEnum(line.IsWorkDay).Value
                };

                if (line.Week != "" && line.Week != "null")
                {
                    workCalendarRule.Week = new WeekEnum(line.Week).Value;
                }
                if (line.Year != "" && line.Year != "null")
                {
                    workCalendarRule.Year = int.Parse(line.Year);
                }
                if (line.Month != "" && line.Month != "null")
                {
                    workCalendarRule.Month = int.Parse(line.Month);
                }
                if (line.Day != "" && line.Day != "null")
                {
                    workCalendarRule.Day = int.Parse(line.Day);
                }
                if (line.Number != "" && line.Number != "null")
                {
                    workCalendarRule.Number = int.Parse(line.Number);
                }
                if (line.ShiftDef != "" && line.ShiftDef != "null")
                {
                    ShiftDef sd = ShiftDef.GetByCode(line.ShiftDef);

                    if (sd != null)
                    {
                        workCalendarRule.ShiftDef = sd.ID;
                    }
                }

                workCalendarRule.RuleValue = "0";
                // TODO: 此处RuleValue在数据库中不能为空, 故先赋值, 待修改.

                workCalendar.WorkCalendarRule.Add(workCalendarRule);
            }

            db.WorkCalendar.InsertOnSubmit(workCalendar);

            db.SubmitChanges();
        }
Beispiel #2
0
 private void detach_WorkCalendarRule(WorkCalendarRule entity)
 {
     this.SendPropertyChanging();
     entity.ShiftDef1 = null;
 }
Beispiel #3
0
 partial void DeleteWorkCalendarRule(WorkCalendarRule instance);
Beispiel #4
0
 partial void UpdateWorkCalendarRule(WorkCalendarRule instance);
Beispiel #5
0
 partial void InsertWorkCalendarRule(WorkCalendarRule instance);
Beispiel #6
0
 private void attach_WorkCalendarRule(WorkCalendarRule entity)
 {
     this.SendPropertyChanging();
     entity.WorkCalendar = this;
 }