USE [LIMS]
GO
/****** Object:  Table [dbo].[ActionsTypes]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ActionsTypes](
	[ActionTypeID] [int] IDENTITY(1,1) NOT NULL,
	[NameEn] [nvarchar](255) NOT NULL,
	[NameAr] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NOT NULL,
	[DescriptionEn] [nvarchar](500) NULL,
	[DescriptionAr] [nvarchar](500) NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[ActionTypeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Assign_Permissions_2_Roles]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Assign_Permissions_2_Roles](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ModuleID] [int] NOT NULL,
	[PermID] [int] NOT NULL,
	[RoleID] [int] NOT NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[BackupsRestores]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[BackupsRestores](
	[BackupRestoreID] [int] IDENTITY(1,1) NOT NULL,
	[NameAR] [nvarchar](255) NOT NULL,
	[NameEN] [nvarchar](255) NOT NULL,
	[RunAt] [datetime] NULL,
	[RepeatEvery] [nvarchar](50) NULL,
	[SavePath] [nvarchar](500) NULL,
	[NotesAR] [nvarchar](max) NULL,
	[Hour] [int] NULL,
	[NotesEN] [nvarchar](max) NULL,
PRIMARY KEY CLUSTERED 
(
	[BackupRestoreID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Calibrations]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Calibrations](
	[CalibrationID] [int] IDENTITY(1,1) NOT NULL,
	[CalibrationTypeID] [int] NOT NULL,
	[Name] [nvarchar](255) NOT NULL,
	[SerialNumber] [nvarchar](100) NULL,
	[CalibrationDate] [datetime] NULL,
	[CalibrationCompanyID] [int] NULL,
	[TechnicianID] [int] NULL,
	[ReferenceNumber] [nvarchar](100) NULL,
	[CalibrationType] [nvarchar](255) NULL,
	[CalibrationStandard] [nvarchar](255) NULL,
	[CalibrationCertificate] [nvarchar](500) NULL,
	[CalibrationMethodology] [nvarchar](255) NULL,
	[CalibrationResults] [nvarchar](max) NULL,
	[NextCalibrationDate] [datetime] NULL,
	[RecommendedActions] [nvarchar](max) NULL,
	[Notes] [nvarchar](max) NULL,
	[CalibrationPerformedBy] [nvarchar](255) NULL,
	[CompanyNameAR] [nvarchar](255) NULL,
	[CompanyNameEN] [nvarchar](255) NULL,
	[AddressAR] [nvarchar](255) NULL,
	[AddressEN] [nvarchar](255) NULL,
	[Owner] [nvarchar](255) NULL,
	[Phone] [nvarchar](50) NULL,
	[Mobile] [nvarchar](50) NULL,
	[EmailTo] [nvarchar](255) NULL,
	[EmailCC] [nvarchar](255) NULL,
	[IsActive] [bit] NULL,
	[TechnicianNameAR] [nvarchar](255) NULL,
	[TechnicianNameEN] [nvarchar](255) NULL,
	[TechnicianMobile] [nvarchar](50) NULL,
	[TechnicianEmail] [nvarchar](255) NULL,
PRIMARY KEY CLUSTERED 
(
	[CalibrationID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[CalibrationsAttachments]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CalibrationsAttachments](
	[AttachmentID] [int] IDENTITY(1,1) NOT NULL,
	[FileName] [nvarchar](255) NOT NULL,
	[FilePath] [nvarchar](500) NOT NULL,
	[CalibrationID] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[AttachmentID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[CalibrationsCompanies]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CalibrationsCompanies](
	[CompanyID] [int] IDENTITY(1,1) NOT NULL,
	[NameAR] [nvarchar](255) NOT NULL,
	[NameEN] [nvarchar](255) NOT NULL,
	[Phone] [nvarchar](50) NULL,
	[Mobile] [nvarchar](50) NULL,
	[EmailTo] [nvarchar](255) NULL,
	[EmailCC] [nvarchar](255) NULL,
	[Owner] [nvarchar](255) NULL,
	[AddressAR] [nvarchar](255) NULL,
	[AddressEN] [nvarchar](255) NULL,
	[IsActive] [bit] NULL,
PRIMARY KEY CLUSTERED 
(
	[CompanyID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[CalibrationsTechnicians]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CalibrationsTechnicians](
	[TechnicianID] [int] IDENTITY(1,1) NOT NULL,
	[CompanyID] [int] NOT NULL,
	[NameAR] [nvarchar](255) NOT NULL,
	[NameEN] [nvarchar](255) NOT NULL,
	[Phone] [nvarchar](50) NULL,
	[Mobile] [nvarchar](50) NULL,
	[Email] [nvarchar](255) NULL,
	[IsActive] [bit] NULL,
PRIMARY KEY CLUSTERED 
(
	[TechnicianID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Contracts]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Contracts](
	[ContractID] [int] IDENTITY(1,1) NOT NULL,
	[CustomerID] [int] NOT NULL,
	[ContractTypeID] [int] NULL,
	[ContractStartDate] [datetime] NOT NULL,
	[ContractEndDate] [datetime] NOT NULL,
	[ContractStatus] [nvarchar](50) NULL,
	[PricingModel] [nvarchar](50) NULL,
	[Discounts] [decimal](5, 2) NULL,
	[ContractValue] [decimal](18, 2) NULL,
	[PaymentTerms] [nvarchar](255) NULL,
	[AdvancePayment] [decimal](18, 2) NULL,
	[ContractDocument] [nvarchar](500) NULL,
	[RelatedDocuments] [nvarchar](max) NULL,
	[NotesComments] [nvarchar](max) NULL,
	[ExpiryNotification] [datetime] NULL,
	[RenewalTerms] [nvarchar](500) NULL,
PRIMARY KEY CLUSTERED 
(
	[ContractID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[ContractScopeOfWork]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ContractScopeOfWork](
	[ContractScopeOfWork] [int] IDENTITY(1,1) NOT NULL,
	[SeriveOrTest] [bit] NOT NULL,
	[SeriveID] [int] NULL,
	[TestID] [int] NULL,
	[Limits] [nvarchar](500) NULL,
	[SpecialTerms] [nvarchar](500) NULL,
	[ContractID] [int] NOT NULL,
 CONSTRAINT [PK_ContractScopeOfWork] PRIMARY KEY CLUSTERED 
(
	[ContractScopeOfWork] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[ContractTypes]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ContractTypes](
	[ContractTypeID] [int] IDENTITY(1,1) NOT NULL,
	[NameAR] [nvarchar](255) NOT NULL,
	[NameEN] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NULL,
	[DescriptionAR] [nvarchar](max) NULL,
	[DescriptionEN] [nvarchar](max) NULL,
PRIMARY KEY CLUSTERED 
(
	[ContractTypeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Countries]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Countries](
	[CountryID] [int] IDENTITY(1,1) NOT NULL,
	[NameAr] [nvarchar](255) NOT NULL,
	[NameEn] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NOT NULL,
	[DescriptionAr] [nvarchar](500) NULL,
	[DescriptionEn] [nvarchar](500) NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[CountryID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Currencies]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Currencies](
	[CurrencyID] [int] IDENTITY(1,1) NOT NULL,
	[NameAR] [nvarchar](255) NOT NULL,
	[NameEN] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NULL,
	[Symbol] [nvarchar](255) NOT NULL,
	[DescriptionAR] [nvarchar](max) NULL,
	[DescriptionEN] [nvarchar](max) NULL,
 CONSTRAINT [PK_Currencies] PRIMARY KEY CLUSTERED 
(
	[CurrencyID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[CustomerContacts]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CustomerContacts](
	[ContactID] [int] IDENTITY(1,1) NOT NULL,
	[ContactName] [nvarchar](255) NOT NULL,
	[Email1] [nvarchar](255) NULL,
	[Email2] [nvarchar](255) NULL,
	[Mobile1] [nvarchar](50) NULL,
	[PositionID] [int] NULL,
	[CustomerID] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[ContactID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[CustomerRequests]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CustomerRequests](
	[RequestID] [int] IDENTITY(1,1) NOT NULL,
	[CustomerID] [int] NOT NULL,
	[ProjectID] [int] NULL,
	[ServiceTypeID] [int] NULL,
	[ServiceID] [int] NULL,
	[AssignTo] [nvarchar](255) NULL,
	[RequestNo] [nvarchar](50) NULL,
	[Status] [nvarchar](50) NULL,
	[PriorityID] [int] NULL,
	[DescriptionEn] [nvarchar](500) NULL,
	[DescriptionAr] [nvarchar](500) NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[RequestID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[CustomerRequestsStages]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CustomerRequestsStages](
	[RequestStageID] [int] IDENTITY(1,1) NOT NULL,
	[RequestID] [int] NOT NULL,
	[StageID] [int] NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[RequestStageID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Customers]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Customers](
	[CustomerID] [int] IDENTITY(1,1) NOT NULL,
	[CustomerTypeID] [int] NOT NULL,
	[CustomerNameAr] [nvarchar](255) NOT NULL,
	[CustomerNameEn] [nvarchar](255) NOT NULL,
	[LegalNameAr] [nvarchar](255) NOT NULL,
	[LegalNameEn] [nvarchar](255) NOT NULL,
	[Phone] [nvarchar](50) NOT NULL,
	[AddressAr] [nvarchar](500) NOT NULL,
	[AddressEn] [nvarchar](500) NOT NULL,
	[EmailTo] [nvarchar](255) NULL,
	[Position] [nvarchar](255) NULL,
	[DiscountRate] [decimal](5, 2) NULL,
	[Attachments] [nvarchar](max) NULL,
	[Contacts] [nvarchar](max) NULL,
	[BankDetails] [nvarchar](max) NULL,
	[Mobile1] [nvarchar](50) NOT NULL,
	[Mobile2] [nvarchar](50) NULL,
	[EmailCC] [nvarchar](255) NULL,
	[VatNumber] [nvarchar](50) NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
 CONSTRAINT [PK__Customer__A4AE64B81216312A] PRIMARY KEY CLUSTERED 
(
	[CustomerID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[CustomersAttachments]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CustomersAttachments](
	[AttachmentID] [int] IDENTITY(1,1) NOT NULL,
	[FileName] [nvarchar](255) NOT NULL,
	[FilePath] [nvarchar](500) NOT NULL,
	[CustomerID] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[AttachmentID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[CustomerTypes]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CustomerTypes](
	[CustomerTypeID] [int] IDENTITY(1,1) NOT NULL,
	[NameAR] [nvarchar](255) NOT NULL,
	[NameEN] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NULL,
	[DescriptionAR] [nvarchar](max) NULL,
	[DescriptionEN] [nvarchar](max) NULL,
PRIMARY KEY CLUSTERED 
(
	[CustomerTypeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Departments]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Departments](
	[DepartmentID] [int] IDENTITY(1,1) NOT NULL,
	[NameEn] [nvarchar](255) NOT NULL,
	[NameAr] [nvarchar](255) NOT NULL,
	[DepartmentCode] [nvarchar](50) NOT NULL,
	[HeadOfDepartmentID] [int] NOT NULL,
	[Phone] [nvarchar](50) NULL,
	[Email] [nvarchar](255) NULL,
	[DescriptionAr] [nvarchar](500) NULL,
	[DescriptionEn] [nvarchar](500) NULL,
	[IsActive] [bit] NOT NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
 CONSTRAINT [PK__Departme__B2079BCD1DAB148B] PRIMARY KEY CLUSTERED 
(
	[DepartmentID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[DiscountSettings]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DiscountSettings](
	[DiscountSettingID] [int] IDENTITY(1,1) NOT NULL,
	[EmployeeID] [int] NOT NULL,
	[MaximumDiscount] [decimal](5, 2) NULL,
	[ApplicableToQuotation] [bit] NULL,
	[ApplicableToOrder] [bit] NULL,
	[ApplicableToInvoice] [bit] NULL,
	[ApplicableToContract] [bit] NULL,
	[ApplicableToClient] [bit] NULL,
PRIMARY KEY CLUSTERED 
(
	[DiscountSettingID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[EmailSettings]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EmailSettings](
	[EmailSettingID] [int] IDENTITY(1,1) NOT NULL,
	[MailDriver] [nvarchar](50) NULL,
	[Username] [nvarchar](255) NULL,
	[FromAddress] [nvarchar](255) NULL,
	[Host] [nvarchar](255) NULL,
	[Password] [nvarchar](255) NULL,
	[FromName] [nvarchar](255) NULL,
	[Port] [int] NULL,
	[Encryption] [nvarchar](50) NULL,
PRIMARY KEY CLUSTERED 
(
	[EmailSettingID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[EmployeesCertificates]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EmployeesCertificates](
	[CertificateID] [int] IDENTITY(1,1) NOT NULL,
	[EmployeeID] [int] NOT NULL,
	[CertificateName] [nvarchar](255) NULL,
	[IssueDate] [datetime] NULL,
	[ExpiryDate] [datetime] NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[CertificateID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[EmployeesCertificatsAttachments]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EmployeesCertificatsAttachments](
	[Code] [int] IDENTITY(1,1) NOT NULL,
	[FileName] [nvarchar](255) NULL,
	[FilePath] [nvarchar](500) NULL,
	[NotifyBeforeExpireDays] [int] NULL,
	[RepeatEveryDays] [int] NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[Code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[EmployeeUsers]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EmployeeUsers](
	[EmployeeUserID] [int] IDENTITY(1,1) NOT NULL,
	[NameEn] [nvarchar](255) NOT NULL,
	[NameAr] [nvarchar](255) NOT NULL,
	[CountryID] [int] NULL,
	[DepartmentID] [int] NULL,
	[JobID] [int] NULL,
	[ProfilePicture] [nvarchar](255) NULL,
	[Status] [nvarchar](50) NULL,
	[NotesEn] [nvarchar](500) NULL,
	[NotesAr] [nvarchar](500) NULL,
	[Phone] [nvarchar](50) NULL,
	[Mobile] [nvarchar](50) NULL,
	[Email] [nvarchar](255) NULL,
	[Password] [nvarchar](255) NULL,
	[BirthDate] [datetime] NULL,
	[QualificationType] [nvarchar](100) NULL,
	[AddressEn] [nvarchar](255) NULL,
	[AddressAr] [nvarchar](255) NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[EmployeeUserID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Equipment]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Equipment](
	[EquipmentID] [int] IDENTITY(1,1) NOT NULL,
	[NameEN] [nvarchar](255) NOT NULL,
	[NameAR] [nvarchar](255) NOT NULL,
	[Code] [nvarchar](100) NULL,
	[CategoryID] [int] NOT NULL,
	[DepartmentID] [int] NULL,
	[ModelNumber] [nvarchar](100) NULL,
	[ManufacturerID] [int] NULL,
	[SerialNumber] [nvarchar](100) NULL,
	[PurchaseDate] [datetime] NULL,
	[WarrantyExpiryDate] [datetime] NULL,
	[Status] [nvarchar](50) NULL,
	[CalibrationFrequency] [nvarchar](255) NULL,
	[LastCalibrationDate] [datetime] NULL,
	[NextCalibrationDue] [datetime] NULL,
	[LabLocationID] [int] NULL,
	[AssignedTo] [nvarchar](255) NULL,
	[UserManual] [nvarchar](500) NULL,
	[CalibrationCertificates] [nvarchar](max) NULL,
	[Attachments] [nvarchar](max) NULL,
 CONSTRAINT [PK__Equipmen__344745994FDE3305] PRIMARY KEY CLUSTERED 
(
	[EquipmentID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[EquipmentCategories]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EquipmentCategories](
	[CategoryID] [int] IDENTITY(1,1) NOT NULL,
	[CategoryNameAr] [nvarchar](250) NOT NULL,
	[CategoryNameEn] [nvarchar](250) NULL,
	[DescriptionAr] [ntext] NULL,
	[DescriptionEn] [ntext] NULL,
 CONSTRAINT [PK_EquipmentCategories] PRIMARY KEY CLUSTERED 
(
	[CategoryID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[GeneratedTestReports]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GeneratedTestReports](
	[GeneratedTestReportID] [int] IDENTITY(1,1) NOT NULL,
	[CreatedBy] [nvarchar](255) NOT NULL,
	[Result] [nvarchar](max) NULL,
	[Status] [nvarchar](50) NULL,
	[OrderID] [int] NOT NULL,
	[IsDelivered] [bit] NULL,
	[DeliveredDate] [datetime] NULL,
PRIMARY KEY CLUSTERED 
(
	[GeneratedTestReportID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[GeneratedTestReportsStages]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[GeneratedTestReportsStages](
	[GeneratedTestReportsStageID] [int] IDENTITY(1,1) NOT NULL,
	[GeneratedTestReportID] [int] NOT NULL,
	[StageID] [int] NOT NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [nvarchar](255) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[GeneratedTestReportsStageID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Investigations]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Investigations](
	[InvestigationID] [int] IDENTITY(1,1) NOT NULL,
	[InvestigationNo] [nvarchar](50) NOT NULL,
	[RequestDate] [datetime] NULL,
	[OrderID] [int] NOT NULL,
	[NoOfServices] [int] NULL,
	[Status] [nvarchar](50) NULL,
	[AssignTo] [nvarchar](255) NULL,
PRIMARY KEY CLUSTERED 
(
	[InvestigationID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[InvestigationServices]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[InvestigationServices](
	[ServiceID] [int] IDENTITY(1,1) NOT NULL,
	[InvestigationID] [int] NOT NULL,
	[StartDate] [datetime] NULL,
	[EndDate] [datetime] NULL,
	[Status] [nvarchar](50) NULL,
	[AssignedTo] [nvarchar](255) NULL,
	[ExecutedBy] [nvarchar](255) NULL,
PRIMARY KEY CLUSTERED 
(
	[ServiceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[InvestigationStages]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[InvestigationStages](
	[InvestigationStageID] [int] IDENTITY(1,1) NOT NULL,
	[InvestigationID] [int] NOT NULL,
	[StageID] [int] NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[InvestigationStageID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Invoices]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Invoices](
	[InvoiceID] [int] IDENTITY(1,1) NOT NULL,
	[CustomerID] [int] NOT NULL,
	[ProjectID] [int] NOT NULL,
	[ContractID] [int] NULL,
	[PaymentMethodID] [int] NOT NULL,
	[PaymentTerms] [nvarchar](255) NULL,
	[Currency] [nvarchar](50) NULL,
	[QuotedByID] [int] NULL,
	[Attachments] [nvarchar](max) NULL,
	[QuotationID] [int] NULL,
	[OrderID] [int] NOT NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
 CONSTRAINT [PK__Invoices__D796AAD5A5A7503A] PRIMARY KEY CLUSTERED 
(
	[InvoiceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[InvoicesAttachments]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[InvoicesAttachments](
	[AttachmentID] [int] IDENTITY(1,1) NOT NULL,
	[FileName] [nvarchar](255) NOT NULL,
	[FilePath] [nvarchar](500) NOT NULL,
	[InvoiceID] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[AttachmentID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[InvoicesServices]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[InvoicesServices](
	[ServiceID] [int] IDENTITY(1,1) NOT NULL,
	[InvoiceID] [int] NOT NULL,
	[ServiceType] [nvarchar](255) NULL,
	[ServiceName] [nvarchar](255) NULL,
	[Price] [decimal](18, 2) NULL,
PRIMARY KEY CLUSTERED 
(
	[ServiceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[InvoicesStages]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[InvoicesStages](
	[InvoicesStageID] [int] IDENTITY(1,1) NOT NULL,
	[InvoiceID] [int] NOT NULL,
	[StageID] [int] NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[InvoicesStageID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[InvoicesTest]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[InvoicesTest](
	[TestID] [int] IDENTITY(1,1) NOT NULL,
	[InvoiceID] [int] NOT NULL,
	[TestType] [nvarchar](255) NULL,
	[TestName] [nvarchar](255) NULL,
	[TestMethod] [nvarchar](255) NULL,
	[Accredited] [nvarchar](3) NULL,
	[Unit] [nvarchar](50) NULL,
	[Quantity] [decimal](10, 2) NULL,
	[Price] [decimal](18, 2) NULL,
	[TestLocation] [nvarchar](255) NULL,
PRIMARY KEY CLUSTERED 
(
	[TestID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[LabCertifications]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LabCertifications](
	[LabCertificationID] [int] IDENTITY(1,1) NOT NULL,
	[FileName] [nvarchar](255) NOT NULL,
	[AttachmentFile] [nvarchar](500) NOT NULL,
	[ExpireDate] [datetime] NULL,
	[EnableNotification] [bit] NULL,
	[NotificationBeforeExpire] [int] NULL,
	[NotificationEvery] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[LabCertificationID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[LabSettings]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LabSettings](
	[LabSettingID] [int] IDENTITY(1,1) NOT NULL,
	[BusinessNameAR] [nvarchar](255) NOT NULL,
	[BusinessNameEN] [nvarchar](255) NOT NULL,
	[StartDate] [datetime] NULL,
	[Email] [nvarchar](255) NOT NULL,
	[Fax] [nvarchar](50) NULL,
	[CurrencySymbolPlacement] [nvarchar](50) NULL,
	[UploadLogo] [nvarchar](500) NULL,
	[TimeFormat] [nvarchar](50) NULL,
	[AddressAR] [nvarchar](255) NULL,
	[AddressEN] [nvarchar](255) NULL,
	[Phone] [nvarchar](50) NULL,
	[Currency] [nvarchar](50) NULL,
	[TimeZone] [nvarchar](50) NULL,
	[DateFormat] [nvarchar](50) NULL,
PRIMARY KEY CLUSTERED 
(
	[LabSettingID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Logs]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Logs](
	[LogID] [int] IDENTITY(1,1) NOT NULL,
	[FieldName] [nvarchar](255) NULL,
	[TableName] [nvarchar](255) NULL,
	[OldValue] [nvarchar](500) NULL,
	[NewValue] [nvarchar](500) NULL,
	[ActionTypeID] [int] NULL,
	[CreateDate] [datetime] NULL,
	[CreatedByUserID] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[LogID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Materials]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Materials](
	[MaterialID] [int] IDENTITY(1,1) NOT NULL,
	[MaterialNameAR] [nvarchar](255) NOT NULL,
	[MaterialNameEN] [nvarchar](255) NOT NULL,
	[DescriptionAR] [nvarchar](500) NULL,
	[DescriptionEN] [nvarchar](500) NULL,
	[IsActive] [bit] NOT NULL,
	[MaterialTypeID] [int] NOT NULL,
	[MaterialSpecifications] [nvarchar](500) NULL,
	[Density] [decimal](10, 2) NULL,
	[MoistureContent] [decimal](10, 2) NULL,
	[ParticleSize] [decimal](10, 2) NULL,
	[ChemicalComposition] [nvarchar](500) NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
 CONSTRAINT [PK__Material__C506131742E3DEB4] PRIMARY KEY CLUSTERED 
(
	[MaterialID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[MaterialsDisbursements]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MaterialsDisbursements](
	[DisbursementID] [int] IDENTITY(1,1) NOT NULL,
	[MaterialID] [int] NOT NULL,
	[DeliverEmployee] [int] NULL,
	[ReceivedEmployee] [int] NULL,
	[Worksheets] [nvarchar](255) NULL,
	[Tests] [nvarchar](255) NULL,
	[DeliveryDate] [datetime] NULL,
	[Notes] [nvarchar](500) NULL,
	[Remarks] [nvarchar](500) NULL,
	[Status] [nvarchar](50) NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[DisbursementID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[MaterialsDisbursementsDetails]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MaterialsDisbursementsDetails](
	[DetailID] [int] IDENTITY(1,1) NOT NULL,
	[MaterialTypeID] [int] NOT NULL,
	[MaterialID] [int] NOT NULL,
	[MaterialName] [nvarchar](255) NOT NULL,
	[Quantity] [decimal](10, 2) NOT NULL,
	[UnitID] [int] NOT NULL,
 CONSTRAINT [PK__Material__135C314D1A176E3C] PRIMARY KEY CLUSTERED 
(
	[DetailID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[MaterialsTypes]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MaterialsTypes](
	[MaterialTypeID] [int] IDENTITY(1,1) NOT NULL,
	[NameAr] [nvarchar](255) NOT NULL,
	[NameEn] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NOT NULL,
	[DescriptionAr] [nvarchar](500) NULL,
	[DescriptionEn] [nvarchar](500) NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[MaterialTypeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Modules]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Modules](
	[ModuleID] [int] IDENTITY(1,1) NOT NULL,
	[NameEn] [nvarchar](255) NOT NULL,
	[NameAr] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NOT NULL,
	[DescriptionEn] [nvarchar](500) NULL,
	[DescriptionAr] [nvarchar](500) NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[ModuleID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[NotificationsEmailTemplates]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[NotificationsEmailTemplates](
	[EmailTemplateID] [int] IDENTITY(1,1) NOT NULL,
	[PublicationFromAddress] [nvarchar](255) NULL,
	[SamplePublicationEmailBody] [nvarchar](max) NULL,
	[AlwaysSendPublicationEmailToResponsible] [bit] NULL,
	[SampleRejectionEmailBody] [nvarchar](max) NULL,
	[SampleInvalidationEmailNotification] [bit] NULL,
	[SampleReceiveNotifications] [bit] NULL,
	[SampleReceiveNotificationEmailBody] [nvarchar](max) NULL,
PRIMARY KEY CLUSTERED 
(
	[EmailTemplateID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[NotificationsSMSTemplates]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[NotificationsSMSTemplates](
	[SMSTemplateID] [int] IDENTITY(1,1) NOT NULL,
	[PublicationNotifications] [nvarchar](max) NULL,
	[RejectionNotifications] [nvarchar](max) NULL,
	[InvalidationNotifications] [nvarchar](max) NULL,
	[ReceivedNotifications] [nvarchar](max) NULL,
PRIMARY KEY CLUSTERED 
(
	[SMSTemplateID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Objects]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Objects](
	[ObjectID] [int] IDENTITY(1,1) NOT NULL,
	[ObjectNameEn] [nvarchar](255) NOT NULL,
	[ObjectNameAr] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NOT NULL,
	[DataTables] [nvarchar](500) NOT NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[ObjectID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Orders]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Orders](
	[OrderID] [int] IDENTITY(1,1) NOT NULL,
	[CustomerID] [int] NOT NULL,
	[ProjectID] [int] NOT NULL,
	[ContractID] [int] NULL,
	[PaymentMethodID] [int] NULL,
	[PaymentTerms] [nvarchar](255) NULL,
	[Currency] [nvarchar](50) NULL,
	[QuotedByID] [int] NULL,
	[Attachments] [nvarchar](max) NULL,
	[QuotationID] [int] NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[OrderID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[OrdersAttachments]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[OrdersAttachments](
	[AttachmentID] [int] IDENTITY(1,1) NOT NULL,
	[FileName] [nvarchar](255) NOT NULL,
	[FilePath] [nvarchar](500) NOT NULL,
	[OrderID] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[AttachmentID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[OrderServices]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[OrderServices](
	[ServiceID] [int] IDENTITY(1,1) NOT NULL,
	[OrderID] [int] NOT NULL,
	[ServiceType] [nvarchar](255) NULL,
	[ServiceName] [nvarchar](255) NULL,
	[Price] [decimal](18, 2) NULL,
PRIMARY KEY CLUSTERED 
(
	[ServiceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[OrdersSamples]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[OrdersSamples](
	[SampleID] [int] IDENTITY(1,1) NOT NULL,
	[OrderID] [int] NOT NULL,
	[Remarks] [nvarchar](max) NULL,
	[SubTotal] [decimal](18, 2) NULL,
	[Discount] [decimal](5, 2) NULL,
	[SelectTax] [decimal](5, 2) NULL,
	[SubTotalAfterTax] [decimal](18, 2) NULL,
	[Tax] [decimal](18, 2) NULL,
	[Total] [decimal](18, 2) NULL,
	[ApprovedBy] [nvarchar](255) NULL,
	[SampleTypeID] [int] NULL,
	[Quantity] [decimal](10, 2) NULL,
	[BackupSample] [nvarchar](255) NULL,
	[BroughtByID] [int] NULL,
	[SampleHandler] [nvarchar](255) NULL,
	[Source] [nvarchar](255) NULL,
	[StructureElement] [nvarchar](255) NULL,
	[CementContent] [decimal](10, 2) NULL,
	[CoatingDate] [datetime] NULL,
PRIMARY KEY CLUSTERED 
(
	[SampleID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[OrderStages]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[OrderStages](
	[OrderRequestStageID] [int] IDENTITY(1,1) NOT NULL,
	[OrderID] [int] NOT NULL,
	[StageID] [int] NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[OrderRequestStageID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[OrdersTest]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[OrdersTest](
	[TestID] [int] IDENTITY(1,1) NOT NULL,
	[OrderID] [int] NOT NULL,
	[TestType] [nvarchar](255) NULL,
	[TestName] [nvarchar](255) NULL,
	[TestMethod] [nvarchar](255) NULL,
	[Accredited] [nvarchar](3) NULL,
	[UnitID] [int] NOT NULL,
	[Quantity] [decimal](10, 2) NULL,
	[Price] [decimal](18, 2) NULL,
	[TestLocation] [nvarchar](255) NULL,
 CONSTRAINT [PK__OrdersTe__8CC3310001FAF96D] PRIMARY KEY CLUSTERED 
(
	[TestID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[PaymentMethods]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PaymentMethods](
	[PaymentMethodID] [int] IDENTITY(1,1) NOT NULL,
	[NameAr] [nvarchar](255) NOT NULL,
	[NameEn] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NOT NULL,
	[DescriptionAr] [nvarchar](500) NULL,
	[DescriptionEn] [nvarchar](500) NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[PaymentMethodID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Permissions]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Permissions](
	[PermissionID] [int] IDENTITY(1,1) NOT NULL,
	[NameEn] [nvarchar](255) NOT NULL,
	[NameAr] [nvarchar](255) NOT NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[PermissionID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Positions]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Positions](
	[PositionID] [int] IDENTITY(1,1) NOT NULL,
	[NameAR] [nvarchar](255) NOT NULL,
	[NameEN] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NULL,
	[DescriptionAR] [nvarchar](max) NULL,
	[DescriptionEN] [nvarchar](max) NULL,
 CONSTRAINT [PK_Positions] PRIMARY KEY CLUSTERED 
(
	[PositionID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Priority]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Priority](
	[PriorityID] [int] IDENTITY(1,1) NOT NULL,
	[PriorityNameEn] [nvarchar](50) NOT NULL,
	[PriorityNameAr] [nvarchar](50) NULL,
	[IsActive] [bit] NULL,
PRIMARY KEY CLUSTERED 
(
	[PriorityID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[ProjectAttachments]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ProjectAttachments](
	[AttachmentID] [int] IDENTITY(1,1) NOT NULL,
	[FileName] [nvarchar](255) NOT NULL,
	[FilePath] [nvarchar](500) NOT NULL,
	[ProjectID] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[AttachmentID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[ProjectContacts]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ProjectContacts](
	[ProjectContactID] [int] IDENTITY(1,1) NOT NULL,
	[ContactName] [nvarchar](255) NOT NULL,
	[Email1] [nvarchar](255) NULL,
	[Email2] [nvarchar](255) NULL,
	[Mobile1] [nvarchar](50) NULL,
	[PositionID] [int] NULL,
	[ProjectID] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[ProjectContactID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Projects]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Projects](
	[ProjectID] [int] IDENTITY(1,1) NOT NULL,
	[CustomerID] [int] NOT NULL,
	[ProjectNumber] [nvarchar](50) NOT NULL,
	[ProjectNameAr] [nvarchar](255) NOT NULL,
	[ProjectNameEn] [nvarchar](255) NOT NULL,
	[ProjectStartDate] [datetime] NOT NULL,
	[AddressA] [nvarchar](500) NOT NULL,
	[AddressEn] [nvarchar](500) NOT NULL,
	[Location] [nvarchar](255) NULL,
	[DescriptionAr] [nvarchar](500) NOT NULL,
	[DescriptionEn] [nvarchar](500) NOT NULL,
	[BINumber] [nvarchar](255) NULL,
PRIMARY KEY CLUSTERED 
(
	[ProjectID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Quotations]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Quotations](
	[QuotationID] [int] IDENTITY(1,1) NOT NULL,
	[RequestID] [int] NULL,
	[CustomerID] [int] NOT NULL,
	[ProjectID] [int] NOT NULL,
	[ContractID] [int] NULL,
	[PaymentMethodID] [int] NULL,
	[PaymentTerms] [nvarchar](255) NULL,
	[ValidityPeriod] [datetime] NULL,
	[QuotedBy] [nvarchar](255) NULL,
	[InquiredBy] [nvarchar](255) NULL,
	[Attachments] [nvarchar](max) NULL,
	[Remarks] [nvarchar](max) NULL,
	[SubTotal] [decimal](18, 2) NULL,
	[Discount] [decimal](5, 2) NULL,
	[SelectTax] [decimal](5, 2) NULL,
	[SubTotalAfterTax] [decimal](18, 2) NULL,
	[Tax] [decimal](18, 2) NULL,
	[Total] [decimal](18, 2) NULL,
	[ApprovedBy] [nvarchar](255) NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[QuotationID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[QuotationsAttachments]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[QuotationsAttachments](
	[AttachmentID] [int] IDENTITY(1,1) NOT NULL,
	[FileName] [nvarchar](255) NOT NULL,
	[FilePath] [nvarchar](500) NOT NULL,
	[QuotationID] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[AttachmentID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[QuotationsServices]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[QuotationsServices](
	[ServiceID] [int] IDENTITY(1,1) NOT NULL,
	[QuotationID] [int] NOT NULL,
	[ServiceType] [nvarchar](255) NULL,
	[ServiceName] [nvarchar](255) NULL,
	[Price] [decimal](18, 2) NULL,
PRIMARY KEY CLUSTERED 
(
	[ServiceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[QuotationsStages]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[QuotationsStages](
	[QuotationsStageID] [int] IDENTITY(1,1) NOT NULL,
	[QuotationID] [int] NOT NULL,
	[StageID] [int] NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[QuotationsStageID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[QuotationsTest]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[QuotationsTest](
	[TestID] [int] IDENTITY(1,1) NOT NULL,
	[QuotationID] [int] NOT NULL,
	[TestType] [nvarchar](255) NULL,
	[TestLocation] [nvarchar](255) NULL,
	[Quantity] [decimal](10, 2) NULL,
	[UnitID] [int] NOT NULL,
	[Price] [decimal](18, 2) NULL,
	[TestDescriptionEn] [nvarchar](500) NULL,
	[TestDescriptionAr] [nvarchar](500) NULL,
	[Accredited] [nvarchar](3) NULL,
 CONSTRAINT [PK__Quotatio__8CC331002EAE5984] PRIMARY KEY CLUSTERED 
(
	[TestID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Roles]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Roles](
	[RoleID] [int] IDENTITY(1,1) NOT NULL,
	[NameEn] [nvarchar](255) NOT NULL,
	[NameAr] [nvarchar](255) NOT NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[RoleID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[SampleAttachments]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SampleAttachments](
	[AttachmentID] [int] IDENTITY(1,1) NOT NULL,
	[SampleRegisterID] [int] NOT NULL,
	[FileName] [nvarchar](255) NOT NULL,
	[FileType] [nvarchar](50) NULL,
	[FilePath] [nvarchar](500) NOT NULL,
	[UploadDate] [datetime] NULL,
	[UploadedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[AttachmentID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[SampleRegisters]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[SampleRegisters](
	[SampleRegisterID] [int] IDENTITY(1,1) NOT NULL,
	[OrderID] [varchar](50) NULL,
	[SampleNo] [varchar](50) NOT NULL,
	[CustomerID] [int] NOT NULL,
	[ProjectID] [int] NOT NULL,
	[SampleTypeID] [int] NOT NULL,
	[RegistrationDate] [date] NOT NULL,
	[SampleDescription] [nvarchar](2000) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[UnitOfMeasurementID] [int] NULL,
	[StorageLocationID] [int] NOT NULL,
	[CollectionDate] [date] NULL,
	[CollectedByID] [int] NULL,
	[RetentionPeriod] [int] NULL,
	[DisposalID] [int] NULL,
	[PriorityLevelID] [int] NULL,
	[CreatedDate] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastModifiedDate] [datetime] NULL,
	[LastModifiedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[SampleRegisterID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
UNIQUE NONCLUSTERED 
(
	[SampleNo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[SamplesTypes]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SamplesTypes](
	[SampleTypeID] [int] IDENTITY(1,1) NOT NULL,
	[NameAR] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NULL,
	[DescriptionAR] [nvarchar](max) NULL,
	[NameEN] [nvarchar](255) NOT NULL,
	[DescriptionEN] [nvarchar](max) NULL,
PRIMARY KEY CLUSTERED 
(
	[SampleTypeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[SampleTests]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SampleTests](
	[SampleTestID] [int] IDENTITY(1,1) NOT NULL,
	[SampleID] [int] NOT NULL,
	[TestCategoryID] [int] NOT NULL,
	[TestID] [int] NOT NULL,
	[Quantity] [int] NULL,
	[UnitID] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[SampleTestID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Services]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Services](
	[ServiceID] [int] IDENTITY(1,1) NOT NULL,
	[NameAR] [nvarchar](255) NOT NULL,
	[NameEN] [nvarchar](255) NOT NULL,
	[ServiceTypeID] [int] NULL,
	[IsActive] [bit] NULL,
	[DescriptionAR] [nvarchar](max) NULL,
	[DescriptionEN] [nvarchar](max) NULL,
PRIMARY KEY CLUSTERED 
(
	[ServiceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[ServicesTypes]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ServicesTypes](
	[ServiceTypeID] [int] IDENTITY(1,1) NOT NULL,
	[NameAR] [nvarchar](255) NOT NULL,
	[NameEN] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NULL,
	[DescriptionAR] [nvarchar](max) NULL,
	[DescriptionEN] [nvarchar](max) NULL,
PRIMARY KEY CLUSTERED 
(
	[ServiceTypeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[SMSSettings]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SMSSettings](
	[SMSSettingID] [int] IDENTITY(1,1) NOT NULL,
	[SMSService] [nvarchar](255) NULL,
	[SMSURL] [nvarchar](500) NULL,
	[SMSToParam] [nvarchar](255) NULL,
	[SMSMessageParam] [nvarchar](255) NULL,
	[SMSRequestMethod] [nvarchar](50) NULL,
PRIMARY KEY CLUSTERED 
(
	[SMSSettingID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[StagesNames]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[StagesNames](
	[Code] [int] IDENTITY(1,1) NOT NULL,
	[NameAr] [nvarchar](255) NOT NULL,
	[NameEn] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NOT NULL,
	[ObjectID] [int] NULL,
	[ShowToCustomer] [bit] NOT NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[Code] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[StorageLocations]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[StorageLocations](
	[StorageLocationID] [int] IDENTITY(1,1) NOT NULL,
	[NameAr] [nvarchar](255) NOT NULL,
	[NameEn] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NOT NULL,
	[DescriptionAr] [nvarchar](500) NULL,
	[DescriptionEn] [nvarchar](500) NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[StorageLocationID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[TestCategories]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TestCategories](
	[TestCategoryID] [int] IDENTITY(1,1) NOT NULL,
	[NameAR] [nvarchar](255) NOT NULL,
	[NameEN] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NULL,
	[DescriptionAR] [nvarchar](max) NULL,
	[DescriptionEN] [nvarchar](max) NULL,
 CONSTRAINT [PK__TestCate__2CE3751D6AA99368] PRIMARY KEY CLUSTERED 
(
	[TestCategoryID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Tests]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Tests](
	[TestID] [int] IDENTITY(1,1) NOT NULL,
	[TestNameAR] [nvarchar](255) NOT NULL,
	[TestNameEN] [nvarchar](255) NOT NULL,
	[ReportTitleEN] [nvarchar](255) NULL,
	[ReportTitleAR] [nvarchar](255) NULL,
	[DocumentCode] [nvarchar](100) NULL,
	[RevisionNum] [nvarchar](50) NULL,
	[DescriptionAR] [nvarchar](max) NULL,
	[DescriptionEN] [nvarchar](max) NULL,
	[DepartmentID] [int] NULL,
	[PrimaryEquipment] [nvarchar](255) NULL,
	[IssueDate] [datetime] NULL,
	[Revision_Num] [nvarchar](50) NULL,
	[CategoryID] [int] NOT NULL,
	[SecondaryEquipment] [nvarchar](255) NULL,
	[TestCode] [nvarchar](100) NULL,
	[Accredited] [nvarchar](3) NULL,
	[CreditedByInput] [nvarchar](255) NULL,
	[ReferenceStandards] [nvarchar](max) NULL,
	[FullStandardPDF] [nvarchar](500) NULL,
	[StandardCode] [nvarchar](100) NULL,
	[StandardSummaryPDF] [nvarchar](500) NULL,
	[UnitID] [int] NOT NULL,
	[CurrencyID] [int] NOT NULL,
	[UnitPrice] [decimal](18, 2) NULL,
	[MinUnitPrice] [decimal](18, 2) NULL,
	[MinimumQuantity] [int] NULL,
	[SampleTypeID] [int] NOT NULL,
	[SampleVolume] [decimal](18, 2) NULL,
	[Retention] [nvarchar](255) NULL,
	[TestMethodology] [nvarchar](255) NULL,
	[ResultFormat] [nvarchar](255) NULL,
	[TurnaroundTime] [nvarchar](255) NULL,
	[ExpectedOutput] [nvarchar](max) NULL,
	[AcceptableRangeMin] [decimal](18, 2) NULL,
	[AcceptableRangeMax] [decimal](18, 2) NULL,
	[NumberOfDecimals] [int] NULL,
	[RequiredForVerify] [nvarchar](3) NULL,
	[ResultType] [nvarchar](255) NULL,
	[DefaultResult] [nvarchar](max) NULL,
 CONSTRAINT [PK__Tests__8CC331002AA8A89D] PRIMARY KEY CLUSTERED 
(
	[TestID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Tools]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Tools](
	[ToolID] [int] IDENTITY(1,1) NOT NULL,
	[ItemNameAR] [nvarchar](255) NOT NULL,
	[ItemNameEN] [nvarchar](255) NOT NULL,
	[ItemCode] [nvarchar](100) NULL,
	[CategoryID] [int] NOT NULL,
	[Department] [nvarchar](255) NULL,
	[Manufacturer] [nvarchar](255) NULL,
	[ModelNumber] [nvarchar](100) NULL,
	[SerialNumber] [nvarchar](100) NULL,
	[Status] [nvarchar](50) NULL,
	[QuantityAvailable] [int] NULL,
	[UnitOfMeasure] [nvarchar](50) NULL,
	[Location] [nvarchar](255) NULL,
	[AssignedTo1] [nvarchar](255) NULL,
	[AssignedTo2] [nvarchar](255) NULL,
	[CalibrationFrequency] [nvarchar](255) NULL,
	[LastCalibrationDate] [datetime] NULL,
	[NextCalibrationDue] [datetime] NULL,
	[MaintenanceSchedule] [nvarchar](255) NULL,
	[UserManual] [nvarchar](500) NULL,
	[WarrantyDetails] [nvarchar](500) NULL,
	[Attachments] [nvarchar](max) NULL,
 CONSTRAINT [PK__Tools__CC0CEBB1913DD700] PRIMARY KEY CLUSTERED 
(
	[ToolID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[ToolsCategories]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ToolsCategories](
	[CategoryID] [int] IDENTITY(1,1) NOT NULL,
	[CategoryNameAr] [nvarchar](250) NOT NULL,
	[CategoryNameEn] [nvarchar](250) NULL,
	[DescriptionAr] [ntext] NULL,
	[DescriptionEn] [ntext] NULL,
 CONSTRAINT [PK_ToolsCategories] PRIMARY KEY CLUSTERED 
(
	[CategoryID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Units]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Units](
	[UnitID] [int] IDENTITY(1,1) NOT NULL,
	[NameAr] [nvarchar](255) NOT NULL,
	[NameEn] [nvarchar](255) NOT NULL,
	[IsActive] [bit] NOT NULL,
	[DescriptionAr] [nvarchar](500) NULL,
	[DescriptionEn] [nvarchar](500) NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
	[LastUpdateDateTime] [datetime] NULL,
	[LastUpdatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[UnitID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[Worksheets]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Worksheets](
	[WorksheetID] [int] IDENTITY(1,1) NOT NULL,
	[WorksheetNo] [nvarchar](50) NOT NULL,
	[RequestDate] [datetime] NULL,
	[OrderID] [int] NOT NULL,
	[NoOfTests] [int] NULL,
	[Status] [nvarchar](50) NULL,
	[AssignTo] [nvarchar](255) NULL,
PRIMARY KEY CLUSTERED 
(
	[WorksheetID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[WorksheetsStages]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[WorksheetsStages](
	[WorksheetStageID] [int] IDENTITY(1,1) NOT NULL,
	[WorksheetID] [int] NOT NULL,
	[StageID] [int] NULL,
	[CreatedDateTime] [datetime] NULL,
	[CreatedBy] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[WorksheetStageID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
/****** Object:  Table [dbo].[WorksheetsTests]    Script Date: 12/16/2024 5:24:09 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[WorksheetsTests](
	[TestID] [int] IDENTITY(1,1) NOT NULL,
	[WorksheetID] [int] NOT NULL,
	[StartDate] [datetime] NULL,
	[EndDate] [datetime] NULL,
	[Status] [nvarchar](50) NULL,
	[AssignedTo] [nvarchar](255) NULL,
	[ExecutedBy] [nvarchar](255) NULL,
PRIMARY KEY CLUSTERED 
(
	[TestID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
ALTER TABLE [dbo].[ActionsTypes] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[ActionsTypes] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[Assign_Permissions_2_Roles] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Assign_Permissions_2_Roles] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[Countries] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Countries] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[CustomerRequests] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[CustomerRequestsStages] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Customers] ADD  CONSTRAINT [DF__Customers__Creat__75A278F5]  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Customers] ADD  CONSTRAINT [DF__Customers__LastU__76969D2E]  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[Departments] ADD  CONSTRAINT [DF__Departmen__Creat__2A4B4B5E]  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Departments] ADD  CONSTRAINT [DF__Departmen__LastU__2B3F6F97]  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[EmployeesCertificates] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[EmployeesCertificates] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[EmployeesCertificatsAttachments] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[EmployeesCertificatsAttachments] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[EmployeeUsers] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[EmployeeUsers] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[GeneratedTestReportsStages] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Investigations] ADD  DEFAULT (getdate()) FOR [RequestDate]
GO
ALTER TABLE [dbo].[InvestigationStages] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Invoices] ADD  CONSTRAINT [DF__Invoices__Create__41EDCAC5]  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Invoices] ADD  CONSTRAINT [DF__Invoices__LastUp__42E1EEFE]  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[InvoicesStages] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Logs] ADD  DEFAULT (getdate()) FOR [CreateDate]
GO
ALTER TABLE [dbo].[Materials] ADD  CONSTRAINT [DF__Materials__Creat__68487DD7]  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Materials] ADD  CONSTRAINT [DF__Materials__LastU__693CA210]  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[MaterialsDisbursements] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[MaterialsDisbursements] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[MaterialsTypes] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[MaterialsTypes] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[Modules] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Modules] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[Objects] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Objects] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[Orders] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Orders] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[OrderStages] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[PaymentMethods] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[PaymentMethods] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[Permissions] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Permissions] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[Priority] ADD  DEFAULT ((1)) FOR [IsActive]
GO
ALTER TABLE [dbo].[Quotations] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Quotations] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[QuotationsStages] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Roles] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Roles] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[SampleAttachments] ADD  DEFAULT (getdate()) FOR [UploadDate]
GO
ALTER TABLE [dbo].[SampleRegisters] ADD  DEFAULT (getdate()) FOR [CreatedDate]
GO
ALTER TABLE [dbo].[StagesNames] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[StagesNames] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[StorageLocations] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[StorageLocations] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[Units] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Units] ADD  DEFAULT (getdate()) FOR [LastUpdateDateTime]
GO
ALTER TABLE [dbo].[Worksheets] ADD  DEFAULT (getdate()) FOR [RequestDate]
GO
ALTER TABLE [dbo].[WorksheetsStages] ADD  DEFAULT (getdate()) FOR [CreatedDateTime]
GO
ALTER TABLE [dbo].[Assign_Permissions_2_Roles]  WITH CHECK ADD  CONSTRAINT [FK__Assign_Perm__Module] FOREIGN KEY([ModuleID])
REFERENCES [dbo].[Modules] ([ModuleID])
GO
ALTER TABLE [dbo].[Assign_Permissions_2_Roles] CHECK CONSTRAINT [FK__Assign_Perm__Module]
GO
ALTER TABLE [dbo].[Assign_Permissions_2_Roles]  WITH CHECK ADD  CONSTRAINT [FK__Assign_Perm__Role] FOREIGN KEY([RoleID])
REFERENCES [dbo].[Roles] ([RoleID])
GO
ALTER TABLE [dbo].[Assign_Permissions_2_Roles] CHECK CONSTRAINT [FK__Assign_Perm__Role]
GO
ALTER TABLE [dbo].[Assign_Permissions_2_Roles]  WITH CHECK ADD  CONSTRAINT [FK__Assign_to__Perm] FOREIGN KEY([PermID])
REFERENCES [dbo].[Permissions] ([PermissionID])
GO
ALTER TABLE [dbo].[Assign_Permissions_2_Roles] CHECK CONSTRAINT [FK__Assign_to__Perm]
GO
ALTER TABLE [dbo].[Calibrations]  WITH CHECK ADD  CONSTRAINT [FK_Calibrations_CalibrationsTechnicians] FOREIGN KEY([TechnicianID])
REFERENCES [dbo].[CalibrationsTechnicians] ([TechnicianID])
GO
ALTER TABLE [dbo].[Calibrations] CHECK CONSTRAINT [FK_Calibrations_CalibrationsTechnicians]
GO
ALTER TABLE [dbo].[CalibrationsAttachments]  WITH CHECK ADD  CONSTRAINT [FK__Calibrati__Calib__attachments] FOREIGN KEY([CalibrationID])
REFERENCES [dbo].[Calibrations] ([CalibrationID])
GO
ALTER TABLE [dbo].[CalibrationsAttachments] CHECK CONSTRAINT [FK__Calibrati__Calib__attachments]
GO
ALTER TABLE [dbo].[CalibrationsTechnicians]  WITH CHECK ADD  CONSTRAINT [FK__Calibration__Compaany] FOREIGN KEY([CompanyID])
REFERENCES [dbo].[CalibrationsCompanies] ([CompanyID])
GO
ALTER TABLE [dbo].[CalibrationsTechnicians] CHECK CONSTRAINT [FK__Calibration__Compaany]
GO
ALTER TABLE [dbo].[CalibrationsTechnicians]  WITH CHECK ADD  CONSTRAINT [FK_CalibrationsTechnicians_CalibrationsCompanies] FOREIGN KEY([CompanyID])
REFERENCES [dbo].[CalibrationsCompanies] ([CompanyID])
GO
ALTER TABLE [dbo].[CalibrationsTechnicians] CHECK CONSTRAINT [FK_CalibrationsTechnicians_CalibrationsCompanies]
GO
ALTER TABLE [dbo].[Contracts]  WITH CHECK ADD  CONSTRAINT [FK__Contracts__Customers__0F624AF8] FOREIGN KEY([CustomerID])
REFERENCES [dbo].[Customers] ([CustomerID])
GO
ALTER TABLE [dbo].[Contracts] CHECK CONSTRAINT [FK__Contracts__Customers__0F624AF8]
GO
ALTER TABLE [dbo].[Contracts]  WITH CHECK ADD  CONSTRAINT [FK_Contracts_ContractTypes] FOREIGN KEY([ContractTypeID])
REFERENCES [dbo].[ContractTypes] ([ContractTypeID])
GO
ALTER TABLE [dbo].[Contracts] CHECK CONSTRAINT [FK_Contracts_ContractTypes]
GO
ALTER TABLE [dbo].[ContractScopeOfWork]  WITH CHECK ADD  CONSTRAINT [FK__ContractScope__Contract] FOREIGN KEY([ContractID])
REFERENCES [dbo].[Contracts] ([ContractID])
GO
ALTER TABLE [dbo].[ContractScopeOfWork] CHECK CONSTRAINT [FK__ContractScope__Contract]
GO
ALTER TABLE [dbo].[ContractScopeOfWork]  WITH CHECK ADD  CONSTRAINT [FK_ContractScopeOfWork_Contracts] FOREIGN KEY([ContractID])
REFERENCES [dbo].[Contracts] ([ContractID])
GO
ALTER TABLE [dbo].[ContractScopeOfWork] CHECK CONSTRAINT [FK_ContractScopeOfWork_Contracts]
GO
ALTER TABLE [dbo].[ContractScopeOfWork]  WITH CHECK ADD  CONSTRAINT [FK_ContractScopeOfWork_Services] FOREIGN KEY([SeriveID])
REFERENCES [dbo].[Services] ([ServiceID])
GO
ALTER TABLE [dbo].[ContractScopeOfWork] CHECK CONSTRAINT [FK_ContractScopeOfWork_Services]
GO
ALTER TABLE [dbo].[ContractScopeOfWork]  WITH CHECK ADD  CONSTRAINT [FK_ContractScopeOfWork_Tests] FOREIGN KEY([TestID])
REFERENCES [dbo].[Tests] ([TestID])
GO
ALTER TABLE [dbo].[ContractScopeOfWork] CHECK CONSTRAINT [FK_ContractScopeOfWork_Tests]
GO
ALTER TABLE [dbo].[Currencies]  WITH CHECK ADD  CONSTRAINT [FK_Currencies_Currencies] FOREIGN KEY([CurrencyID])
REFERENCES [dbo].[Currencies] ([CurrencyID])
GO
ALTER TABLE [dbo].[Currencies] CHECK CONSTRAINT [FK_Currencies_Currencies]
GO
ALTER TABLE [dbo].[CustomerContacts]  WITH CHECK ADD  CONSTRAINT [FK__CustomerC__Custo__01142BA1] FOREIGN KEY([CustomerID])
REFERENCES [dbo].[Customers] ([CustomerID])
GO
ALTER TABLE [dbo].[CustomerContacts] CHECK CONSTRAINT [FK__CustomerC__Custo__01142BA1]
GO
ALTER TABLE [dbo].[CustomerContacts]  WITH CHECK ADD  CONSTRAINT [FK_CustomerContacts_Positions] FOREIGN KEY([PositionID])
REFERENCES [dbo].[Positions] ([PositionID])
GO
ALTER TABLE [dbo].[CustomerContacts] CHECK CONSTRAINT [FK_CustomerContacts_Positions]
GO
ALTER TABLE [dbo].[CustomerRequests]  WITH CHECK ADD  CONSTRAINT [FK__CustomerR__Custo__7A672E12] FOREIGN KEY([CustomerID])
REFERENCES [dbo].[Customers] ([CustomerID])
GO
ALTER TABLE [dbo].[CustomerRequests] CHECK CONSTRAINT [FK__CustomerR__Custo__7A672E12]
GO
ALTER TABLE [dbo].[CustomerRequestsStages]  WITH CHECK ADD  CONSTRAINT [FK__CustomerR__Request] FOREIGN KEY([RequestID])
REFERENCES [dbo].[CustomerRequests] ([RequestID])
GO
ALTER TABLE [dbo].[CustomerRequestsStages] CHECK CONSTRAINT [FK__CustomerR__Request]
GO
ALTER TABLE [dbo].[Customers]  WITH CHECK ADD  CONSTRAINT [FK_Customers_CustomerTypes] FOREIGN KEY([CustomerTypeID])
REFERENCES [dbo].[CustomerTypes] ([CustomerTypeID])
GO
ALTER TABLE [dbo].[Customers] CHECK CONSTRAINT [FK_Customers_CustomerTypes]
GO
ALTER TABLE [dbo].[CustomersAttachments]  WITH CHECK ADD  CONSTRAINT [FK__Customers__Custo__03F0984C] FOREIGN KEY([CustomerID])
REFERENCES [dbo].[Customers] ([CustomerID])
GO
ALTER TABLE [dbo].[CustomersAttachments] CHECK CONSTRAINT [FK__Customers__Custo__03F0984C]
GO
ALTER TABLE [dbo].[Departments]  WITH CHECK ADD  CONSTRAINT [FK_Departments_EmployeeUsers] FOREIGN KEY([HeadOfDepartmentID])
REFERENCES [dbo].[EmployeeUsers] ([EmployeeUserID])
GO
ALTER TABLE [dbo].[Departments] CHECK CONSTRAINT [FK_Departments_EmployeeUsers]
GO
ALTER TABLE [dbo].[EmployeesCertificates]  WITH CHECK ADD FOREIGN KEY([EmployeeID])
REFERENCES [dbo].[EmployeeUsers] ([EmployeeUserID])
GO
ALTER TABLE [dbo].[Equipment]  WITH CHECK ADD  CONSTRAINT [FK_Equipment_EquipmentCategories] FOREIGN KEY([CategoryID])
REFERENCES [dbo].[EquipmentCategories] ([CategoryID])
GO
ALTER TABLE [dbo].[Equipment] CHECK CONSTRAINT [FK_Equipment_EquipmentCategories]
GO
ALTER TABLE [dbo].[GeneratedTestReportsStages]  WITH CHECK ADD FOREIGN KEY([GeneratedTestReportID])
REFERENCES [dbo].[Orders] ([OrderID])
GO
ALTER TABLE [dbo].[Investigations]  WITH CHECK ADD FOREIGN KEY([OrderID])
REFERENCES [dbo].[Orders] ([OrderID])
GO
ALTER TABLE [dbo].[InvestigationServices]  WITH CHECK ADD FOREIGN KEY([InvestigationID])
REFERENCES [dbo].[Investigations] ([InvestigationID])
GO
ALTER TABLE [dbo].[InvestigationStages]  WITH CHECK ADD FOREIGN KEY([InvestigationID])
REFERENCES [dbo].[Investigations] ([InvestigationID])
GO
ALTER TABLE [dbo].[Invoices]  WITH CHECK ADD  CONSTRAINT [FK__Invoices__Contra] FOREIGN KEY([ContractID])
REFERENCES [dbo].[Contracts] ([ContractID])
GO
ALTER TABLE [dbo].[Invoices] CHECK CONSTRAINT [FK__Invoices__Contra]
GO
ALTER TABLE [dbo].[Invoices]  WITH CHECK ADD  CONSTRAINT [FK__Invoices__Custom__43D61337] FOREIGN KEY([CustomerID])
REFERENCES [dbo].[Customers] ([CustomerID])
GO
ALTER TABLE [dbo].[Invoices] CHECK CONSTRAINT [FK__Invoices__Custom__43D61337]
GO
ALTER TABLE [dbo].[Invoices]  WITH CHECK ADD  CONSTRAINT [FK__Invoices__OrderI__47A6A41B] FOREIGN KEY([OrderID])
REFERENCES [dbo].[Orders] ([OrderID])
GO
ALTER TABLE [dbo].[Invoices] CHECK CONSTRAINT [FK__Invoices__OrderI__47A6A41B]
GO
ALTER TABLE [dbo].[Invoices]  WITH CHECK ADD  CONSTRAINT [FK__Invoices__Projec__44CA3770] FOREIGN KEY([ProjectID])
REFERENCES [dbo].[Projects] ([ProjectID])
GO
ALTER TABLE [dbo].[Invoices] CHECK CONSTRAINT [FK__Invoices__Projec__44CA3770]
GO
ALTER TABLE [dbo].[Invoices]  WITH CHECK ADD  CONSTRAINT [FK__Invoices__Quotat__46B27FE2] FOREIGN KEY([QuotationID])
REFERENCES [dbo].[Quotations] ([QuotationID])
GO
ALTER TABLE [dbo].[Invoices] CHECK CONSTRAINT [FK__Invoices__Quotat__46B27FE2]
GO
ALTER TABLE [dbo].[Invoices]  WITH CHECK ADD  CONSTRAINT [FK_Invoices_Invoices_payment] FOREIGN KEY([PaymentMethodID])
REFERENCES [dbo].[PaymentMethods] ([PaymentMethodID])
GO
ALTER TABLE [dbo].[Invoices] CHECK CONSTRAINT [FK_Invoices_Invoices_payment]
GO
ALTER TABLE [dbo].[InvoicesAttachments]  WITH CHECK ADD  CONSTRAINT [FK__InvoicesA__Invoi__4E53A1AA] FOREIGN KEY([InvoiceID])
REFERENCES [dbo].[Invoices] ([InvoiceID])
GO
ALTER TABLE [dbo].[InvoicesAttachments] CHECK CONSTRAINT [FK__InvoicesA__Invoi__4E53A1AA]
GO
ALTER TABLE [dbo].[InvoicesServices]  WITH CHECK ADD  CONSTRAINT [FK__InvoicesS__Invoi__55009F39] FOREIGN KEY([InvoiceID])
REFERENCES [dbo].[Invoices] ([InvoiceID])
GO
ALTER TABLE [dbo].[InvoicesServices] CHECK CONSTRAINT [FK__InvoicesS__Invoi__55009F39]
GO
ALTER TABLE [dbo].[InvoicesStages]  WITH CHECK ADD  CONSTRAINT [FK__InvoicesS__Invoi__4B7734FF] FOREIGN KEY([InvoiceID])
REFERENCES [dbo].[Invoices] ([InvoiceID])
GO
ALTER TABLE [dbo].[InvoicesStages] CHECK CONSTRAINT [FK__InvoicesS__Invoi__4B7734FF]
GO
ALTER TABLE [dbo].[InvoicesTest]  WITH CHECK ADD  CONSTRAINT [FK__InvoicesT__Invoi__5224328E] FOREIGN KEY([InvoiceID])
REFERENCES [dbo].[Invoices] ([InvoiceID])
GO
ALTER TABLE [dbo].[InvoicesTest] CHECK CONSTRAINT [FK__InvoicesT__Invoi__5224328E]
GO
ALTER TABLE [dbo].[Logs]  WITH CHECK ADD  CONSTRAINT [FK__Logs__ActionType__Logs] FOREIGN KEY([ActionTypeID])
REFERENCES [dbo].[ActionsTypes] ([ActionTypeID])
GO
ALTER TABLE [dbo].[Logs] CHECK CONSTRAINT [FK__Logs__ActionType__Logs]
GO
ALTER TABLE [dbo].[Logs]  WITH CHECK ADD  CONSTRAINT [FK_Logs_EmployeeUsers] FOREIGN KEY([CreatedByUserID])
REFERENCES [dbo].[EmployeeUsers] ([EmployeeUserID])
GO
ALTER TABLE [dbo].[Logs] CHECK CONSTRAINT [FK_Logs_EmployeeUsers]
GO
ALTER TABLE [dbo].[Materials]  WITH CHECK ADD  CONSTRAINT [FK__Materials__Mater__6A30C649] FOREIGN KEY([MaterialTypeID])
REFERENCES [dbo].[MaterialsTypes] ([MaterialTypeID])
GO
ALTER TABLE [dbo].[Materials] CHECK CONSTRAINT [FK__Materials__Mater__6A30C649]
GO
ALTER TABLE [dbo].[MaterialsDisbursements]  WITH CHECK ADD  CONSTRAINT [FK__Materials__Mater__6EF57B66] FOREIGN KEY([MaterialID])
REFERENCES [dbo].[Materials] ([MaterialID])
GO
ALTER TABLE [dbo].[MaterialsDisbursements] CHECK CONSTRAINT [FK__Materials__Mater__6EF57B66]
GO
ALTER TABLE [dbo].[MaterialsDisbursementsDetails]  WITH CHECK ADD  CONSTRAINT [FK__Materials__Material] FOREIGN KEY([MaterialTypeID])
REFERENCES [dbo].[MaterialsTypes] ([MaterialTypeID])
GO
ALTER TABLE [dbo].[MaterialsDisbursementsDetails] CHECK CONSTRAINT [FK__Materials__Material]
GO
ALTER TABLE [dbo].[MaterialsDisbursementsDetails]  WITH CHECK ADD  CONSTRAINT [FK__Materials__Unit] FOREIGN KEY([UnitID])
REFERENCES [dbo].[Units] ([UnitID])
GO
ALTER TABLE [dbo].[MaterialsDisbursementsDetails] CHECK CONSTRAINT [FK__Materials__Unit]
GO
ALTER TABLE [dbo].[MaterialsDisbursementsDetails]  WITH CHECK ADD  CONSTRAINT [FK_MaterialsDisbursementsDetails_Materials] FOREIGN KEY([MaterialID])
REFERENCES [dbo].[Materials] ([MaterialID])
GO
ALTER TABLE [dbo].[MaterialsDisbursementsDetails] CHECK CONSTRAINT [FK_MaterialsDisbursementsDetails_Materials]
GO
ALTER TABLE [dbo].[Orders]  WITH CHECK ADD  CONSTRAINT [FK__Orders__Contract] FOREIGN KEY([ContractID])
REFERENCES [dbo].[Contracts] ([ContractID])
GO
ALTER TABLE [dbo].[Orders] CHECK CONSTRAINT [FK__Orders__Contract]
GO
ALTER TABLE [dbo].[Orders]  WITH CHECK ADD  CONSTRAINT [FK__Orders__Customer__2BFE89A6] FOREIGN KEY([CustomerID])
REFERENCES [dbo].[Customers] ([CustomerID])
GO
ALTER TABLE [dbo].[Orders] CHECK CONSTRAINT [FK__Orders__Customer__2BFE89A6]
GO
ALTER TABLE [dbo].[Orders]  WITH CHECK ADD FOREIGN KEY([ProjectID])
REFERENCES [dbo].[Projects] ([ProjectID])
GO
ALTER TABLE [dbo].[Orders]  WITH CHECK ADD FOREIGN KEY([QuotationID])
REFERENCES [dbo].[Quotations] ([QuotationID])
GO
ALTER TABLE [dbo].[OrdersAttachments]  WITH CHECK ADD FOREIGN KEY([OrderID])
REFERENCES [dbo].[Orders] ([OrderID])
GO
ALTER TABLE [dbo].[OrderServices]  WITH CHECK ADD  CONSTRAINT [FK__OrderService__Order] FOREIGN KEY([OrderID])
REFERENCES [dbo].[Orders] ([OrderID])
GO
ALTER TABLE [dbo].[OrderServices] CHECK CONSTRAINT [FK__OrderService__Order]
GO
ALTER TABLE [dbo].[OrdersSamples]  WITH CHECK ADD FOREIGN KEY([OrderID])
REFERENCES [dbo].[Orders] ([OrderID])
GO
ALTER TABLE [dbo].[OrderStages]  WITH CHECK ADD FOREIGN KEY([OrderID])
REFERENCES [dbo].[Orders] ([OrderID])
GO
ALTER TABLE [dbo].[OrdersTest]  WITH CHECK ADD  CONSTRAINT [FK__OrdersTes__Order__3587F3E0] FOREIGN KEY([OrderID])
REFERENCES [dbo].[Orders] ([OrderID])
GO
ALTER TABLE [dbo].[OrdersTest] CHECK CONSTRAINT [FK__OrdersTes__Order__3587F3E0]
GO
ALTER TABLE [dbo].[OrdersTest]  WITH CHECK ADD  CONSTRAINT [FK_OrdersTest_Units] FOREIGN KEY([UnitID])
REFERENCES [dbo].[Units] ([UnitID])
GO
ALTER TABLE [dbo].[OrdersTest] CHECK CONSTRAINT [FK_OrdersTest_Units]
GO
ALTER TABLE [dbo].[Positions]  WITH CHECK ADD  CONSTRAINT [FK_Positions_Positions] FOREIGN KEY([PositionID])
REFERENCES [dbo].[Positions] ([PositionID])
GO
ALTER TABLE [dbo].[Positions] CHECK CONSTRAINT [FK_Positions_Positions]
GO
ALTER TABLE [dbo].[ProjectAttachments]  WITH CHECK ADD FOREIGN KEY([ProjectID])
REFERENCES [dbo].[Projects] ([ProjectID])
GO
ALTER TABLE [dbo].[ProjectContacts]  WITH CHECK ADD FOREIGN KEY([ProjectID])
REFERENCES [dbo].[Projects] ([ProjectID])
GO
ALTER TABLE [dbo].[Projects]  WITH CHECK ADD  CONSTRAINT [FK__Projects__Custom__06CD04F7] FOREIGN KEY([CustomerID])
REFERENCES [dbo].[Customers] ([CustomerID])
GO
ALTER TABLE [dbo].[Projects] CHECK CONSTRAINT [FK__Projects__Custom__06CD04F7]
GO
ALTER TABLE [dbo].[Quotations]  WITH CHECK ADD  CONSTRAINT [FK__Quotation__Contracts] FOREIGN KEY([ContractID])
REFERENCES [dbo].[Contracts] ([ContractID])
GO
ALTER TABLE [dbo].[Quotations] CHECK CONSTRAINT [FK__Quotation__Contracts]
GO
ALTER TABLE [dbo].[Quotations]  WITH CHECK ADD  CONSTRAINT [FK__Quotation__Custo__17F790F9] FOREIGN KEY([CustomerID])
REFERENCES [dbo].[Customers] ([CustomerID])
GO
ALTER TABLE [dbo].[Quotations] CHECK CONSTRAINT [FK__Quotation__Custo__17F790F9]
GO
ALTER TABLE [dbo].[Quotations]  WITH CHECK ADD FOREIGN KEY([ProjectID])
REFERENCES [dbo].[Projects] ([ProjectID])
GO
ALTER TABLE [dbo].[Quotations]  WITH CHECK ADD FOREIGN KEY([RequestID])
REFERENCES [dbo].[CustomerRequests] ([RequestID])
GO
ALTER TABLE [dbo].[QuotationsAttachments]  WITH CHECK ADD FOREIGN KEY([QuotationID])
REFERENCES [dbo].[Quotations] ([QuotationID])
GO
ALTER TABLE [dbo].[QuotationsServices]  WITH CHECK ADD FOREIGN KEY([QuotationID])
REFERENCES [dbo].[Quotations] ([QuotationID])
GO
ALTER TABLE [dbo].[QuotationsStages]  WITH CHECK ADD FOREIGN KEY([QuotationID])
REFERENCES [dbo].[Quotations] ([QuotationID])
GO
ALTER TABLE [dbo].[QuotationsTest]  WITH CHECK ADD  CONSTRAINT [FK__Quotation__Quota__1DB06A4F] FOREIGN KEY([QuotationID])
REFERENCES [dbo].[Quotations] ([QuotationID])
GO
ALTER TABLE [dbo].[QuotationsTest] CHECK CONSTRAINT [FK__Quotation__Quota__1DB06A4F]
GO
ALTER TABLE [dbo].[QuotationsTest]  WITH CHECK ADD  CONSTRAINT [FK_QuotationsTest_Units] FOREIGN KEY([UnitID])
REFERENCES [dbo].[Units] ([UnitID])
GO
ALTER TABLE [dbo].[QuotationsTest] CHECK CONSTRAINT [FK_QuotationsTest_Units]
GO
ALTER TABLE [dbo].[SampleAttachments]  WITH CHECK ADD  CONSTRAINT [FK_SampleAttachments_Samples] FOREIGN KEY([SampleRegisterID])
REFERENCES [dbo].[SampleRegisters] ([SampleRegisterID])
GO
ALTER TABLE [dbo].[SampleAttachments] CHECK CONSTRAINT [FK_SampleAttachments_Samples]
GO
ALTER TABLE [dbo].[SampleRegisters]  WITH CHECK ADD  CONSTRAINT [FK_SampleRegisters_Customers] FOREIGN KEY([CustomerID])
REFERENCES [dbo].[Customers] ([CustomerID])
GO
ALTER TABLE [dbo].[SampleRegisters] CHECK CONSTRAINT [FK_SampleRegisters_Customers]
GO
ALTER TABLE [dbo].[SampleRegisters]  WITH CHECK ADD  CONSTRAINT [FK_SampleRegisters_PriorityLevels] FOREIGN KEY([PriorityLevelID])
REFERENCES [dbo].[Priority] ([PriorityID])
GO
ALTER TABLE [dbo].[SampleRegisters] CHECK CONSTRAINT [FK_SampleRegisters_PriorityLevels]
GO
ALTER TABLE [dbo].[SampleRegisters]  WITH CHECK ADD  CONSTRAINT [FK_SampleRegisters_Projects] FOREIGN KEY([ProjectID])
REFERENCES [dbo].[Projects] ([ProjectID])
GO
ALTER TABLE [dbo].[SampleRegisters] CHECK CONSTRAINT [FK_SampleRegisters_Projects]
GO
ALTER TABLE [dbo].[SampleRegisters]  WITH CHECK ADD  CONSTRAINT [FK_SampleRegisters_SampleTypes] FOREIGN KEY([SampleTypeID])
REFERENCES [dbo].[SamplesTypes] ([SampleTypeID])
GO
ALTER TABLE [dbo].[SampleRegisters] CHECK CONSTRAINT [FK_SampleRegisters_SampleTypes]
GO
ALTER TABLE [dbo].[SampleRegisters]  WITH CHECK ADD  CONSTRAINT [FK_SampleRegisters_StorageLocations_place] FOREIGN KEY([CollectedByID])
REFERENCES [dbo].[StorageLocations] ([StorageLocationID])
GO
ALTER TABLE [dbo].[SampleRegisters] CHECK CONSTRAINT [FK_SampleRegisters_StorageLocations_place]
GO
ALTER TABLE [dbo].[SampleRegisters]  WITH CHECK ADD  CONSTRAINT [FK_SampleRegisters_UnitOfMeasurement] FOREIGN KEY([UnitOfMeasurementID])
REFERENCES [dbo].[Units] ([UnitID])
GO
ALTER TABLE [dbo].[SampleRegisters] CHECK CONSTRAINT [FK_SampleRegisters_UnitOfMeasurement]
GO
ALTER TABLE [dbo].[SampleRegisters]  WITH CHECK ADD  CONSTRAINT [FK_SampleRegisters_Users_CollectedBy] FOREIGN KEY([CollectedByID])
REFERENCES [dbo].[EmployeeUsers] ([EmployeeUserID])
GO
ALTER TABLE [dbo].[SampleRegisters] CHECK CONSTRAINT [FK_SampleRegisters_Users_CollectedBy]
GO
ALTER TABLE [dbo].[SampleTests]  WITH CHECK ADD  CONSTRAINT [FK_SampleTests_Samples] FOREIGN KEY([SampleID])
REFERENCES [dbo].[SampleRegisters] ([SampleRegisterID])
GO
ALTER TABLE [dbo].[SampleTests] CHECK CONSTRAINT [FK_SampleTests_Samples]
GO
ALTER TABLE [dbo].[SampleTests]  WITH CHECK ADD  CONSTRAINT [FK_SampleTests_TestNames] FOREIGN KEY([TestID])
REFERENCES [dbo].[Tests] ([TestID])
GO
ALTER TABLE [dbo].[SampleTests] CHECK CONSTRAINT [FK_SampleTests_TestNames]
GO
ALTER TABLE [dbo].[SampleTests]  WITH CHECK ADD  CONSTRAINT [FK_SampleTests_TestTypes] FOREIGN KEY([TestCategoryID])
REFERENCES [dbo].[TestCategories] ([TestCategoryID])
GO
ALTER TABLE [dbo].[SampleTests] CHECK CONSTRAINT [FK_SampleTests_TestTypes]
GO
ALTER TABLE [dbo].[SampleTests]  WITH CHECK ADD  CONSTRAINT [FK_SampleTests_Units] FOREIGN KEY([UnitID])
REFERENCES [dbo].[Units] ([UnitID])
GO
ALTER TABLE [dbo].[SampleTests] CHECK CONSTRAINT [FK_SampleTests_Units]
GO
ALTER TABLE [dbo].[Services]  WITH CHECK ADD  CONSTRAINT [FK__Services__Servictypes] FOREIGN KEY([ServiceTypeID])
REFERENCES [dbo].[ServicesTypes] ([ServiceTypeID])
GO
ALTER TABLE [dbo].[Services] CHECK CONSTRAINT [FK__Services__Servictypes]
GO
ALTER TABLE [dbo].[Tests]  WITH CHECK ADD  CONSTRAINT [FK_Tests_Currencies] FOREIGN KEY([CurrencyID])
REFERENCES [dbo].[Currencies] ([CurrencyID])
GO
ALTER TABLE [dbo].[Tests] CHECK CONSTRAINT [FK_Tests_Currencies]
GO
ALTER TABLE [dbo].[Tests]  WITH CHECK ADD  CONSTRAINT [FK_Tests_Departments] FOREIGN KEY([DepartmentID])
REFERENCES [dbo].[Departments] ([DepartmentID])
GO
ALTER TABLE [dbo].[Tests] CHECK CONSTRAINT [FK_Tests_Departments]
GO
ALTER TABLE [dbo].[Tests]  WITH CHECK ADD  CONSTRAINT [FK_Tests_SamplesTypes] FOREIGN KEY([SampleTypeID])
REFERENCES [dbo].[SamplesTypes] ([SampleTypeID])
GO
ALTER TABLE [dbo].[Tests] CHECK CONSTRAINT [FK_Tests_SamplesTypes]
GO
ALTER TABLE [dbo].[Tests]  WITH CHECK ADD  CONSTRAINT [FK_Tests_TestCategories] FOREIGN KEY([CategoryID])
REFERENCES [dbo].[TestCategories] ([TestCategoryID])
GO
ALTER TABLE [dbo].[Tests] CHECK CONSTRAINT [FK_Tests_TestCategories]
GO
ALTER TABLE [dbo].[Tests]  WITH CHECK ADD  CONSTRAINT [FK_Tests_Tests] FOREIGN KEY([TestID])
REFERENCES [dbo].[Tests] ([TestID])
GO
ALTER TABLE [dbo].[Tests] CHECK CONSTRAINT [FK_Tests_Tests]
GO
ALTER TABLE [dbo].[Tests]  WITH CHECK ADD  CONSTRAINT [FK_Tests_Units] FOREIGN KEY([UnitID])
REFERENCES [dbo].[Units] ([UnitID])
GO
ALTER TABLE [dbo].[Tests] CHECK CONSTRAINT [FK_Tests_Units]
GO
ALTER TABLE [dbo].[Tools]  WITH CHECK ADD  CONSTRAINT [FK_Tools_ToolsCategories] FOREIGN KEY([CategoryID])
REFERENCES [dbo].[ToolsCategories] ([CategoryID])
GO
ALTER TABLE [dbo].[Tools] CHECK CONSTRAINT [FK_Tools_ToolsCategories]
GO
ALTER TABLE [dbo].[Worksheets]  WITH CHECK ADD FOREIGN KEY([OrderID])
REFERENCES [dbo].[Orders] ([OrderID])
GO
ALTER TABLE [dbo].[WorksheetsStages]  WITH CHECK ADD FOREIGN KEY([WorksheetID])
REFERENCES [dbo].[Worksheets] ([WorksheetID])
GO
ALTER TABLE [dbo].[WorksheetsTests]  WITH CHECK ADD FOREIGN KEY([WorksheetID])
REFERENCES [dbo].[Worksheets] ([WorksheetID])
GO
ALTER TABLE [dbo].[DiscountSettings]  WITH CHECK ADD CHECK  (([MaximumDiscount]>=(0) AND [MaximumDiscount]<=(100)))
GO
ALTER TABLE [dbo].[InvoicesTest]  WITH CHECK ADD CHECK  (([Accredited]='No' OR [Accredited]='Yes'))
GO
ALTER TABLE [dbo].[OrdersTest]  WITH CHECK ADD  CONSTRAINT [CK__OrdersTes__Accre__3493CFA7] CHECK  (([Accredited]='No' OR [Accredited]='Yes'))
GO
ALTER TABLE [dbo].[OrdersTest] CHECK CONSTRAINT [CK__OrdersTes__Accre__3493CFA7]
GO
ALTER TABLE [dbo].[QuotationsTest]  WITH CHECK ADD  CONSTRAINT [CK__Quotation__Accre__1CBC4616] CHECK  (([Accredited]='No' OR [Accredited]='Yes'))
GO
ALTER TABLE [dbo].[QuotationsTest] CHECK CONSTRAINT [CK__Quotation__Accre__1CBC4616]
GO
ALTER TABLE [dbo].[Tests]  WITH CHECK ADD  CONSTRAINT [CK__Tests__Accredite__625A9A57] CHECK  (([Accredited]='No' OR [Accredited]='Yes'))
GO
ALTER TABLE [dbo].[Tests] CHECK CONSTRAINT [CK__Tests__Accredite__625A9A57]
GO
ALTER TABLE [dbo].[Tests]  WITH CHECK ADD  CONSTRAINT [CK__Tests__RequiredF__634EBE90] CHECK  (([RequiredForVerify]='No' OR [RequiredForVerify]='Yes'))
GO
ALTER TABLE [dbo].[Tests] CHECK CONSTRAINT [CK__Tests__RequiredF__634EBE90]
GO
