Vous êtes sur la page 1sur 160

SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].

[Us p_GetReportsForComplaintManager]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' --[Usp_GetReportsForComplaintManager] ''0'',''0'',''0'',''2000-01-01 00:00:00.0 00'',''2011-02-14 00:00:00.000'' ,''admin'',''0'',''0'',''0'',''0'' CREATE PROCEDURE [dbo].[Usp_GetReportsForComplaintManager] -- ''3'',''0'',''0'', ''17-01-2011'',''18-02-2011'' ,''0'',''0'',''0'',''0'',''0'' ( @AWB_NUMBER VARCHAR(50), @ALLOCATED_TO VARCHAR(50), @COMPLAINT_CATEGORY varchar(50), @From_Date varchar(50), @To_Date varchar(50), @CREATED_BY varchar(50), @REFERENCE_NUMBER varchar(50), @ACCOUNT_NUMBER varchar(50), @BARCODE_NUMBER varchar(50), @COMPLAINER_CONTACT_NUMBER varchar(50) ) AS BEGIN declare @str varchar(4000) set @str='' SELECT c.[COMLAINT_TYPE] as Complaint_Type, c.[AWB_NUMBER] as AWB_Number , c.[ACCOUNT_NUMBER] as Account_Number, c.[REFERENCE_NUMBER] as Reference_Number , c.[COMPLAINER_NAME] as Complainer_Name, [Complaint_Category_Name]=(select category_name from categories where cate gory_id=c.[COMPLAINT_CATEGORY]), c.[COMPLAINT_RECEVIED_BY] as Complaint_Received_By, c.[COMPLAINER_CONTACT_NUMBER] as Complainer_Contact_No , [Allocated_To_Name]=(select category_name from categories where category_i d=c.[ALLOCATED_TO]), c.[REMARKS] as Remarks , c.[Created_By] as [User], convert(varchar,c.[Created_Date],105) as Created_Date '' set @str=@str+''FROM [COMPLAINT_MANAGER] c ,INWARD_SCANNING i where c.Is_Delet ed=0 '' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @str=@str+'' and '' +''c.Created_Date between ''''''+ @From_Date+'''''' an d ''''''+@To_Date+'''''''' End Else

Begin if not @From_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''c.Created_Date BETWEEN ''''''+ @From_Date+'''''' an d ''''''+''3000-02-19 00:00:00.000''+'''''''' print(@str) if not @To_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''c.Created_Date between ''''''+''2000-01-01 00:00:00 .000''+'''''' and ''''''+@To_Date+'''''''' End if(@ALLOCATED_TO!=''0'') set @str=@str + '' and ALLOCATED_TO=''''''+@ALLOCATED_TO+'''''''' if(@AWB_NUMBER!=''0'') set @str=@str + ''and c.AWB_NUMBER=''''''+@AWB_NUMBER +'''''''' if(@COMPLAINT_CATEGORY!=''0'') set @str=@str + ''and c.COMPLAINT_CATEGORY=''+@COMPLAINT_CATEGORY +'''' if(@CREATED_BY!=''0'') set @str=@str + ''and c.CREATED_BY=''''''+@CREATED_BY +'''''''' if(@BARCODE_NUMBER!=''0'') set @str=@str + ''and i.BARCODE_NUMBER=''''''+@BARCODE_NUMBER +'''''''' if(@ACCOUNT_NUMBER!=''0'') set @str=@str + ''and c.ACCOUNT_NUMBER=''''''+@ACCOUNT_NUMBER +'''''''' if(@REFERENCE_NUMBER!=''0'') set @str=@str + ''and c.REFERENCE_NUMBER=''''''+@REFERENCE_NUMBER +'''''''' if(@COMPLAINER_CONTACT_NUMBER!=''0'') set @str=@str + ''and c.COMPLAINER_CONTACT_NUMBER=''''''+@COMPLAINER_CONTACT_NU MBER +'''''''' set @str=@str+'' and c.AWB_NUMBER=i.AWB_NUMBER '' print(@str) exec(@str) END --select *from complaint_manager

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetCountofSoftCopyForDashBoard]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetCountofSoftCopyForDashBoard] --''18-01-2011'' ( @Created_Date varchar(50) ) AS BEGIN SELECT PARTY_CODE as [Party Code], --[Party Name]=(select Category_Name from Categories where Category_ID = PARTY_ CODE), BILL_CYCLE, COUNT(BARCODE) FROM SOFT_COPY WHERE CONVERT(VARCHAR,CREATED_DATE,105)=@CREATED_DATE group by PARTY_CODE ,BILL_CYCLE END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[FE EDBACK]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[FEEDBACK]( [FEEDBACK_ID] [int] IDENTITY(1,1) NOT NULL, [FEEDBACK_TYPE] [int] NOT NULL, [SUBJECT] [varchar](100) NOT NULL, [COMMENTS] [varchar](3000) NOT NULL, [COLUMN001] [varchar](50) NULL, [COLUMN002] [varchar](50) NULL, [COLUMN003] [varchar](50) NULL, [COLUMN004] [varchar](50) NULL, [COLUMN005] [varchar](50) NULL, [COLUMN006] [varchar](50) NULL, [COLUMN007] [varchar](50) NULL, [COLUMN008] [varchar](50) NULL, [COLUMN009] [varchar](50) NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL,

[CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_FEEDBACK] PRIMARY KEY CLUSTERED ( [FEEDBACK_ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_DeleteExistingExcelData]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Procedure Name :Usp_DeleteExistingExcelData -- Created By :Srinivas.L -- Created Date :30-08-2010 -- Modified By : -- Modified Date : -- Description : Delete the Existing Excel Sheet Data -- ============================================= CREATE PROCEDURE [dbo].[Usp_DeleteExistingExcelData] AS Begin Delete From SOFT_COPY

End ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetBarcodeonAWB]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE Procedure [dbo].[Usp_GetBarcodeonAWB] ( @AWB_NUMBER int ) as Begin select Barcode_number from INWARD_SCANNING where AWB_NUMBER=@AWB_NUMBER END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TE LECALLING_TRANSACTIONS]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[TELECALLING_TRANSACTIONS]( [TELECALLER_ID] [int] IDENTITY(1,1) NOT NULL, [AWB_NUMBER] [int] NOT NULL, [CUSTOMER_NAME] [varchar](50) NULL, [ACCOUNT_NUMBER] [varchar](50) NULL, [REFERENCE_NUMBER] [varchar](50) NULL, [CONTACT_NUMBER] [varchar](50) NOT NULL, [FLAT_NO] [varchar](50) NULL, [STREET_NAME] [varchar](50) NULL, [CITY] [varchar](50) NULL, [STATE] [varchar](50) NULL, [PINCODE] [varchar](50) NULL, [IS_CONNECTED] [varchar](50) NULL, [SPOKE_TO] [varchar](50) NULL, [RELATION_ID] [int] NULL, [TELE_STATUS_YES] [varchar](50) NULL, [TELE_STATUS_NO] [varchar](50) NULL, [NEW_ADDRESS] [varchar](500) NULL, [REMARKS] [varchar](3000) NULL, [RTO_BOY] [varchar](50) NULL, [FLAT_NO_NEW] [varchar](50) NULL, [STREET_NAME_NEW] [varchar](50) NULL, [CITY_NEW] [varchar](50) NULL, [STATE_NEW] [varchar](50) NULL, [PINCODE_NEW] [varchar](50) NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_TELECALLING_TRANSACTIONS] PRIMARY KEY CLUSTERED ( [TELECALLER_ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetReportsForTelecalling]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetReportsForTelecalling] --''0'',''0'',''0'',''2011 -02-11 00:00:00.000'',''3000-02-19 00:00:00.000'',''admin'' ( @REASON Varchar(50), @PARTY_CODE varchar(50),

@BILLCYCLE varchar(50), @From_Date varchar(50), @To_Date varchar(50), @CREATED_BY varchar(50) ) AS BEGIN declare @str varchar(4000) set @str='' SELECT T.[AWB_NUMBER] as AWb_Number, [R T O Reason]=(Select Category_Name from Categories where Category_ID = S TATUS_UPDATION.[REASON]), T.CUSTOMER_NAME as Customer_Name, T.[ACCOUNT_NUMBER] as Account_Number , T.[REFERENCE_NUMBER] as Reference_Number, T.[CONTACT_NUMBER] as Contact_Number, [SPOKE_TO] as Spoke_To , Relation = (Select Category_Name from Categories where Category_ID = T.REL ATION_ID), [TELE_STATUS_YES] as Tele_status_Yes, [TELE_STATUS_NO] as Tele_Status_No, T.FLAT_NO as Flat_no, T.STREET_NAME as Street_Name,T.CITY as City, T.STATE as State,T.PINCODE as Pincode, Party=(Select Category_Name from Categories where Category_ID = INWARD_SCA NNING.PARTY_CODE), INWARD_SCANNING.BILLCYCLE as BillCycle, T.[REMARKS] as Remarks, T.[Created_By] , convert(varchar,T.[Created_Date],105) as Created_Date , T.[Modified_By] , convert(varchar, T.[Modified_Date],105) as Modified_Date FROM [TELECALLING] T INNER JOIN INWARD_SCANNING on INWARD_SCANNING.AWB_NUMBER=T.AWB_NUMBER inner join STATUS_UPDATION on STATUS_UPDATION.AWB_NUMBER=T.AWB_NUMBER WHERE T.[IS_DELETED]=0'' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @str=@str+'' and '' +''T.Created_Date between ''''''+ @From_Date+'''''' an d ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' --set @str=@str+'' and '' +''convert(varchar,Created_Date,105) between ''''''+ @From_Date+'''''' and ''''''+''12/31/9999''+'''''''' set @str=@str+'' and '' +''T.Created_Date BETWEEN ''''''+ @From_Date+'''''' an d ''''''+''3000-02-19 00:00:00.000''+''''''''

if not @To_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''T.Created_Date between ''''''+''2000-01-01 00:00:00 .000''+'''''' and ''''''+@To_Date+'''''''' End

if(@CREATED_BY!=''0'') set @str=@str + ''and T.CREATED_BY=''''''+@CREATED_BY +'''''''' if(@PARTY_CODE!=''0'') set @str=@str + '' and INWARD_SCANNING.PARTY_CODE=''+@PARTY_CODE+'''' if(@BILLCYCLE!=''0'') set @str=@str + '' and INWARD_SCANNING.BILLCYCLE=''''''+@BILLCYCLE+'''''''' if(@REASON!=''0'') set @str=@str + '' and STATUS_UPDATION.REASON=''''''+@REASON+'''''''' --if(@TELE_STATUS_YES!=''0'') --set @str=@str + ''and TELECALLING.TELE_STATUS_YES=''+@TELE_STATUS_YES +'''' ---if(@TELE_STATUS_NO!=''0'') --set @str=@str + ''and TELECALLING.TELE_STATUS_NO=''+@TELE_STATUS_NO +'''' SET @str=@str+''order by T.CREATED_DATE desc'' exec(@str) print(@str) END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CA TEGORIES]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[CATEGORIES]( [CATEGORY_ID] [int] IDENTITY(1,1) NOT NULL, [CATEGORY_NAME] [varchar](50) NOT NULL, [PARENT_CATEGORY_ID] [int] NOT NULL, [COLUMN001] [varchar](50) NULL, [COLUMN002] [varchar](50) NULL, [COLUMN003] [varchar](50) NULL, [COLUMN004] [varchar](50) NULL, [COLUMN005] [varchar](50) NULL, [COLUMN006] [varchar](50) NULL, [COLUMN007] [varchar](50) NULL, [COLUMN008] [varchar](50) NULL, [COLUMN009] [varchar](50) NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_CATEGORIES] PRIMARY KEY CLUSTERED ( [CATEGORY_ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CU STOMER_DETAILS]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[CUSTOMER_DETAILS]( [CUSTOMER_ID] [int] IDENTITY(1,1) NOT NULL, [CUSTOMER_NAME] [varchar](50) NOT NULL, [FIRST_NAME] [varchar](50) NOT NULL, [MIDDLE_NAME] [varchar](50) NULL, [LAST_NAME] [varchar](50) NOT NULL, [BARCODE_NUMBER] [varchar](50) NOT NULL, [AWB_NUMBER] [int] NOT NULL,

[ACCOUNT_NUMBER] [int] NULL, [REFERENCE_NUMBER] [int] NULL, [PRIORITY] [int] NULL, [STATUS] [int] NULL, [REMARKS] [varchar](3000) NULL, [PARTY] [int] NOT NULL, [TAT] [int] NOT NULL, [ADDRESS] [varchar](500) NOT NULL, [MOBILE_NUMBER] [varchar](50) NOT NULL, [EMAIL_ID] [varchar](50) NULL, [COLUMN001] [varchar](50) NULL, [COLUMN002] [varchar](50) NULL, [COLUMN003] [varchar](50) NULL, [COLUMN004] [varchar](50) NULL, [COLUMN005] [varchar](50) NULL, [COLUMN006] [varchar](50) NULL, [COLUMN007] [varchar](50) NULL, [COLUMN008] [varchar](50) NULL, [COLUMN009] [varchar](50) NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[US P_GetReports]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= --Procedure Name :USP_GetReports --Purpose :To get the Reports --Created By :Ramana.N --Create Date :20-4-2010 --Modified By : --Modified Date : --Description : --Comments : -- ============================================= CREATE PROCEDURE [dbo].[USP_GetReports] --''0'',''0'',''2000-02-11 00:00:00.000' ',''2011-02-11 00:00:00.000'',''0'',''0'',''0'',''0'',''0'' ( @AWB_NUMBER varchar(50), @Status_Id varchar(50), @From_Date varchar(50), @To_Date varchar(50), @ACCOUNT_NUMBER varchar(50), @REFERENCE_NUMBER varchar(50), @BARCODE_NUMBER varchar(50), @PARTY_CODE varchar(50), @BILLCYCLE varchar(50)

) AS Begin declare @strSQL varchar(4000) set @strSQL=''select edp.AWB_NUMBER as AWB_Number, Party=(select Category_Name from Categories where Category_Id=inward.PARTY_CODE) , inward.ACCOUNT_NUMBER as Account_Number, inward.REFERENCE_NUMBER as Reference_Number, inward.BARCODE_NUMBER as Barcode_Number, inward.FIRST_NAME as [Customer Name], Status_Name=(select Category_Name from Categories where Category_Id=edp.STATUS), edp.DELIVERY_DATE as Delivery_Date, Delivery_Boy=(select Category_Name from Categories where Category_Id=edp.DELIVER Y_BOY_ID), edp.RECEIVED_BY as Received_By, Relation=(select Category_Name from Categories where Category_Id=edp.RELATIONSHI P), edp.CUSTOMER_CONTACT_NUMBER as Customer_Contact_Number, inward.FLAT_NO as [Flat no],inward.STREET_NAME as [Street Name],inward.CITY as C ity, inward.STATE as State,inward.PINCODE as Pincode, Area_Name=(select Category_Name from Categories where Category_Id=s.Area_Code), inward.BILLCYCLE as BillCycle, edp.PAGEBUNDLE_NUMBER as PageBundle_Number, edp.Created_By, convert(varchar,edp.Created_Date,105) as Created_Date'' set @strSQL=@strSQL+'' from ELECTRONIC_DATA_PROCESSING edp,INWARD_SCANNING inwar d,Status_Updation s where edp.Is_Deleted=0 '' if(@Status_Id!=''0'') set @strSQL=@strSQL + ''and edp.STATUS=''+@Status_Id +'''' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @strSQL=@strSQL+'' and '' +''inward.Created_Date between ''''''+ @From_Dat e+'''''' and ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' --set @str=@str+'' and '' +''convert(varchar,Created_Date,105) between ''''''+ @From_Date+'''''' and ''''''+''12/31/9999''+'''''''' set @strSQL=@strSQL+'' and '' +''inward.Created_Date BETWEEN ''''''+ @From_Dat e+'''''' and ''''''+''3000-02-19 00:00:00.000''+'''''''' if not @To_Date= ''2000-01-01 00:00:00.000'' set @strSQL=@strSQL+'' and '' +''inward.Created_Date between ''''''+''2000-0101 00:00:00.000''+'''''' and ''''''+@To_Date+''''''''

End

if(@ACCOUNT_NUMBER !=''0'') set @strSQL=@strSQL + ''and inward.ACCOUNT_NUMBER =''''''+@ACCOUNT_NUMBER +''' ''''' if(@REFERENCE_NUMBER!=''0'') set @strSQL=@strSQL + ''and inward.REFERENCE_NUMBER=''''''+@REFERENCE_NUMBER +' ''''''' if(@BARCODE_NUMBER!=''0'') set @strSQL=@strSQL + ''and inward.BARCODE_NUMBER=''''''+@BARCODE_NUMBER +''''' ''' if(@PARTY_CODE!=''0'') set @strSQL=@strSQL + ''and inward.PARTY_CODE=''+@PARTY_CODE +'''' if(@BILLCYCLE!=''0'') set @strSQL=@strSQL + ''and inward.BILLCYCLE=''''''+@BILLCYCLE +'''''''' if(@AWB_NUMBER!=''0'') set @strSQL=@strSQL + ''and edp.AWB_NUMBER=''+@AWB_NUMBER +'''' set @strSQL=@strSQL+'' and edp.AWB_NUMBER=inward.AWB_NUMBER and edp.AWB_NUMBER =s.AWB_NUMBER '' exec(@strSQL) --print(@strSQL) End

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EM PLOYEE_REGISTRATION]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[EMPLOYEE_REGISTRATION]( [REGISTRATION_ID] [int] IDENTITY(1,1) NOT NULL, [EMPLOYEE_ID] [varchar](50) NOT NULL, [USER_NAME] [varchar](50) NOT NULL, [PASSWORD] [varchar](50) NOT NULL, [FIRST_NAME] [varchar](50) NOT NULL, [LAST_NAME] [varchar](50) NOT NULL, [ADDRESS] [varchar](500) NOT NULL, [CONTACT_NUMBER] [varchar](50) NULL, [DESIGNATION_ID] [int] NOT NULL, [EMAIL_ID] [varchar](100) NULL, [EMPLOYEE_TYPE_ID] [int] NULL, [AREA_CODE] [int] NULL, [PHOTO] [varchar](500) NULL, [AGENCY_NAME] [varchar](50) NULL, [COLUMN005] [varchar](50) NULL, [COLUMN006] [varchar](50) NULL, [COLUMN007] [varchar](50) NULL, [COLUMN008] [varchar](50) NULL, [COLUMN009] [varchar](50) NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_EMPLOYEE_REGISTRATION_1] PRIMARY KEY CLUSTERED ( [REGISTRATION_ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetReportsForNoService]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- [Usp_GetReportsForOutwardScanning] ''0'',''0'',''0'',''0'',''0'',''17-01-2011 '',''18-01-2011''

CREATE procedure [dbo].[Usp_GetReportsForNoService]-- ''0'',''0'',''0'',''17-012011'',''18-01-2011'' ( @CREATED_BY varchar(50), @PARTY varchar(50), @BILLCYCLE varchar(50), @From_Date varchar(50), @To_Date varchar(50) ) as begin declare @str varchar(4000) set @str='' select out.AWB_NUMBER as AWB_Number, out.BARCODE_NUMBER as Barcode_Number, out.ACCOUNT_NUMBER as Account_Number, out.REFERENCE_NUMBER as Reference_Number, out.CUSTOMER_FIRST_NAME as Customer_First_Name, out.CUSTOMER_LAST_NAME as Customer_Last_Name,out.CUSTOMER_EMAIL_ID as Customer_E mail_Id, Party_code = (Select Category_Name from Categories where Category_ID = out.[PART Y]), i.BILLCYCLE as BillCycle, out.CUSTOMER_ADDRESS as Customer_Address, out.PRIORITY as Priority,out.STATUS as Status,out.TAT, out.Created_By,convert(varchar,out.Created_Date,105) as Created_Date '' set @str=@str + '' From OUTWARD_WITHOUTAREACODE out, INWARD_SCANNING i where out .IS_DELETED=0'' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @str=@str+'' and '' +''out.Created_Date between ''''''+ @From_Date+'''''' and ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' --set @str=@str+'' and '' +''convert(varchar,Created_Date,105) between ''''''+ @From_Date+'''''' and ''''''+''12/31/9999''+'''''''' set @str=@str+'' and '' +''out.Created_Date BETWEEN ''''''+ @From_Date+'''''' and ''''''+''3000-02-19 00:00:00.000''+'''''''' print(@str) if not @To_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''out.Created_Date between ''''''+''2000-01-01 00:00: 00.000''+'''''' and ''''''+@To_Date+'''''''' print(@str) End set @str=@str+'' and out.AWB_NUMBER=i.AWB_NUMBER ''

if(@CREATED_BY!=''0'') set @str=@str + ''and out.CREATED_BY=''''''+@CREATED_BY + '''''''' if(@PARTY!=''0'') set @str=@str + ''and out.PARTY=''''''+@PARTY + '''''''' if(@BILLCYCLE!=''0'') set @str=@str + ''and i.BILLCYCLE=''''''+@BILLCYCLE + '''''''' exec(@str) print(@str) End

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UdateSoftCopy]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_UdateSoftCopy] ( --@SOFT_COPY_ID int,

@CREATED_BY varchar(50), @BARCODE Varchar(50), --@CREATED_DATE datetime, @ERROR varchar(50) out ) as begin update SOFT_COPY set CREATED_BY=@CREATED_BY , CREATED_DATE=getdate(), IS_DELETED=0 where BARCODE=@BARCODE --where SOFT_COPY_ID=@SOFT_COPY_ID set @ERROR=''updated successfully'' end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_DeleteInwardScanning]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

CREATE procedure [dbo].[Usp_DeleteInwardScanning] --222,''Deleted Succesfully'' ( @AWB_NUMBER varchar(50), @Error varchar(50) out ) as begin delete from INWARD_SCANNING where AWB_NUMBER=@AWB_NUMBER set @Error=''Deleted Succesfully'' end

' END GO

SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetStatisticalReports]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

--[Usp_GetStatisticalReports] ''2011-03-01 00:00:00.000'',''3000-02-19 00:00:00. 000'',''INWARD_SCANNING'' CREATE procedure [dbo].[Usp_GetStatisticalReports] ( @From_Date varchar(50), @To_Date varchar(50), @SelectPage varchar(50) ) as declare @str varchar(2000) --------------------------------------------------------declare @sqldates varchar(2000) declare @pivot varchar(2000) ----------------------------------------------------------------create table #pivot_columns (pivot_column varchar(100)) --------------------------------------------------------Select @sqldates='' select distinct(convert(varchar, Created_Date, 105)) from ''+ @SelectPage +'' wh ere IS_DELETED = 0 '' --print(@sqldates) --if(@From_Date!=''01-01-1900'' and @To_Date!=''01-01-1900'') if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin --set @sqldates=@sqldates+'' and '' +''convert(varchar, Created_Date,105) betw een ''''''+ @From_Date+'''''' and ''''''+@To_Date+'''''''' set @sqldates=@sqldates+'' and '' +'' Created_Date between ''''''+ @From_Date+ '''''' and ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' set @sqldates=@sqldates+'' and '' +''Created_Date between ''''''+ @From_Date+' ''''' and ''''''+''3000-02-19 00:00:00.000''+'''''''' --print(@sqldates) if not @To_Date= ''2000-01-01 00:00:00.000'' set @sqldates=@sqldates+'' and '' +''Created_Date between ''''''+''2000-01-01 00:00:00.000''+'''''' and ''''''+@To_Date+'''''''' set @sqldates=@sqldates+''order by convert(varchar,Created_Date,105) asc'' --set @sqldates=@sqldates+''order by Created_Date asc'' print(@sqldates) End ------------------------------------------------------------------insert into #pivot_columns

exec(@sqldates) --------------------------------------------------------------------select @pivot=coalesce(@pivot+'','','''')+''[''+pivot_column+'']''from #pivot_co lumns -------------------------------------------------------------set @str=''SELECT CREATED_BY as [User],''+@pivot+'' FROM (SELECT convert(varchar, CREATED_DATE,105) as dates, awb_number, CREATED_BY FROM ''+ @SelectPage+'' where IS_DELETED=0) AS SourceTable PIVOT ( count(awb_number) FOR dates IN (''+@pivot+ '') ) AS PivotTable '' --print(@str) exec(@str)

-- AND RECEIVED_BY !='' +''''''signature''''''+ ''

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Se archRecordsByTableNameAndText]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= --Procedure Name : SearchRecordsByTableNameAndText --Purpose : Search Records By Table Name And Text --Created By : Ramana.N --Create Date : 10/08/2010 --Modified By : --Modified Date : --Description : Search Records By Table Name And Text -- ============================================= CREATE PROCEDURE [dbo].[SearchRecordsByTableNameAndText] ( @Table_Name varchar(50), @Search_Text varchar(50) ) AS begin set nocount on; --Declaration of variables ----------------------------------------------------------------------Declare @columnName varchar(60) Declare @selectSql varchar(1000)

Declare @whereCondition varchar(1000) Declare @columnCount int Declare @count int Declare @finalSql varchar(2000) --Declare @Search_Text varchar(40) Declare @tableName varchar(40) -------------------------------------------------------------------------set set set set @tableName=@Table_Name @columnCount=0 @whereCondition='''' @count=0

--preparing basic sql select command --declare cursor for geting column name --------------------------------------------------------------declare mycursor cursor for select column_name from information_schema.columns where table_name = @tableName order by ordinal_position ---------------------------------------------get count of columns ----------------------------------------------------------open mycursor Fetch next from mycursor into @columnName while @@FETCH_STATUS = 0 begin set @columnCount=@columnCount+1 Fetch next from mycursor into @columnName end close mycursor --------------------------------------------------------------------open cursor for buliding sql --------------------------------------------------------------open mycursor Fetch next from mycursor into @columnName while @@FETCH_STATUS = 0 begin set @count=@count+1 --print @columnName if (@count <> @columnCount) begin set @whereCondition= @whereCondition+@columnName+'' ''+''Like''+'' ' '+''''''''+''%''+@Search_Text+''%''+''''''''+'' ''+''or''+'' '' end else begin set @whereCondition= @whereCondition+@columnName+'' ''+''Like''+'' ' '+''''''''+''%''+@Search_Text+''%''+'''''''' end fetch next from mycursor into @columnName end--end while close mycursor deallocate mycursor ------------------------------------------------------------------------------------

--combine select and where clause --------------------------------------------set @selectSql = ''SELECT * FROM''+'' ''+ @tableName+'' ''+''WHERE ('' set @finalSql=@selectSql+@whereCondition+'') ''+''and Is_Deleted = 0'' print @finalSql exec (@finalSql) --exec final sql end --end procedure

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SC REENS]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[SCREENS]( [SCREEN_ID] [int] IDENTITY(1,1) NOT NULL, [SCREEN_NAME] [varchar](150) NOT NULL, [URL] [varchar](150) NOT NULL, [DESCRIPTION] [varchar](150) NULL, [COLUMN001] [varchar](50) NULL, [COLUMN002] [varchar](50) NULL, [COLUMN003] [varchar](50) NULL, [COLUMN004] [varchar](50) NULL, [COLUMN005] [varchar](50) NULL, [COLUMN006] [varchar](50) NULL, [COLUMN007] [varchar](50) NULL, [COLUMN008] [varchar](50) NULL, [COLUMN009] [varchar](50) NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_SCREENS] PRIMARY KEY CLUSTERED ( [SCREEN_ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OU TWARD_SCANNING_MISROUTE]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[OUTWARD_SCANNING_MISROUTE]( [OUTWARD_SCANNING_ID] [int] IDENTITY(1,1) NOT NULL, [BARCODE_NUMBER] [varchar](50) NOT NULL, [AWB_NUMBER] [int] NOT NULL, [ACCOUNT_NUMBER] [varchar](50) NULL,

[REFERENCE_NUMBER] [varchar](50) NULL, [CUSTOMER_FIRST_NAME] [varchar](50) NOT NULL, [CUSTOMER_LAST_NAME] [varchar](50) NULL, [PARTY] [int] NOT NULL, [CUSTOMER_EMAIL_ID] [varchar](50) NULL, [AREA_CODE] [int] NOT NULL, [CUSTOMER_ADDRESS] [varchar](2500) NULL, [PRIORITY] [varchar](50) NULL, [STATUS] [int] NULL, [TAT] [int] NULL, [RETURNED_DATE] [datetime] NULL, [IS_MISROUTE] [bit] NULL, [COLUMN003] [varchar](50) NULL, [COLUMN004] [varchar](50) NULL, [COLUMN005] [varchar](50) NULL, [COLUMN006] [varchar](50) NULL, [COLUMN007] [varchar](50) NULL, [COLUMN008] [varchar](50) NULL, [COLUMN009] [varchar](50) NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_OUTWARD_SCANNING_MISROUTE] PRIMARY KEY CLUSTERED ( [OUTWARD_SCANNING_ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[IN WARD_LOAD]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[INWARD_LOAD]( [INWARD_ID] [int] IDENTITY(1,1) NOT NULL, [PICKUP_DATE_TIME] [varchar](50) NOT NULL, [PARTY_CODE] [int] NOT NULL, [BILLCYCLE] [int] NOT NULL, [NUMBER_OF_DOCUMENTS] [int] NOT NULL, [AREA_CODE] [varchar](50) NOT NULL, [PICKED_UP_BY] [int] NULL, [REMARKS] [varchar](3000) NOT NULL, [EDITABLE_DATE_TIME] [varchar](50) NULL, [PARTICULARS] [varchar](50) NULL, [EDITABLE_TIME] [varchar](50) NULL, [COLUMN004] [varchar](50) NULL, [COLUMN005] [varchar](50) NULL, [COLUMN006] [varchar](50) NULL, [COLUMN007] [varchar](50) NULL, [COLUMN008] [varchar](50) NULL, [COLUMN009] [varchar](50) NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL,

[MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_INWARD] PRIMARY KEY CLUSTERED ( [INWARD_ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CO MPLAINTS_ALLOCATION]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[COMPLAINTS_ALLOCATION]( [COMPLAINT_ALLOCATED_ID] [int] IDENTITY(1,1) NOT NULL, [ALLOCATED_TO] [varchar](50) NOT NULL, [NO_OF_COMPLAINTS] [int] NULL, [NO_OF_DOCUMENTS] [int] NULL, [NO_OF_PICKUPS] [int] NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_COMPLAINTS_ALLOCATION] PRIMARY KEY CLUSTERED ( [COMPLAINT_ALLOCATED_ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TE LESCANNING]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[TELESCANNING]( [TELESCANNING_ID] [int] IDENTITY(1,1) NOT NULL, [AWB_NUMBER] [int] NOT NULL, [IS_CONNECTED] [varchar](50) NULL, [CUSTOMER_NAME] [varchar](50) NULL, [SPOKE_TO] [varchar](50) NULL, [RELATION_ID] [int] NULL, [REMARKS] [varchar](50) NULL, [STATUS] [int] NULL, [IS_DELETED] [bit] NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_TELESCANNING] PRIMARY KEY CLUSTERED ( [TELESCANNING_ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END

GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetBarcodefromSoftCopy]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetBarcodefromSoftCopy] as begin set nocount on select * from SOFT_COPY end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetStatisticalReportsPartywise]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

--Usp_GetStatisticalReportsPartywise ''BRANCH_OPERATIONS'', ''admin'',''2000-0101 00:00:00.000'',''2011-03-08 00:00:00.000'',''0'' CREATE PROCEDURE [dbo].[Usp_GetStatisticalReportsPartywise] ( @SelectPage varchar(50), @CREATED_BY varchar(50), @From_Date varchar(50), @To_Date varchar(50), @STATUS varchar(50) ) as declare @strsql varchar(4000) if(@SelectPage =''INWARD_SCANNING'') begin set @strsql='' select PARTY_CODE, [Party Name]=(select Category_Name from Categories where Category_ID = PARTY_CO DE), BILLCYCLE, count(*) as [Count] from INWARD_SCANNING where IS_DELETED=0 '' if(@CREATED_BY !=''0'') set @strsql=@strsql + '' and CREATED_BY =''''''+@CREATED_BY +'''''''' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'')

Begin set @strsql=@strsql+'' and '' +''Created_Date between ''''''+ @From_Date+''''' ' and ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' set @strsql=@strsql +'' and '' +''Created_Date between ''''''+ @From_Date+'''' '' and ''''''+''3000-02-19 00:00:00.000''+'''''''' if not @To_Date= ''2000-01-01 00:00:00.000'' set @strsql=@strsql +'' and '' +''Created_Date between ''''''+''2000-01-01 00: 00:00.000''+'''''' and ''''''+@To_Date+'''''''' End if(@STATUS !=''0'') set @strsql=@strsql + ''and STATUS =''''''+@STATUS +'''''''' set @strsql=@strsql +'' GROUP BY PARTY_CODE,BILLCYCLE '' --print(@strsql) Exec(@strsql) End ------------------------------------------------------------------else if(@SelectPage =''INWARD_LOAD'' ) begin set @strsql='' select PARTY_CODE, [Party Name]=(select Category_Name from Categories where Category_ID = PARTY_CO DE), BILLCYCLE, Sum(NUMBER_OF_DOCUMENTS) as [Count] from INWARD_LOAD where IS_DELETED=0 '' if(@CREATED_BY !=''0'') set @strsql=@strsql + '' and CREATED_BY =''''''+@CREATED_BY +'''''''' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @strsql=@strsql+'' and '' +''Created_Date between ''''''+ @From_Date+''''' ' and ''''''+@To_Date+'''''''' --print(@strsql) End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' set @strsql=@strsql +'' and '' +''Created_Date between ''''''+ @From_Date+'''' '' and ''''''+''3000-02-19 00:00:00.000''+'''''''' if not @To_Date= ''2000-01-01 00:00:00.000'' set @strsql=@strsql +'' and '' +''Created_Date between ''''''+''2000-01-01 00:0 0:00.000''+'''''' and ''''''+@To_Date+'''''''' End if(@STATUS !=''0'') set @strsql=@strsql + ''and STATUS =''''''+@STATUS +'''''''' set @strsql=@strsql +'' GROUP BY PARTY_CODE,BILLCYCLE '' --print(@strsql) Exec(@strsql) End

------------------------------------------------------------------------else if(@SelectPage = ''OUTWARD_SCANNING'') BEGIN set @strsql='' select i.PARTY_CODE, [Party Name]=(select Category_Name from Categories where Category_ID = PARTY_CO DE), i.BILLCYCLE, COUNT(*) as [Count] from OUTWARD_SCANNING out inner join INWARD_SCANNING i on i.awb_number=out.awb_number where out.IS_DELETED=0 AND IS_MISROUTE=0 '' if(@CREATED_BY !=''0'') set @strsql=@strsql + '' and out.CREATED_BY =''''''+@CREATED_BY +'''''''' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @strsql=@strsql+'' and '' +''out.Created_Date between ''''''+ @From_Date+' ''''' and ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' set @strsql=@strsql +'' and '' +''out.Created_Date between ''''''+ @From_Date+ '''''' and ''''''+''3000-02-19 00:00:00.000''+'''''''' if not @To_Date= ''2000-01-01 00:00:00.000'' set @strsql=@strsql +'' and '' +''out.Created_Date between ''''''+''2000-01-01 00:00:00.000''+'''''' and ''''''+@To_Date+'''''''' End if(@STATUS !=''0'') set @strsql=@strsql + ''and STATUS =''''''+@STATUS +'''''''' set @strsql=@strsql +'' GROUP BY I.PARTY_CODE,I.BILLCYCLE '' print(@strsql) exec(@strsql) END -------------------------------------------------------------else --(@SelectPage = ''BRANCH_OPERATIONS'') begin set @strsql='' select I. PARTY_CODE, [Party Name]=(select Category_Name from Categories where Category_ID =I.PARTY_C ODE), I.BILLCYCLE, count(*) as [Count] from ''+ @SelectPage + '' '' set @strsql=@strsql + ''inner join INWARD_SCANNING I ON I.AWB_NUMBER='' +@Select Page+ ''.AWB_NUMBER'' set @strsql=@strsql + '' where '' + @SelectPage+ ''.IS_DELETED=0 '' --print(@strsql) if(@CREATED_BY !=''0'')

set @strsql=@strsql + '' and '' + @SelectPage+ ''.CREATED_BY =''''''+@CREATED_BY +'''''''' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @strsql=@strsql+'' and '' +'''' + @SelectPage+ ''.Created_Date between ''' '''+ @From_Date+'''''' and ''''''+@To_Date+'''''''' print(@strsql) End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' set @strsql=@strsql +'' and '' +'''' + @SelectPage+ ''.Created_Date between '' ''''+ @From_Date+'''''' and ''''''+''3000-02-19 00:00:00.000''+'''''''' if not @To_Date= ''2000-01-01 00:00:00.000'' set @strsql=@strsql +'' and '' +'''' + @SelectPage+ ''.Created_Date between '' ''''+''2000-01-01 00:00:00.000''+'''''' and ''''''+@To_Date+'''''''' End if(@STATUS !=''0'') set @strsql=@strsql + ''and ''+ @SelectPage+ ''. STATUS =''''''+@STATUS +'''''' '' set @strsql=@strsql +'' GROUP BY I.PARTY_CODE,I.BILLCYCLE '' print(@strsql) exec(@strsql) end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_DeleteTeleCallingDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== -- Procedure Name :Usp_DeleteTeleCallingDetails -- Created By :Srinivas.L -- Created Date :7-09-2010 -- Modified By : -- Modified Date : -- Description :To Delete the Telecalling details -- ============================================= CREATE PROCEDURE [dbo].[Usp_DeleteTeleCallingDetails] ( @TELECALLER_ID int, @Error varchar(100) out ) as

begin update TELECALLING set IS_DELETED = 1 where TELECALLER_ID = @TELECALLER_ID set @Error = ''Deleted Successfully'' end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetStatisticalReportCountForEDP]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' --Usp_GetStatisticalReportCountForEDP ''2000-01-01 00:00:00.000'',''2011-03-01 0 0:00:00.000'' CREATE procedure [dbo].[Usp_GetStatisticalReportCountForEDP] ( @From_Date varchar(50), @To_Date varchar(50) ) as declare @strsql varchar(2000) declare @str varchar(2000) set @strsql='' select CREATED_BY, count(*) from ELECTRONIC_DATA_PROCESSING where RECEIVED_BY !='' +''''''signature''''''+'' and is_deleted=0'' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @strsql=@strsql+'' and '' +''Created_Date between ''''''+ @From_Date+''''' ' and ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' set @strsql=@strsql+'' and '' +''Created_Date between ''''''+ @From_Date+''''' ' and ''''''+''3000-03-19 00:00:00.000''+'''''''' if not @To_Date= ''2000-01-01 00:00:00.000'' set @strsql=@strsql+'' and '' +''Created_Date between ''''''+''2000-01-01 00:0 0:00.000''+'''''' and ''''''+@To_Date+'''''''' End set @strsql=@strsql+''group by CREATED_BY'' exec(@strsql) --print(@strsql) set @str='' select CREATED_BY, count(*) from ELECTRONIC_DATA_PROCESSING where RECEIVED_BY ='' +''''''signature''''''+'''' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'')

Begin set @str=@str+'' and '' +''Created_Date between ''''''+ @From_Date+'''''' and ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''convert(varchar,Created_Date,105) between ''''''+ @ From_Date+'''''' and ''''''+''3000-03-19 00:00:00.000''+'''''''' if not @To_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''convert(varchar,Created_Date,105) between ''''''+'' 2000-01-01 00:00:00.000''+'''''' and ''''''+@To_Date+'''''''' End set @str=@str+''group by CREATED_BY'' exec(@str) ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetStatisticalReportUserwise]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- Usp_GetStatisticalReportUserwise ''INWARD_SCANNING'', ''0'',''2000-01-01 00:0 0:00.000'',''2000-01-01 00:00:00.000'',0 CREATE procedure [dbo].[Usp_GetStatisticalReportUserwise] ( @SelectPage varchar(50), @CREATED_BY varchar(50), @FROM_DATE varchar(50), @TO_DATE varchar(50), @STATUS varchar(50) ) as begin declare @strsql varchar(4000) set @strsql=''select CREATED_BY,count(*) as Total from ''+@SelectPage+'' where I S_DELETED=0'' if(@CREATED_BY !=''0'') set @strsql=@strsql + ''and CREATED_BY =''''''+@CREATED_BY +'''''''' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @strsql=@strsql+'' and '' +''Created_Date between ''''''+ @From_Date+''''' ' and ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000''

set @strsql=@strsql+'' and '' +''Created_Date between ''''''+ @From_Date+''''' ' and ''''''+''3000-02-19 00:00:00.000''+'''''''' if not @To_Date= ''2000-01-01 00:00:00.000'' set @strsql=@strsql+'' and '' +''Created_Date between ''''''+''2000-01-01 00:0 0:00.000''+'''''' and ''''''+@To_Date+'''''''' End if(@STATUS !=''0'') set @strsql=@strsql + ''and STATUS =''''''+@STATUS +'''''''' set @strsql=@strsql+''group by CREATED_BY'' --print(@strsql) exec(@strsql) end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetScannedDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'CREATE procedure [dbo].[Usp_GetScannedDeta ils]--''admin'' ( @CREATED_BY varchar(50) ) as begin select BARCODE_NUMBER,AWB_NUMBER from INWARD_SCANNING where CREATED_BY=@CREATED_BY and convert(varchar,CREATED_DATE,103)=convert(varch ar,getdate(),103) and IS_DELETED=0 order by CREATED_DATE desc end

' END GO

SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetBarcodefromInwardScanning]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

CREATE PROCEDURE [dbo].[Usp_GetBarcodefromInwardScanning] --( --@BARCODE_NUMBER varchar(50) --) as set nocount on select BARCODE_NUMBER from INWARD_SCANNING --where BARCODE_NUMBER=@BARCODE_NUMBER

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetReportsForSoftCopy]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetReportsForSoftCopy] ( @From_Date varchar(50), @To_Date varchar(50), @CREATED_BY varchar(50) ) AS BEGIN declare @str varchar(4000) set @str='' SELECT [SOFT_COPY_ID], [BARCODE], [ACC_NO], [BILL_REF_NO], [TELEPHONE_NO], [NAME],FLAT_NO,STREET_NAME,[CITY],STATE,[PIN_CODE],[BILL_CYCLE],[ALTERNATE_CONTA CT_NO],[PRIORITY],[PARTY_CODE],[Created_By], convert(varchar,CREATED_DATE,105) as Created_Date FROM [SOFT_COPY] '' if(@From_Date!=''01/01/1900'' and @To_Date!=''01/01/1900'')

Begin set @str=@str +''where convert(varchar,Created_Date,105) between ''''''+ @From _Date+'''''' and ''''''+@To_Date+'''''''' if(@CREATED_BY!=''0'') set @str=@str + '' CREATED_BY=''''''+@CREATED_BY +'''''''' End Else Begin if not @From_Date= ''01/01/1900'' set @str=@str +''where convert(varchar,Created_Date,105) between ''''''+ @From _Date+'''''' and ''''''+''12/31/9999''+'''''''' if not @To_Date= ''01/01/1900'' set @str=@str +''where convert(varchar,Created_Date,105) between ''''''+''01/0 1/2000''+'''''' and ''''''+@To_Date+'''''''' End if(@From_Date=''01/01/1900'' and @To_Date=''01/01/1900'') begin if(@CREATED_BY!=''0'') set @str=@str + ''where CREATED_BY=''''''+@CREATED_BY +'''''''' end exec(@str) print(@str) END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetReportsForInwardLoad]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetReportsForInwardLoad] --''0'',''2011-02-11 00:00: 00.000'',''2011-02-11 00:00:00.000'',''M01'',''0'' ( @PARTY_CODE varchar(50), @From_Date varchar(50), @To_Date varchar(50), @BILLCYCLE varchar(50), @CREATED_BY varchar(50)

) as begin --+'' ''+ [EDITABLE_TIME] as PICKUPDATETIME, declare @str varchar(4000) set @str='' SELECT convert(varchar,[EDITABLE_DATE_TIME],103) as [PickupDate], [Party] = (Select Category_Name from Categories where Category_ID = PARTY _CODE), [Bill_Cycle] = (Select Category_Name from Categories where Category_ID = B ILLCYCLE), [Particulars] = (Select Category_Name from Categories where Category_ID = PARTICULARS) , [NUMBER_OF_DOCUMENTS] as [No.of Documents], [Pickedup_By]=(select Category_Name from Categories where Category_ID= PICKED_U P_BY), [AREA_CODE] as [POD/PickedUpSheetNo] , [REMARKS]as Remarks, [Created_By] FROM INWARD_LOAD where IS_DELETED=0'' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @str=@str+'' and '' +''Created_Date between ''''''+ @From_Date+'''''' and ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''Created_Date BETWEEN ''''''+ @From_Date+'''''' and ''''''+''3000-02-19 00:00:00.000''+'''''''' print(@str) if not @To_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''Created_Date between ''''''+''2000-01-01 00:00:00.0 00''+'''''' and ''''''+@To_Date+'''''''' End if(@PARTY_CODE!=''0'') set @str=@str + '' and PARTY_CODE=''+@PARTY_CODE+'''' if(@BILLCYCLE!=''0'') set @str=@str + ''and BILLCYCLE=''+@BILLCYCLE +'''' if(@CREATED_BY!=''0'') set @str=@str + ''and CREATED_BY=''''''+@CREATED_BY +'''''''' exec(@str) --print(@str)

End

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_BadSignaturepercentage]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_BadSignaturepercentage] -- ''24-02-2011'',''25-02-20 11'' ( @From_Date varchar(50), @To_Date varchar(50) ) as declare @strsql varchar(2000) declare @str varchar(2000) declare @percentage varchar(2000) ------------------------------------------------------------------set nocount on set @str='' select out.area_code as [Area Code],count(*) as [Total] from dbo.ELECTRONIC_DATA_PROCESSING edp inner join dbo.OUTWARD_SCANNING out on out.AWB_NUMBER=edp.AWB_NUMBER where edp.is_deleted=0'' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @str=@str+'' and '' +''edp.Created_Date between ''''''+ @From_Date+'''''' and ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''edp.Created_Date between ''''''+ @From_Date+'''''' and ''''''+''3000-02-19 00:00:00.000''+'''''''' if not @To_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''edp.Created_Date between ''''''+''2000-01-01 00:00: 00.000''+'''''' and ''''''+@To_Date+'''''''' End set @str=@str+''group by out.area_code'' exec(@str) print(@str) set @strsql='' select out.area_code as [Area Code],count(*) as [Bad Signature] from ELECTRONIC _DATA_PROCESSING edp inner join dbo.OUTWARD_SCANNING out on out.AWB_NUMBER=edp.AWB_NUMBER where edp.is_deleted=0 and edp.BAD_SIGNATURE='' +''''''yes''''''+''''

if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @strsql=@strsql+'' and '' +''edp.Created_Date between ''''''+ @From_Date+' ''''' and ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' set @strsql=@strsql+'' and '' +''edp.Created_Date between ''''''+ @From_Date+' ''''' and ''''''+''3000-02-19 00:00:00.000''+'''''''' if not @To_Date= ''2000-01-01 00:00:00.000'' set @strsql=@strsql+'' and '' +''edp.Created_Date between ''''''+''01-01-2000' '+'''''' and ''''''+@To_Date+'''''''' End set @strsql=@strsql+''group by out.area_code'' exec(@strsql) print(@strsql)

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OU TWARD_WITHOUTAREACODE]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[OUTWARD_WITHOUTAREACODE]( [OUTWARD_SCANNING_ID] [int] IDENTITY(1,1) NOT NULL, [BARCODE_NUMBER] [varchar](50) NOT NULL, [AWB_NUMBER] [int] NULL, [ACCOUNT_NUMBER] [varchar](50) NULL, [REFERENCE_NUMBER] [varchar](50) NULL, [CUSTOMER_FIRST_NAME] [varchar](50) NOT NULL, [CUSTOMER_LAST_NAME] [varchar](50) NULL, [PARTY] [int] NOT NULL, [CUSTOMER_EMAIL_ID] [varchar](50) NULL, [CUSTOMER_ADDRESS] [varchar](2500) NULL, [PRIORITY] [varchar](50) NULL, [STATUS] [int] NULL, [TAT] [int] NULL, [BILLCYCLE] [varchar](50) NULL, [COLUMN002] [varchar](50) NULL, [COLUMN003] [varchar](50) NULL, [COLUMN004] [varchar](50) NULL, [COLUMN005] [varchar](50) NULL, [COLUMN006] [varchar](50) NULL, [COLUMN007] [varchar](50) NULL, [COLUMN008] [varchar](50) NULL, [COLUMN009] [varchar](50) NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL,

[MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_OUTWARD_WITHOUTAREACODE] PRIMARY KEY CLUSTERED ( [OUTWARD_SCANNING_ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetReportsForOutwardScanning]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' --[Usp_GetReportsForOutwardScanning] ''0'',''0'',''0'',''0'',''0'',''2010-02-11 00:00:00.000'',''3000-02-19 00:00:00.000'' CREATE procedure [dbo].[Usp_GetReportsForOutwardScanning] --''0'',''0'',''51'',' 'M01'',''true'',''01/01/1900'',''01/01/1900'' ( @AREA_CODE varchar(50), @CREATED_BY varchar(50), @PARTY varchar(50), @BILLCYCLE varchar(50), @IS_MISROUTE varchar(50), @From_Date varchar(50), @To_Date varchar(50) ) as begin declare @str varchar(4000) set @str='' select out.BARCODE_NUMBER as Barcode_Number, out.AWB_NUMBER as AWB_Number,out.ACCOUNT_NUMBER as Account_Number, out.REFERENCE_NUMBER as Reference_Number, Party_code = (Select Category_Name from Categories where Category_ID = out.[PART Y]), Area=(Select Category_Name from Categories where Category_ID = out.AREA_CODE), out.CUSTOMER_FIRST_NAME as Customer_First_Name,out.CUSTOMER_LAST_NAME as Custome r_Last_Name,out.CUSTOMER_EMAIL_ID as Customer_Email_Id, i.BILLCYCLE as BillCycle, out.CUSTOMER_ADDRESS as Customer_Address, out.PRIORITY as Priority,out.STATUS as Status,out.TAT, out.Created_By,convert(varchar,out.Created_Date,105) as Created_Date'' set @str=@str + '' From OUTWARD_SCANNING out, INWARD_SCANNING i where out.IS_DEL ETED=0'' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @str=@str+'' and '' +''out.Created_Date between ''''''+ @From_Date+'''''' and ''''''+@To_Date+'''''''' End Else

Begin if not @From_Date= ''2000-01-01 00:00:00.000'' --set @str=@str+'' and '' +''convert(varchar,Created_Date,105) between ''''''+ @From_Date+'''''' and ''''''+''12/31/9999''+'''''''' set @str=@str+'' and '' +''out.Created_Date BETWEEN ''''''+ @From_Date+'''''' and ''''''+''3000-02-19 00:00:00.000''+'''''''' print(@str) if not @To_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''out.Created_Date between ''''''+''2000-01-01 00:00: 00.000''+'''''' and ''''''+@To_Date+'''''''' print(@str) End if(@AREA_CODE!=''0'') set @str=@str + '' and out.AREA_CODE='''''' + @AREA_CODE + '''''''' set @str=@str+'' and out.AWB_NUMBER=i.AWB_NUMBER '' if(@CREATED_BY!=''0'') set @str=@str + ''and out.CREATED_BY=''''''+@CREATED_BY + '''''''' if(@PARTY!=''0'') set @str=@str + ''and out.PARTY=''''''+@PARTY + '''''''' if(@BILLCYCLE!=''0'') set @str=@str + ''and i.BILLCYCLE=''''''+@BILLCYCLE + '''''''' if(@IS_MISROUTE!=''0'') set @str=@str + ''and out.IS_MISROUTE=''''''+@IS_MISROUTE + '''''''' exec(@str) --print(@str) End

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SO FT_COPY]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[SOFT_COPY]( [SOFT_COPY_ID] [int] IDENTITY(1,1) NOT NULL, [CREATED_BY] [varchar](50) NULL, [CREATED_DATE] [varchar](50) NULL, [IS_DELETED] [bit] NULL, [BARCODE] [varchar](50) NULL, [ACC_NO] [varchar](50) NULL, [BILL_REF_NO] [varchar](50) NULL, [TELEPHONE_NO] [varchar](50) NULL, [NAME] [varchar](100) NULL, [FLAT_NO] [varchar](50) NULL, [STREET_NAME] [varchar](50) NULL, [CITY] [varchar](100) NULL, [STATE] [varchar](50) NULL, [PIN_CODE] [varchar](50) NULL, [BILL_CYCLE] [varchar](50) NULL, [ALTERNATE_CONTACT_NO] [varchar](50) NULL, [PRIORITY] [varchar](50) NULL, [PARTY_CODE] [varchar](50) NULL, CONSTRAINT [PK_SOFT_COPY] PRIMARY KEY CLUSTERED ( [SOFT_COPY_ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetReportsForTeleScanning]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

--[Usp_GetReportsForTeleScanning] ''0'',''2011-02-11 00:00:00.000'',''3000-02-19 00:00:00.000'',''0'' CREATE PROCEDURE [dbo].[Usp_GetReportsForTeleScanning] (

@AWB_NUMBER varchar(50), @From_Date varchar(50), @To_Date varchar(50), @CREATED_BY varchar(50) ) AS BEGIN declare @str varchar(4000) set @str='' SELECT T.[AWB_NUMBER] as AWb_Number, T.CUSTOMER_NAME as Customer_Name, T.IS_CONNECTED as connected, T.SPOKE_TO as [Spoke To], Relation = (Select Category_Name from Categories where Category_ID = T.RE LATION_ID), T.[REMARKS] as Remarks, T.[Created_By] , Status=(Select Category_Name from Categories where Category_ID = T.STATUS), convert(varchar,T.[Created_Date],105) as Created_Date FROM [TELESCANNING] T WHERE T.[IS_DELETED]=0'' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @str=@str+'' and '' +''T.Created_Date between ''''''+ @From_Date+'''''' an d ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' --set @str=@str+'' and '' +''convert(varchar,Created_Date,105) between ''''''+ @From_Date+'''''' and ''''''+''12/31/9999''+'''''''' set @str=@str+'' and '' +''T.Created_Date BETWEEN ''''''+ @From_Date+'''''' an d ''''''+''3000-02-19 00:00:00.000''+'''''''' if not @To_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''T.Created_Date between ''''''+''2000-01-01 00:00:00 .000''+'''''' and ''''''+@To_Date+'''''''' End if(@CREATED_BY!=''0'') set @str=@str + ''and T.CREATED_BY=''''''+@CREATED_BY +'''''''' if(@AWB_NUMBER!=''0'') set @str=@str + '' and T.AWB_NUMBER=''+@AWB_NUMBER+''''

exec(@str) print(@str) END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[US P_GetReportsForBranchOperation]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'--[dbo].[USP_GetReportsForBranchOperation] ''0'',''2000-02-11 00:00:00.000'',''2011-02-11 00:00:00.000'',''0'',''0'',''0'' ,''0'' CREATE PROCEDURE [dbo].[USP_GetReportsForBranchOperation] ( @AREA_CODE varchar(50), @From_Date varchar(50), @To_Date varchar(50), @DELEVERY_BOY varchar(50),

@PARTY_CODE varchar(50), @BILLCYCLE varchar(50), @CREATED_BY varchar(50) ) AS Begin declare @strSQL varchar(4000) set @strSQL=''select B.AWB_NUMBER as AWB_Number, Area_Name=(select Category_Name from Categories where Category_Id=B.AREA_CODE), Delevery_Boy_Name=(select Category_Name from Categories where Category_Id=B.DELE VERY_BOY), B.FIRST_NAME as First_Name, Party=(select Category_Name from Categories where Category_Id=inward.PARTY_CODE) , inward.BILLCYCLE as BillCycle, B.PRIORITY as Priority, B.TAT , B.Created_By, convert(varchar,B.Created_Date,105) as Created_Date'' set @strSQL=@strSQL+'' FROM BRANCH_OPERATIONS B ,INWARD_SCANNING inward where B. Is_Deleted=0'' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @strSQL=@strSQL+'' and '' +''B.Created_Date between ''''''+ @From_Date+''' ''' and ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' --set @str=@str+'' and '' +''convert(varchar,Created_Date,105) between ''''''+ @From_Date+'''''' and ''''''+''12/31/9999''+'''''''' set @strSQL=@strSQL+'' and '' +''B.Created_Date BETWEEN ''''''+ @From_Date+''' ''' and ''''''+''3000-02-19 00:00:00.000''+'''''''' if not @To_Date= ''2000-01-01 00:00:00.000'' set @strSQL=@strSQL+'' and '' +''B.Created_Date between ''''''+''2000-01-01 00 :00:00.000''+'''''' and ''''''+@To_Date+'''''''' End if(@AREA_CODE!=''0'') set @strSQL=@strSQL + ''and B.AREA_CODE=''+@AREA_CODE +'''' if(@DELEVERY_BOY!=''0'') set @strSQL=@strSQL + ''and DELEVERY_BOY=''+@DELEVERY_BOY +'''' if(@PARTY_CODE!=''0'') set @strSQL=@strSQL + ''and inward.PARTY_CODE=''''''+@PARTY_CODE +'''''''' if(@BILLCYCLE!=''0'') set @strSQL=@strSQL + ''and inward.BILLCYCLE=''''''+@BILLCYCLE +'''''''' if(@CREATED_BY!=''0'')

set @strSQL=@strSQL + ''and CREATED_BY=''''''+@CREATED_BY +'''''''' set @strSQL=@strSQL+'' and B.AWB_NUMBER=inward.AWB_NUMBER '' exec(@strSQL) print(@strSQL) End

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[IN WARD_SCANNING]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[INWARD_SCANNING]( [INWARD_SCANNING_ID] [int] IDENTITY(1,1) NOT NULL, [BARCODE_NUMBER] [varchar](50) NOT NULL, [AWB_NUMBER] [int] NOT NULL, [ACCOUNT_NUMBER] [varchar](50) NOT NULL, [REFERENCE_NUMBER] [varchar](50) NULL, [PARTY_CODE] [int] NULL, [BILLCYCLE] [varchar](50) NOT NULL,

[FIRST_NAME] [varchar](50) NULL, [PRIORITY] [varchar](50) NULL, [TAT] [int] NULL, [CONTACT_NO] [varchar](50) NULL, [ALTERNATE_CONTACT_NO] [varchar](50) NULL, [FLAT_NO] [varchar](50) NULL, [STREET_NAME] [varchar](50) NULL, [CITY] [varchar](50) NULL, [STATE] [varchar](50) NULL, [PINCODE] [varchar](50) NULL, [AREA_CODE] [int] NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_INWARD_SCANNING_1] PRIMARY KEY CLUSTERED ( [AWB_NUMBER] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_MisReport]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'CREATE procedure [dbo].[Usp_MisReport]-- ' '01/01/1900'',''01/01/1900'',''0'','''' ( @From_Date varchar(50), @To_Date varchar(50), @SelectType varchar(50), @MisString varchar(50) ) as begin declare @str varchar(4000) set @str='' select edp.AWB_NUMBER as AWB_Number, Party=(select Category_Name from Categories where Category_Id=inward.PARTY_CODE) , inward.ACCOUNT_NUMBER as Account_Number, inward.REFERENCE_NUMBER as Reference_Number, inward.BARCODE_NUMBER as Barcode_Number, inward.FIRST_NAME as [Customer Name], Status_Name=(select Category_Name from Categories where Category_Id=edp.STATUS), edp.DELIVERY_DATE as Delivery_Date, Delivery_Boy=(select Category_Name from Categories where Category_Id=edp.DELIVER Y_BOY_ID), edp.RECEIVED_BY as Received_By, Relation=(select Category_Name from Categories where Category_Id=edp.RELATIONSHI P), edp.CUSTOMER_CONTACT_NUMBER as Customer_Contact_Number, inward.ADDRESS as Address, inward.CITY as City, inward.PINCODE as Pincode,

Area_Name=(select Category_Name from Categories where Category_Id=s.Area_Code), inward.BILLCYCLE as BillCycle, edp.PAGEBUNDLE_NUMBER as PageBundle_Number, edp.Created_By, convert(varchar,edp.Created_Date,105) as Created_Date'' set @str=@str+'' from ELECTRONIC_DATA_PROCESSING edp,INWARD_SCANNING inward,Stat us_Updation s where edp.Is_Deleted=0 '' if(@From_Date!=''01/01/1900'' and @To_Date!=''01/01/1900'') Begin set @str=@str+'' and '' +''convert(varchar,inward.Created_Date,105) between '' ''''+ @From_Date+'''''' and ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''01/01/1900'' set @str=@str+'' and '' +''convert(varchar,inward.Created_Date,105) between '' ''''+ @From_Date+'''''' and ''''''+''12/31/9999''+'''''''' if not @To_Date= ''01/01/1900'' set @str=@str+'' and '' +''convert(varchar,inward.Created_Date,105) between '' ''''+''01/01/2000''+'''''' and ''''''+@To_Date+'''''''' End if(@MisString!=''0'') begin if(@SelectType= ''AWB No'') set @str=@str + ''and edp.AWB_NUMBER in ( ''+@MisString +'')''+'''' if(@SelectType = ''Acc No'') set @str=@str + ''and inward.ACCOUNT_NUMBER in ( ''''''+@MisString +'''''')''+'' '' if(@SelectType = ''Barcode No'') set @str=@str + ''and inward.BARCODE_NUMBER in ( ''''''+@MisString +'''''')''+'' '' if(@SelectType = ''Reff No'') set @str=@str + ''and inward.REFERENCE_NUMBER in ( ''''''+@MisString +'''''')''+ '''' end set @str=@str+'' and edp.AWB_NUMBER=inward.AWB_NUMBER and edp.AWB_NUMBER=s.AWB _NUMBER '' exec(@str) print(@str) end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_getTeleTransactions]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_getTeleTransactions] -- ''01/01/1900 '',''01/01/1900 '' ( @From_Date varchar(50), @To_Date varchar(50) ) AS BEGIN declare @str varchar(4000) set @str='' SELECT AWB_NUMBER as Awb_Number, CUSTOMER_NAME as Customer_Name, ACCOUNT_NUMBER as Account_Number, REFERENCE_NUMBER as Reference_Number, CONTACT_NUMBER as Contact_Number, ADDRESS as Address, SPOKE_TO as Spoke_To, NEW_ADDRESS New_Address, RTO_BOY as Rto_Boy, REMARKS as Remarks, convert(varchar,CREATE_DATE,105) as Created_Date from TELECALLING_TRANSACTIONS where IS_DELETED=0'' if(@From_Date!=''01/01/1900'' and @To_Date!=''01/01/1900'') Begin set @str=@str+'' and '' +''CREATE_DATE between ''''''+convert(varchar, @From_D ate, 101)+'''''' and ''''''+convert(varchar,@To_Date,101)+'''''''' End Else Begin if not @From_Date= ''01/01/1900'' set @str=@str+'' and '' +''CREATE_DATE between ''''''+convert(varchar, @From_D ate, 101)+'''''' and ''''''+convert(varchar,''12/31/9999'',101)+'''''''' if not @To_Date= ''01/01/1900'' set @str=@str+'' and '' +''CREATE_DATE between ''''''+convert(varchar, ''01/01 /2000'', 101)+'''''' and ''''''+convert(varchar,@To_Date,101)+'''''''' End exec(@str) print(@str) END

' END GO SET ANSI_NULLS ON

GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetReportsForStatusUpdation]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' --[Usp_GetReportsForStatusUpdation] ''2011-02-11 00:00:00.000'',''3000-02-19 00: 00:00.000'',''0'',''0'',''0'',''0'' CREATE PROCEDURE [dbo].[Usp_GetReportsForStatusUpdation] ( @From_Date varchar(50), @To_Date varchar(50), @DELIVERY_BOY varchar(50), @PAGE_BUNDLE_NUMNER varchar(50), @STATUS varchar(50), @CREATED_BY varchar(50) ) AS BEGIN set nocount on declare @str varchar(4000) set @str='' SELECT [PAGE_BUNDLE_NUMNER] as PageBundle_Number, [AWB_NUMBER] as AWB_Number, AreaCode= (select Category_Name from Categories where Category_ID = AREA_CODE) , [DELIVERY_DATE] as Delivery_Date, DeliveryBoy=(select Category_Name from Categories where Category_ID = DELIVERY _BOY), Status=(select Category_Name from Categories where Category_ID = STATUS), [R.T.O Reason]=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=[REASON]) , [FIRST_NAME] as FirstName, [PRIORITY] as Priority, [TAT], [Created_By], convert(varchar,[Created_Date],105) as Created_Date FROM STATUS_UPDATION where IS_DELETED=0 '' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @str=@str+'' and '' +''Created_Date between ''''''+ @From_Date+'''''' and ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''Created_Date BETWEEN ''''''+ @From_Date+'''''' and ''''''+''3000-02-19 00:00:00.000''+'''''''' print(@str) if not @To_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''Created_Date between ''''''+''2000-01-01 00:00:00.0

00''+'''''' and ''''''+@To_Date+'''''''' print(@str) End if(@DELIVERY_BOY!=''0'') set @str=@str+ '' and DELIVERY_BOY=''+@DELIVERY_BOY+'''' if(@PAGE_BUNDLE_NUMNER!=''0'') set @str=@str+ '' and PAGE_BUNDLE_NUMNER=''''''+@PAGE_BUNDLE_NUMNER+'''''''' if(@STATUS!=''0'') set @str=@str+ '' and STATUS=''+@STATUS+'''' if(@CREATED_BY!=''0'') set @str=@str + ''and CREATED_BY=''''''+@CREATED_BY +'''''''' exec(@str) end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetReportsForEDP]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'--[dbo].[Usp_GetReportsForEDP] ''0'', ''2 011-02-11 00:00:00.000'',''3000-02-19 00:00:00.000'',''0'',''0'',''0'',''0'' CREATE PROCEDURE [dbo].[Usp_GetReportsForEDP] -- ''0'', ''01/01/1900'',''01/01/1 900'',''0'',''0'',''0'',''0'' ( @DELIVERY_BOY_ID varchar(50), @From_Date varchar(50), @To_Date varchar(50),

@PARTY_CODE varchar(50), @BILLCYCLE varchar(50), @BAD_SIGNATURE varchar(50), @CREATED_BY varchar(50) ) AS BEGIN declare @str varchar(4000) set nocount on set @str='' SELECT ELECTRONIC_DATA_PROCESSING.PAGEBUNDLE_NUMBER as PageBundle_Number, ELECTRONIC_DATA_PROCESSING.AWB_NUMBER as AWB_Number , ELECTRONIC_DATA_PROCESSING.CUSTOMER_NAME as Customer_Name , convert(varchar, DELIVERY_DATE,105) as Delivery_Date , Party=(Select Category_Name from Categories where Category_ID = INWARD_SCAN NING.PARTY_CODE), INWARD_SCANNING.BILLCYCLE as BillCycle, Delivery_Boy=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=[DELIV ERY_BOY_ID]), [RECEIVED_BY] as Received_By, [FIRST_NAME] as Customer_Name, Relation=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=[RELATIONS HIP]), [CUSTOMER_CONTACT_NUMBER] as Customer_Contact_Number , Status_Name=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=ELECTRO NIC_DATA_PROCESSING.STATUS), [REMARKS] as Remarks, ELECTRONIC_DATA_PROCESSING.[BAD_SIGNATURE] as BadSignature, ELECTRONIC_DATA_PROCESSING.[Created_By], convert(varchar,ELECTRONIC_DATA_PROCESSING.Created_Date,105) as Created_Dat e FROM [ELECTRONIC_DATA_PROCESSING] INNER JOIN INWARD_SCANNING on INWARD_SCANNING.AWB_NUMBER=ELECTRONIC_DATA_PROCES SING.AWB_NUMBER where ELECTRONIC_DATA_PROCESSING.IS_DELETED=0'' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @str=@str+'' and '' +''ELECTRONIC_DATA_PROCESSING.Created_Date between ''' '''+ @From_Date+'''''' and ''''''+@To_Date+'''''''' End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''ELECTRONIC_DATA_PROCESSING.Created_Date BETWEEN ''' '''+ @From_Date+'''''' and ''''''+''3000-02-19 00:00:00.000''+'''''''' print(@str) if not @To_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''ELECTRONIC_DATA_PROCESSING.Created_Date between ''' '''+''2000-01-01 00:00:00.000''+'''''' and ''''''+@To_Date+''''''''

print(@str) End

if(@DELIVERY_BOY_ID!=''0'') set @str=@str + '' and DELIVERY_BOY_ID=''+@DELIVERY_BOY_ID+'''' if(@PARTY_CODE!=''0'') set @str=@str + '' and INWARD_SCANNING.PARTY_CODE=''+@PARTY_CODE+'''' if(@BILLCYCLE!=''0'') set @str=@str + '' and INWARD_SCANNING.BILLCYCLE=''''''+@BILLCYCLE+'''''''' if(@BAD_SIGNATURE!=''0'') set @str=@str + '' and ELECTRONIC_DATA_PROCESSING.BAD_SIGNATURE=''''''+@BAD_SIGN ATURE+'''''''' if(@CREATED_BY!=''0'') set @str=@str + ''and ELECTRONIC_DATA_PROCESSING.CREATED_BY=''''''+@CREATED_BY +'''''''' print(@str) exec(@str) END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[BR ANCH_OPERATIONS]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[BRANCH_OPERATIONS]( [BranchOperation_Id] [int] IDENTITY(1,1) NOT NULL, [AREA_CODE] [int] NOT NULL, [DELEVERY_BOY] [int] NOT NULL, [AWB_NUMBER] [int] NOT NULL, [FIRST_NAME] [varchar](50) NOT NULL, [PRIORITY] [varchar](50) NOT NULL, [TAT] [int] NOT NULL, [COLUMN001] [varchar](50) NULL, [COLUMN002] [varchar](50) NULL, [COLUMN003] [varchar](50) NULL, [COLUMN004] [varchar](50) NULL, [COLUMN005] [varchar](50) NULL, [COLUMN006] [varchar](50) NULL, [COLUMN007] [varchar](50) NULL, [COLUMN008] [varchar](50) NULL, [COLUMN009] [varchar](50) NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_BRANCH_OPERATIONS] PRIMARY KEY CLUSTERED ( [AWB_NUMBER] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SC REEN_PERMISIONS]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[SCREEN_PERMISIONS]( [PERMISSION_ID] [varchar](50) NOT NULL, [SCREEN_ID] [int] NOT NULL, [ROLE_ID] [int] NOT NULL, [Page_Acess] [bit] NOT NULL, [Report_Access] [bit] NULL, [COLUMN002] [varchar](50) NULL, [COLUMN003] [varchar](50) NULL,

[COLUMN004] [varchar](50) NULL, [COLUMN005] [varchar](50) NULL, [COLUMN006] [varchar](50) NULL, [COLUMN007] [varchar](50) NULL, [COLUMN008] [varchar](50) NULL, [COLUMN009] [varchar](50) NULL, [IS_DELETED] [bit] NULL, [CREATED_BY] [varchar](50) NULL, [CREATED_DATE] [datetime] NULL, [MODIFIED_BY] [varchar](50) NULL, [MODIFIED_DATE] [datetime] NULL, CONSTRAINT [PK_SCREEN_PERMISIONS] PRIMARY KEY CLUSTERED ( [PERMISSION_ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EL ECTRONIC_DATA_PROCESSING]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[ELECTRONIC_DATA_PROCESSING]( [EDP_ID] [int] IDENTITY(1,1) NOT NULL, [AWB_NUMBER] [int] NOT NULL, [DELIVERY_DATE] [varchar](50) NOT NULL, [DELIVERY_BOY_ID] [int] NOT NULL, [RECEIVED_BY] [varchar](50) NOT NULL, [RELATIONSHIP] [int] NULL, [CUSTOMER_CONTACT_NUMBER] [varchar](50) NOT NULL, [STATUS] [int] NULL, [REMARKS] [varchar](3000) NULL, [CUSTOMER_NAME] [varchar](50) NULL, [PAGEBUNDLE_NUMBER] [varchar](50) NULL, [BAD_SIGNATURE] [varchar](50) NULL, [COLUMN004] [varchar](50) NULL, [COLUMN005] [varchar](50) NULL, [COLUMN006] [varchar](50) NULL, [COLUMN007] [varchar](50) NULL, [COLUMN008] [varchar](50) NULL, [COLUMN009] [varchar](50) NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_ELECTRONIC_DATA_PROCESSING] PRIMARY KEY CLUSTERED ( [AWB_NUMBER] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ST ATUS_UPDATION]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[STATUS_UPDATION]( [STATUS_UPDATE_ID] [int] IDENTITY(1,1) NOT NULL, [AREA_CODE] [int] NULL, [DELIVERY_BOY] [int] NULL, [PAGE_BUNDLE_NUMNER] [varchar](50) NULL, [STATUS] [int] NOT NULL, [AWB_NUMBER] [int] NOT NULL, [FIRST_NAME] [varchar](50) NOT NULL, [PRIORITY] [varchar](50) NOT NULL, [TAT] [int] NOT NULL, [REASON] [int] NULL, [DELIVERY_DATE] [varchar](50) NULL, [COLUMN005] [varchar](50) NULL, [COLUMN006] [varchar](50) NULL, [COLUMN007] [varchar](50) NULL, [COLUMN008] [varchar](50) NULL, [COLUMN009] [varchar](50) NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_STATUS_UPDATION] PRIMARY KEY CLUSTERED ( [AWB_NUMBER] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OU TWARD_SCANNING]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[OUTWARD_SCANNING]( [OUTWARD_SCANNING_ID] [int] IDENTITY(1,1) NOT NULL, [BARCODE_NUMBER] [varchar](50) NOT NULL, [AWB_NUMBER] [int] NOT NULL, [ACCOUNT_NUMBER] [varchar](50) NULL, [REFERENCE_NUMBER] [varchar](50) NULL, [CUSTOMER_FIRST_NAME] [varchar](50) NOT NULL, [CUSTOMER_LAST_NAME] [varchar](50) NULL, [PARTY] [int] NOT NULL, [CUSTOMER_EMAIL_ID] [varchar](50) NULL, [AREA_CODE] [int] NOT NULL, [CUSTOMER_ADDRESS] [varchar](2500) NULL, [PRIORITY] [varchar](50) NULL, [STATUS] [int] NULL, [TAT] [int] NULL, [RETURNED_DATE] [datetime] NULL, [IS_MISROUTE] [bit] NULL, [COLUMN003] [varchar](50) NULL, [COLUMN004] [varchar](50) NULL, [COLUMN005] [varchar](50) NULL, [COLUMN006] [varchar](50) NULL,

[COLUMN007] [varchar](50) NULL, [COLUMN008] [varchar](50) NULL, [COLUMN009] [varchar](50) NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_OUTWARD_SCANNING] PRIMARY KEY CLUSTERED ( [AWB_NUMBER] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CO MPLAINT_MANAGER]') AND type in (N'U')) BEGIN CREATE TABLE [dbo].[COMPLAINT_MANAGER]( [COMPLAINT_ID] [int] IDENTITY(1,1) NOT NULL, [COMLAINT_TYPE] [varchar](50) NOT NULL, [AWB_NUMBER] [int] NOT NULL, [ACCOUNT_NUMBER] [varchar](50) NULL, [REFERENCE_NUMBER] [varchar](50) NULL, [COMPLAINER_NAME] [varchar](50) NOT NULL, [COMPLAINT_CATEGORY] [int] NOT NULL, [COMPLAINT_RECEVIED_BY] [varchar](50) NOT NULL, [COMPLAINER_CONTACT_NUMBER] [varchar](50) NULL, [ALLOCATED_TO] [varchar](50) NULL, [REMARKS] [varchar](500) NULL, [COMPLAINTDATE] [varchar](50) NULL, [COMPLAINT_MONTH] [varchar](50) NULL, [AREA_CODE] [int] NULL, [COMPLAINT_STATUS] [varchar](50) NULL, [COLUMN006] [varchar](50) NULL, [COLUMN007] [varchar](50) NULL, [COLUMN008] [varchar](50) NULL, [COLUMN009] [varchar](50) NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_COMPLAINT_MANAGER] PRIMARY KEY CLUSTERED ( [COMPLAINT_ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TE LECALLING]') AND type in (N'U'))

BEGIN CREATE TABLE [dbo].[TELECALLING]( [TELECALLER_ID] [int] IDENTITY(1,1) NOT NULL, [AWB_NUMBER] [int] NOT NULL, [ACCOUNT_NUMBER] [varchar](50) NULL, [REFERENCE_NUMBER] [varchar](50) NULL, [CONTACT_NUMBER] [varchar](50) NOT NULL, [FLAT_NO] [varchar](50) NULL, [STREET_NAME] [varchar](50) NULL, [CITY] [varchar](50) NULL, [STATE] [varchar](50) NULL, [PINCODE] [varchar](50) NULL, [IS_CONNECTED] [varchar](50) NULL, [SPOKE_TO] [varchar](50) NULL, [RELATION_ID] [int] NULL, [TELE_STATUS_YES] [varchar](50) NULL, [TELE_STATUS_NO] [varchar](50) NULL, [NEW_ADDRESS] [varchar](500) NULL, [REMARKS] [varchar](3000) NULL, [RTO_BOY] [varchar](50) NULL, [CUSTOMER_NAME] [varchar](50) NULL, [FLAT_NO_NEW] [varchar](50) NULL, [STREET_NAME_NEW] [varchar](50) NULL, [CITY_NEW] [varchar](50) NULL, [STATE_NEW] [varchar](50) NULL, [PINCODE_NEW] [varchar](50) NULL, [COLUMN008] [varchar](50) NULL, [COLUMN009] [varchar](50) NULL, [IS_DELETED] [bit] NOT NULL, [CREATED_BY] [varchar](50) NOT NULL, [CREATED_DATE] [datetime] NOT NULL, [MODIFIED_BY] [varchar](50) NOT NULL, [MODIFIED_DATE] [datetime] NOT NULL, CONSTRAINT [PK_TELECALLING] PRIMARY KEY CLUSTERED ( [TELECALLER_ID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdateTelecallingTransactions]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'--set ANSI_NULLS ON --set QUOTED_IDENTIFIER ON --go CREATE PROCEDURE [dbo].[Usp_UpdateTelecallingTransactions] ( @AWB_NUMBER int, @ACCOUNT_NUMBER varchar(50), @REFERENCE_NUMBER varchar(50), @FLAT_NO varchar(50), @STREET_NAME varchar(50),

@CITY varchar(50), @STATE varchar(50), @PINCODE varchar(50), @CONTACT_NUMBER varchar(50), @SPOKE_TO varchar(50), @RELATION_ID int, @TELE_STATUS_YES varchar(50) , @TELE_STATUS_NO varchar(50) , @NEW_ADDRESS varchar(500), @FLAT_NO_NEW varchar(50), @STREET_NAME_NEW varchar(50), @CITY_NEW varchar(50), @STATE_NEW varchar(50), @PINCODE_NEW varchar(50), @REMARKS varchar(3000), @RTO_BOY varchar(50), @MODIFIED_BY VARCHAR(50), @RESULT varchar(100) out ) AS -SET NOCOUNT ON; -BEGIN TRANSACTION; BEGIN Update [TELECALLING] SET AWB_NUMBER=@AWB_NUMBER, ACCOUNT_NUMBER=@ACCOUNT_NUMBER, REFERENCE_NUMBER=@REFERENCE_NUMBER, FLAT_NO=@FLAT_NO, STREET_NAME=@STREET_NAME, CITY=@CITY, STATE=@STATE, PINCODE=@PINCODE, CONTACT_NUMBER=@CONTACT_NUMBER, SPOKE_TO=@SPOKE_TO, TELE_STATUS_YES=@TELE_STATUS_YES, TELE_STATUS_NO=@TELE_STATUS_NO , NEW_ADDRESS=@NEW_ADDRESS , REMARKS=@REMARKS, FLAT_NO_NEW=@FLAT_NO_NEW, STREET_NAME_NEW=@STREET_NAME_NEW, CITY_NEW=@CITY_NEW, STATE_NEW=@STATE_NEW, PINCODE_NEW=@PINCODE_NEW, MODIFIED_BY=@MODIFIED_BY, MODIFIED_DATE=getdate() where AWB_NUMBER=@AWB_NUMBER set @RESULT= '' Updated successfully'' --IF @@ERROR <> 0 -- BEGIN --- Rollback the transaction -ROLLBACK ---- Raise an error and return -RAISERROR (''Error in Updating New Address in TELECALLINGTranacstions.'', 16,1) -RETURN END --COMMIT'

END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdateTelecalling]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

CREATE PROCEDURE [dbo].[Usp_UpdateTelecalling] ( @AWB_NUMBER int, @ACCOUNT_NUMBER varchar(50), @REFERENCE_NUMBER varchar(50), @FLAT_NO varchar(50), @STREET_NAME varchar(50), @CITY varchar(50), @STATE varchar(50), @PINCODE varchar(50), @CONTACT_NUMBER varchar(50), @SPOKE_TO varchar(50), @RELATION_ID int, @TELE_STATUS_YES varchar(50) , @TELE_STATUS_NO varchar(50) , @NEW_ADDRESS varchar(500), @FLAT_NO_NEW varchar(50), @STREET_NAME_NEW varchar(50), @CITY_NEW varchar(50), @STATE_NEW varchar(50), @PINCODE_NEW varchar(50), @REMARKS varchar(3000), @RTO_BOY varchar(50), @MODIFIED_BY VARCHAR(50), @RESULT varchar(100) out ) AS SET NOCOUNT ON; BEGIN TRANSACTION; Update [TELECALLING] SET AWB_NUMBER=@AWB_NUMBER, ACCOUNT_NUMBER=@ACCOUNT_NUMBER, REFERENCE_NUMBER=@REFERENCE_NUMBER, FLAT_NO=@FLAT_NO, STREET_NAME=@STREET_NAME, CITY=@CITY, STATE=@STATE, PINCODE=@PINCODE, CONTACT_NUMBER=@CONTACT_NUMBER, SPOKE_TO=@SPOKE_TO, TELE_STATUS_YES=@TELE_STATUS_YES, TELE_STATUS_NO=@TELE_STATUS_NO , NEW_ADDRESS=@NEW_ADDRESS , REMARKS=@REMARKS, FLAT_NO_NEW=@FLAT_NO_NEW,

STREET_NAME_NEW=@STREET_NAME_NEW, CITY_NEW=@CITY_NEW, STATE_NEW=@STATE_NEW, PINCODE_NEW=@PINCODE_NEW, MODIFIED_BY=@MODIFIED_BY, MODIFIED_DATE=getdate() where AWB_NUMBER=@AWB_NUMBER -- Rollback the transaction if there were any errors IF @@ERROR <> 0 BEGIN -- Rollback the transaction ROLLBACK -- Raise an error and return RAISERROR (''Error in Updating New Address in TELECALLING.'',16,1) RETURN END --updating new address in the inward scanning update INWARD_SCANNING SET FLAT_NO=@FLAT_NO_NEW, STREET_NAME=@STREET_NAME_NEW, CITY=@CITY_NEW, STATE=@STATE_NEW, PINCODE=@PINCODE_NEW WHERE AWB_NUMBER=@AWB_NUMBER -- Rollback the transaction if there were any errors IF @@ERROR <> 0 BEGIN -- Rollback the transaction ROLLBACK -- Raise an error and return RAISERROR (''Error in Updating New Address in INWARD_SCANNING '',16,1) RETURN END --updating new address in the outward scanning update OUTWARD_SCANNING set CUSTOMER_ADDRESS=@NEW_ADDRESS WHERE AWB_NUMBER=@AWB_NUMBER -- Rollback the transaction if there were any errors IF @@ERROR <> 0 BEGIN -- Rollback the transaction ROLLBACK -- Raise an error and return RAISERROR (''Error in Updating New Address in OUTWARD_SCANNING '',16,1) RETURN END SET @RESULT=''Updated successfully''

--COMMIT TRANSACTION; COMMIT

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetTeleCallingTransactionBYAWB]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

CREATE PROCEDURE [dbo].[Usp_GetTeleCallingTransactionBYAWB]-- 27 @AWB_NUMBER int AS BEGIN SELECT tt.[TELECALLER_ID] , tt.[AWB_NUMBER] , tt.[CUSTOMER_NAME], tt.[ACCOUNT_NUMBER] , tt.[REFERENCE_NUMBER] , tt.[CONTACT_NUMBER] , tt.FLAT_NO , tt.STREET_NAME, tt.CITY, tt.STATE, tt.PINCODE, tt.[IS_CONNECTED], tt.[SPOKE_TO] , tt.[RELATION_ID] , tt.[TELE_STATUS_YES] , tt.[TELE_STATUS_NO] , tt.[NEW_ADDRESS] , tt.[REMARKS] , tt.[RTO_BOY], --tt.IS_DELETED, tt.[CREATED_BY] , tt.[CREATED_DATE] , tt.[MODIFIED_BY] , tt.[MODIFIED_DATE], RELATION = (Select Category_Name

from Categories where Category_ID = tt.RELATION_ID), t.FLAT_NO, t.STREET_NAME, t.CITY, t.STATE, t.PINCODE FROM TELECALLING_TRANSACTIONS tt inner join TELECALLING t on t.AWB_NUMBER=tt.AWB_NUMBER WHERE tt.AWB_NUMBER=@AWB_NUMBER and t.IS_DELETED=0 order by [TELECALLER_ID] desc END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_SearchTeleCallingDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' --------============================================= Procedure Name :Usp_SearchTeleCallingDetails Purpose :To Search the Telecalling Details from the grid Created By : Srinivas.L Created :7/09/2010 Modified By : Modified Date : =============================================

CREATE PROCEDURE [dbo].[Usp_SearchTeleCallingDetails] -- ''10123'' @SEARCH_TEXT varchar(100) AS BEGIN SELECT [TELECALLER_ID], [AWB_NUMBER] , [ACCOUNT_NUMBER] , [REFERENCE_NUMBER] , [CONTACT_NUMBER] , [SPOKE_TO] , [RELATION_ID] , [TELE_STATUS_YES] , [TELE_STATUS_NO] , [NEW_ADDRESS] , FLAT_NO,

STREET_NAME, CITY, STATE, PINCODE, [REMARKS] , [CUSTOMER_NAME], T.[CREATED_BY] , T.[CREATED_DATE] , T.[MODIFIED_BY] , T.[MODIFIED_DATE], RELATION = (Select Category_Name from Categories where Category_ID = RELATI ON_ID), T.CUSTOMER_NAME, -Category_Name , T.RTO_BOY FROM dbo.[TELECALLING] T --inner join Categories on Category_ID=RELATION_ID WHERE T.[IS_DELETED]=0 and (AWB_NUMBER like ''%''+ @SEARCH_TEXT +''%'' or ACCOUNT_NUMBER like ''%''+ @SEARCH_TEXT +''%'' or SPOKE_TO like ''%''+ @SEARCH_TEXT +''%'' or REFERENCE_NUMBER like ''%''+ @SEARCH_TEXT +''%'' or CONTACT_NUMBER like ''%''+ @SEARCH_TEXT +''%'' or CUSTOMER_NAME like ''%''+ @SEARCH_TEXT +''%'' or TELE_STATUS_YES like ''%''+ @SEARCH_TEXT +''%'' or TELE_STATUS_NO like ''%''+ @SEARCH_TEXT +''%''or --RELATION_ID like ''%''+ @SEARCH_TEXT +''%''or T.CUSTOMER_NAME like ''%'' + @SEARCH_TEXT + ''%'' or --Category_Name like ''%''+ @SEARCH_TEXT +''%'' or [NEW_ADDRESS] like ''%''+ @SEARCH_TEXT +''%'' or FLAT_NO like ''%''+ @SEARCH_TEXT +''%'' or STREET_NAME like ''%''+ @SEARCH_TEXT +''%'' or CITY like ''%''+ @SEARCH_TEXT +''%'' or STATE like ''%''+ @SEARCH_TEXT +''%'' or PINCODE like ''%''+ @SEARCH_TEXT +''%'' or [REMARKS] like ''%''+ @SEARCH_TEXT +''%'' or RTO_BOY like ''%''+ @SEARCH_TEXT +''%'' ) END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetTeleCallingDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Procedure Name :Usp_GetTeleCallingDetails -- Created By :Srinivas.L -- Created Date :7-09-2010 -- Modified By : -- Modified Date : -- Description :To get the Telecalling details to bind the grid -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetTeleCallingDetails] as BEGIN SELECT [TELECALLER_ID] , [AWB_NUMBER] , [ACCOUNT_NUMBER] , [REFERENCE_NUMBER] , [CUSTOMER_NAME], [CONTACT_NUMBER] , FLAT_NO, STREET_NAME, CITY, STATE, PINCODE, [SPOKE_TO] , [RELATION_ID] , [TELE_STATUS_YES] , [TELE_STATUS_NO] , [NEW_ADDRESS] , FLAT_NO_NEW, STREET_NAME_NEW, CITY_NEW, STATE_NEW, PINCODE_NEW, [REMARKS] , [CREATED_BY] , [CREATED_DATE] , [MODIFIED_BY] , [MODIFIED_DATE], RELATION = (Select Category_Name from Categories where Category_ID = RELAT ION_ID) FROM [TELECALLING] WHERE [IS_DELETED]=0 order by CREATED_DATE desc END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertTelecallingdetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

---------

============================================= Procedure Name :Usp_InsertTelecallingdetails Created By :Srinivas.L Created Date :6-09-2010 Modified By : Modified Date : Description : =============================================

CREATE PROCEDURE [dbo].[Usp_InsertTelecallingdetails] @AWB_NUMBER int, @ACCOUNT_NUMBER varchar(50), @REFERENCE_NUMBER varchar(50), @CUSTOMER_NAME varchar(50), @CONTACT_NUMBER varchar(50), @FLAT_NO varchar(50), @STREET_NAME varchar(50), @CITY varchar(50), @STATE varchar(50), @PINCODE varchar(50), @SPOKE_TO varchar(50), @RELATION_ID int, @TELE_STATUS_YES varchar(50) , @TELE_STATUS_NO varchar(50) , @NEW_ADDRESS varchar(500), @IS_CONNECTED Varchar(50), @REMARKS varchar(3000), @RTO_BOY varchar(50), @FLAT_NO_NEW varchar(50), @STREET_NAME_NEW varchar(50), @CITY_NEW varchar(50), @STATE_NEW varchar(50), @PINCODE_NEW varchar(50), @CREATED_BY varchar(50), @Error varchar(500) output AS declare @cnt int select @cnt= count(*) from [TELECALLING] where IS_DELETED=0 and AWB_NUMBER= @AW B_NUMBER

if(@cnt>0) begin set @Error=''AWB already exists'' end else begin INSERT INTO [TELECALLING] ( AWB_NUMBER, ACCOUNT_NUMBER, REFERENCE_NUMBER, CUSTOMER_NAME, CONTACT_NUMBER, FLAT_NO, STREET_NAME, CITY, STATE, PINCODE, IS_CONNECTED, SPOKE_TO, RELATION_ID, TELE_STATUS_YES, TELE_STATUS_NO, NEW_ADDRESS, REMARKS, RTO_BOY, FLAT_NO_NEW, STREET_NAME_NEW, CITY_NEW, STATE_NEW, PINCODE_NEW, IS_DELETED, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE ) VALUES ( @AWB_NUMBER, @ACCOUNT_NUMBER, @REFERENCE_NUMBER, @CUSTOMER_NAME, @CONTACT_NUMBER, @FLAT_NO, @STREET_NAME, @CITY, @STATE, @PINCODE, @IS_CONNECTED, @SPOKE_TO, @RELATION_ID, @TELE_STATUS_YES, @TELE_STATUS_NO, @NEW_ADDRESS, @REMARKS, @RTO_BOY, @FLAT_NO_NEW, @STREET_NAME_NEW ,

@CITY_NEW, @STATE_NEW, @PINCODE_NEW, 0, @CREATED_BY, GETDATE(), @CREATED_BY, GETDATE() ) SET @Error = @AWB_NUMBER end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetFeedbackDetailsWithSearchtext]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== -- Procedure Name :Usp_GetFeedbackDetailsWithSearc htext -- Created By :Ramana.N -- Created Date :08-09-2010 -- Modified By : -- Modified Date : -- Description :To Get the feedback details with search text -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetFeedbackDetailsWithSearchtext] ( @Searchtext varchar(50) ) AS SELECT f.[FEEDBACK_ID] , f.[SUBJECT] , f.[COMMENTS] , f.[IS_DELETED] , f.[CREATED_BY] , f.[CREATED_DATE] , f.[MODIFIED_BY] ,

f.[MODIFIED_DATE], f.[Feedback_Type] as Category_Id, c.CATEGORY_NAME as Feedback_Type from CATEGORIES c,Feedback f where convert(varchar,c.CATEGORY_ID)= f.Feedback_T ype and ( f.[SUBJECT] like ''%''+ @Searchtext +''%'' or f.[COMMENTS] like ''% ''+ @Searchtext +''%'' ) and f.[IS_DELETED]=0' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[HD _CreateFeedback]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== --Procedure Name :Usp_CreateFeedback --Purpose :Insert --Created By :Ramana.N --Create Date :12-08-2010 --Modified By : --Modified Date : -- Description :Inserts feedabck Details. --Comments : -- ============================================= CREATE PROCEDURE [dbo].[HD_CreateFeedback] ( @FEEDBACK_TYPE int, @SUBJECT varchar(100), @COMMENTS varchar(3000), @Column001 varchar(50), @Column002 varchar(50), @Column003 varchar(50), @Column004 varchar(50), @Column005 varchar(50), @Column006 varchar(50), @Column007 varchar(50), @Column008 varchar(50), @Column009 varchar(50), @Created_By nvarchar(50), @Error varchar(500) out ) AS BEGIN INSERT INTO FEEDBACK ( [FEEDBACK_TYPE] ,[SUBJECT] ,[COMMENTS] ,[Column001] ,[Column002] ,[Column003] ,[Column004] ,[Column005]

,[Column006] ,[Column007] ,[Column008] ,[Column009] ,[Created_By] ,[Created_Date] ,[Modified_By] ,[Modified_Date] ,[Is_Deleted] ) VALUES ( @FEEDBACK_TYPE ,@Subject ,@Comments ,@Column001 ,@Column002 ,@Column003 ,@Column004 ,@Column005 ,@Column006 ,@Column007 ,@Column008 ,@Column009 ,@Created_By ,getdate() ,@Created_By ,getdate() ,0 ) SET @Error = ''Feedback sent successfully'' END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_DeleteFeedback]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== --Procedure Name :Usp_DeleteFeedback --Purpose :Deletes Feedback Details. -- Created By :Ramana.N -- Create Date :13-08-2010 --Modified By : --Modified Date : --Comments : -- ============================================= CREATE PROCEDURE [dbo].[Usp_DeleteFeedback] ( @FEEDBACK_ID int, @Error varchar(500) out

) AS Begin --Added to prevent extra result sets from -- Updating the values SET NOCOUNT ON; -- Insert statements for procedure here Update FeedBack set [Is_Deleted]=1 where [FEEDBACK_ID]=@FEEDBACK_ID SET @Error = ''Feedback Deleted successfully''

end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_CreateFeedback]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== --Procedure Name :Usp_CreateFeedback --Purpose :Insert --Created By :Ramana.N --Create Date :12-08-2010 --Modified By : --Modified Date : -- Description :Inserts feedabck Details. --Comments : -- ============================================= CREATE PROCEDURE [dbo].[Usp_CreateFeedback] ( @FEEDBACK_TYPE int, @SUBJECT varchar(100), @COMMENTS varchar(3000), @Created_By varchar(50), @Error varchar(500) out ) AS BEGIN INSERT INTO FEEDBACK ( [FEEDBACK_TYPE] ,[SUBJECT] ,[COMMENTS] ,[Created_By] ,[Created_Date] ,[Modified_By] ,[Modified_Date] ,[Is_Deleted]

) VALUES ( @FEEDBACK_TYPE ,@Subject ,@Comments ,@Created_By ,getdate() ,@Created_By ,getdate() ,0 ) SET @Error = ''Feedback sent successfully'' END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetFeedbackDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Procedure Name :Usp_GetFeedbackDetails -- Created By :Ramana.N -- Created Date :12-08-2010 -- Modified By : -- Modified Date : -- Description :To Get the feedback details -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetFeedbackDetails] AS SELECT c.CATEGORY_NAME as Feedback_Type, f.[FEEDBACK_ID] , f.[SUBJECT] , f.[COMMENTS] , f.[IS_DELETED] , f.[CREATED_BY] , f.[CREATED_DATE] , f.[MODIFIED_BY] , f.[MODIFIED_DATE], f.[Feedback_Type] as Category_Id -c.CATEGORY_NAME as Feedback_Type from CATEGORIES c,Feedback f where convert(varchar,c.CATEGORY_ID)= f.Feedback_T ype and f.[IS_DELETED]=0 RETURN ' END

GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertTelecallingtransaction]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

CREATE PROCEDURE [dbo].[Usp_InsertTelecallingtransaction] @AWB_NUMBER int, @CUSTOMER_NAME varchar(50), @ACCOUNT_NUMBER varchar(50), @REFERENCE_NUMBER varchar(50), @CONTACT_NUMBER varchar(50), @FLAT_NO varchar(50), @STREET_NAME varchar(50), @CITY varchar(50), @STATE varchar(50), @PINCODE varchar(50), @IS_CONNECTED VARCHAR(50), @SPOKE_TO varchar(50), @RELATION_ID int, @TELE_STATUS_YES varchar(50) , @TELE_STATUS_NO varchar(50) , @NEW_ADDRESS varchar(500), @REMARKS varchar(3000), @RTO_BOY varchar(50), @FLAT_NO_NEW varchar(50), @STREET_NAME_NEW varchar(50), @CITY_NEW varchar(50), @STATE_NEW varchar(50), @PINCODE_NEW varchar(50), @CREATED_BY varchar(50), @Error varchar(500) output AS --declare @cnt int -- select @cnt= count(*) from [TELECALLING_TRANSACTIONS] where IS_DELETED=0 and AWB_NUMBER= @AWB_NUMBER ---if(@cnt>0) --begin --set @Error=''AWB already exists'' --end --else begin INSERT INTO [TELECALLING_TRANSACTIONS] ( AWB_NUMBER, CUSTOMER_NAME, ACCOUNT_NUMBER, REFERENCE_NUMBER, CONTACT_NUMBER, FLAT_NO, STREET_NAME,

CITY, STATE, PINCODE, IS_CONNECTED, SPOKE_TO, RELATION_ID, TELE_STATUS_YES, TELE_STATUS_NO, NEW_ADDRESS, REMARKS, RTO_BOY, FLAT_NO_NEW, STREET_NAME_NEW, CITY_NEW, STATE_NEW, PINCODE_NEW, IS_DELETED, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE ) VALUES ( @AWB_NUMBER, @CUSTOMER_NAME, @ACCOUNT_NUMBER, @REFERENCE_NUMBER, @CONTACT_NUMBER, @FLAT_NO_NEW, @STREET_NAME_NEW, @CITY_NEW, @STATE_NEW, @PINCODE_NEW, @IS_CONNECTED, @SPOKE_TO, @RELATION_ID, @TELE_STATUS_YES, @TELE_STATUS_NO, @NEW_ADDRESS, @REMARKS, @RTO_BOY, @FLAT_NO_NEW, @STREET_NAME_NEW, @CITY_NEW, @STATE_NEW, @PINCODE_NEW, 0, @CREATED_BY, GETDATE(), @CREATED_BY, GETDATE() ) SET @Error = @AWB_NUMBER end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdateMisRouteOutward]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_UpdateMisRouteOutward] ( @AWB_NUMBER int, @MODIFIED_BY varchar(50), @ERROR varchar(50) out ) as begin set nocount on; update OUTWARD_SCANNING set RETURNED_DATE=getdate(), MODIFIED_BY= @MODIFIED_BY, MODIFIED_DATE=getdate(), IS_MISROUTE=1 where AWB_NUMBER=@AWB_NUMBER set @ERROR=''AWB Saved'' end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertOutwardScanning]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= --Procedure Name :Usp_InsertOutwardScanning --Created By :Srinivas.L --Created Date :03-09-2010 --Modified By : --Modified Date : --Description :To Insert The OutwardScanning -- ============================================= CREATE PROCEDURE [dbo].[Usp_InsertOutwardScanning] @BARCODE_NUMBER varchar(50), @AWB_NUMBER int, @ACCOUNT_NUMBER varchar(50), @REFERENCE_NUMBER varchar(50), @CUSTOMER_FIRST_NAME varchar(50), @PARTY int, @AREA_CODE int,

@CUSTOMER_ADDRESS varchar(2500), @PRIORITY varchar(50), @CREATED_BY varchar(50), @TAT int, @Error varchar(100) out AS declare @cnt int declare @cntnoservice int select @cnt= count(*) from [OUTWARD_SCANNING] where IS_DELETED=0 and AWB_NUMBER= @AWB_NUMBER select @cntnoservice= count(*) from [OUTWARD_WITHOUTAREACODE] where AWB_NUMBER= @AWB_NUMBER if(@cnt>0) begin set @Error=''AWB already exists'' end else if(@cntnoservice>0) begin set @Error=''AWB Number is in No service'' end else begin INSERT INTO [OUTWARD_SCANNING] ( BARCODE_NUMBER, AWB_NUMBER, ACCOUNT_NUMBER, REFERENCE_NUMBER, CUSTOMER_FIRST_NAME, PARTY, AREA_CODE, CUSTOMER_ADDRESS, PRIORITY, TAT, RETURNED_DATE, IS_MISROUTE, IS_DELETED, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE ) VALUES ( @BARCODE_NUMBER, @AWB_NUMBER, @ACCOUNT_NUMBER, @REFERENCE_NUMBER, @CUSTOMER_FIRST_NAME, @PARTY, @AREA_CODE, @CUSTOMER_ADDRESS,

@PRIORITY, @TAT, getdate(), 0, 0, @CREATED_BY, getdate()+1, @CREATED_BY, getdate() +1 ) set @Error=''Saved Successfully'' end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetCountofOutDocsForDashBoard]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetCountofOutDocsForDashBoard] -- ''18-01-2011'' ( @Created_Date varchar(50) ) AS BEGIN select OUT.AREA_CODE, AREA=(select Category_Name from Categories where Category_ID = OUT.AREA_CODE), PARTY as [Party Code], [Party Name]=(select Category_Name from Categories where Category_ID = OUT.PART Y), I.BILLCYCLE, count(*) as [Count] from OUTWARD_SCANNING OUT inner join INWARD_SCANNING I ON I.AWB_NUMBER=OUT.AWB_NUMBER where OUT.IS_DELETED=0 and IS_MISROUTE=0 and convert(varchar,OUT.CREATED_DATE,105) = @CREATED_DATE group by OUT.AREA_CODE,OUT.PARTY ,I.BILLCYCLE end '

END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetManifestReport]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' --[Usp_GetManifestReport] ''20-02-2011'',58 CREATE procedure [dbo].[Usp_GetManifestReport] ( @CREATED_DATE varchar(50), @AREA_CODE int ) as begin select OUT.AREA_CODE, AREA=(select Category_Name from Categories where Category_ID = OUT.AREA_CODE), PARTY as [Party Code], [Party Name]=(select Category_Name from Categories where Category_ID = OUT.PART Y), I.BILLCYCLE, count(*) as [Count] from OUTWARD_SCANNING OUT inner join INWARD_SCANNING I ON I.AWB_NUMBER=OUT.AWB_NUMBER where OUT.IS_DELETED=0 and OUT.AREA_CODE=@AREA_CODE and IS_MISROUTE=0 and convert(varchar,OUT.CREATED_DATE,105) = @CREATED_DATE group by OUT.AREA_CODE,OUT.PARTY ,I.BILLCYCLE select OUT.AREA_CODE, AREA=(select Category_Name from Categories where Category_ID = OUT.AREA_CODE), PARTY as [Party Code], [Party Name]=(select Category_Name from Categories where Category_ID = OUT.PART Y), I.BILLCYCLE,count(IS_MISROUTE) as [Mis Route Count] from OUTWARD_SCANNING OUT inner join INWARD_SCANNING I ON I.AWB_NUMBER=OUT.AWB_NUMBER where OUT.IS_MISROUTE=1 and OUT.IS_DELETED=0 and OUT.AREA_CODE=@AREA_CODE and convert(varchar,OUT.CREATED_DATE,105) = @CREATED_DATE group by OUT.AREA_CODE,OUT.PARTY ,I.BILLCYCLE end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetAreaCodeforComplaints]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetAreaCodeforComplaints]-- ''14-02-2011'',58 ( @CREATED_DATE varchar(50), @AREA_CODE int ) as begin set nocount on; select c.COMPLAINTDATE+ ''/''+ convert(varchar, c.[COMPLAINT_ID]) AS CUSTOMER_RE FERENCE_NUMBER, c.AWB_NUMBER,c.COMPLAINT_CATEGORY,c.ACCOUNT_NUMBER,c.REFERENCE_NUMBER,c.COMPLAIN ER_NAME,c.COMPLAINER_CONTACT_NUMBER, out.CUSTOMER_ADDRESS, c.COMPLAINT_MONTH,c.REMARKS,c.CREATED_BY AS [COMPLAINTS_RECEIVED_BY], Area_Name=(select category_name from categories where category_id=out.area_code) from complaint_manager c inner join outward_scanning out on out.awb_number=c.awb_number where convert(varchar,c.created_date,105)=@created_date and out.AREA_CODE=@AREA_ CODE and c.is_deleted=0 --select count(*) from complaint_manager where convert(varchar,created_date,105) =@created_date and AREA_CODE=@AREA_CODE set nocount off; end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetComplaintsByUser]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetComplaintsByUser]-- ''14-02-2011'',58 ( @CREATED_DATE varchar(50), @ALLOCATED_TO int ) as begin set nocount on select c.COMPLAINT_ID, c.COMPLAINT_STATUS,

c.COMPLAINTDATE+ ''/''+ convert(varchar, c.[COMPLAINT_ID]) AS CUSTOMER_REFERENCE _NUMBER, c.AWB_NUMBER,Complaint_category=(select category_name from categories where cate gory_id=c.COMPLAINT_CATEGORY) ,c.ACCOUNT_NUMBER,c.REFERENCE_NUMBER,c.COMPLAINER_NAME, c.COMPLAINER_CONTACT_NUMBER, out.CUSTOMER_ADDRESS, c.COMPLAINT_MONTH,c.REMARKS,c.[CREATED_BY] AS [COMPLAINT_RECEIVED_BY], Area_Name=(select category_name from categories where category_id=out.area_code) from complaint_manager c inner join outward_scanning out on out.awb_number=c.awb_number where convert(varchar,c.created_date,105)=@created_date and c.ALLOCATED_TO=@ALLOCATED_TO and c.is_deleted=0 end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetGraphforMisRoute]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetGraphforMisRoute] --''18-01-2011'' ( @CREATED_DATE varchar(50) ) as BEGIN SELECT OUT.AREA_CODE, AREA=(select Category_Name from Categories where Category_ID = OUT.AREA_CODE), PARTY as [Party Code], [Party Name]=(select Category_Name from Categories where Category_ID = OUT.PART Y), I.BILLCYCLE, COUNT(IS_MISROUTE) FROM OUTWARD_SCANNING OUT inner join INWARD_SCANNING I ON I.AWB_NUMBER=OUT.AWB_NUMBER WHERE CONVERT(VARCHAR,OUT.CREATED_DATE,105)=@CREATED_DATE AND OUT.IS_DELETED=0 and OUT.IS_MISROUTE=1 group by OUT.AREA_CODE,OUT.PARTY ,I.BILLCYCLE END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetGraphforOutward]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetGraphforOutward] --''18-01-2011'' ( @Created_Date varchar(50) ) AS BEGIN select OUT.AREA_CODE, AREA=(select Category_Name from Categories where Category_ID = OUT.AREA_CODE), PARTY as [Party Code], [Party Name]=(select Category_Name from Categories where Category_ID = OUT.PART Y), I.BILLCYCLE, count(*) as [Count] from OUTWARD_SCANNING OUT inner join INWARD_SCANNING I ON I.AWB_NUMBER=OUT.AWB_NUMBER where OUT.IS_DELETED=0 and IS_MISROUTE=0 and convert(varchar,OUT.CREATED_DATE,105) = @CREATED_DATE group by OUT.AREA_CODE,OUT.PARTY ,I.BILLCYCLE end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetDetailsForStickerPrinting]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetDetailsForStickerPrinting]-- 1,20 ( @AWB_NUMBER1 varchar(50), @AWB_NUMBER2 varchar(50) ) as begin set nocount on select INWARD_SCANNING.AWB_NUMBER, AREA_CODE=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=OUT.[AREA_CODE ]), INWARD_SCANNING.REFERENCE_NUMBER, INWARD_SCANNING.TAT, INWARD_SCANNING.BILLCYCLE, PARTY_CODE=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=INWARD_SCANNI NG.[PARTY_CODE]), Convert(varchar,INWARD_SCANNING.CREATED_DATE,103) as DATE, INWARD_SCANNING.PRIORITY, INWARD_SCANNING.FIRST_NAME, INWARD_SCANNING.CONTACT_NO from INWARD_SCANNING inner join OUTWARD_SCANNING out on out.BARCODE_NUMBER= INWARD_SCANNING.BARCODE_N

UMBER where INWARD_SCANNING.IS_DELETED=0 AND INWARD_SCANNING.AWB_NUMBER between @AWB_NUMBER1 and @AWB_NUMBER2 END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetCustomerDetailsByAWBNumber]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== -- Procedure Name :Usp_GetCustomerDetailsByAWBNumb er -- Created By :Ramana.N -- Created Date :04-09-2010 -- Modified By : -- Modified Date : -- Description :GetCustomerDetailsByAwbNumber -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetCustomerDetailsByAWBNumber] ( @AWB int ) AS SELECT [CUSTOMER_FIRST_NAME] , [PRIORITY], [TAT] FROM [OUTWARD_SCANNING] where [AWB_NUMBER]=@AWB ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us

p_GetCountOfDeliverdRecords]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

CREATE PROCEDURE [dbo].[Usp_GetCountOfDeliverdRecords] --''29-01-2011'' ( @CREATED_DATE varchar(50) ) as begin SELECT S.AREA_CODE, AREA=(select Category_Name from Categories where Category_ID = S.AREA_CODE), PARTY_CODE as [Party Code], [Party Name]=(select Category_Name from Categories where Category_ID = I.PARTY_ CODE), I.BILLCYCLE, count(STATUS) as Delivered FROM STATUS_UPDATION S inner join INWARD_SCANNING I ON I.AWB_NUMBER=S.AWB_NUMBER WHERE STATUS= (select category_id from categories where category_name =''Delive red'') and convert(varchar,S.CREATED_DATE,105) =@CREATED_DATE AND S.IS_DELETED=0 group by S.AREA_CODE,I.PARTY_CODE ,I.BILLCYCLE END

select * from status_updation where convert(varchar,CREATED_DATE,105) =''29-01-2 011''

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetManifestReportForStatus]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' --[Usp_GetManifestReportForStatus] ''17-01-2011'',58 CREATE procedure [dbo].[Usp_GetManifestReportForStatus] ( @CREATED_DATE varchar(50), @AREA_CODE int ) as begin select S.AREA_CODE, AREA=(select Category_Name from Categories where Category_ID = S.AREA_CODE), I.PARTY_CODE as [Party Code], [Party Name]=(select Category_Name from Categories where Category_ID = I.PARTY_

CODE), [Delivered Status]= (select category_id from categories ''Delivered''),

where category_name =

dcat.category_name, I.BILLCYCLE, count(dcat.category_name) as [Delivered Count] from STATUS_UPDATION S inner join CATEGORIES dcat on dcat.category_name =''Delivered'' inner join INWARD_SCANNING I on I.AWB_NUMBER=S.AWB_NUMBER where S.IS_DELETED=0 and S.AREA_CODE=@AREA_CODE and STATUS=(select category_id from categories where category_name=''Delivered' ') and convert(varchar,S.CREATED_DATE,105) = @CREATED_DATE group by S.AREA_CODE,dcat.category_name,I.PARTY_CODE,I.BILLCYCLE ------------------------------------------------For R T O select S.AREA_CODE, AREA=(select Category_Name from Categories where Category_ID = S.AREA_CODE), I.PARTY_CODE as [Party Code], [Party Name]=(select Category_Name from Categories where Category_ID = I.PARTY_ CODE), [R T O Status]= (select category_id from categories where category_name =''R T O''), rcat.category_name, I.BILLCYCLE, count(rcat.category_name) as [RTO Count] from STATUS_UPDATION S inner join CATEGORIES rcat on rcat.category_name =''R T O'' inner join INWARD_SCANNING I on I.AWB_NUMBER=S.AWB_NUMBER where S.IS_DELETED=0 and S.AREA_CODE=@AREA_CODE and STATUS=(select category_id from categories where category_name=''R T O'') and convert(varchar,S.CREATED_DATE,105) = @CREATED_DATE group by S.AREA_CODE,rcat.category_name,I.PARTY_CODE,I.BILLCYCLE END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[US P_GetCustomerUpdationDetailsByAWBNumber]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Procedure Name :Usp_GetCustomerUpdationDetailsB yAWBNumber -- Created By :Ramana.N -- Created Date :06-09-2010 -- Modified By : -- Modified Date : -- Description :GetCustomerUpdationDetailsByAWBNumber -- =============================================

CREATE PROCEDURE [dbo].[USP_GetCustomerUpdationDetailsByAWBNumber] --''225'' ( @AWB int ) AS set nocount on select STATUS, STATUS_Name=(select Category_Name from Categories where Category_Id=STATUS), convert(varchar,[DELIVERY_DATE],105)as DeliveryDate, Delivery_Boy, DELIVERY_BOY_Name=(select Category_Name from Categories where Category_Id=Delive ry_Boy), FIRST_NAME , PAGE_BUNDLE_NUMNER , PRIORITY FROM [STATUS_UPDATION] where [AWB_NUMBER]=@AWB

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[us p_GetTeleScanningwithSearch]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE PROCEDURE [dbo].[usp_GetTeleScanningwithSearch]-- '''' --''satisfied'' ( @SEARCH_TEXT varchar(50) ) AS BEGIN SELECT T. TELESCANNING_ID, T.AWB_NUMBER, T.CUSTOMER_NAME, T.IS_CONNECTED, T.SPOKE_TO, RELATION = (Select Category_Name from Categories where Category_ID = T.RELATION_ID), T.REMARKS, STATUS= (Select Category_Name from Categories where Category_ID = T. STATUS),

catrel.Category_Name , catstatus.Category_Name from TELESCANNING T inner join Categories catrel on catrel.Category_ID=RELATION_ID inner join Categories catstatus on catstatus.Category_ID=STATUS where T.IS_DELETED=0 and convert(varchar, T.CREATED_DATE,103)=convert(varchar,getdate(),103) and ( T.[AWB_NUMBER] like ''%''+ @SEARCH_TEXT +''%'' or T.[IS_CONNECTED] like ''%'' + @SEARCH_TEXT + ''%'' or T.CUSTOMER_NAME like ''%'' + @SEARCH_TEXT + ''%'' or T.[SPOKE_TO] like ''%'' + @SEARCH_TEXT + ''%'' or T.REMARKS like ''%''+ @SEARCH_TEXT +''%'' or T.[CREATED_BY] like ''%''+ @SEARCH_TEXT +''%'' or -- catrel.Category_Name like ''%'' +@SEARCH_TEXT +''%'' or catstatus.Category_Name like ''%'' +@SEARCH_TEXT +''%'' ) order by TELESCANNING_ID desc END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetSTATUSUPDATION]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Procedure Name :Usp_GetSTATUSUPDATION -- Created By :BALU -- Created Date :18-12-2010 -- Modified By : -- Modified Date : -- Description :To Get the STATUS_UPDATION -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetSTATUSUPDATION] AS SELECT [PAGE_BUNDLE_NUMNER] as PageBundle_Number, [AWB_NUMBER] as AWB_Number, AreaCode= (select Category_Name from Categories where Category_ID = AREA_CODE) , [STATUS_UPDATE_ID] ,

[AREA_CODE], --[DELIVERY_DATE], convert(varchar, [DELIVERY_DATE],105) as Delivery_Date, [DELIVERY_BOY], [STATUS], [REASON]=(select Category_Name from Categories where Category_ID = [REASON]), DeliveryBoy=(select Category_Name from Categories where Category_ID = DELIVERY _BOY), Status_name=(select Category_Name from Categories where Category_ID = STATUS), [FIRST_NAME] as FirstName, [PRIORITY] as Priority, [TAT], -- convert(varchar, [DELIVERY_DATE],105), [IS_DELETED] , [CREATED_BY] , [CREATED_DATE] , [MODIFIED_BY] , [MODIFIED_DATE] FROM STATUS_UPDATION where IS_DELETED=0 order by STATUS_UPDATE_ID desc RETURN

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetReportPermisions]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

--[Usp_GetReportPermisions] ''edpmanager'' CREATE procedure [dbo].[Usp_GetReportPermisions] --''scanner'' ( @User_Name varchar(50) ) AS BEGIN declare @RoleId varchar(50) select @RoleId = designation_Id from EMPLOYEE_REGISTRATION where [user_ name] = @User_Name select S.SCREEN_ID,S.SCREEN_NAME ,SP.ROLE_ID, ROLE_NAME=(select Category_Name from Categories where Category_Id=SP.ROLE_ ID) from SCREENS S,SCREEN_PERMISIONS SP where S.Screen_Id=SP.Screen_Id and SP.Is_Deleted=0 and S.Is_Deleted=0 and SP .Role_Id = @RoleId and SP.Report_Access=1 order by SCREEN_ID asc END

' END GO

SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetAreaCodebasedonBarcode]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

