using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text.RegularExpressions;
using System.Data;
using System.Data.OracleClient;

/// <summary>
/// Summary description for Validate_Regix_Manager
/// </summary>
public class Validate_Manager
{
    public Validate_Manager()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    public static bool Validate_Data(string input,int ID)
    {
          DataTable dtRes = new DataTable();
            try
            {
                 string DBConnection = Helper.dbConnection();

                  OracleConnection oracon = new OracleConnection(DBConnection);
       
                OracleCommand oraCom = new OracleCommand();
                oraCom.CommandText = "select * from Validate_Regex_Manager where ID  =" + ID + "";
                oraCom.Connection = oracon;
                OracleDataAdapter da = new OracleDataAdapter(oraCom);
               

                da.Fill(dtRes);
                if (dtRes.Rows.Count > 0)
                    return Regex.IsMatch(input, dtRes.Rows[0]["REGEX"].ToString());
                else
                    return false;

       
            
            }
            catch (Exception ex)
            {
                return false; 
            }
        
          

    }

    public static bool Validate_Data_Message(string input, int ID, out string ErrorMesage)
    {
        DataTable dtRes = new DataTable();
        try
        {
            string DBConnection = Helper.dbConnection();

            OracleConnection oracon = new OracleConnection(DBConnection);

            OracleCommand oraCom = new OracleCommand();
            oraCom.CommandText = "select * from Validate_Regex_Manager where ID  =" + ID + ")";
            oraCom.Connection = oracon;
            OracleDataAdapter da = new OracleDataAdapter(oraCom);

            ErrorMesage = "";
            da.Fill(dtRes);
            if (dtRes.Rows.Count > 0)
            {
                ErrorMesage = "";
                return Regex.IsMatch(input, dtRes.Rows[0]["REGEX"].ToString());

            }
            else
                return false;



        }
        catch (Exception ex)
        {
            ErrorMesage = ex.Message;
            return false;
        }



    }
}