/*Below Different Tab controls themes*/

/* ajax__tab_xp-theme theme */

.Tab .ajax__tab_header
{
    color: #4682b4;
    font-family: Calibri;
    font-size: 14px;
    font-weight: bold;
    background: url("../../Images/black_navi.jpg") repeat-x;
    margin-left: 0px;
    width: 980px;
    height: 38px;
    vertical-align: middle;
}
/*Body*/
.Tab .ajax__tab_body
{
    border: 1px solid #b4cbdf;
    padding-top: 0px;
    width: 978px;
    padding-bottom: 10px;
}
/*Tab Active*/
.Tab .ajax__tab_active .ajax__tab_tab
{
    color: #75BECF;
    background: url("../../Images/tab_active.gif") repeat-x;
    height: 20px;
}
.Tab .ajax__tab_active .ajax__tab_inner
{
    color: #75BECF;
    background: url("../../Images/tab_active.gif") no-repeat left;
    padding-left: 10px;
}
.Tab .ajax__tab_active .ajax__tab_outer
{
    color: #75BECF;
    background: url("../../Images/tab_active.gif") no-repeat right;
    padding-right: 6px;
    margin-top: 8px;
}
/*Tab Hover*/
.Tab .ajax__tab_hover .ajax__tab_tab
{
    color: #75BECF;
    background: url("../../Images/tab_hover.gif") repeat-x;
    height: 20px;
}
.Tab .ajax__tab_hover .ajax__tab_inner
{
    color: #75BECF;
    background: url("../../Images/tab_hover.gif") no-repeat left;
    padding-left: 10px;
}
.Tab .ajax__tab_hover .ajax__tab_outer
{
    color: #75BECF;
    background: url("../../Images/tab_hover.gif") no-repeat right;
    padding-right: 6px;
}
/*Tab Inactive*/
.Tab .ajax__tab_tab
{
    color: #ffffff;
    background: url("../../Images/tab_Inactive.gif") repeat-x;
    height: 20px;
}
.Tab .ajax__tab_inner
{
    color: #ffffff;
    background: url("../../Images/tab_inactive.gif") no-repeat left;
    padding-left: 10px;
}
.Tab .ajax__tab_outer
{
    padding-right: 6px;
    margin-right: 1px;
    border-right: 1px solid #FFFFFF;
}
/*Above Different Tab controls theme*/


/*Below Calendar controls themes*/
.MyCalendar .ajax__calendar_container
{
    background-color: #e2e2e2;
    border: solid 1px #cccccc;
}

.MyCalendar .ajax__calendar_header
{
    background-color: #ffffff;
    margin-bottom: 4px;
}


.MyCalendar .MyCalendar .ajax__calendar_next, .MyCalendar .ajax__calendar_prev
{
    color: #004080;
    padding-top: 3px;
}

.MyCalendar .ajax__calendar_title
{
    color: #004080;
    padding-bottom:5px;
}

.MyCalendar .ajax__calendar_body
{
    background-color: #e9e9e9;
    border: solid 1px #cccccc;
}

.MyCalendar .ajax__calendar_dayname
{
    text-align: center;
    font-weight: bold;
    margin-bottom: 4px;
    margin-top: 2px;
}

.MyCalendar .ajax__calendar_day
{
    text-align: center;
}

.MyCalendar .ajax__calendar_hover .ajax__calendar_day, .MyCalendar .ajax__calendar_hover .ajax__calendar_month, .MyCalendar .ajax__calendar_hover .ajax__calendar_year, .MyCalendar .ajax__calendar_active
{
    color: #004080;
    font-weight: bold;
    background-color: #ffffff;
}

.MyCalendar .ajax__calendar_today
{
    font-weight: bold;
    padding-top:0px;
    padding-bottom:5px;
}