CREATE procedure [dbo].[Usp_GetAreaCodebasedonBarcode] -- 94999 --( --@barcode_number varchar(50) --) as SET NOCOUNT ON; select barcode_number, area_code, area_name=(select category_name from categories where category_id=[area_code]) from inward_scanning --where barcode_number=@barcode_number

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetCountofScannedDocsForDashBoard]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetCountofScannedDocsForDashBoard] --''18-01-2011'' ( @Created_Date varchar(50) ) AS BEGIN SELECT AREA_CODE, AREA=(select Category_Name from Categories where Category_ID = AREA_CODE), [PARTY_CODE] as [Party Code], [PARTY_CODE]=(select Category_Name from Categories where Category_ID = PARTY_CO DE), BILLCYCLE, COUNT(AWB_NUMBER) FROM INWARD_SCANNING WHERE CONVERT(VARCHAR,CREATED_DATE,105)=@CREATED_DATE AND IS_DELETED=0 group by AREA_CODE,PARTY_CODE ,BILLCYCLE END ' END

GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[us p_GetTeleScanningDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE PROCEDURE [dbo].[usp_GetTeleScanningDetails] AS BEGIN SELECT TELESCANNING_ID, T.AWB_NUMBER, T.CUSTOMER_NAME, edp.CUSTOMER_CONTACT_NUMBER, T.IS_CONNECTED, T.SPOKE_TO, RELATION = (Select Category_Name from Categories where Category_ID = T.RELATION_ID), T.REMARKS, STATUS= (Select Category_Name from Categories where Category_ID =T.S TATUS), T.CREATED_BY from TELESCANNING T inner join ELECTRONIC_DATA_PROCESSING edp on edp.AWB_NUMBER=T.AWB_NUMBER where T.IS_DELETED=0 and convert(varchar,T.CREATED_DATE,103)=convert(varchar,getdate(),103) order by TELESCANNING_ID desc END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetEDPDetailsWithSearch]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -----============================================= Procedure Name :Usp_GetEDPDetailsWithSearch Created By :Ramana.N Created Date :13-09-2010 Modified By :

