if not Exists(SELECT * FROM information_schema.tables where Table_name = 'Shift') begin Create table Shift ( ID int Primary key, Code int not null, Title nvarchar(200) null, Dom_ID int references Domain(ID) not null, -- روزکاری/شبکاری/عصرکاری/تعطیل StartTime smallint not null, -- زمان شروع شیفت EndTime smallint not null, -- زمان پایان شیفت RestStartTime smallint not null, -- شروع استراحت RestEndTime smallint not null, -- پایان استراحت IsEndTimeInNextDay int references Domain(ID) not null, -- بازه پایان شیفت در روز بعد است [Description] nvarchar(1000), CodeKarbar int references Karbar(ID) not null, TarikhSabt int not null, SaatSabt smallint not null ) end go if not Exists(SELECT * FROM information_schema.tables where Table_name = 'WorkGroup') begin Create table WorkGroup ( ID int Primary key, Code int not null, Title nvarchar(200) null, PeriodCirculation int not null, -- دوره گردش TarikhBase int not null, -- تاریخ مبنا TarikhBaseG date not null, -- تاریخ مبنا میلادی Dom_ID_EnterExitType int references Domain(ID) not null, -- نوع ورود/خروج Dom_ID_IsHolidayOfficialHoliday int references Domain(ID) not null, -- تعطیلات رسمی در تقویم برای این گروه تعطیل در نظر گرفته شود؟ Dom_ID_CalcVacation int references Domain(ID) not null, -- مرخصی محاسبه شود؟ DayVacationCountInYear float not null, -- تعداد روز مرخصی در سال HoursCountEqualOneDay smallint not null, -- تعداد ساعت معادل یک روز MaxDayVacationRequireInYear int not null, -- سقف مرخصی روزانه استحقاقی در سال MaxDayVacationNoRequireInYear int not null, -- سقف مرخصی روزانه غیراستحقاقی در سال MaxDayVacationSickInYear int not null, -- سقف مرخصی روزانه استعلاجی در سال MaxWatchVacationInMonth float not null, -- سقف مرخصی ساعتی در ماه MaxWatchVacationInDay float not null, -- سقف مرخصی ساعتی در روز DayVacationCountTransferToNextYear float not null, -- تعداد روزهای مرخصی قابل انتقال به سال بعد Dom_ID_CalcOvertime int references Domain(ID) not null, -- اضافه کار محاسبه شود؟ MaxOvertimeInMonth int not null, -- سقف اضافه کار در ماه CoefficientOvertimeInDayHoliday float not null, -- ضریب اضافه کار روز تعطیلی CoefficientOvertimeInShiftHoliday float not null, -- ضریب اضافه کار شیفت تعطیلی Dom_ID_CalcOvertimeBeforeEnter int references Domain(ID) not null, -- اضافه کار قبل از ورود محاسبه شود؟ Dom_ID_CalcOvertimeAfterExit int references Domain(ID) not null, -- اضافه کار بعد از خروج محاسبه شود؟ Dom_ID_CalcOvertimeInPresenceOfVacation int references Domain(ID) not null, -- در صورت حضور در هنگام مرخصی، برای فرد اضافه کار محاسبه شود؟ Dom_ID_CalcOvertimeInPresenceOfMission int references Domain(ID) not null, -- در صورت حضور در هنگام ماموریت، برای فرد اضافه کار محاسبه شود؟ CodeKarbar int references Karbar(ID) not null, TarikhSabt int not null, SaatSabt smallint not null ) end go if not Exists(SELECT * FROM information_schema.tables where Table_name = 'Calendar') begin Create table Calendar ( ID int Primary key, Code int not null, Title nvarchar(200) null, IsLeapYear bit not null, Dom_ID_BeginDay int references Domain(ID) not null, -- اولین روز سال [Description] nvarchar(1000), CodeKarbar int references Karbar(ID) not null, TarikhSabt int not null, SaatSabt smallint not null ) end go if not Exists(SELECT * FROM information_schema.tables where Table_name = 'CalendarDetail') begin Create table CalendarDetail ( ID int Primary key, Cal_ID int references Calendar(ID) not null, Tarikh int not null, GTarikh date not null, IsWeeklyHoliday bit not null, -- تعطیل هفتگی IsFormalHoliday bit not null, -- تعطیل رسمی Dom_ID_Day int references Domain(ID) not null, -- روز هفته [Description] nvarchar(1000), CodeKarbar int references Karbar(ID) not null, TarikhSabt int not null, SaatSabt smallint not null ) end go if not Exists(SELECT * FROM information_schema.tables where Table_name = 'ShiftWorkGroup') begin Create table ShiftWorkGroup ( ID int Primary key, Shi_ID int references Shift(ID) not null, WG_ID int references Workgroup(ID) not null, Priority int not null, [Description] nvarchar(1000), CodeKarbar int references Karbar(ID) not null, TarikhSabt int not null, SaatSabt smallint not null ) end go if not Exists(SELECT * FROM information_schema.tables where Table_name = 'PeopleWorkGroup') begin Create table PeopleWorkGroup ( ID int Primary key, Taf_ID bigint references Tafsili(ID) not null, WG_ID int references Workgroup(ID) not null, StartDate int not null, EndDate int not null, [Description] nvarchar(1000), CodeKarbar int references Karbar(ID) not null, TarikhSabt int not null, SaatSabt smallint not null ) end go if not Exists(SELECT * FROM information_schema.tables where Table_name = 'PersianCalendar') begin Create table PersianCalendar ( ID int Primary key, [Year] int not null, [Month] int not null, [Day] int not null, DayOfWeek int not null, Jdate int not null, GDate date not null, ) end