IF NOT EXISTS (SELECT * FROM AC_Setting.sys.columns  WHERE Name = N'CompLogo' AND Object_ID = Object_ID(N'AC_Setting.dbo.T_yCompanyName'))

ALTER TABLE AC_Setting.dbo.T_yCompanyName ADD
	CompLogo NVARCHAR(255)
GO

IF NOT EXISTS (SELECT * FROM AC_Setting.sys.columns  WHERE Name = N'AddressPic' AND Object_ID = Object_ID(N'AC_Setting.dbo.T_yCompanyName'))

ALTER TABLE AC_Setting.dbo.T_yCompanyName ADD
	AddressPic NVARCHAR(255)
GO

IF NOT EXISTS (SELECT * FROM AC_Setting.sys.columns  WHERE Name = N'CurrencyTitle' AND Object_ID = Object_ID(N'AC_Setting.dbo.T_yCompanyName'))

ALTER TABLE AC_Setting.dbo.T_yCompanyName ADD
	CurrencyTitle NVARCHAR(255)
GO

IF NOT EXISTS (SELECT * FROM AC_Setting.sys.columns  WHERE Name = N'MahaleFaaliyat' AND Object_ID = Object_ID(N'AC_Setting.dbo.T_yCompanyName'))

ALTER TABLE AC_Setting.dbo.T_yCompanyName ADD
	MahaleFaaliyat NVARCHAR(255)
GO

IF NOT EXISTS (SELECT * FROM AC_Setting.sys.columns  WHERE Name = N'ShomareSabt' AND Object_ID = Object_ID(N'AC_Setting.dbo.T_yCompanyName'))

ALTER TABLE AC_Setting.dbo.T_yCompanyName ADD
	ShomareSabt NVARCHAR(255)
GO


IF NOT EXISTS (SELECT * FROM AC_Setting.sys.columns  WHERE Name = N'Mobile' AND Object_ID = Object_ID(N'AC_Setting.dbo.T_yCompanyName'))

ALTER TABLE AC_Setting.dbo.T_yCompanyName ADD
	Mobile NVARCHAR(255)
GO

IF NOT EXISTS (SELECT * FROM AC_Setting.sys.columns  WHERE Name = N'ShenaseMelli' AND Object_ID = Object_ID(N'AC_Setting.dbo.T_yCompanyName'))

ALTER TABLE AC_Setting.dbo.T_yCompanyName ADD
	ShenaseMelli NVARCHAR(255)
GO

IF NOT EXISTS (SELECT * FROM AC_Setting.sys.columns  WHERE Name = N'Website' AND Object_ID = Object_ID(N'AC_Setting.dbo.T_yCompanyName'))

ALTER TABLE AC_Setting.dbo.T_yCompanyName ADD
	Website NVARCHAR(255)
GO

IF NOT EXISTS (SELECT * FROM AC_Setting.sys.columns  WHERE Name = N'Active' AND Object_ID = Object_ID(N'AC_Setting.dbo.T_YearMony'))

ALTER TABLE AC_Setting.dbo.T_YearMony ADD
	Active Bit
GO


IF NOT EXISTS (SELECT * FROM AC_Setting.sys.columns  WHERE Name = N'Pass2' AND Object_ID = Object_ID(N'AC_Setting.dbo.T_yUsers'))

ALTER TABLE AC_Setting.dbo.T_yUsers ADD
	Pass2 NVARCHAR(255)
GO

USE [AC_Setting]
GO


IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_YearMony_Edit_Date_Dore]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[T_YearMony_Edit_Date_Dore]
GO

USE [AC_Setting]
GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[T_YearMony_Edit_Date_Dore] 

@StrDes NVARCHAR(255),
@Date1 NVARCHAR(10),
@Date2 NVARCHAR(10)
   

AS
BEGIN
	
	DECLARE @D1 NVARCHAR(10)
	DECLARE @D2 NVARCHAR(10)
	
	IF (LEN(@Date1)<10)
		BEGIN
			SET @D1=left(@Date1,4)	+'/'+RIGHT(left(@Date1,6),2)+'/' +RIGHT(@Date1,2)
			SET @D2=left(@Date2,4)	+'/'+RIGHT(left(@Date2,6),2)+'/' +RIGHT(@Date2,2)
		END		
	ELSE
		BEGIN
			SET @D1=@Date1	
			SET @D2=@Date2	
		END			
UPDATE    AC_Setting.dbo.T_YearMony
SET              StartDate = @Date1, EndDate = @Date2, Name = N'از تاريخ ' + @D1 + N' الي ' + @D2
WHERE     (DBID = @StrDes)


	
END



              



GO



USE [AC_Setting]
GO


IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[T_YearMony_Active_DActive_Dore]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[T_YearMony_Active_DActive_Dore]
GO

USE [AC_Setting]
GO


SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE PROCEDURE [dbo].[T_YearMony_Active_DActive_Dore] 

@StrDes NVARCHAR(255),
@Active Bit	,
@ResultVal INT OUTPUT
   

AS
BEGIN
	
	DECLARE @Comp INT
	
	SELECT     @Comp=COMPANYID
	FROM         AC_Setting.dbo.T_YearMony
	WHERE     (DBID = @StrDes)
	
	SELECT     @ResultVal=COUNT(*)
	FROM         AC_Setting.dbo.T_YearMony
	WHERE     (COMPANYID = @Comp) AND (isnull(ACTIVE,1)<>0)

	IF (@Active<>0 )
		BEGIN

			UPDATE    AC_Setting.dbo.T_YearMony
			SET              Active = @Active
			WHERE     (DBID = @StrDes)
		END
	ELSE
		if (@ResultVal>1)
			UPDATE    AC_Setting.dbo.T_YearMony
			SET              Active = @Active
			WHERE     (DBID = @StrDes)
		ELSE
			SET @ResultVal=-2			
	
	
	
END



              



GO


IF NOT EXISTS (SELECT * FROM sys.columns  WHERE Name = N'EndEditOpNoe' AND Object_ID = Object_ID(N'AC_Setting.dbo.T_yUsers'))
ALTER TABLE AC_Setting.dbo.T_yUsers ADD
	EndEditOpNoe int NULL,
	EndEditOpValue int NULL,
	FlagAmin bit NULL,
	FlagAdamRoyatSanadAdmin bit NULL
GO