-- Modified Date : -- Description :To Get the EDP Details with search text -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetEDPDetailsWithSearch]-- ''-''-- ''206'' ( @SearchText varchar(50) ) AS set nocount on SELECT [EDP_ID] , E.[AWB_NUMBER] , E.CUSTOMER_NAME, convert(varchar, DELIVERY_DATE,105) as DELIVERY_DATE, DELIVERY_BOY=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=E.[DE LIVERY_BOY_ID]), [DELIVERY_BOY_ID] , [RECEIVED_BY] , Relation=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=E.[RELATI ONSHIP]), [RELATIONSHIP] , [CUSTOMER_CONTACT_NUMBER] , STATUS_NAME=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=E.[STA TUS]), [STATUS] , [REMARKS] , E.[CREATED_BY] , E.[CREATED_DATE] , E.[MODIFIED_BY] , E.[MODIFIED_DATE], catdel.CATEGORY_NAME, catRel.CATEGORY_NAME, catStatus.CATEGORY_NAME, convert(varchar,E.[DELIVERY_DATE],105) FROM [ELECTRONIC_DATA_PROCESSING] E inner join CATEGORIES catdel on catdel.CATEGORY_ID =DELIVERY_BOY_ID inner join CATEGORIES catRel on catRel.CATEGORY_ID =RELATIONSHIP inner join CATEGORIES catStatus on catStatus.CATEGORY_ID=STATUS where E.Is_Deleted=0 and ( [AWB_NUMBER] like @SearchText or convert(varchar,[DELIVERY_DATE],103) like ''%''+ @SearchText +''%'' or [DELIVERY_DATE] like ''%''+ @SearchText +''%'' or E.CUSTOMER_NAME like ''%'' + @SearchText +''%'' or [CUSTOMER_CONTACT_NUMBER] like ''%''+ @SearchText +''%'' or [REMARKS] like ''%''+ @SearchText +''%'' or [RECEIVED_BY] like ''%''+ @SearchText +''%'' or E.[CREATED_DATE] like ''%''+ @SearchText +''%'' or E.[CREATED_BY] like ''%''+ @SearchText +''%'' or catdel. CATEGORY_NAME like ''%''+ @SearchText + ''%'' or catRel.CATEGORY_NAME like ''%'' + @SearchText + ''%'' or catStatus.CATEGORY_NAME like ''%'' + @SearchText + ''%'' or convert(varchar,E.[DELIVERY_DATE],105) like ''%'' + @SearchText + ''%'' ) order by EDP_ID desc

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetEDPDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Procedure Name :Usp_GetEDPDetails -- Created By :Ramana.N -- Created Date :08-09-2010 -- Modified By : -- Modified Date : -- Description :To Get the EDP Details -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetEDPDetails] AS set nocount on SELECT [EDP_ID] , E.AWB_NUMBER , convert(varchar, DELIVERY_DATE,105) as DELIVERY_DATE , DELIVERY_BOY=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=[DELI VERY_BOY_ID]), [DELIVERY_BOY_ID] , E.[RECEIVED_BY] , RELATION=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=[RELATION SHIP]), [RELATIONSHIP] , E.[CUSTOMER_CONTACT_NUMBER] , STATUS_NAME=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=STATUS ), STATUS, E.[REMARKS] , E.CREATED_BY , E.CREATED_DATE , E.MODIFIED_BY , E.MODIFIED_DATE, E.CUSTOMER_NAME, PARTY_NAME=(Select Category_Name from Categories where Category_ID = inwar d.PARTY_CODE), E.BAD_SIGNATURE FROM [ELECTRONIC_DATA_PROCESSING] E inner join INWARD_SCANNING inward on inward.AWB_NUMBER=E.AWB_NUMBER

