using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Globalization;


/// <summary>
/// Summary description for DataOperation
/// </summary>
namespace DataOper
{
    public class DataOperation
    {

        public DataOperation()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public DataTable return_dt(string sqlQuery)
        {
            DataTable dt = new DataTable();
            SqlConnection con = new SqlConnection();
            con.ConnectionString = ConfigurationManager.ConnectionStrings["Myconn"].ToString();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandText = sqlQuery;
            SqlDataAdapter ad = new SqlDataAdapter();
            ad.SelectCommand = cmd;
            ad.Fill(dt);
            return dt;

        }

        public int sqlExec(string sqlQuery)
        {
            int NoOfAffectedRow=0;
            SqlConnection con = new SqlConnection();
            con.ConnectionString = ConfigurationManager.ConnectionStrings["Myconn"].ToString();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandText = sqlQuery;
            con.Open();
            NoOfAffectedRow = cmd.ExecuteNonQuery();
            con.Close();
            return NoOfAffectedRow;

        }

        public string DateEntry(string date)
        {
            if (date != "")
            {
                date = DateTime.ParseExact(date, "yyyy-MM-dd", CultureInfo.InvariantCulture).ToString("dd-MMM-yyyy");
            }
            return date;
        }

        public string DateShow(string date)
        {
            if (date != "")
            {
                date = Convert.ToDateTime(date).ToString("dd-MMM-yyyy");
            }
            return date;
        }
        
    }
}