if not Exists(SELECT * FROM information_schema.tables where Table_name = 'Task') begin create table Task ( ID int Primary key, Title nvarchar(500), Name nvarchar(500), Dom_ID_Status int references Domain(ID) not null, -- فعال/غیرفعال Dom_ID_Type int references Domain(ID) not null, -- شروع فرآیند - پایان فرآیند - گام فرآیند [Description] nvarchar(1000) ) end if not Exists(SELECT * FROM information_schema.tables where Table_name = 'TaskDependency') begin create table TaskDependency ( ID int Primary key, Tas_ID_Process int references Task(ID) not null, Tas_ID_From int references Task(ID) not null, Tas_ID_To int references Task(ID) not null, Dom_ID_Status int references Domain(ID) not null, -- فعال/غیرفعال DllName nvarchar(1000), FormPath nvarchar(1000), Parameter nvarchar(1000), [Description] nvarchar(max) ) end if not Exists(SELECT * FROM information_schema.tables where Table_name = 'TaskPermission') begin create table TaskPermission ( ID int Primary key, Tas_ID int references Task(ID) not null, Dom_ID_Type int references Domain(ID) not null, -- نوع مجوز Dom_ID_Status int references Domain(ID) null, -- فعال/غیرفعال Kar_ID int references Karbar(ID) null, [Description] nvarchar(max), TarikhSabt int not null, SaatSabt smallint not null, CodeKarbar int references Karbar(ID) not null ) end if not Exists(SELECT * FROM information_schema.tables where Table_name = 'Matter') begin create table Matter ( ID bigint Primary key, Dom_ID_Type int references Domain(ID) not null,-- -- نوع: سند حسابداری، فاکتور ...؛ Code int not null , FC_ID int references Finance_Cycle(ID) not null,--references Org_ID int references OtherProperties(ID) not null,--references Dom_ID_Status int references Domain(ID) not null,-- فعال/غیرفعال TarikhSabt int not null, SaatSabt smallint not null, CodeKarbar int references Karbar(ID) not null ) end if not Exists(SELECT * FROM information_schema.tables where Table_name = 'Refer') begin create table Refer ( ID bigint Primary key, Mat_ID bigint references Matter (ID) not null, Dom_ID_Action int references Domain(ID) null,--, -- ابطال , ارجاع به کارتابل فرد ديگر , ارجاع جهت اطلاع , ارجاع جهت اظهار نظر , برگشت , خارج كردن از كارتابل به صورت سيستمي , تعليق , درانتظار , موافقت مي شود , Tas_ID int references Task(ID) not null, TD_ID int references TaskDependency(ID) not null, Kar_ID int references Karbar(ID) not null,-- ReferDate int not null default 0, -- تاریخ ارجاع ReferTime smallint not null default 0, -- زمان ارجاع ViewDate int not null default 0, -- تاریخ مشاهده ViewTime smallint not null default 0, -- زمان مشاهده SendDate int not null default 0, -- تاریخ خروج از کارتابل SendTime smallint not null default 0, -- زمان خروج از کارتابل Dom_ID_Status int references Domain(ID) not null,--, -- مشاهده شده , مشاهده نشده , اقدام شده ReferComment nvarchar(max), Ref_ID bigint references Refer(ID) null, Kar_ID_Sender int references Karbar(ID), Kar_ID_Receiver int references Karbar(ID), MachineName nvarchar(200), TarikhSabt int not null, SaatSabt smallint not null, CodeKarbar int references Karbar(ID) not null ) end go