where E.IS_DELETED=0 order by EDP_ID desc

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetComplaintDetailsWithSearch]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetComplaintDetailsWithSearch] -- ''single'' --'''' --''Raj'' ( @Search_Text Varchar(50) ) AS set nocount on SELECT [COMPLAINT_ID] , [COMLAINT_TYPE] , -[COMLAINT_TYPE_NAME]=(select category_name from categories where categor y_id=[COMLAINT_TYPE]), [AWB_NUMBER] , [ACCOUNT_NUMBER] , [REFERENCE_NUMBER] , [COMPLAINER_NAME] , [COMPLAINT_CATEGORY] , [COMPLAINT_CATEGORY_NAME]=(select category_name from categories where cate gory_id=[COMPLAINT_CATEGORY]), [COMPLAINT_RECEVIED_BY] , [COMPLAINER_CONTACT_NUMBER] , [ALLOCATED_TO], [ALLOCATED_TO_NAME]=(select category_name from categories where category_i d=[ALLOCATED_TO]), [REMARKS] , COMPLAINT_MONTH, C. COMPLAINTDATE+ ''/''+convert(varchar,[COMPLAINT_ID]) as Complaintdateid , C.[CREATED_BY] , convert(varchar,C.[CREATED_DATE],105) as DATE , C.[MODIFIED_BY] , C.[MODIFIED_DATE], catcat.category_name -catalc.category_name

FROM [COMPLAINT_MANAGER] C inner join categories catcat on catcat.category_id=COMPLAINT_CATEGORY --inner join categories catalc on catalc.category_id=ALLOCATED_TO where C.Is_Deleted=0 and ([AWB_NUMBER] like ''%''+ @Search_Text +''%'' or [COMLAINT_TYPE] like ''%''+ @Search_Text+''%'' or [ACCOUNT_NUMBER] like ''%''+ @Search_Text +''%'' or [REFERENCE_NUMBER] like ''%''+ @Search_Text +''%'' or [COMPLAINER_NAME] like ''%''+ @Search_Text +''%'' or [COMPLAINT_RECEVIED_BY] like ''%''+ @Search_Text +''%'' or [COMPLAINER_CONTACT_NUMBER] like ''%''+ @Search_Text +''%'' or [REMARKS] like ''%''+ @Search_Text +''%'' or COMPLAINT_MONTH like ''%'' + @Search_Text + ''%'' or COMPLAINTDATE+ ''/''+convert(varchar,[COMPLAINT_ID]) like ''%'' + @Search_Text + ''%''or catcat.category_name like ''%''+ @Search_Text +''%'' -- catalc.category_name like ''%''+ @Search_Text +''%'' )

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetTeleCallingDetailsByAWB]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== -- Procedure Name :Usp_GetTeleCallingDetailsByAWB -- Created By :Srinivas.L -- Created Date :6-09-2010 -- Modified By : -- Modified Date : -- Description : -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetTeleCallingDetailsByAWB] -- 5 @AWB_NUMBER int AS

BEGIN SELECT inward.[AWB_NUMBER] , inward.[ACCOUNT_NUMBER] , inward.[REFERENCE_NUMBER] , inward.[CONTACT_NO] , inward.FLAT_NO, inward.STREET_NAME, inward.CITY, inward.STATE, inward.PINCODE, [REASON]=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=[REASON]), inward.[FIRST_NAME], PARTY_NAME=(Select Category_Name from Categories where Category_ID = inward. PARTY_CODE) FROM [INWARD_SCANNING] inward inner join STATUS_UPDATION on STATUS_UPDATION.AWB_NUMBER=inward.AWB_NUMBER where STATUS_UPDATION.AWB_NUMBER = @AWB_NUMBER END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetGetStatusUpdationByAWB]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

--------

-- ============================================= Procedure Name :Usp_GetGetStatusUpdationByAWB Created By :Srinivas.L Created Date :4-09-2010 Modified By : Modified Date : Description : =============================================

CREATE PROCEDURE [dbo].[Usp_GetGetStatusUpdationByAWB]-- 97 @AWB_NUMBER int AS SELECT [AWB_NUMBER] , [FIRST_NAME] , [PRIORITY] , [TAT] , [FLAT_NO], [STREET_NAME], [CITY], [STATE], [PINCODE],

[AREA_CODE]=(Select Category_Name from Categories where Category_ID = AREA _CODE) , [AREA_CODE] FROM [INWARD_SCANNING] where AWB_NUMBER = @AWB_NUMBER

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetCountofTeleScanForDashBoard]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetCountofTeleScanForDashBoard] --''27-01-2011'' ( @Created_Date varchar(50) ) AS BEGIN SELECT I.AREA_CODE, AREA=(select Category_Name from Categories where Category_ID = I.AREA_CODE), I.PARTY_CODE as [Party Code], [Party Name]=(select Category_Name from Categories where Category_ID = I.PARTY_ CODE), I.BILLCYCLE, COUNT(T.AWB_NUMBER) FROM TELESCANNING T inner join INWARD_SCANNING I ON I.AWB_NUMBER=T.AWB_NUMBER WHERE CONVERT(VARCHAR,T.CREATED_DATE,105)=@CREATED_DATE AND T.IS_DELETED=0 group by I.AREA_CODE,I.PARTY_CODE ,I.BILLCYCLE END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetOutwardScanningDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Procedure Name :Usp_GetOutwardScanningDetails -- Created By :Srinivas.L -- Created Date :2-09-2010

-----

Modified By : Modified Date : Description : =============================================

CREATE PROCEDURE [dbo].[Usp_GetOutwardScanningDetails] ( @AWB_NUMBER varchar(50) ) AS SELECT [BARCODE_NUMBER] , [AWB_NUMBER] , [ACCOUNT_NUMBER] , [REFERENCE_NUMBER] , [PARTY_CODE] , [FIRST_NAME] , [PRIORITY] , [TAT] , [FLAT_NO]+'',''+[STREET_NAME]+'',''+CITY+'',''+STATE+'',''+PINCODE AS ADDR ESS, Party = (Select Category_Name from Categories where Category_ID = PARTY_CO DE), [BILLCYCLE] FROM [INWARD_SCANNING] where AWB_NUMBER = @AWB_NUMBER

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetBillCycles]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetBillCycles] as begin set nocount on select category_name from categories where parent_category_id in (select category_id from categories cat where parent_category_id= (select category_id from categories where category_name=''Party Code'')) end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON

GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetCountOfRTORecords]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetCountOfRTORecords] --''28-01-2011'' ( @CREATED_DATE varchar(50) ) as begin SELECT S.AREA_CODE, AREA=(select Category_Name from Categories where Category_ID = S.AREA_CODE), PARTY_CODE as [Party Code], [Party Name]=(select Category_Name from Categories where Category_ID = I.PARTY_ CODE), I.BILLCYCLE, count(STATUS) as [RTO] FROM STATUS_UPDATION S inner join INWARD_SCANNING I ON I.AWB_NUMBER=S.AWB_NUMBER where STATUS= (select category_id from categories where category_name =''R T O '') and convert(varchar,S.CREATED_DATE,105) =@CREATED_DATE AND S.IS_DELETED=0 group by S.AREA_CODE,I.PARTY_CODE ,I.BILLCYCLE END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetBranchOperation]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetBranchOperation] AS set nocount on select [BranchOperation_Id], [AWB_NUMBER] , [AREA_CODE], AreaCode=(select Category_Name from Categories where Category_ID = AREA_CODE), [DELEVERY_BOY], DeliveryBoy=(select Category_Name from Categories where Category_ID = DELEVERY_ BOY), [FIRST_NAME], [PRIORITY],

[TAT], [IS_DELETED] , [CREATED_BY] , [CREATED_DATE] , [MODIFIED_BY] , [MODIFIED_DATE] FROM BRANCH_OPERATIONS where IS_DELETED=0 order by BranchOperation_Id desc RETURN

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetoutwardwithoutArea]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

-- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetoutwardwithoutArea] AS BEGIN select --[AREA_CODE], [PARTY], OUTWARD_WITHOUTAREACODE.[BARCODE_NUMBER], PARTY_NAME=(select Category_Name from Categories where Category_ID = PARTY) , [BILLCYCLE], OUTWARD_WITHOUTAREACODE.[AWB_NUMBER], convert(varchar,OUTWARD_WITHOUTAREACODE.CREATED_DATE,105) as CREATED_DATE, CREATED_BY FROM OUTWARD_WITHOUTAREACODE --inner join INWARD_SCANNING on INWARD_SCANNING.AWB_NUMBER=OUTWARD_WITHOUTAREAC ODE.AWB_NUMBER where OUTWARD_WITHOUTAREACODE.IS_DELETED=0 and convert(varchar,OUTWARD_WITHOUTAR EACODE.CREATED_DATE,103)= convert(varchar,getdate(),103) -- and OUTWARD_WITHOUTAREACODE.CREATED_DATE=''1/7/2011 12:00:00 AM'' order by OUTWARD_SCANNING_ID desc END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetAreacode]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetAreacode] as begin select category_id from categories where category_name=''Hyd00'' end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetCountofEDPForDashBoard]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetCountofEDPForDashBoard] --''27-01-2011'' ( @Created_Date varchar(50) ) AS BEGIN SELECT I.AREA_CODE, AREA=(select Category_Name from Categories where Category_ID = I.AREA_CODE), I.PARTY_CODE as [Party Code], [Party Name]=(select Category_Name from Categories where Category_ID = I.PARTY_ CODE), I.BILLCYCLE, COUNT(E.AWB_NUMBER) FROM ELECTRONIC_DATA_PROCESSING E inner join INWARD_SCANNING I ON I.AWB_NUMBER=E.AWB_NUMBER WHERE CONVERT(VARCHAR,E.CREATED_DATE,105)=@CREATED_DATE AND E.IS_DELETED=0 group by I.AREA_CODE,I.PARTY_CODE ,I.BILLCYCLE END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetDeliveryBoy]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetDeliveryBoy] as begin set nocount on select distinct(DELIVERY_BOY) as DELIVERYBOY, DELIVERYBOYNAME=(select Category_Name from Categories where Category_ID = DELIV ERY_BOY) from STATUS_UPDATION end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetCountofTeleCallingForDashBoard]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

CREATE PROCEDURE [dbo].[Usp_GetCountofTeleCallingForDashBoard] --''28-01-2011'' ( @Created_Date varchar(50) ) AS BEGIN SELECT I.AREA_CODE, AREA=(select Category_Name from Categories where Category_ID = I.AREA_CODE), I.PARTY_CODE as [Party Code], [Party Name]=(select Category_Name from Categories where Category_ID = I.PARTY_ CODE), I.BILLCYCLE, COUNT(T.AWB_NUMBER) FROM TELECALLING T inner join INWARD_SCANNING I ON I.AWB_NUMBER=T.AWB_NUMBER WHERE CONVERT(VARCHAR,T.CREATED_DATE,105)=@CREATED_DATE AND T.IS_DELETED=0 group by I.AREA_CODE,I.PARTY_CODE ,I.BILLCYCLE END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetCountofComplaintsForDashBoard]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetCountofComplaintsForDashBoard] --''27-01-2011'' ( @Created_Date varchar(50) ) AS BEGIN SELECT I.AREA_CODE, AREA=(select Category_Name from Categories where Category_ID = I.AREA_CODE), I.PARTY_CODE as [Party Code], [Party Name]=(select Category_Name from Categories where Category_ID = I.PARTY_ CODE), I.BILLCYCLE, COUNT(C.AWB_NUMBER) FROM COMPLAINT_MANAGER C inner join INWARD_SCANNING I ON I.AWB_NUMBER=C.AWB_NUMBER WHERE CONVERT(VARCHAR,C.CREATED_DATE,105)=@CREATED_DATE AND C.IS_DELETED=0 group by I.AREA_CODE,I.PARTY_CODE ,I.BILLCYCLE END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetGraphofInward]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetGraphofInward] --''18-01-2011'' ( @CREATED_DATE varchar(50) ) as BEGIN SELECT PARTY_CODE,BILLCYCLE,

[Party Name]=(select Category_Name from Categories where Category_ID = PARTY_CO DE), [Billcycle name]=(select Category_Name from Categories where Category_ID = BILL CYCLE), --[PARTY_CODE]+''''+[BILLCYCLE] as pb, SUM(NUMBER_OF_DOCUMENTS) as Count FROM INWARD_LOAD WHERE convert(varchar,CREATED_DATE,105) = @CREATED_DATE AND IS_DELETED=0 GROUP BY PARTY_CODE, BILLCYCLE END' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdateSubCategory]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= --Procedure Name :Usp_UpdateSubCategory --Created By :Srinivas.L --Created Date :5-08-2010 --Modified By : --Modified Date : --Description :To update the category and subcategories -- ============================================= CREATE PROCEDURE [dbo].[Usp_UpdateSubCategory] --''Feedback Types'',34, ''Admin Details'',''Joe'',''Updated successfully'' ( @CATEGORY_NAME varchar(50), @CATEGORY_ID int, @PARENT_CATEGORY_NAME varchar(50), @MODIFIED_BY varchar(50), @ERROR VARCHAR(100) out ) AS BEGIN set nocount on; declare @PARENT_CATEGORY_ID varchar(50) select @PARENT_CATEGORY_ID=PARENT_CATEGORY_ID from CATEGORIES where CAT EGORY_ID =@CATEGORY_ID and IS_DELETED=0 --To check if the subcategory already exists if(exists(select * from CATEGORIES where CATEGORY_NAME=@CATEGORY_NAME an d CATEGORY_ID!=@CATEGORY_ID and IS_DELETED=0 )) begin set @ERROR=@CATEGORY_NAME+ '' already exists '' return end --To check if the category already exists if(exists(select * from CATEGORIES where CATEGORY_NAME=@PARENT_CATEGORY_ NAME and CATEGORY_ID != @PARENT_CATEGORY_ID and IS_DELETED=0 )) begin set @ERROR=@PARENT_CATEGORY_NAME+ '' already exists ''