.MyCalendar .ajax__calendar_other, .MyCalendar .ajax__calendar_hover .ajax__calendar_today, .MyCalendar .ajax__calendar_hover .ajax__calendar_title
{
    color: #bbbbbb;
}
/*Above Calendar controls theme*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Text;

namespace DataBaseService
{
    public partial class DataBaseService : IDataBaseService
    {
        public static string ConnectionString = Convert.ToString(System.Configuration.ConfigurationManager.ConnectionStrings["con"]);

        static SqlConnection GlobalConn()
        {
            SqlConnection sql = new SqlConnection(ConnectionString);
            return sql;
        }

        public  DataSet GetDataSet(string uspName, string[] paramArray, object[] valueArray)
        {
            SqlConnection con = null;
            DataSet dataSet;
            SqlDataAdapter sqlDataAdapter;
            SqlCommand sqlCommand;
            int i;
            dataSet = new DataSet();
            try
            {
                sqlDataAdapter = new SqlDataAdapter();
                sqlDataAdapter.SelectCommand = new SqlCommand();
                con = GlobalConn();
                con.Open();

                sqlDataAdapter.SelectCommand.Connection = con;

                sqlCommand = sqlDataAdapter.SelectCommand;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = uspName;
                i = 0;
                while ((((!paramArray.Length.Equals(0)) && (!valueArray.Length.Equals(0))) && (paramArray.Length.Equals(valueArray.Length))) && (i < paramArray.Length))
                {
                    if (paramArray[i] != null)
                    {
                        sqlCommand.Parameters.AddWithValue(paramArray[i], valueArray[i]);
                    }
                    i++;
                }
                sqlDataAdapter.Fill(dataSet);

            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message, Ex);
            }
            finally
            {
                con.Close();
            }
            return dataSet;
        }

        public DataSet GetDataSetWithOutParam(string spName)
        {
            SqlConnection con = null;
            DataSet dataSet;
            SqlDataAdapter sqlDataAdapter;
            SqlCommand sqlCommand;
            dataSet = new DataSet();
            try
            {
                sqlDataAdapter = new SqlDataAdapter();
                sqlDataAdapter.SelectCommand = new SqlCommand();
                con = GlobalConn();
                con.Open();

                sqlDataAdapter.SelectCommand.Connection = con;

                sqlCommand = sqlDataAdapter.SelectCommand;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = spName;
                sqlDataAdapter.Fill(dataSet);
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message, Ex);
            }
            finally
            {
                con.Close();
            }
            return dataSet;
        }

        public DataSet GetDataSetReturnWithParam(string uspName, string[] paramArray, object[] valueArray, string OutParamName, out Int32 OutParam)
        {
            SqlConnection con = null;
            DataSet dataSet;
            SqlDataAdapter sqlDataAdapter;
            SqlCommand sqlCommand;
            int i;
            dataSet = new DataSet();
            OutParam = 0;
            try
            {
                sqlDataAdapter = new SqlDataAdapter();
                sqlDataAdapter.SelectCommand = new SqlCommand();
               
                con = GlobalConn();
                con.Open();

                sqlDataAdapter.SelectCommand.Connection = con;

                sqlCommand = sqlDataAdapter.SelectCommand;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = uspName;
                i = 0;
                while ((((!paramArray.Length.Equals(0)) && (!valueArray.Length.Equals(0))) && (paramArray.Length.Equals(valueArray.Length))) && (i < paramArray.Length))
                {
                    if (paramArray[i] != null)
                    {
                        sqlCommand.Parameters.AddWithValue(paramArray[i], valueArray[i]);
                    }
                    i++;
                }
                //Set out parameter
                sqlCommand.Parameters.AddWithValue(OutParamName, OutParam);
                sqlCommand.Parameters[OutParamName].Direction = ParameterDirection.Output;
                sqlCommand.Parameters[OutParamName].DbType = System.Data.DbType.Int32;
                sqlDataAdapter.Fill(dataSet);
                if (sqlCommand.Parameters[OutParamName] != null)
                {
                    OutParam = Convert.ToInt32(sqlCommand.Parameters[OutParamName].Value); //sqlCommand.Parameters.Add(OutParamName, SqlDbType.Int)
                }
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message, Ex);
            }
            finally
            {
                con.Close();
            }
            return dataSet;
        }

        public DataSet GetDataSetWithReturnValue(string uspName, string[] paramArray, object[] valueArray, out Int32 OutParam)
        {
            SqlConnection con = null;
            DataSet dataSet;
            SqlDataAdapter sqlDataAdapter;
            SqlCommand sqlCommand;
            int i;
            dataSet = new DataSet();
            OutParam = 0;
            string OutParamName = "@ReturnValue";

            try
            {
                sqlDataAdapter = new SqlDataAdapter();
                sqlDataAdapter.SelectCommand = new SqlCommand();
                con = GlobalConn();
                con.Open();

                sqlDataAdapter.SelectCommand.Connection = con;

                sqlCommand = sqlDataAdapter.SelectCommand;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = uspName;
                i = 0;
                while ((((!paramArray.Length.Equals(0)) && (!valueArray.Length.Equals(0))) && (paramArray.Length.Equals(valueArray.Length))) && (i < paramArray.Length))
                {
                    if (paramArray[i] != null)
                    {
                        sqlCommand.Parameters.AddWithValue(paramArray[i], valueArray[i]);
                    }
                    i++;
                }
                //Set out parameter
                sqlCommand.Parameters.AddWithValue(OutParamName, OutParam);
                sqlCommand.Parameters[OutParamName].Direction = ParameterDirection.ReturnValue;
                sqlCommand.Parameters[OutParamName].SqlDbType = SqlDbType.Int;
                sqlDataAdapter.Fill(dataSet);
                if (sqlCommand.Parameters[OutParamName] != null)
                {
                    OutParam = Convert.ToInt32(sqlCommand.Parameters[OutParamName].Value); //sqlCommand.Parameters.Add(OutParamName, SqlDbType.Int)
                }
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message, Ex);
            }
            finally
            {
                con.Close();
            }
            return dataSet;
        }

        public  DataTable GetDataTable(string uspName, string strParam, string strMain)
        {
            SqlConnection con = null;
            DataTable dataTable;
            SqlDataAdapter sqlDataAdapter;
            dataTable = new DataTable();
            try
            {
                sqlDataAdapter = new SqlDataAdapter();
                sqlDataAdapter.SelectCommand = new SqlCommand();
                con = GlobalConn();
                con.Open();

                sqlDataAdapter.SelectCommand.Connection = con;
                SqlCommand sqlCommand = sqlDataAdapter.SelectCommand;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = uspName;
                sqlCommand.Parameters.Add(strParam, SqlDbType.VarChar).Value = strMain;
                sqlDataAdapter.Fill(dataTable);
            }
            catch (Exception Ex)
            {
                //GlobalConnection.dtlMessageBox = new SgtDetailMsgBox("Problem in Getting Data.", Ex.Message);
                throw new Exception(Ex.Message, Ex);
            }
            finally
            {
                con.Close();
            }
            return dataTable;
        }

        public  void ExecuteSPReturn(string uspName)
        {
            SqlConnection con = null;
            try
            {
                SqlCommand sqlCommand = new SqlCommand();
                con = GlobalConn();
                con.Open();

                sqlCommand.Connection = con;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = uspName;
                sqlCommand.ExecuteNonQuery();
               
            }
            catch (Exception Ex)
            {
                //GlobalConnection.dtlMessageBox = new SgtDetailMsgBox("Problem occured during execution.", Ex.Message);
                throw new Exception(Ex.Message, Ex);
            }
            finally
            {
                con.Close();
            }
        }

        public  object ExecuteSPReturnWithParam(string uspName, string[] ParamArr, object[] ValueArr, object OutParam)
        {
            SqlConnection con = null;
            string str;
            SqlCommand sqlCommand;
            int i;
            try
            {
                str = "";
                sqlCommand = new SqlCommand();
                con = GlobalConn();
               
                SqlConnection sqlCon = con;
                sqlCon.Open();
                sqlCommand.Connection = sqlCon;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = uspName;
                if ((ParamArr.Length.Equals(0)) || (ValueArr.Length.Equals(0)))
                {
                    return "";
                }
                if (!ParamArr.Length.Equals(ValueArr.Length))
                {
                    return "";
                }
                i = 0;
                while (i < ParamArr.Length)
                {
                    if (ParamArr[i] != null)
                    {
                        sqlCommand.Parameters.AddWithValue(ParamArr[i], ValueArr[i]);
                    }
                    str = string.Concat(str, ",", ValueArr[i].ToString());
                    i++;
                }
                sqlCommand.Parameters["@OutParam"].Direction = ParameterDirection.Output;
                sqlCommand.Parameters["@OutParam"].DbType = System.Data.DbType.Int64;
                sqlCommand.ExecuteNonQuery();
                OutParam = sqlCommand.Parameters.Add("@OutParam", SqlDbType.BigInt).Value;
                sqlCon.Close();
               
            }
            catch (Exception Ex)
            {
                //GlobalConnection.dtlMessageBox = new SgtDetailMsgBox("Problem occured during execution.", Ex.Message);
                throw new Exception(Ex.Message, Ex);
            }
            finally
            {
                con.Close();
            }
            return OutParam;
        }

        public  long SetAddDataXML(string uspName, DataSet ds, long ID )
        {
            SqlConnection con = null;
            object obj;
            string str;
            SqlDataAdapter sqlDataAdapter;
            obj = new object();
            str = "";
            obj = 0;
            try
            {
                sqlDataAdapter = new SqlDataAdapter();
                sqlDataAdapter.SelectCommand = new SqlCommand();
                con = GlobalConn();
                con.Open();

                sqlDataAdapter.SelectCommand.Connection = con;
               
                SqlCommand sqlCommand = sqlDataAdapter.SelectCommand;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = uspName;
                MemoryStream memoryStream = new MemoryStream();
                ds.WriteXml(memoryStream);
                memoryStream.Position = 0;
                StreamReader streamReader = new StreamReader(memoryStream);
                str = streamReader.ReadToEnd();
                sqlCommand.Parameters.AddWithValue("@AddData", str);
                //sqlCommand.Parameters.AddWithValue("@MasterType", mstType);
                sqlCommand.Parameters["@Outparam"].Direction = ParameterDirection.Output;
                sqlCommand.ExecuteNonQuery();
                obj = sqlCommand.Parameters.Add("@Outparam", SqlDbType.BigInt).Value;

              


            }
            catch (Exception Ex)
            {
                //GlobalConnection.dtlMessageBox = new SgtDetailMsgBox("Problem occured during execution. Unable to save data.", Ex.Message);
                throw new Exception(Ex.Message, Ex);
            }
            finally
            {
                con.Close();
            }
            return Convert.ToInt64(obj);
        }

        public  void ExecuteSQLQuery(string sStr)
        {
            SqlConnection con = null;
            try
            {
               
                SqlCommand sqlCommand = new SqlCommand();
                con = GlobalConn();
                con.Open();

                sqlCommand.Connection = con;
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.CommandText = sStr;
                sqlCommand.ExecuteNonQuery();
            }
            catch (Exception Ex)
            {
                //GlobalConnection.dtlMessageBox = new SgtDetailMsgBox("Problem occured during execution. Unable to do the operation.", Ex.Message);
                throw new Exception(Ex.Message, Ex);
            }
            finally
            {
                con.Close();
            }
        }


        public int ExecuteNonQueryWithReturn(string uspName, string[] paramArray, object[] valueArray)
        {
            SqlConnection sqlCon = null;

            try
            {

                int result = 0;
                SqlCommand sqlCommand = new SqlCommand();
                sqlCon = GlobalConn();
                sqlCon.Open();

                sqlCommand.Connection = sqlCon;

                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = uspName;
                int i = 0;
                while ((((!paramArray.Length.Equals(0)) && (!valueArray.Length.Equals(0))) && (paramArray.Length.Equals(valueArray.Length))) && (i < paramArray.Length))
                {
                    if (paramArray[i] != null)
                    {
                        sqlCommand.Parameters.AddWithValue(paramArray[i], valueArray[i]);
                    }
                    i++;
                }
                SqlParameter myParm = sqlCommand.Parameters.Add("@ReturnValue", SqlDbType.Int);
                sqlCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.ReturnValue;
                sqlCommand.ExecuteNonQuery();
                result = (Int32)sqlCommand.Parameters["@ReturnValue"].Value;


                return result;

            }
            catch (Exception Ex)
            {

                throw new Exception(Ex.Message, Ex);

            }
            finally
            {
                sqlCon.Close();
            }
          
        }

        public int ExecuteNonQueryWithReturn(string uspName, string param, System.Data.SqlTypes.SqlXml value)
        {
            SqlConnection sqlCon = null;

            try
            {

                int result = 0;
                SqlCommand sqlCommand = new SqlCommand();
                sqlCon = GlobalConn();
                sqlCon.Open();

                sqlCommand.Connection = sqlCon;

                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = uspName;
               
                sqlCommand.Parameters.Add(param, SqlDbType.Xml);
                sqlCommand.Parameters[param].Value = value.Value.Replace(" xmlns=\"http://tempuri.org/\"", "");
               
                SqlParameter myParm = sqlCommand.Parameters.Add("@ReturnValue", SqlDbType.Int);
                sqlCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.ReturnValue;

                sqlCommand.ExecuteNonQuery();
                result = (Int32)sqlCommand.Parameters["@ReturnValue"].Value;


                return result;

            }
            catch (Exception Ex)
            {

                throw new Exception(Ex.Message, Ex);

            }
            finally
            {
                sqlCon.Close();
            }

        }



        public int ExecuteNonQueryWithSaveXML(string uspName, string[] paramArray, object[] valueArray, string xmlparam, System.Data.SqlTypes.SqlXml value)
        {
            SqlConnection sqlCon = null;

            try
            {

                int result = 0;
                SqlCommand sqlCommand = new SqlCommand();
                sqlCon = GlobalConn();
                sqlCon.Open();

                sqlCommand.Connection = sqlCon;

                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = uspName;
                int i = 0;
                while ((((!paramArray.Length.Equals(0)) && (!valueArray.Length.Equals(0))) && (paramArray.Length.Equals(valueArray.Length))) && (i < paramArray.Length))
                {
                    if (paramArray[i] != null)
                    {
                        sqlCommand.Parameters.AddWithValue(paramArray[i], valueArray[i]);
                    }
                    i++;
                }
              
                sqlCommand.Parameters.Add(xmlparam, SqlDbType.Xml);
                sqlCommand.Parameters[xmlparam].Value = value.Value.Replace(" xmlns=\"http://tempuri.org/\"", "");

                SqlParameter myParm = sqlCommand.Parameters.Add("@ReturnValue", SqlDbType.Int);
                sqlCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.ReturnValue;

                sqlCommand.ExecuteNonQuery();
                result = (Int32)sqlCommand.Parameters["@ReturnValue"].Value;


                return result;

            }
            catch (Exception Ex)
            {

                throw new Exception(Ex.Message, Ex);

            }
            finally
            {
                sqlCon.Close();
            }

        }




        public int ExecuteSPWithReturn(string uspName)
        {
            SqlConnection con = null;
            int result = 0;
            try
            {
                SqlCommand sqlCommand = new SqlCommand();
                con = GlobalConn();
                con.Open();

                sqlCommand.Connection = con;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = uspName;
               
                sqlCommand.Parameters.Add("@ReturnValue", SqlDbType.Int);
                sqlCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.ReturnValue;

                sqlCommand.ExecuteNonQuery();
                result = (Int32)sqlCommand.Parameters["@ReturnValue"].Value;
            }
            catch (Exception Ex)
            {
                //GlobalConnection.dtlMessageBox = new SgtDetailMsgBox("Problem occured during execution.", Ex.Message);
                throw new Exception(Ex.Message, Ex);
            }
            finally
            {
                con.Close();
            }
            return result;
        }

        public int ExecuteNonQuery(string uspName, string[] paramArray, object[] valueArray)
        {
            SqlConnection sqlCon = null;
            try
            {
                int result=0;
                SqlCommand sqlCommand = new SqlCommand();
                 sqlCon= GlobalConn();
                sqlCon.Open();
                sqlCommand.Connection = sqlCon;
                   
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = uspName;
                int i = 0;
                while ((((!paramArray.Length.Equals(0)) && (!valueArray.Length.Equals(0))) && (paramArray.Length.Equals(valueArray.Length))) && (i < paramArray.Length))
                {
                    if (paramArray[i] != null)
                    {
                        sqlCommand.Parameters.AddWithValue(paramArray[i], valueArray[i]);
                    }
                    i++;
                }
                result = sqlCommand.ExecuteNonQuery();
                sqlCon.Close();
              return result;
             
            }
            catch (Exception Ex)
            {
               
                throw new Exception(Ex.Message, Ex);
               
            }
            finally
            {
                sqlCon.Close();
            }
          
        }

        
    }
}
/// <summary>
            /// Encrypt a string using dual encryption method. Return a encrypted cipher Text
            /// </summary>
            /// <param name="toEncrypt">string to be encrypted</param>
            /// <param name="useHashing">use hashing? send to for extra secirity</param>
            /// <returns></returns>
            public static string Encrypt(string toEncrypt, bool useHashing)
            {
                byte[] keyArray;
                byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);

                //System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
                // Get the key from config file
                //string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
                //By Rohit kumar
                string key = "truworth infotech limited";
                //System.Windows.Forms.MessageBox.Show(key);
                if (useHashing)
                {
                    MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                    keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                    hashmd5.Clear();
                }
                else
                    keyArray = UTF8Encoding.UTF8.GetBytes(key);

                TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
                tdes.Key = keyArray;
                tdes.Mode = CipherMode.ECB;
                tdes.Padding = PaddingMode.PKCS7;

                ICryptoTransform cTransform = tdes.CreateEncryptor();
                byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
                tdes.Clear();
                return Convert.ToBase64String(resultArray, 0, resultArray.Length);
            }


            /// <summary>
            /// DeCrypt a string using dual encryption method. Return a DeCrypted clear string
            /// </summary>
            /// <param name="cipherString">encrypted string</param>
            /// <param name="useHashing">Did you use hashing to encrypt this data? pass true is yes</param>
            /// <returns></returns>
            public static string Decrypt(string cipherString, bool useHashing)
            {
                byte[] keyArray;
                byte[] toEncryptArray = Convert.FromBase64String(cipherString);

                //System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
                //Get your key from config file to open the lock!
                //string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
                //BY Rohit kumar
                string key = "truworth infotech limited";

                if (useHashing)
                {
                    MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
                    keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                    hashmd5.Clear();
                }
                else
                    keyArray = UTF8Encoding.UTF8.GetBytes(key);

                TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
                tdes.Key = keyArray;
                tdes.Mode = CipherMode.ECB;
                tdes.Padding = PaddingMode.PKCS7;

                ICryptoTransform cTransform = tdes.CreateDecryptor();
                byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);

                tdes.Clear();
                return UTF8Encoding.UTF8.GetString(resultArray);
            }
<asp:RegularExpressionValidator ID="rgvClientCount" runat="server" ControlToValidate="txtClientCount"
                                ValidationExpression="^[1-9][0-9]{0,7}$" ErrorMessage="Numbers Only! (1-9999)"
                                Display="Dynamic" SetFocusOnError="true" ValidationGroup="Submit" />

UPDATE    Patient
SET    Patient_Area = Area.Area_Desc --etc
FROM    Patient
    JOIN
    Area ON Patient.Patient_Area=Area.Area_Id

USE [RiskCurve]
GO
/****** Object:  StoredProcedure [dbo].[CatchError]    Script Date: 02/09/2012 17:17:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*********************************************************
 Procedure Name: CatchError
 Version:        1.0
 Purpose:       This procedure is used to save ERROR LOG .                                                        
 Input:            Many peramnetrs
 Default value: None                                                                                  
 Output:       
 Returns:       
 Dependencies: 
 Tables:        Request
 Procedures:    No
 Created By:    Pradeep Kumar
 Created Date:  19-MAY-2011
 Checked by & Date:                                                              
 Modifier & Date:
 Modification Description:
 Modification Purpose:
 Limitations/Restriction:
 Algorithm:
 *********************************************************/


ALTER PROCEDURE [dbo].[CatchError]   
AS

BEGIN
   
    --To keep the error message
    Declare @ErrMsg as varchar(1000)
   
    BEGIN TRY 
       
        INSERT INTO dbo.Error_Log(Error_Date,Error_Msg,Error_Number,Error_Source )
        SELECT DATEADD(HOUR, 20, GETDATE()), ERROR_MESSAGE() ,ERROR_NUMBER(), ERROR_PROCEDURE()


    END TRY 
 
    BEGIN CATCH 
    
    END CATCH
   
    set @ErrMsg = ERROR_MESSAGE()
   
    Raiserror(@ErrMsg -- Error Message
        , 16 --Severity Level
        , 1 --State
        )

END