/****** Object:  StoredProcedure [dbo].[QSubPFrm_SanadHesabdarySF3_ImportExcel]    Script Date: 07/25/2023 15:50:44 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[QSubPFrm_SanadHesabdarySF3_ImportExcel]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
DROP PROCEDURE [dbo].[QSubPFrm_SanadHesabdarySF3_ImportExcel]
GO
/****** Object:  Table [dbo].[dbo_tblColumns]    Script Date: 07/25/2023 15:50:41 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[dbo_tblColumns]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[dbo_tblColumns]
GO
/****** Object:  Table [dbo].[dbo_tblSpreadsheets]    Script Date: 07/25/2023 15:50:41 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[dbo_tblSpreadsheets]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [dbo].[dbo_tblSpreadsheets]
GO
/****** Object:  Table [dbo].[dbo_tblSpreadsheets]    Script Date: 07/25/2023 15:50:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[dbo_tblSpreadsheets]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[dbo_tblSpreadsheets](
	[SSID] [int] IDENTITY(1,1) NOT NULL,
	[SSName] [nvarchar](255) NULL,
	[AppendTo] [nvarchar](255) NULL,
	[CheckColumn] [nvarchar](255) NULL,
	[HeaderRow] [int] NULL,
 CONSTRAINT [PK_dbo_tblSpreadsheets] PRIMARY KEY CLUSTERED 
(
	[SSID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[dbo_tblSpreadsheets] ON
INSERT [dbo].[dbo_tblSpreadsheets] ([SSID], [SSName], [AppendTo], [CheckColumn], [HeaderRow]) VALUES (1, N'NewMembers', N'TRANSACTION2', N'variz', 11)
SET IDENTITY_INSERT [dbo].[dbo_tblSpreadsheets] OFF
/****** Object:  Table [dbo].[dbo_tblColumns]    Script Date: 07/25/2023 15:50:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[dbo_tblColumns]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[dbo_tblColumns](
	[fldkey] [int] IDENTITY(1,1) NOT NULL,
	[SSID] [int] NULL,
	[ColumnRef] [smallint] NULL,
	[ColumnHeader] [nvarchar](255) NULL,
	[BoundField] [nvarchar](255) NULL,
	[BoundFieldCaption] [nvarchar](255) NULL,
 CONSTRAINT [PK_dbo_tblColumns] PRIMARY KEY CLUSTERED 
(
	[fldkey] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[dbo_tblColumns] ON
INSERT [dbo].[dbo_tblColumns] ([fldkey], [SSID], [ColumnRef], [ColumnHeader], [BoundField], [BoundFieldCaption]) VALUES (1, 1, 0, N'RADIF', N'radif', N'ردیف')
INSERT [dbo].[dbo_tblColumns] ([fldkey], [SSID], [ColumnRef], [ColumnHeader], [BoundField], [BoundFieldCaption]) VALUES (2, 1, 1, N'tarikh', N'TextAID', N'تاریخ')
INSERT [dbo].[dbo_tblColumns] ([fldkey], [SSID], [ColumnRef], [ColumnHeader], [BoundField], [BoundFieldCaption]) VALUES (3, 1, 2, N'variz', N'Sharh', N'شرح سند')
INSERT [dbo].[dbo_tblColumns] ([fldkey], [SSID], [ColumnRef], [ColumnHeader], [BoundField], [BoundFieldCaption]) VALUES (5, 1, 3, N'BED', N'DARBed', N'بدهکار')
INSERT [dbo].[dbo_tblColumns] ([fldkey], [SSID], [ColumnRef], [ColumnHeader], [BoundField], [BoundFieldCaption]) VALUES (7, 1, 4, N'Bed', N'PARBes', N'بستانکار')
SET IDENTITY_INSERT [dbo].[dbo_tblColumns] OFF
/****** Object:  StoredProcedure [dbo].[QSubPFrm_SanadHesabdarySF3_ImportExcel]    Script Date: 07/25/2023 15:50:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[QSubPFrm_SanadHesabdarySF3_ImportExcel]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE PROCEDURE [dbo].[QSubPFrm_SanadHesabdarySF3_ImportExcel] (@TxtLinkToSub NVARCHAR(255) )
AS
SELECT        TRID, Flag1, Flag2, Date1, Sharh, SAID, HESABID, PARBes, DARBed, radif, GOID, KOLID, THESABID, FieldT1, TextNumberSA, TextShSA, FieldN1, TRAID, Flag3, TextNHSID2, CurMablagh, CurRef, CurRate, FieldT2, 
                         ThesabIDSath2, FieldN2 AS GOID2, FieldN3 AS KOLID2, FieldN4 AS HESABID2, FieldN5 AS THESABID2, FieldN6 AS ThesabIDSath22, FieldN7, FieldT3, FieldT4, FieldT5, FieldT6, FieldT7, FieldT8, TextKalaName, TextAIDKh,TextAID
FROM            TRANSACTION2
WHERE        (Date1 = @TxtLinkToSub)
ORDER BY radif

' 
END
GO