return end -- Updates the subcategory begin try begin transaction update CATEGORIES set CATEGORY_NAME=@CATEGORY_NAME, MODIFIED_BY =@MODIFIED_BY , MODIFIED_DATE=getdate() where CATEGORY_ID=@CATEGORY_ID if(@PARENT_CATEGORY_ID !=0 OR @PARENT_CATEGORY_ID !='''') begin update CATEGORIES set CATEGORY_NAME=@PARENT_CATEGORY_NAME, MODIFIED_BY =@MODIFIED_BY , MODIFIED_DATE=getdate() where CATEGORY_ID=@PARENT_CATEGORY_ID end SET @ERROR = ''Updated successfully'' commit end try begin catch if @@trancount > 0 rollback end catch END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdateAllCategories]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== --Procedure Name :Usp_Usr_UpdateCategories --Created By :Srinivas.L --Created Date :5-08-2010 --Modified By : --Modified Date : --Description :To update all the categories i.e. all categories,subcategorie s and items -- ============================================= CREATE PROCEDURE [dbo].[Usp_UpdateAllCategories] ( @CATEGORY_ID int, @CATEGORY_NAME varchar(500), @SUBCATEGORY_NAME varchar(50),

@PARENTCATEGORY_NAME varchar(50), @MODIFIED_BY varchar(50), @ERROR varchar(100) out ) AS BEGIN declare @SububcategoryId varchar(50) declare @ParentId varchar(50) select @SububcategoryId=Parent_Category_Id from [CATEGORIES] where CATEGORY_ID= @CATEGORY_ID select @ParentId=Parent_Category_Id from [CATEGORIES] where CATEGORY_ID=@Sububc ategoryId ---It checks whether supplied category name exist in database or not if it exist it returns error message if(exists(select * from [CATEGORIES] where CATEGORY_NAME= @PARENTCATEGORY_NAME and CATEGORY_ID!=@ParentId and PARENT_CATEGORY_ID=0)) BEGIN SET @ERROR= @PARENTCATEGORY_NAME+ '' already exists'' return END ---It checks whether supplied subcategory name exist in database or not if it e xist it returns error message if(exists(select * from [CATEGORIES] where CATEGORY_NAME=@SUBCATEGORY_NAME and PARENT_CATEGORY_ID=@ParentId and CATEGORY_ID!=@SububcategoryId)) BEGIN SET @ERROR=@SUBCATEGORY_NAME+'' already exists'' return END ---It checks whether supplied item name exist in database or not if it exist it returns error message if(exists(select * from [CATEGORIES] where CATEGORY_NAME= @CATEGORY_NAME and PARENT_CATEGORY_ID=@SububcategoryId and CATEGORY_ID!=@CATEGORY_ID )) BEGIN SET @ERROR=@CATEGORY_NAME+'' already exists'' return END else BEGIN ---If supplied item name is not present in database it will update that record UPDATE [CATEGORIES] SET CATEGORY_NAME = @CATEGORY_NAME,

MODIFIED_BY = @MODIFIED_BY, MODIFIED_DATE = getdate() where CATEGORY_ID = @CATEGORY_ID if(@SububcategoryId !='''' or @SububcategoryId is not null ) BEGIN ---If supplied subcategory name is not present in database it will update th at record UPDATE [CATEGORIES] SET CATEGORY_NAME = @SUBCATEGORY_NAME, MODIFIED_BY = @MODIFIED_BY, MODIFIED_DATE = getdate() where CATEGORY_ID = @SububcategoryId END if(@ParentId !='''' or @ParentId is not null) BEGIN ---If supplied category name is not present in database it will update that record UPDATE [CATEGORIES] SET CATEGORY_NAME = @PARENTCATEGORY_NAME, MODIFIED_BY = @MODIFIED_BY, MODIFIED_DATE = getdate() where CATEGORY_ID = @ParentId END --After Updating succesfully this message is set to the variable @Error SET @ERROR=''Updated successfully'' END END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_Categories_SearchText]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= --Procedure Name :Usp_Categories_SearchText --Created By :Srinivas.L --Created Date :5-08-2010 --Modified By : --Modified Date : --Description :To search the categories

-- ============================================= CREATE PROCEDURE [dbo].[Usp_Categories_SearchText] --''rajesh'' ( @SEARCH_TEXT varchar(50)---This variable for storing search text --@Error varchar(50) out ) AS BEGIN set nocount on ---Joining table with itself for identifying Category,Subcategory and Items select Category.CATEGORY_NAME as ''Category'', isnull(Sub.CATEGORY_NAME,'' '') as ''Subcategory'', isnull(Item.CATEGORY_NAME,'' '') as ''Item'', isnull(Category.CATEGORY_ID,'' '') as ''CategoryID'', isnull(Sub.CATEGORY_ID,'' '') as ''SubcategoryID'', isnull(Item.CATEGORY_ID,'' '') as ''ItemID'', Item.CREATED_BY as ''CreatedBy'', Item.CREATED_DATE as ''Created Date'', Category.CREATED_DATE as ''CategoryCreatedDate'', Sub.CREATED_DATE as ''SubcategoryCreatedDate'' from CATEGORIES Category ---Here left join is used because even if subcategory is not there for c ategory, it will display category name left outer join CATEGORIES Sub on Category.CATEGORY_ID = Sub.PARENT_CATE GORY_ID and Sub.IS_DELETED=0 ---Here left join is used because even if item is not there for subcategory i t will display subcategory name left outer join CATEGORIES Item on Item.PARENT_CATEGORY_ID = Sub.CATEGOR Y_ID and Sub.PARENT_CATEGORY_ID is not null and Item.IS_DELETED=0 where Category.PARENT_CATEGORY_ID=0 and Category.IS_DELETED=0 ---If given search text matches with any one of category,subcategory or item it will return that record and ( Category.CATEGORY_NAME like ''%''+ @SEARCH_TEXT +''%'' or Sub.CATEGORY_NAME like ''%''+ @SEARCH_TEXT +''%'' or Item.CATEGORY_NAME like ''%''+ @SEARCH_TEXT +''%'' ) END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetRoles]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'CREATE procedure [dbo].[Usp_GetRoles] ( @USER_NAME varchar(50) ) as begin select DESIGNATION_ID,

Designation = (Select Category_Name from Categories where Category_ID = DESIGNAT ION_ID) from EMPLOYEE_REGISTRATION where [USER_NAME]=@USER_NAME end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertSubcategories]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= --Procedure Name :Usp_InsertSubcategories --Created By :Srinivas.L --Created Date :5-08-2010 --Modified By : --Modified Date : --Description :To insert subcategories -- ============================================= CREATE PROCEDURE [dbo].[Usp_InsertSubcategories] @CATEGORY_NAME varchar(100), @PARENT_CATEGORY_ID int, @MODIFIED_BY varchar(50), @RESULT varchar(100) out AS BEGIN if not exists (select CATEGORY_NAME from CATEGORIES where CATEGORY_NAME= @CATEGORY_NAME and PARENT_CATEGORY_ID =@PARENT_CATEGORY_ID and IS_DELETED=0 ) begin set nocount on; insert into CATEGORIES ( CATEGORY_NAME, PARENT_CATEGORY_ID, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE, IS_DELETED ) values ( @CATEGORY_NAME, @PARENT_CATEGORY_ID , @MODIFIED_BY, GETDATE(), @MODIFIED_BY, GETDATE(), 0 ) set @RESULT=''Inserted successfully''

end else begin set @RESULT=''Subcategory already exists'' end END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetAllCategories]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' --------============================================= Procedure Name :Usp_GetAllCategories Created By :Srinivas.L Created Date :5-08-2010 Modified By : Modified Date : Description : Selects all the categories and items =============================================

CREATE PROCEDURE [dbo].[Usp_GetAllCategories] AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from interfering wi th SELECT statements. SET NOCOUNT ON; ---Joining table with itself for identifying Category,Subcategory and It ems select Category.CATEGORY_NAME as ''Category'', isnull(Sub.CATEGORY_NAME,'' '') as ''Subcategory'', isnull(Item.CATEGORY_NAME,'' '') as ''Item'', isnull(Category.CATEGORY_ID,'' '') as ''CategoryID'', isnull(Sub.CATEGORY_ID,'' '') as ''SubcategoryID'', isnull(Item.CATEGORY_ID,'' '') as ''ItemID'', Item.CREATED_BY as ''CreatedBy'', Item.CREATED_DATE as ''Created Date'', Category.CREATED_DATE as ''CategoryCreatedDate'', Sub.CREATED_DATE as ''SubcategoryCreatedDate'' from CATEGORIES Category ---Here left join is used because even if subcategory is not there for c ategory, it will display category name left outer join CATEGORIES Sub on Category.CATEGORY_ID = Sub.PARENT_CATE GORY_ID and Sub.IS_DELETED=0 ---Here left join is used because even if item is not there for subcategory i t will display subcategory name left outer join CATEGORIES Item on Item.PARENT_CATEGORY_ID = Sub.CATEGOR

Y_ID and Sub.PARENT_CATEGORY_ID is not null and Item.IS_DELETED=0 where Category.PARENT_CATEGORY_ID=0 and Category.IS_DELETED=0 END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdateCategory]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= --Procedure Name :Usp_UpdateCategory --Created By :Srinivas.L --Created Date :5-08-2010 --Modified By : --Modified Date : --Description :To update the category -- ============================================= CREATE PROCEDURE [dbo].[Usp_UpdateCategory] @CATEGORY_NAME varchar(50), @CATEGORY_ID int, @MODIFIED_BY varchar(50), @ERROR VARCHAR(100) out AS BEGIN if exists(select * from CATEGORIES where CATEGORY_NAME=@CATEGORY_NAME an d CATEGORY_ID !=@CATEGORY_ID and PARENT_CATEGORY_ID=0 ) begin -- This message will be shown if the category name already exists in the ta ble set @ERROR= @CATEGORY_NAME +'' already exists'' return end else -- If the Category name does not exist then it will be updated successful ly begin update CATEGORIES set CATEGORY_NAME=@CATEGORY_NAME, MODIFIED_BY= @MODIFIED_BY, MODIFIED_DATE= getdate() where CATEGORY_ID=@CATEGORY_ID set @ERROR= @CATEGORY_NAME +'' Updated successfully'' end

END' END GO

SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetAllItemsByCategoryName]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetAllItemsByCategoryName]-- 58 @CATEGORY_NAME varchar(100) AS begin -- SET NOCOUNT ON added to prevent extra result sets from interfering with SELE CT statements. SET NOCOUNT ON; select CATEGORY_ID, CATEGORY_NAME from CATEGORIES Category where PARENT_CATEGORY_ID in (select CATEGORY_ID from CATEGORIES where CATEGORY_NAME = @CATEG ORY_NAME) and IS_DELETED = 0 order by CATEGORY_NAME end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_SaveCategories]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= --Procedure Name :Usp_SaveCategories --Created By :Srinivas.L --Created Date :5-08-2010 --Modified By : --Modified Date : --Description :To save the category , subcategory and item -- ============================================= CREATE PROCEDURE [dbo].[Usp_SaveCategories] ( @CATEGORY_NAME varchar(1000), @PARENT_CATEGORY_ID varchar(50), @MODIFIED_BY varchar(50), @RESULT varchar(100) out

) AS BEGIN --declare @SubcategoryId varchar(50) -- declare @ParentId varchar(50)

if not exists(select CATEGORY_NAME from CATEGORIES where CATEGORY_NAME=@CATEG ORY_NAME and PARENT_CATEGORY_ID=@PARENT_CATEGORY_ID ) begin insert into CATEGORIES ( CATEGORY_NAME, PARENT_CATEGORY_ID, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE, IS_DELETED ) values ( @CATEGORY_NAME, @PARENT_CATEGORY_ID, @MODIFIED_BY, GETDATE(), @MODIFIED_BY, GETDATE(), 0 ) set @RESULT=''Inserted successfully'' end else begin set @RESULT=''Item already exists'' return end END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_SearchEmployeeDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

-- ============================================= --Procedure Name : Usp_SearchEmployeeDetails --Created By : Srinivas.L --Created Date : 13-08-2010 --Modified By : --Modified Date : --Description :To Search the employee details -- ============================================= CREATE PROCEDURE [dbo].[Usp_SearchEmployeeDetails] @Search_Text varchar(100) AS Begin select EMPLOYEE_ID, [USER_NAME], FIRST_NAME, LAST_NAME, ADDRESS, CONTACT_NUMBER, EMAIL_ID, DESIGNATION_ID, EMPLOYEE_TYPE_ID, AREA_CODE, AGENCY_NAME, Employee_Type_Name = (Select Category_Name from Categories where Categor y_ID = Employee_Type_Id), Designation = (Select Category_Name from Categories where Category_ID = Desi gnation_Id), Area = (Select Category_Name from Categories where Category_ID = Area_Code), E.IS_DELETED, E.CREATED_BY, E.CREATED_DATE, E.MODIFIED_BY, E.MODIFIED_DATE, catemp.Category_Name, catdes.Category_Name, catarea.Category_Name from EMPLOYEE_REGISTRATION E inner join Categories catemp on catemp.Category_ID =Employee_Type_Id inner join Categories catdes on catdes.Category_ID=Designation_Id inner join Categories catarea on catarea.Category_ID=Area_Code where E.IS_DELETED=0 and ([USER_NAME] LIKE @Search_Text or FIRST_NAME LIKE ''%''+ @Search_Text + ''%'' or EMPLOYEE_ID LIKE ''%''+ @Search_Text + ''%'' or LAST_NAME LIKE ''%''+ @Search_Text + ''%'' or ADDRESS LIKE ''%''+ @Search_Text + ''%'' or CONTACT_NUMBER LIKE ''%''+ @Search_Text + ''%'' or EMAIL_ID LIKE ''%''+ @Search_Text + ''%'' or DESIGNATION_ID LIKE ''%''+ @Search_Text + ''%'' or EMPLOYEE_TYPE_ID LIKE ''%''+ @Search_Text + ''%'' or AREA_CODE LIKE ''%''+ @Search_Text + ''%'' or

AGENCY_NAME LIKE ''%''+ @Search_Text + ''%'' or catemp.Category_Name LIKE ''%''+ @Search_Text + ''%'' or catdes.Category_Name LIKE ''%''+ @Search_Text + ''%'' or catarea.Category_Name LIKE ''%''+ @Search_Text + ''%'') ORDER BY [USER_NAME] ASC End

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetCategory]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Procedure Name :Usp_GetCategory -- Created By :Srinivas.L -- Created Date :5-08-2010 -- Modified By : -- Modified Date : -- Description : Select the Category -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetCategory] AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from interfering with SELE CT statements. SET NOCOUNT ON; select CATEGORY_ID ,CATEGORY_NAME FROM CATEGORIES WHERE PARENT_CATEGORY_ID=0 an d IS_DELETED=0 order by CATEGORY_NAME asc END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetSubCategories]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= --Procedure Name :Usp_GetSubCategories --Created By :Srinivas.L --Created Date :5-08-2010

--Modified By : --Modified Date : --Description :To select the subcategories -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetSubCategories] @PARENT_CATEGORY_ID int AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from interfering with SELE CT statements. SET NOCOUNT ON; SELECT CATEGORY_NAME ,CATEGORY_ID FROM CATEGORIES WHERE PARENT_CATEGORY_ ID=@PARENT_CATEGORY_ID order by CATEGORY_NAME asc END' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetDesignationByUsername]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Procedure Name :Usp_GetDesignationByUsername -- Created By :Ramana.N -- Created Date :17-09-2010 -- Modified By : -- Modified Date : -- Description :To get the designation by username -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetDesignationByUsername] @User_Name varchar(50) AS begin set nocount on select designation_Id, Designtation=(select Category_Name from Categories where Category_Id=des ignation_Id) from EMPLOYEE_REGISTRATION where [user_name] = @User_Name RETURN end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetCountofBranchForDashBoard]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetCountofBranchForDashBoard] --''17-01-2011'' (

@Created_Date varchar(50) ) AS BEGIN SELECT B.AREA_CODE, AREA=(select Category_Name from Categories where Category_ID = B.AREA_CODE), PARTY_CODE as [Party Code], [Party Name]=(select Category_Name from Categories where Category_ID = I.PARTY_ CODE), I.BILLCYCLE, COUNT(B.AWB_NUMBER) FROM BRANCH_OPERATIONS B inner join INWARD_SCANNING I ON I.AWB_NUMBER=B.AWB_NUMBER WHERE CONVERT(VARCHAR,B.CREATED_DATE,105)=@CREATED_DATE AND B.IS_DELETED=0 group by B.AREA_CODE,I.PARTY_CODE ,I.BILLCYCLE END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetInwardLoad]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

-- ============================================= -- Procedure Name :Usp_GetInwardLoad -- Created By :Ramana.N -- Created Date :20-08-2010 -- Modified By : -- Modified Date : -- Description :To Get the InwardLoad -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetInwardLoad] AS SELECT [INWARD_ID] , convert(varchar,[EDITABLE_DATE_TIME],103)+'' ''+ [EDITABLE_TIME] as PICKU PDATETIME, [PARTY_CODE] , [BILLCYCLE] , PARTY = (Select Category_Name from Categories where Category_ID = PARTY_CO DE), BILL_CYCLE = (Select Category_Name from Categories where Category_ID = BIL LCYCLE), [PARTICULARS] as PARTICULAR, [PARTICULARS] = (Select Category_Name from Categories where Category_ID = PARTICULARS) , [NUMBER_OF_DOCUMENTS] , [PICKED_UP_BY] ,

PICKEDUP_BY=(select Category_Name from Categories where Category_ID= PICKE D_UP_BY), -- [AREA_CODE] as ORIGIN , [AREA_CODE] as POD, [REMARKS] , [IS_DELETED] , [CREATED_BY] , [CREATED_DATE] , [MODIFIED_BY] , [MODIFIED_DATE] -- FROM INWARD_LOAD where IS_DELETED=0 FROM INWARD_LOAD where IS_DELETED=0 order by INWARD_ID desc RETURN

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetEmployeeDetails]') AND type in (N'P', N'PC')) BEGIN

EXEC dbo.sp_executesql @statement = N' -- ============================================= --Procedure Name : Usp_GetEmployeeDetails --Created By : Srinivas.L --Created Date : 10-08-2010 --Modified By : --Modified Date : --Description :To get the employee details -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetEmployeeDetails] AS Begin set nocount on select Er.EMPLOYEE_ID, Er.USER_NAME, Er.FIRST_NAME, Er.LAST_NAME, Er.ADDRESS, Er.CONTACT_NUMBER, Er.EMAIL_ID, Er.DESIGNATION_ID, Er.EMPLOYEE_TYPE_ID, Er.AREA_CODE, Er.AGENCY_NAME, Er.IS_DELETED, Er.CREATED_BY, Er.CREATED_DATE, Er.MODIFIED_BY, Er.MODIFIED_DATE, EMPLOYEE_TYPE_NAME = (Select Category_Name from Categories where Category_ID = E mployee_Type_Id), -- Employee_Type_Name = (Select Category_Name from Categories where Category_ID = Employee_Type_Id), DESIGNATION = (Select Category_Name from Categories where Category_ID = Designa tion_Id), AREA = (Select Category_Name from Categories where Category_ID = Area_Code) from EMPLOYEE_REGISTRATION Er where Er.IS_DELETED=0 ORDER BY REGISTRATION_ID desc End

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetComplaintDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== --Procedure Name :Usp_GetComplaintDetails

--Created By :Ramana.N --Created Date :07-09-2010 --Modified By : --Modified Date : --Description :To get The Complaint details -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetComplaintDetails] as set nocount on SELECT [COMPLAINT_ID] , [COMLAINT_TYPE] , -- [COMLAINT_TYPE_NAME]=(select category_name from categories where categor y_id=[COMLAINT_TYPE]), [AWB_NUMBER] , [ACCOUNT_NUMBER] , [REFERENCE_NUMBER] , [COMPLAINER_NAME] , [COMPLAINT_CATEGORY] , [COMPLAINT_CATEGORY_NAME]=(select category_name from categories where cate gory_id=[COMPLAINT_CATEGORY]), [COMPLAINT_RECEVIED_BY] , [COMPLAINER_CONTACT_NUMBER] , [ALLOCATED_TO], [ALLOCATED_TO_NAME]=(select category_name from categories where category_i d=[ALLOCATED_TO]), [COMPLAINT_MONTH], [REMARKS] , [CREATED_BY] , [CREATED_DATE] , [MODIFIED_BY] , [MODIFIED_DATE], COMPLAINTDATE+ ''/''+ convert(varchar, [COMPLAINT_ID]) as COMPLAINTDATEID , convert(varchar,[CREATED_DATE],105) as DATE, [CREATED_BY] FROM [COMPLAINT_MANAGER] where Is_Deleted=0 order by COMPLAINT_ID desc

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertCategory]') AND type in (N'P', N'PC')) BEGIN

EXEC dbo.sp_executesql @statement = N' -- ============================================= --Procedure Name : Usp_InsertCategory --Created By : Srinivas.L --Created Date : 5-08-2010 --Modified By : --Modified Date : --Description :To insert the category -- ============================================= CREATE PROCEDURE [dbo].[Usp_InsertCategory] @CATEGORY_NAME varchar(1000), @PARENT_CATEGORY_ID int, @MODIFIED_BY varchar(50), @RESULT varchar(100) out AS BEGIN if not exists (select CATEGORY_NAME from CATEGORIES where CATEGORY_NAME= @CATEGORY_NAME and PARENT_CATEGORY_ID =0 and IS_DELETED=0 ) begin insert into CATEGORIES ( CATEGORY_NAME, PARENT_CATEGORY_ID, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE, IS_DELETED ) values ( @CATEGORY_NAME, @PARENT_CATEGORY_ID , @MODIFIED_BY, GETDATE(), @MODIFIED_BY, GETDATE(), 0 ) set @RESULT=''Inserted successfully'' end else begin set @RESULT=''Category already exists'' end END

' END

GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetInwardLoadWithSearch]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

-- ============================================= -- Procedure Name :Usp_GetInwardLoadWithSearch -- Created By :Ramana.N -- Created Date :21-08-2010 -- Modified By : -- Modified Date : -- Description :To Get the InwardLoad with Search -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetInwardLoadWithSearch] --5 --''M02'' ( @SEARCH_TEXT varchar(50)---This variable for storing search text ) AS SELECT [INWARD_ID] , convert(varchar,[EDITABLE_DATE_TIME],103) +'' ''+ [EDITABLE_TIME] as Pick upDateTime , [PARTY_CODE] , [BILLCYCLE] , [PARTICULARS] as PARTICULAR , [NUMBER_OF_DOCUMENTS] , [AREA_CODE] as POD, [PICKED_UP_BY] , [REMARKS] , I.[IS_DELETED] , I.[CREATED_BY] , I.[CREATED_DATE] , I.[MODIFIED_BY] , I.[MODIFIED_DATE], Party = (Select Category_Name from Categories where Category_ID = PARTY_CO DE), Bill_Cycle = (Select Category_Name from Categories where Category_ID = BIL LCYCLE), [PARTICULARS]= (Select Category_Name from Categories where Category_ID = P ARTICULARS) , PICKEDUP_BY = (Select Category_Name from Categories where Category_ID = PI CKED_UP_BY) , catpick.Category_Name ,catpat.Category_Name,catparty.Category_Name, catbill.Category_Name FROM [INWARD_LOAD] I inner join CATEGORIES inner join CATEGORIES inner join CATEGORIES inner join CATEGORIES where I.IS_DELETED=0 catpick on catpick.CATEGORY_ID =PICKED_UP_BY catbill on catbill.CATEGORY_ID =BILLCYCLE catpat on catpat.CATEGORY_ID =PARTICULARS catparty on catparty.CATEGORY_ID =PARTY_CODE

and ( [NUMBER_OF_DOCUMENTS] like @SEARCH_TEXT or [REMARKS] like ''%''+ @SEARCH_TEXT +''%'' or [AREA_CODE] like ''%''+@SEARCH_TEXT +''%'' or catpick.Category_Name like ''%''+@SEARCH_TEXT +''%'' or catbill.Category_Name like ''%''+@SEARCH_TEXT +''%'' or catpat.Category_Name like ''%''+@SEARCH_TEXT +''%'' or catparty.Category_Name like ''%''+@SEARCH_TEXT +''%'' )

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetStatusUpdationWithSearch]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetStatusUpdationWithSearch]--'''' --''''Delivered'' '' ( @SEARCH_TEXT varchar(50)---This variable for storing search text ) AS begin select [STATUS_UPDATE_ID] , s.[AREA_CODE], s.[DELIVERY_BOY], s.[PAGE_BUNDLE_NUMNER] as PageBundle_Number, s.[STATUS], s.[AWB_NUMBER] as AWB_Number, s.[FIRST_NAME] as FirstName, s.[PRIORITY] as Priority, s.[TAT], s.[REASON], convert(varchar,s.[DELIVERY_DATE],105) as [DELIVERY_DATE], s.[IS_DELETED] , s.[CREATED_BY] , s.[CREATED_DATE] , s.[MODIFIED_BY] , s.[MODIFIED_DATE], AreaCode= (select Category_Name from Categories where Category_ID =s.AREA_CODE) , DeliveryBoy=(select Category_Name from Categories where Category_ID =s.DELIVERY _BOY), Status_name=(select Category_Name from Categories where Category_ID =s.STATUS) ,

catdel.CATEGORY_NAME, catarea.CATEGORY_NAME, catStatus.CATEGORY_NAME FROM STATUS_UPDATION s inner join CATEGORIES catStatus on catStatus.CATEGORY_ID=STATUS inner join CATEGORIES catdel on catdel.CATEGORY_ID =[DELIVERY_BOY] inner join CATEGORIES catarea on catarea.CATEGORY_ID =AREA_CODE where s.IS_DELETED=0 and ( [PAGE_BUNDLE_NUMNER] like ''%''+@SEARCH_TEXT +''%'' or [AWB_NUMBER] like ''%''+@SEARCH_TEXT +''%'' or [FIRST_NAME] like ''%''+@SEARCH_TEXT +''%'' or [PRIORITY] like ''%''+@SEARCH_TEXT +''%'' or [TAT] like @SEARCH_TEXT or s.[REASON] like ''%''+@SEARCH_TEXT +''%'' or s.[DELIVERY_DATE] like ''%''+@SEARCH_TEXT + ''%'' or s.[CREATED_BY] like ''%''+@SEARCH_TEXT +''%'' or s.[CREATED_DATE] like ''%''+@SEARCH_TEXT +''%'' or catdel. CATEGORY_NAME like ''%''+ @SEARCH_TEXT + ''%'' or catarea.CATEGORY_NAME like ''%'' + @SEARCH_TEXT + ''%'' or catStatus.CATEGORY_NAME like ''%'' + @SEARCH_TEXT + ''%'' ) END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetDetailsByAWBForEDP]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

CREATE procedure [dbo].[Usp_GetDetailsByAWBForEDP] ( @PAGE_BUNDLE_NUMNER varchar(50) ) as begin select STATUS_UPDATION.AWB_NUMBER as [AWB Number], ELECTRONIC_DATA_PROCESSING.RECEIVED_BY as [Received By], ELECTRONIC_DATA_PROCESSING.CUSTOMER_CONTACT_NUMBER as [Contact Number], Relation=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=[RELATIONSHIP]) from STATUS_UPDATION left outer join ELECTRONIC_DATA_PROCESSING on ELECTRONIC_DATA_PROCESSING.AWB_NUM BER=STATUS_UPDATION.AWB_NUMBER where STATUS_UPDATION.PAGE_BUNDLE_NUMNER=@PAGE_BUNDLE_NUMNER end

' END

GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetDetailsForComplaintsByAWBNumber]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetDetailsForComplaintsByAWBNumber] --''26'' ( @Search_Text Varchar(50) ) AS BEGIN SELECT edp.AWB_NUMBER, edp.PAGEBUNDLE_NUMBER, edp.CUSTOMER_NAME, i.ACCOUNT_NUMBER, i.BARCODE_NUMBER, i.REFERENCE_NUMBER, edp. [DELIVERY_DATE] , DELIVERY_BOY=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=edp. [DELIVERY_BOY_ID]), [RECEIVED_BY] , [RELATIONSHIP]=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=edp .[RELATIONSHIP]), i.[CONTACT_NO], i.FLAT_NO+'',''+i.STREET_NAME+'',''+i.CITY+'',''+i.STATE+'',''+i.PINCODE a s [ADDRESS], STATUS=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=edp.STATUS) , [RTO_Reason]=(select CATEGORY_NAME from CATEGORIES where CATEGORY_ID=s.REA SON), REMARKS FROM ELECTRONIC_DATA_PROCESSING edp inner join [INWARD_SCANNING] i on i.AWB_NUMBER=edp.AWB_NUMBER inner join [STATUS_UPDATION] s on s.AWB_NUMBER=edp.AWB_NUMBER --WHERE edp.AWB_NUMBER=@AWB_NUMBER where edp.IS_DELETED=0 and (edp.[AWB_NUMBER] like @Search_Text or i.[ACCOUNT_NUMBER] like @Search_Text or i.[REFERENCE_NUMBER] like @Search_Text or i.[CONTACT_NO] like @Search_Text or i.[BARCODE_NUMBER] like @Search_Text ) END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetScreens]') AND type in (N'P', N'PC'))

BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== -- Procedure Name :Usp_GetScreens -- Created By :Ramana.N -- Created Date :09-08-2010 -- Modified By : -- Modified Date : -- Description :To Get the screens -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetScreens] ( @BoolSearch bit =null, @Search_Text varchar(100)='''' ) AS if((@Search_Text is null or @Search_Text='''') or @BoolSearch = 0) begin -- Select statements for procedure here SELECT Screen_Id,Screen_Name,URL,Description from Screens where Is_Delet ed=0 order by Screen_Name end else begin Exec SearchRecordsByTableNameAndText ''Screens'',@Search_Text end -- query to get AllScreens SELECT Screen_Id,Screen_Name,URL,Description from Screens where Is_Deleted=0 ord er by Screen_Name' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetScreenPrivilegesbyRole]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

-- ============================================= -- Procedure Name :Usp_GetScreenPrivilegesbyRole -- Created By :Srinivas.L -- Created Date :16-09-2010 -- Modified By : -- Modified Date : -- Description :To show the screens based on the respective rol e only -- ============================================= --[Usp_GetScreenPrivilegesbyRole] ''admin'' CREATE PROCEDURE [dbo].[Usp_GetScreenPrivilegesbyRole] --''admin'' @User_Name varchar(50) AS

BEGIN declare @RoleId varchar(50) select @RoleId = designation_Id from EMPLOYEE_REGISTRATION where [user_name] = @User_Name select S.SCREEN_ID,S.SCREEN_NAME from SCREENS S,SCREEN_PERMISIONS SP where S.Screen_Id=SP.Screen_Id and SP.Is_Deleted=0 and S.Is_Deleted=0 and SP.Role_Id = @RoleId

END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetUsersbyScreens]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetUsersbyScreens] --''Softcopy Upload'' ( @SCREEN_NAME varchar(50) ) as begin select [USER_NAME] from EMPLOYEE_REGISTRATION E inner join SCREEN_PERMISIONS SP on sp.ROLE_ID = E.designation_Id inner join SCREENS S on S.SCREEN_ID=SP.SCREEN_ID where S.Screen_Id=SP.Screen_Id and SP.Is_Deleted=0 and S.Is_Deleted=0 and S.SCREEN_NAME=@SCREEN_NAME end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_AuthenticateLogin]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

-- ============================================= -- Procedure Name :Usp_AuthenticateLogin -- Created By :Ramana.N -- Created Date :19-08-2010 -- Modified By : -- Modified Date : -- Description :To authenticate the users -- ============================================= CREATE PROCEDURE [dbo].[Usp_AuthenticateLogin] ( @User_Name varchar(50), @Password varchar(50), @Error varchar(500) out ) as begin set nocount on declare @iCnt int set @iCnt=0 select @iCnt=count([USER_NAME]) from Employee_Registration where [USER_N AME]=@User_Name and Password=@Password and Is_Deleted=0 if(@iCnt=1) BEGIN SET @Error =''Login successfully'' END ELSE BEGIN SET @Error =''Invalid Username or Password'' END END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetEDPManagerMailID]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetEDPManagerMailID] as begin select [FIRST_NAME]+'' ''+[LAST_NAME] as [Name],EMAIL_ID from EMPLOYEE_REGISTRATION where DESIGNATION_ID=140

end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertEmployeeDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== -- Procedure Name :Usp_InsertEmployeeDetails -- Created By :Srinivas.L -- Created Date :5-08-2010 -- Modified By :Ramana.N -- Modified Date :24-08-2010 -- Description :To insert the employee details -- ============================================= CREATE PROCEDURE [dbo].[Usp_InsertEmployeeDetails] -- ''1'','''',''admin'',''ad min'',''admin'','''',''hyd'',''4444444444'','''',''41'',''46'',''59'','''',''adm in'','''' ( @EMPLOYEE_ID VARCHAR(50), @AGENCY_NAME varchar(50), @USER_NAME VARCHAR(50), @PASSWORD VARCHAR(50), @FIRST_NAME VARCHAR(50), @LAST_NAME VARCHAR(50), @ADDRESS VARCHAR(500), @CONTACT_NUMBER VARCHAR(50), @EMAIL_ID VARCHAR(100), @DESIGNATION_ID int, @EMPLOYEE_TYPE_ID int, @AREA_CODE int, @PHOTO VARCHAR(500), @MODIFIED_BY VARCHAR(50), @RESULT varchar(100) out ) AS begin declare @EmpId varchar(50) select @EmpId= count(*) from EMPLOYEE_REGISTRATION where Employee_Id= @EMPLOYEE_ ID and IS_DELETED=0 if(@EmpId>0) begin SET @RESULT=''User already exists'' end else begin insert into EMPLOYEE_REGISTRATION (

EMPLOYEE_ID, AGENCY_NAME, [USER_NAME], PASSWORD, FIRST_NAME, LAST_NAME, ADDRESS, CONTACT_NUMBER, EMAIL_ID, DESIGNATION_ID, EMPLOYEE_TYPE_ID, AREA_CODE , PHOTO , IS_DELETED, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE ) values ( @EMPLOYEE_ID, @AGENCY_NAME, @USER_NAME, @PASSWORD, @FIRST_NAME, @LAST_NAME, @ADDRESS, @CONTACT_NUMBER, @EMAIL_ID, @DESIGNATION_ID, @EMPLOYEE_TYPE_ID, @AREA_CODE, @PHOTO , 0, @MODIFIED_BY, GETDATE(), @MODIFIED_BY, GETDATE() ) SET @RESULT=''Inserted successfully'' end

end' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetUserDetailsByEmailID]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== -- Procedure Name :Usp_GetUserDetailsByEmailID -- Purpose :To get UserDetails based on Email ID

-- Created By :Ramana.N. -- Created :27/08/2010 -- Modified By : -- Modified Date : -- Comments :Gets UserDetails based on Email ID -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetUserDetailsByEmailID] --''srinivas.l@alliancepros ys.com'' ( @EMAIL_ID varchar(50) ) AS BEGIN SELECT [USER_NAME],Password,EMAIL_ID FROM Employee_Registration WHERE EMAIL_ID=@EMAIL_ID AND IS_DELETED = 0 END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdatePassword]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== -- Procedure Name :Usp_UpdatePassword -- Created By :Srinivas.L -- Created Date :13-09-2010 -- Modified By : -- Modified Date : -- Description :To change the password CREATE PROCEDURE [dbo].[Usp_UpdatePassword] ( @UserName varchar(50), @OldPassword varchar(50), @NewPassword varchar(50), @ConfirmPassword varchar(50) ) AS begin set nocount on; declare @pwd varchar(50) select @pwd=PASSWORD from EMPLOYEE_REGISTRATION where [USER_NAME]=@UserName and IS_DELETED=0 if(@pwd=@OldPassword) BEGIN UPDATE EMPLOYEE_REGISTRATION set [PASSWORD]=@NewPassword WHERE [USER_NAME]=@UserName and [IS_DELETED]=0 and [PASSWORD]=@OldPassword End end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetUserDetailsByUsername]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== -- Procedure Name :Usp_GetUserDetailsByUsername -- Purpose :To get UserDetails based on UserID -- Created By :Ramana.N. -- Created :27/08/2010 -- Modified By : -- Modified Date : -- Comments :Gets UserDetails based on Username -- ============================================= CREATE PROCEDURE [dbo].[Usp_GetUserDetailsByUsername] ( @USER_NAME varchar(50) ) AS BEGIN SELECT [USER_NAME],Password,EMAIL_ID FROM Employee_Registration WHERE [USER_NAME]=@USER_NAME AND IS_DELETED = 0 END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_DeleteEmployeeDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= --Procedure Name : Usp_DeleteEmployeeDetails --Created By : Srinivas.L --Created Date : 9-08-2010 --Modified By : --Modified Date : --Description :To delete the employee details -- ============================================= CREATE PROCEDURE [dbo].[Usp_DeleteEmployeeDetails] @EMPLOYEE_ID VARCHAR(50), @USER_NAME VARCHAR(50), @PASSWORD VARCHAR(50), @FIRST_NAME VARCHAR(50), @LAST_NAME VARCHAR(50), @ADDRESS VARCHAR(500), @CONTACT_NUMBER VARCHAR(50), @EMAIL_ID VARCHAR(100),

