using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Globalization;

namespace WareHouse
{
    class FirstClass
    {
        SqlConnection con;
        public SqlCommand cmd;
        DataTable dt;
        SqlDataAdapter da;

        public FirstClass()
        {
            con = new SqlConnection(Properties.Settings.Default.DBWare_mdbConnectionString.ToString());//"server=(local);Database=Anbar;trusted_connection=yes;");
            
            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 exeCommand(string strName)
        {
            con.Open();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = strName;
            cmd.ExecuteNonQuery();
            con.Close();

        }
        public void exeCommand1(string strName)
        {
            try
            {
                cmd.CommandText = strName;
                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;
        }
    }
    static class GlobalClass //set= GlobalClass.GlobalVar = "aliki"; Get= MessageBox.Show(GlobalClass.GlobalVar);
    {
        private static string m_globalVar = "";
        public static string GlobalVar
        {
            get
            {
                return m_globalVar;
            }
            set
            {
                m_globalVar = value;
            }
        }
    }
}
