Ejemplo n.º 1
0
        public static void DakkaByID(string ID)
        {
            DakkaLinqDataContext db = DBHelper.GetDakkaLinqDataContext();

            WorkRecord re = db.WorkRecord.Single(wr => wr.ID == long.Parse(ID));

            re.Status = StatusEnum.OK.Value;

            db.SubmitChanges();
        }
Ejemplo n.º 2
0
        public static void Make(string EmployeeCode, string WorkCalendarCode, DateTime FromDate, DateTime ToDate)
        {
            Employee     employee     = DakkaData.Employee.GetByCode(EmployeeCode);
            WorkCalendar workCalendar = DakkaData.WorkCalendar.GetByCode(WorkCalendarCode);

            long EmployeeID = employee.ID;

            List <WorkRecord> records = new List <WorkRecord>();

            do
            {
                bool     isWorkDay = false;
                ShiftDef shiftDef  = null;

                foreach (var rule in workCalendar.WorkCalendarRule)
                {
                    if (rule.RuleType == RuleTypeEnum.Week.Value)
                    {
                        if (rule.Week == new WeekEnum(FromDate.DayOfWeek.ToString()).Value)
                        {
                            isWorkDay = rule.IsWorkDay;
                            shiftDef  = rule.ShiftDef1;
                        }
                    }
                    else if (rule.RuleType == RuleTypeEnum.Month.Value)
                    {
                        if (rule.Day == FromDate.Day)
                        {
                            isWorkDay = rule.IsWorkDay;
                            shiftDef  = rule.ShiftDef1;
                        }
                    }
                    else if (rule.RuleType == RuleTypeEnum.Year.Value)
                    {
                        if (rule.Month == FromDate.Month && rule.Day == FromDate.Day)
                        {
                            isWorkDay = rule.IsWorkDay;
                            shiftDef  = rule.ShiftDef1;
                        }
                    }
                    else if (rule.RuleType == RuleTypeEnum.Date.Value)
                    {
                        if (rule.Year == FromDate.Year &&
                            rule.Month == FromDate.Month &&
                            rule.Day == FromDate.Day)
                        {
                            isWorkDay = rule.IsWorkDay;
                            shiftDef  = rule.ShiftDef1;
                        }
                    }
                }

                if (isWorkDay && shiftDef != null)
                {
                    foreach (var shiftPoint in shiftDef.ShiftPoint)
                    {
                        WorkRecord workRecord = new WorkRecord()
                        {
                            Employee  = EmployeeID,
                            WorkPoint = new DateTime(FromDate.Year, FromDate.Month, FromDate.Day,
                                                     shiftPoint.PointTime.Hour, shiftPoint.PointTime.Minute, shiftPoint.PointTime.Second),
                            PointType = shiftPoint.PointType,
                            Status    = StatusEnum.Null.Value
                        };

                        records.Add(workRecord);
                    }
                }

                FromDate = FromDate.AddDays(1);
            }while (FromDate.Date <= ToDate);

            DakkaLinqDataContext db = DBHelper.GetDakkaLinqDataContext();

            db.WorkRecord.InsertAllOnSubmit(records);

            db.SubmitChanges();
        }
Ejemplo n.º 3
0
 partial void DeleteWorkRecord(WorkRecord instance);
Ejemplo n.º 4
0
 partial void UpdateWorkRecord(WorkRecord instance);
Ejemplo n.º 5
0
 partial void InsertWorkRecord(WorkRecord instance);
Ejemplo n.º 6
0
 private void detach_WorkRecord(WorkRecord entity)
 {
     this.SendPropertyChanging();
     entity.Employee1 = null;
 }