@DESIGNATION_ID int, @EMPLOYEE_TYPE_ID int, @AGENCY_NAME VARCHAR(50), @AREA_CODE int, --@PHOTO VARCHAR(500), @MODIFIED_BY VARCHAR(50), @RESULT varchar(100) out AS Begin Update EMPLOYEE_REGISTRATION set Is_Deleted=1 where EMPLOYEE_ID=@EMPLOYEE_ID Set @RESULT=''Employee deleted successfully'' End' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdateEmployeeDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== --Procedure Name : Usp_UpdateEmployeeDetails --Created By : Srinivas.L --Created Date : 9-08-2010 --Modified By : --Modified Date : --Description :To update the employee details -- ============================================= CREATE PROCEDURE [dbo].[Usp_UpdateEmployeeDetails] ( @EMPLOYEE_ID VARCHAR(50), @USER_NAME VARCHAR(50), @FIRST_NAME VARCHAR(50), @LAST_NAME VARCHAR(50), @ADDRESS VARCHAR(500), @CONTACT_NUMBER VARCHAR(50), @EMAIL_ID VARCHAR(100), @DESIGNATION_ID int, @EMPLOYEE_TYPE_ID int, @AREA_CODE int, @PHOTO VARCHAR(500), @AGENCY_NAME VARCHAR(50), @MODIFIED_BY VARCHAR(50), @RESULT varchar(100) out ) AS BEGIN try SET NOCOUNT ON; begin transaction Update EMPLOYEE_REGISTRATION SET EMPLOYEE_ID=@EMPLOYEE_ID, [USER_NAME]=@USER_NAME, FIRST_NAME=@FIRST_NAME,

LAST_NAME=@LAST_NAME, ADDRESS=@ADDRESS, CONTACT_NUMBER=@CONTACT_NUMBER, EMAIL_ID=@EMAIL_ID, DESIGNATION_ID=@DESIGNATION_ID, EMPLOYEE_TYPE_ID=@EMPLOYEE_TYPE_ID , AREA_CODE=@AREA_CODE , AGENCY_NAME=@AGENCY_NAME, PHOTO=@PHOTO, MODIFIED_BY=@MODIFIED_BY, MODIFIED_DATE=getdate() where EMPLOYEE_ID=@EMPLOYEE_ID SET @RESULT=''Updated successfully'' commit END try begin catch if @@trancount > 0 rollback end catch

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_DeleteComplaint]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== --Procedure Name :Usp_DeleteComplaint --Created By :Ramana.N --Created Date :07-09-2010 --Modified By : --Modified Date : --Description :To Delete The Complaint details -- ============================================= CREATE PROCEDURE [dbo].[Usp_DeleteComplaint] ( @Compalint_Id int, @Error varchar(100) out ) AS update COMPLAINT_MANAGER set Is_Deleted=1 where Complaint_Id=@Compalint_Id set @Error=''Deleted Sucessfully'' RETURN ' END

GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdateComplaintRefID]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'CREATE procedure [dbo].[Usp_UpdateComplain tRefID] ( @COMPLAINT_ID int, @COMPLAINTDATE varchar(50), @ERROR varchar(50) out ) as begin update COMPLAINT_MANAGER set COMPLAINTDATE=@COMPLAINTDATE +''/'' + @COMPLAINT_ID where COMPLAINT_ID=@COMPLAINT_ID set @ERROR= '' Updated successfully'' end --select * from COMPLAINT_MANAGER where awb_number=12' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertComplaint]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= --Procedure Name :Usp_InsertComplaint --Created By :Ramana.N --Created Date :06-09-2010 --Modified By : --Modified Date : --Description :To Insert The Complaint details -- ============================================= CREATE PROCEDURE [dbo].[Usp_InsertComplaint]--''13'',''0'',''0'',''0'',''0'',''0 '',''0'',''0'',''0'',''0'',''0'',''12'',''0'',''0'' ( @AWB_NUMBER int, @ACCOUNT_NUMBER varchar(50), @REFERENCE_NUMBER varchar(50), @COMLAINT_TYPE varchar(50), @COMPLAINER_NAME varchar(50), @COMPLAINT_CATEGORY int, @COMPLAINT_RECEVIED_BY varchar(50), @COMPLAINER_CONTACT_NUMBER varchar(50), @ALLOCATED_TO varchar(50), @REMARKS varchar(500), -@COMPLAINTID int, @COMPLAINTDATE varchar(50),

@COMPLAINT_MONTH varchar(50), @CREATED_BY varchar(50) , @Error varchar(50) out ) AS --declare @cnt int -- select @cnt= count(*) from [COMPLAINT_MANAGER] where IS_DELETED=0 and AWB_NUM BER= @AWB_NUMBER -----if(@cnt>0) ----begin ----set @Error=''AWB already exists'' ----end -------else begin INSERT INTO [COMPLAINT_MANAGER] ( AWB_NUMBER, ACCOUNT_NUMBER, REFERENCE_NUMBER, COMLAINT_TYPE, COMPLAINER_NAME, COMPLAINT_CATEGORY, COMPLAINT_RECEVIED_BY, COMPLAINER_CONTACT_NUMBER, ALLOCATED_TO, REMARKS, -COMPLAINTID, COMPLAINTDATE, COMPLAINT_MONTH, IS_DELETED, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE ) VALUES ( @AWB_NUMBER, @ACCOUNT_NUMBER, @REFERENCE_NUMBER, @COMLAINT_TYPE, @COMPLAINER_NAME, @COMPLAINT_CATEGORY, @COMPLAINT_RECEVIED_BY, @COMPLAINER_CONTACT_NUMBER, @ALLOCATED_TO, -@REMARKS, @COMPLAINTID, @COMPLAINTDATE, @COMPLAINT_MONTH, 0, @CREATED_BY, getdate(), @CREATED_BY, getdate()

) set @Error=''Successfully Saved''

end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdateComplaintManager]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_UpdateComplaintManager] ( @COMPLAINT_ID int, @COMLAINT_TYPE varchar(50), @AWB_NUMBER int, @ACCOUNT_NUMBER int, @REFERENCE_NUMBER int, @COMPLAINER_NAME varchar(50), @COMPLAINT_CATEGORY int, @COMPLAINER_CONTACT_NUMBER varchar(50), @REMARKS varchar(500), @MODIFIED_BY varchar(50), @COMPLAINTMONTH Varchar(50), @ERROR VARCHAR(100) out ) as begin try begin transaction update COMPLAINT_MANAGER set COMLAINT_TYPE=@COMLAINT_TYPE, AWB_NUMBER =@AWB_NUMBER, ACCOUNT_NUMBER= @ACCOUNT_NUMBER , REFERENCE_NUMBER= @REFERENCE_NUMBER , COMPLAINER_NAME= @COMPLAINER_NAME, COMPLAINT_CATEGORY= @COMPLAINT_CATEGORY , COMPLAINER_CONTACT_NUMBER= @COMPLAINER_CONTACT_NUMBER, REMARKS= @REMARKS, MODIFIED_BY = @MODIFIED_BY , COMPLAINT_MONTH=@COMPLAINTMONTH, MODIFIED_DATE=getdate() where COMPLAINT_ID=@COMPLAINT_ID set @ERROR= '' Updated successfully'' commit end try begin catch

if @@trancount > 0 rollback end catch

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdateComplaintsStatus]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_UpdateComplaintsStatus] ( @COMPLAINT_ID int, @COMPLAINT_STATUS varchar(50), @ERROR varchar(50) out ) as begin try begin transaction update COMPLAINT_MANAGER set COMPLAINT_STATUS=@COMPLAINT_STATUS where COMPLAINT_ID=@COMPLAINT_ID set @ERROR=''Successfully Updated'' commit end try begin catch if @@trancount > 0 rollback end catch ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetCountOfComplaintStatus]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetCountOfComplaintStatus]-- ''14-02-2011'',128 ( @CREATED_DATE varchar(50),

@ALLOCATED_TO int ) as begin select Count(*) as [completed] from Complaint_manager where COMPLAINT_STATUS=''completed'' and convert(varchar,created_date,105)=@created_date and ALLOCATED_TO=@ALLOCATED_TO and is_deleted=0 select count(*) as [pending] from Complaint_manager where COMPLAINT_STATUS=''pending'' and convert(varchar,created_date,105)=@created_date and ALLOCATED_TO=@ALLOCATED_TO and is_deleted=0 select NO_OF_DOCUMENTS,NO_OF_PICKUPS from COMPLAINTS_ALLOCATION WHERE convert(varchar,CREATED_DATE,105)=@created_date and ALLOCATED_TO=@ALLOCATED_TO and IS_DELETED=0 end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdateComplaintsAllocatedTo]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_UpdateComplaintsAllocatedTo] ( @AREA_CODE int , @ALLOCATED_TO varchar(50), @AWB_NUMBER varchar(50), @COMPLAINT_RECEVIED_BY varchar(50), @ERROR varchar(50) out )as begin try begin transaction update dbo.COMPLAINT_MANAGER set AREA_CODE=@AREA_CODE ,ALLOCATED_TO=@ALLOCATED_TO, COMPLAINT_RECEVIED_BY=@COMPLAINT_RECEVIED_BY where AWB_NUMBER=@AWB_NUMBER set @ERROR= ''Successfully Saved'' commit end try begin catch if @@trancount >0 rollback end catch ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdateScreens]') AND type in (N'P', N'PC')) BEGIN

EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Procedure Name :Usp_UpdateScreens -- Created By :Ramana.N -- Created Date :09-08-2010 -- Modified By : -- Modified Date : -- Description :To Update the screens details -- ============================================= CREATE PROCEDURE [dbo].[Usp_UpdateScreens] ( @Screen_ID nvarchar(50), @ScreenName nvarchar(30), @URL nvarchar(20), @Description nvarchar (100), @Created_BY nvarchar (20), @Error varchar(500) out ) AS begin try set nocount on; begin transaction UPDATE Screens SET Screen_Name=@ScreenName , URL=@URL , DESCRIPTION=@Description , Modified_By=@Created_BY , Modified_Date=GETDATE() WHERE Screen_Id =@Screen_ID SET @Error = @ScreenName +'' updated successfully'' commit end try begin catch if @@trancount > 0 rollback end catch

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertScreens]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Procedure Name :Usp_InsertScreens -- Created By :Ramana.N -- Created Date :09-08-2010 -- Modified By : -- Modified Date :

-- Description :To insert the screens details -- ============================================= CREATE PROCEDURE [dbo].[Usp_InsertScreens] ( @ScreenName nvarchar (30), @Description nvarchar (100), @URL nvarchar(50), @Created_By varchar (20), @Error varchar(500) output ) AS begin declare @scr varchar(50) declare @screenid varchar(50) select @scr= count(*) from Screens where Screen_Name= @ScreenName and IS_DELETED =0 if(@scr>0) begin SET @Error = @ScreenName + '' already exists'' end else begin set nocount on; INSERT INTO Screens ( Screen_Name, URL, Description , Created_By, Created_Date, Modified_By, Modified_Date, IS_deleted ) VALUES ( @ScreenName, @URL, @Description , @Created_By , GETDATE(), @Created_By , getdate(), 0 ) SET @Error = @ScreenName + '' inserted successfully'' end end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON

GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetScreenPermissions]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

---------

============================================= Procedure Name :Usp_GetScreenPermissions Created By :Ramana.N Created Date :12-08-2010 Modified By :srinivas Modified Date :17-09-2010 Description :To Get the screens permissions =============================================

CREATE PROCEDURE [dbo].[Usp_GetScreenPermissions] --''40'' ( @Role_Id varchar(50) ) AS BEGIN declare @RoleId varchar(50) select @RoleId = count(*) from Screen_Permisions where Role_Id =@Role_Id if(@RoleId != 0) begin (select 0 "Page_Acess", 0 "Report_Access",Screen_Id,Screen_Name from Screens where Screen_Id not in (select Screen_Id from Screen_Permisions where Role_Id=@Role_Id) --@Role_Id and Is_Deleted=0 ) union ( select SP.Page_Acess,SP.Report_Access, S.SCREEN_ID,S.SCREEN_NAME from SCREENS S,SCREEN_PERMISIONS SP where S.Screen_Id=SP.Screen_Id and SP.Is_Deleted=0 and S.Is_Deleted=0 and SP.Role_Id=@Role_Id) end else begin (select 0 "Page_Acess",0 "Report_Access",Screen_Id,Screen_Name from Screens where Screen_Id not in (select Screen_Id from Screen_Permisions where Role_Id=@Role_Id) and Is_Deleted=0 ) end END

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_DeleteScreens]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== -- Procedure Name :Usp_DeleteScreens -- Created By :Ramana.N -- Created Date :09-08-2010 -- Modified By : -- Modified Date : -- Description :To Delete the screens details -- ============================================= CREATE PROCEDURE [dbo].[Usp_DeleteScreens] ( @Screen_ID varchar(50), @Created_By varchar(50), @Error varchar(50) out ) as begin update Screens set is_deleted = 1 , Modified_By =@Created_By where Screen_id = @Screen_ID set @Error = ''Deleted Successfully'' end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertOutwardScanningMisRoute]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= --Procedure Name :Usp_InsertOutwardScanning --Created By :Priyanka --Created Date :03-09-2010 --Modified By : --Modified Date : --Description :To Insert The OutwardScanning -- ============================================= CREATE PROCEDURE [dbo].[Usp_InsertOutwardScanningMisRoute] @BARCODE_NUMBER varchar(50),

@AWB_NUMBER int, @ACCOUNT_NUMBER varchar(50), @REFERENCE_NUMBER varchar(50), @CUSTOMER_FIRST_NAME varchar(50), @PARTY int, @AREA_CODE int, @CUSTOMER_ADDRESS varchar(2500), @PRIORITY varchar(50), @CREATED_BY varchar(50), @TAT int, @Error varchar(100) out AS declare @cntnoservice int select @cntnoservice= count(*) from dbo.[OUTWARD_WITHOUTAREACODE] where AWB_NUM BER= @AWB_NUMBER if(@cntnoservice>0) begin set @Error=''AWB Number is in No service'' end else begin set nocount on; INSERT INTO dbo.[OUTWARD_SCANNING_MISROUTE] ( BARCODE_NUMBER, AWB_NUMBER, ACCOUNT_NUMBER, REFERENCE_NUMBER, CUSTOMER_FIRST_NAME, PARTY, AREA_CODE, CUSTOMER_ADDRESS, PRIORITY, TAT, RETURNED_DATE, IS_MISROUTE, IS_DELETED, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE ) VALUES ( @BARCODE_NUMBER, @AWB_NUMBER, @ACCOUNT_NUMBER, @REFERENCE_NUMBER, @CUSTOMER_FIRST_NAME, @PARTY, @AREA_CODE, @CUSTOMER_ADDRESS, @PRIORITY, @TAT, getdate(), 1, 0, @CREATED_BY,

getdate(), @CREATED_BY, getdate() ) set @Error=@AWB_NUMBER end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertInwardLoad]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Procedure Name :Usp_InsertInwardLoad -- Created By :Ramana.N -- Created Date :19-08-2010 -- Modified By : -- Modified Date : -- Description :To Insert Inward Load details -- ============================================= CREATE PROCEDURE [dbo].[Usp_InsertInwardLoad] --''1/1/2011 17:45'',''0'',''0'',' '0'',''0'',''0'',''0'',''0'',''0'',''0'',''0'',''0'' ( @PICKUP_DATE_TIME varchar(50), @PARTY_CODE int, @BILLCYCLE int, @NUMBER_OF_DOCUMENTS int, @AREA_CODE varchar(50), @PICKED_UP_BY varchar(50), @REMARKS varchar(3000), @EDITABLE_DATE_TIME varchar(50), @PARTICULARS int, @EDITABLE_TIME varchar(50), @CREATED_BY varchar(50), @Error varchar(500) output ) AS begin INSERT INTO [INWARD_LOAD] ( PICKUP_DATE_TIME, PARTY_CODE, BILLCYCLE,

"NUMBER_OF_DOCUMENTS", AREA_CODE, PICKED_UP_BY, REMARKS, EDITABLE_DATE_TIME, PARTICULARS, EDITABLE_TIME, IS_DELETED, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE ) VALUES ( @PICKUP_DATE_TIME, @PARTY_CODE, @BILLCYCLE, @NUMBER_OF_DOCUMENTS, @AREA_CODE, @PICKED_UP_BY, @REMARKS, @EDITABLE_DATE_TIME, @PARTICULARS, @EDITABLE_TIME, 0, @CREATED_BY, convert(varchar, getdate(),106), @CREATED_BY, getdate() ) SET @Error = ''Saved Succesfully '' end

