using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Globalization;

namespace MainTemplate
{
    class Class_Db_Connection
    {
            SqlConnection con;
            public SqlCommand cmd;
            DataTable dt;
            SqlDataAdapter da;
            //SqlTriggerContext triggContext = SqlContext.TriggerContext;

            public Class_Db_Connection()
            {
                con = new SqlConnection(Properties.Settings.Default.HotelResJadConnectionString.ToString());
                cmd = new SqlCommand();
                dt = new DataTable();
                cmd.Connection = con;
                da = new SqlDataAdapter(cmd);
            }

            public DataTable dbOut(string sql)
            {
                cmd.CommandText = sql;
                con.Open();
                da.Fill(dt);
                con.Close();
                return dt;
            }



            public DataTable SP_dbOut(string SP_Name)
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = SP_Name;
                con.Open();
                da.Fill(dt);
                con.Close();
                return dt;
            }

            public void exeSp(string spName)
            {
                con.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = spName;
                cmd.ExecuteNonQuery();
                con.Close();

            }
            public void exeSqlCmd(string strSql)
            {
                try
                {
                    cmd.CommandText = strSql;
                    con.Open();
                    cmd.ExecuteNonQuery();
                }
                catch { }
                finally
                {
                    con.Close();
                }

            }

            public string dtShamsi()
            {
                string strMydate;
                PersianCalendar calFar1 = new PersianCalendar();
                strMydate = calFar1.GetYear(DateTime.Now).ToString() + "/" + calFar1.GetMonth(DateTime.Now).ToString("00") + "/" + calFar1.GetDayOfMonth(DateTime.Now).ToString("00");
                return strMydate;
            }
        
    }
}