' END GO

SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetNumberOfDocumentsPerDay]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetNumberOfDocumentsPerDay] ( @CREATED_BY varchar(50) ) AS BEGIN select sum(NUMBER_OF_DOCUMENTS) as noofdoc FROM INWARD_LOAD WHERE is_deleted=0 and CREATED_DATE= convert(varchar, GETDATE(), 106) and CREATED_BY=@CREATED_BY END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdateNumberOfDocuments]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_UpdateNumberOfDocuments] ( @INWARD_ID int, @NUMBER_OF_DOCUMENTS int, @MODIFIED_BY varchar(50), @ERROR VARCHAR(100) out ) as begin set nocount on; update INWARD_LOAD set NUMBER_OF_DOCUMENTS=@NUMBER_OF_DOCUMENTS,MODIFIED_BY=@MODIFIED_BY where INWARD_ID=@INWARD_ID set @ERROR= ''Updated successfully'' end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us

p_DeleteInwardLoad]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Procedure Name :Usp_DeleteInwardLoad -- Created By :Ramana.N -- Created Date :21-08-2010 -- Modified By : -- Modified Date : -- Description :To Delete the Inward Load details -- ============================================= CREATE PROCEDURE [dbo].[Usp_DeleteInwardLoad] ( @Inward_Id varchar(50), @Error varchar(50) out ) as begin delete from INWARD_LOAD where Inward_Id = @Inward_Id set @Error = ''Deleted Successfully'' end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetPageBundleNumber]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetPageBundleNumber] as begin select distinct(PAGE_BUNDLE_NUMNER)as PAGEBUNDLE from STATUS_UPDATION end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertStatusUpdation]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= --Procedure Name :Usp_InsertStatusUpdation --Created By :Srinivas.L

--Created Date :06-09-2010 --Modified By : --Modified Date : --Description :To Insert The Status Updation Details -- ============================================= CREATE PROCEDURE [dbo].[Usp_InsertStatusUpdation] @AREA_CODE int, @DELIVERY_BOY int, @PAGE_BUNDLE_NUMNER varchar(50), @STATUS int, @AWB_NUMBER int, @FIRST_NAME varchar(50), @PRIORITY varchar(50), @TAT int, @REASON int, @DELIVERY_DATE Varchar(50), @CREATED_BY varchar(50), @Error varchar(100) out AS declare @cnt int select @cnt= count(*) from [STATUS_UPDATION] where IS_DELETED=0 and AWB_NUMBER= @AWB_NUMBER if(@cnt>0) begin set @Error=''AWB already exists'' end else begin set nocount on; INSERT INTO [STATUS_UPDATION] ( AREA_CODE, DELIVERY_BOY, PAGE_BUNDLE_NUMNER, STATUS, AWB_NUMBER, FIRST_NAME, PRIORITY, TAT, REASON, DELIVERY_DATE, IS_DELETED, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE ) VALUES ( @AREA_CODE, @DELIVERY_BOY, @PAGE_BUNDLE_NUMNER, @STATUS, @AWB_NUMBER, @FIRST_NAME,

@PRIORITY, @TAT, @REASON, @DELIVERY_DATE, 0, @CREATED_BY, convert(varchar, getdate(),106), @CREATED_BY, GETDATE() ) set @Error=@AWB_NUMBER end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetAWBCountbyUserStatusUpdate]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetAWBCountbyUserStatusUpdate] --''admin'' ( @CREATED_BY varchar(50) ) as begin select count(AWB_Number)as AWB_NUMBER from STATUS_UPDATION where CREATED_DATE=convert(varchar,getdate(),106) and CREATED_BY =@CREATED_BY end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_CountofPageBundlebyStatus]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_CountofPageBundlebyStatus] --''No Page/Bundle'' (

@PAGE_BUNDLE_NUMNER varchar(50) ) as begin select count(PAGE_BUNDLE_NUMNER) from STATUS_UPDATION where PAGE_BUNDLE_NUMNER=@PAGE_BUNDLE_NUMNER end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdatePageBundleNumber]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_UpdatePageBundleNumber] ( @STATUS_UPDATE_ID int, @PAGE_BUNDLE_NUMNER varchar(50), @ERROR VARCHAR(100) out ) as begin set nocount on; update STATUS_UPDATION set PAGE_BUNDLE_NUMNER=@PAGE_BUNDLE_NUMNER where STATUS_UPDATE_ID=@STATUS_UPDATE_ID set @ERROR= ''Updated successfully'' end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Ge tCustomerUpdationDetailsByAWBNumber]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[GetCustomerUpdatio nDetailsByAWBNumber] ( @AWB int ) AS select [STATUS] , [CREATED_DATE],

[DELIVERY_BOY] FROM [STATUS_UPDATION] where [AWB_NUMBER]=@AWB' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_DeleteStatusUpdation]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== -- Author: Praveen -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE PROCEDURE [dbo].[Usp_DeleteStatusUpdation] ( @STATUS_UPDATE_ID int, @Error varchar(50) out ) AS BEGIN delete from STATUS_UPDATION where STATUS_UPDATE_ID=@STATUS_UPDATE_ID set @Error = ''Deleted Successfully'' END ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertComplaints_allocation]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[Usp_InsertComplain ts_allocation] ( @ALLOCATED_TO varchar(50), @NO_OF_COMPLAINTS int, @NO_OF_DOCUMENTS int, @NO_OF_PICKUPS int, @CREATED_BY varchar(50), @Error varchar(500) output ) as begin insert into [COMPLAINTS_ALLOCATION] ( ALLOCATED_TO, NO_OF_COMPLAINTS , NO_OF_DOCUMENTS, NO_OF_PICKUPS, IS_DELETED,

CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE ) VALUES ( @ALLOCATED_TO, @NO_OF_COMPLAINTS , @NO_OF_DOCUMENTS , @NO_OF_PICKUPS , 0, @CREATED_BY , getdate(), @CREATED_BY , getdate() ) SET @Error = ''Saved Successfully'' end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertBranchOperations]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' -- ============================================= -- Procedure Name :Usp_InsertBranchOperations -- Created By :Ramana.N -- Created Date :04-09-2010 -- Modified By : -- Modified Date : -- Description :To insert the Branch Operations details -- ============================================= CREATE PROCEDURE [dbo].[Usp_InsertBranchOperations] ( @AREA_CODE int, @DELEVERY_BOY int, @AWB_NUMBER int, @FIRST_NAME varchar(50), @PRIORITY varchar(50), @TAT int, @CREATED_BY varchar(50), @Error varchar(50) out ) AS declare @cnt int select @cnt= count(*) from [BRANCH_OPERATIONS] where AWB_NUMBER= @AWB_NUMBER if(@cnt>0) begin set @Error=''AWB already exists'' end

else begin INSERT INTO [BRANCH_OPERATIONS] ( AREA_CODE, DELEVERY_BOY, AWB_NUMBER, FIRST_NAME, PRIORITY, TAT, IS_DELETED, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE ) VALUES ( @AREA_CODE, @DELEVERY_BOY, @AWB_NUMBER, @FIRST_NAME, @PRIORITY, @TAT, 0, @CREATED_BY, getdate(), @CREATED_BY, getdate() ) set @Error=@AWB_NUMBER end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertEDPDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== -- Procedure Name :Usp_InsertEDPDetails -- Created By :Ramana.N -- Created Date :06-09-2010 -- Modified By : -- Modified Date : -- Description :Insert EDP Details -- ============================================= CREATE PROCEDURE [dbo].[Usp_InsertEDPDetails] ( @AWB_NUMBER int, @DELIVERY_DATE varchar(50), @DELIVERY_BOY_ID int, @RECEIVED_BY varchar(50),

@RELATIONSHIP int, @CUSTOMER_CONTACT_NUMBER varchar(50), @PAGEBUNDLE_NUMBER varchar(50), @BAD_SIGNATURE varchar(50), @STATUS int, @REMARKS varchar(3000), @CUSTOMER_NAME varchar(50), @CREATED_BY varchar(50), @Error varchar(50) out ) AS declare @cnt int select @cnt= count(*) from [ELECTRONIC_DATA_PROCESSING] where IS_DELETED=0 and A WB_NUMBER = @AWB_NUMBER if(@cnt>0) begin set @Error=''AWB already exists'' end else begin INSERT INTO [ELECTRONIC_DATA_PROCESSING] ( AWB_NUMBER, DELIVERY_DATE, DELIVERY_BOY_ID, RECEIVED_BY, RELATIONSHIP, CUSTOMER_CONTACT_NUMBER, STATUS, REMARKS, CUSTOMER_NAME, PAGEBUNDLE_NUMBER, BAD_SIGNATURE, IS_DELETED, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE ) VALUES ( @AWB_NUMBER, @DELIVERY_DATE, @DELIVERY_BOY_ID, @RECEIVED_BY, @RELATIONSHIP, @CUSTOMER_CONTACT_NUMBER, @STATUS, @REMARKS, @CUSTOMER_NAME, @PAGEBUNDLE_NUMBER, @BAD_SIGNATURE, 0, @CREATED_BY, convert(varchar, getdate(),106), @CREATED_BY, getdate() ) set @Error=@AWB_NUMBER

end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetAWBCountbyUserForDay]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetAWBCountbyUserForDay] ( @CREATED_BY varchar(50) ) as begin select count(AWB_Number)as AWB_NUMBER from ELECTRONIC_DATA_PROCESSING where CREATED_DATE=convert(varchar,getdate(),106) and CREATED_BY =@CREATED_BY end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_DeleteEDPDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_DeleteEDPDetails] ( @EDP_ID varchar(50), @Error varchar(50) out ) as begin DELETE [ELECTRONIC_DATA_PROCESSING] where EDP_ID = @EDP_ID --SET is_deleted = 1 set @Error = ''Deleted Successfully'' end ' END GO

SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_DeleteScreenPermissions]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_DeleteScreenPermissions] ( @Role_Id varchar(50), @Error varchar(50) out ) as begin delete from Screen_Permisions where Role_ID = @Role_Id set @Error = ''Deleted Successfully'' end ' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertTelescanning]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'

CREATE PROCEDURE [dbo].[Usp_InsertTelescanning] @AWB_NUMBER int, @IS_CONNECTED varchar(50), @CUSTOMER_NAME varchar(50), @SPOKE_TO varchar(50), @RELATION_ID int, @REMARKS varchar(3000), @CREATED_BY varchar(50), @STATUS int, @Error varchar(500) output AS begin INSERT INTO [TELESCANNING] ( AWB_NUMBER, IS_CONNECTED, CUSTOMER_NAME, SPOKE_TO, RELATION_ID, REMARKS,

IS_DELETED, CREATED_BY, STATUS, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE ) VALUES ( @AWB_NUMBER, @IS_CONNECTED, @CUSTOMER_NAME, @SPOKE_TO, @RELATION_ID, @REMARKS, 0, @CREATED_BY, @STATUS, GETDATE(), @CREATED_BY, GETDATE() ) SET @Error = @AWB_NUMBER end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertOutwardScanningwithoutAreaCode]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE PROCEDURE [dbo].[Usp_InsertOutwardScanningwithoutAreaCode] @BARCODE_NUMBER varchar(50), @AWB_NUMBER varchar(50), @ACCOUNT_NUMBER varchar(50), @REFERENCE_NUMBER varchar(50),

@CUSTOMER_FIRST_NAME varchar(50), @PARTY int, @CUSTOMER_ADDRESS varchar(2500), @PRIORITY varchar(50), @CREATED_BY varchar(50), @TAT int, @BILLCYCLE varchar(50), @Error varchar(100) out AS declare @cnt int select @cnt= count(*) from dbo.[OUTWARD_WITHOUTAREACODE] where IS_DELETED=0 and BARCODE_NUMBER= @BARCODE_NUMBER if(@cnt>0) begin set @Error=''AWB or Barcode already exists'' end else begin set nocount on; INSERT INTO dbo.[OUTWARD_WITHOUTAREACODE] ( BARCODE_NUMBER, AWB_NUMBER, ACCOUNT_NUMBER, REFERENCE_NUMBER, CUSTOMER_FIRST_NAME, PARTY, CUSTOMER_ADDRESS, PRIORITY, TAT, BILLCYCLE, IS_DELETED, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE ) VALUES ( @BARCODE_NUMBER, @AWB_NUMBER, @ACCOUNT_NUMBER, @REFERENCE_NUMBER, @CUSTOMER_FIRST_NAME, @PARTY, @CUSTOMER_ADDRESS, @PRIORITY, @TAT, @BILLCYCLE, 0, @CREATED_BY, getdate(), @CREATED_BY, getdate() ) set @Error=@AWB_NUMBER

end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetSoftCopyDetailsByBarcode]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_GetSoftCopyDetailsByBarcode] -- ''6208282'' ( @BARCODE varchar(50) ) AS begin set nocount on SELECT [BARCODE] , [ACC_NO] , [BILL_REF_NO] , [NAME] , [BILL_CYCLE] , [PRIORITY], TELEPHONE_NO , ALTERNATE_CONTACT_NO, FLAT_NO, STREET_NAME, CITY, STATE, PIN_CODE, PARTY_CODE FROM [SOFT_COPY] where [BARCODE]=@BARCODE end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_GetReportsForInwardScanning]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE procedure [dbo].[Usp_GetReportsForInwardScanning] --''0'',''0'',''0'',''0 '',''0'',''0'',''2011-02-11 00:00:00.000'',''3000-02-19 00:00:00.000'' ( @FromAWB_NUMBER varchar(50), @ToAWB_NUMBER varchar(50), @PARTY_CODE varchar(50), @BILLCYCLE varchar(50), @PRIORITY varchar(50), @CREATED_BY varchar(50), @From_Date varchar(50), @To_Date varchar(50) ) as begin declare @str varchar(6000) declare @maxAWB_NUMBER varchar(50) declare @minAWB_NUMBER varchar(50) select @maxAWB_NUMBER= max(AWB_NUMBER) from [INWARD_SCANNING] where IS_DELETED=0 select @minAWB_NUMBER= max(AWB_NUMBER) from [INWARD_SCANNING] where IS_DELETED=0 set @str='' select BARCODE_NUMBER as Barcode_Number , AWB_NUMBER as AWB_Number, ACCOUNT_NUMBER as Account_Number, REFERENCE_NUMBER as Reference_Number, Party = (Select Category_Name from Categories where Category_ID = PARTY_CODE), BILLCYCLE as BillCycle , FIRST_NAME as First_Name, PRIORITY as Priority, TAT, CONTACT_NO as Contact_No, ALTERNATE_CONTACT_NO as Alternate_Contact_No, FLAT_NO as [Flat no], STREET_NAME as [Street Name], CITY as City, STATE as State, PINCODE as Pincode, Created_By , convert(varchar,Created_Date,105) as Created_Date From INWARD_SCANNING where IS_ DELETED=0 '' if(@From_Date!=''2000-01-01 00:00:00.000'' and @To_Date!=''2000-01-01 00:00:00.0 00'') Begin set @str=@str+'' and '' +''Created_Date between ''''''+ @From_Date+'''''' and ''''''+@To_Date+''''''''

End Else Begin if not @From_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''Created_Date BETWEEN ''''''+ @From_Date+'''''' and ''''''+''3000-02-19 00:00:00.000''+'''''''' print(@str) if not @To_Date= ''2000-01-01 00:00:00.000'' set @str=@str+'' and '' +''Created_Date between ''''''+''2000-01-01 00:00:00.0 00''+'''''' and ''''''+@To_Date+'''''''' print(@str) End if(@PARTY_CODE!=''0'') set @str=@str + '' and INWARD_SCANNING.PARTY_CODE=''+@PARTY_CODE+'''' if(@BILLCYCLE!=''0'') set @str=@str + '' and INWARD_SCANNING.BILLCYCLE=''''''+@BILLCYCLE +'''''''' if(@PRIORITY!=''0'') set @str=@str + '' and INWARD_SCANNING.PRIORITY=''''''+@PRIORITY + '''''''' if(@CREATED_BY!=''0'') set @str=@str + ''and INWARD_SCANNING.CREATED_BY=''''''+@CREATED_BY + '''''''' if(@FromAWB_NUMBER!=''0'' and @ToAWB_NUMBER!=''0'') Begin set @str=@str+'' and '' +''AWB_NUMBER between ''''''+ @FromAWB_NUMBER+'''''' a nd ''''''+@ToAWB_NUMBER + '''''''' End Else Begin if not @FromAWB_NUMBER= ''0'' set @str=@str+'' and '' +''AWB_NUMBER between ''''''+ @FromAWB_NUMBER+'''''' a nd ''''''+@ToAWB_NUMBER + '''''''' if not @ToAWB_NUMBER= ''0'' set @str=@str+'' and '' +''AWB_NUMBER between ''''''+@FromAWB_NUMBER+'''''' an d ''''''+@ToAWB_NUMBER + '''''''' End exec(@str) print(@str) End ' END GO SET ANSI_NULLS ON GO

SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_InsertInwardScanningDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'-- ======================================= ====== --Procedure Name :Usp_InsertInwardScanningDetails --Created By :Ramana.N --Created Date :01-09-2010 --Modified By : --Modified Date :04-01-2011 --Description :To Insert The Inward Scanning Details -- ============================================= CREATE PROCEDURE [dbo].[Usp_InsertInwardScanningDetails]-- ''6208290'',88,'''',' ''',''1'','''','''','''',''2'',''1'','''','''','''',''22222'',''SUuuu'','''',''' ' ( @BARCODE_NUMBER varchar(50), @AWB_NUMBER int, @ACCOUNT_NUMBER varchar(50), @REFERENCE_NUMBER varchar(50), @PARTY_CODE int, @AREA_CODE int, @BILLCYCLE varchar(50), @FIRST_NAME varchar(50), @PRIORITY varchar(50), @TAT int, @CONTACT_NO varchar(50), @ALTERNATE_CONTACT_NO varchar(50), @FLAT_NO varchar(50), @STREET_NAME varchar(50), @CITY varchar(50), @STATE varchar(50), @PINCODE varchar(50), @CREATED_BY varchar(50), @Error varchar(100) out ) AS declare declare declare declare

@cnt int @maxcount int @AWBCount int @AWB int

IF(@AWB_NUMBER=0) BEGIN select @maxcount= max(AWB_NUMBER) from [INWARD_SCANNING] where IS_DELETE D=0 and CREATED_BY=@CREATED_BY select @AWBCount=count(*) from [INWARD_SCANNING] where IS_DELETED=0 if(@AWBCount=0) begin SET @maxcount=0 end SET @AWB_NUMBER = @maxcount + 1 END select @cnt= count(*) from [INWARD_SCANNING] where AWB_NUMBER= @AWB_NUMBER or B

ARCODE_NUMBER=@BARCODE_NUMBER and IS_DELETED=0 if(@cnt>0) begin set @Error=''Barcode or AWB already exists'' end else begin INSERT INTO [INWARD_SCANNING] ( BARCODE_NUMBER, AWB_NUMBER, ACCOUNT_NUMBER, REFERENCE_NUMBER, PARTY_CODE, AREA_CODE, BILLCYCLE, FIRST_NAME, PRIORITY, TAT, CONTACT_NO , ALTERNATE_CONTACT_NO , FLAT_NO , STREET_NAME , CITY , STATE , PINCODE, IS_DELETED, CREATED_BY, CREATED_DATE, MODIFIED_BY, MODIFIED_DATE ) VALUES ( @BARCODE_NUMBER, @AWB_NUMBER, @ACCOUNT_NUMBER, @REFERENCE_NUMBER, @PARTY_CODE, @AREA_CODE, @BILLCYCLE, @FIRST_NAME, @PRIORITY, @TAT, @CONTACT_NO , @ALTERNATE_CONTACT_NO , @FLAT_NO, @STREET_NAME , @CITY , @STATE , @PINCODE, 0, @CREATED_BY, getdate(), @CREATED_BY, getdate() )

set @Error=''Saved Successfully'' end

' END GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Us p_UpdateInwardScanningDetails]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N' CREATE PROCEDURE [dbo].[Usp_UpdateInwardScanningDetails] ( @BARCODE_NUMBER varchar(50), @ACCOUNT_NUMBER varchar(50), @REFERENCE_NUMBER varchar(50), @BILLCYCLE varchar(50), @FIRST_NAME varchar(50), @PRIORITY varchar(50), @CONTACT_NO varchar(50), @ALTERNATE_CONTACT_NO varchar(50), @FLAT_NO varchar(50), @STREET_NAME varchar(50), @CITY varchar(50), @STATE varchar(50), @PINCODE varchar(50), @RESULT varchar(100) out ) AS BEGIN try set nocount on; begin transaction Update INWARD_SCANNING SET BARCODE_NUMBER=@BARCODE_NUMBER, ACCOUNT_NUMBER=@ACCOUNT_NUMBER, REFERENCE_NUMBER=@REFERENCE_NUMBER, BILLCYCLE=@BILLCYCLE, FIRST_NAME=@FIRST_NAME, PRIORITY=@PRIORITY, CONTACT_NO =@CONTACT_NO, ALTERNATE_CONTACT_NO=@ALTERNATE_CONTACT_NO , FLAT_NO=FLAT_NO, STREET_NAME=STREET_NAME, CITY =CITY, STATE =STATE, PINCODE = PINCODE where BARCODE_NUMBER=@BARCODE_NUMBER SET @RESULT=''Updated successfully''

commit END try begin catch if @@trancount > 0 rollback end catch

' END GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo ].[FK_COMPLAINTS_ALLOCATION_COMPLAINT_MANAGER]') AND parent_object_id = OBJECT_I D(N'[dbo].[COMPLAINTS_ALLOCATION]')) ALTER TABLE [dbo].[COMPLAINTS_ALLOCATION] WITH CHECK ADD CONSTRAINT [FK_COMPLA INTS_ALLOCATION_COMPLAINT_MANAGER] FOREIGN KEY([COMPLAINT_ALLOCATED_ID]) REFERENCES [dbo].[COMPLAINTS_ALLOCATION] ([COMPLAINT_ALLOCATED_ID]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo ].[FK_TELESCANNING_INWARD_SCANNING]') AND parent_object_id = OBJECT_ID(N'[dbo].[ TELESCANNING]')) ALTER TABLE [dbo].[TELESCANNING] WITH CHECK ADD CONSTRAINT [FK_TELESCANNING_IN WARD_SCANNING] FOREIGN KEY([TELESCANNING_ID]) REFERENCES [dbo].[TELESCANNING] ([TELESCANNING_ID]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo ].[FK_BRANCH_OPERATIONS_OUTWARD_SCANNING]') AND parent_object_id = OBJECT_ID(N'[ dbo].[BRANCH_OPERATIONS]')) ALTER TABLE [dbo].[BRANCH_OPERATIONS] WITH CHECK ADD CONSTRAINT [FK_BRANCH_OPE RATIONS_OUTWARD_SCANNING] FOREIGN KEY([AWB_NUMBER]) REFERENCES [dbo].[OUTWARD_SCANNING] ([AWB_NUMBER]) GO

IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo ].[FK_SCREEN_PERMISIONS_SCREENS]') AND parent_object_id = OBJECT_ID(N'[dbo].[SCR EEN_PERMISIONS]')) ALTER TABLE [dbo].[SCREEN_PERMISIONS] WITH NOCHECK ADD CONSTRAINT [FK_SCREEN_P ERMISIONS_SCREENS] FOREIGN KEY([SCREEN_ID]) REFERENCES [dbo].[SCREENS] ([SCREEN_ID]) GO ALTER TABLE [dbo].[SCREEN_PERMISIONS] CHECK CONSTRAINT [FK_SCREEN_PERMISIONS_SCR EENS] GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo ].[FK_ELECTRONIC_DATA_PROCESSING_STATUS_UPDATION]') AND parent_object_id = OBJEC T_ID(N'[dbo].[ELECTRONIC_DATA_PROCESSING]')) ALTER TABLE [dbo].[ELECTRONIC_DATA_PROCESSING] WITH CHECK ADD CONSTRAINT [FK_E LECTRONIC_DATA_PROCESSING_STATUS_UPDATION] FOREIGN KEY([AWB_NUMBER]) REFERENCES [dbo].[STATUS_UPDATION] ([AWB_NUMBER]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo ].[FK_STATUS_UPDATION_INWARD_SCANNING]') AND parent_object_id = OBJECT_ID(N'[dbo ].[STATUS_UPDATION]')) ALTER TABLE [dbo].[STATUS_UPDATION] WITH CHECK ADD CONSTRAINT [FK_STATUS_UPDAT ION_INWARD_SCANNING] FOREIGN KEY([AWB_NUMBER]) REFERENCES [dbo].[INWARD_SCANNING] ([AWB_NUMBER]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo ].[FK_OUTWARD_SCANNING_INWARD_SCANNING1]') AND parent_object_id = OBJECT_ID(N'[d bo].[OUTWARD_SCANNING]')) ALTER TABLE [dbo].[OUTWARD_SCANNING] WITH CHECK ADD CONSTRAINT [FK_OUTWARD_SCA NNING_INWARD_SCANNING1] FOREIGN KEY([AWB_NUMBER]) REFERENCES [dbo].[INWARD_SCANNING] ([AWB_NUMBER]) GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo ].[FK_COMPLAINT_MANAGER_INWARD_SCANNING]') AND parent_object_id = OBJECT_ID(N'[d bo].[COMPLAINT_MANAGER]')) ALTER TABLE [dbo].[COMPLAINT_MANAGER] WITH NOCHECK ADD CONSTRAINT [FK_COMPLAIN T_MANAGER_INWARD_SCANNING] FOREIGN KEY([AWB_NUMBER]) REFERENCES [dbo].[INWARD_SCANNING] ([AWB_NUMBER]) GO ALTER TABLE [dbo].[COMPLAINT_MANAGER] CHECK CONSTRAINT [FK_COMPLAINT_MANAGER_INW ARD_SCANNING] GO IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo ].[FK_TELECALLING_INWARD_SCANNING]') AND parent_object_id = OBJECT_ID(N'[dbo].[T ELECALLING]')) ALTER TABLE [dbo].[TELECALLING] WITH CHECK ADD CONSTRAINT [FK_TELECALLING_INWA RD_SCANNING] FOREIGN KEY([AWB_NUMBER]) REFERENCES [dbo].[INWARD_SCANNING] ([AWB_NUMBER])