Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » Date / Time » Downloads
 
Add your own
alternative version

Persian Calendar with Tray Icon

, 12 Mar 2012 CPOL
A Persian calendar that shows a tray icon
traycalande-binary.zip
hijri.mdb
mytray.exe
traycalande-source.zip
traycalande-source
bin
Release
ClassDiagram1.cd
ClassDiagram2.cd
CrystalReport1.rpt
CrystalReport_task.rpt
CrystalReport_taskall.rpt
hijri.mdb
In_DataSet.xsc
In_DataSet.xss
mytray.csproj.user
mytray.csproj.vspscc
mytray.suo
mytray.vssscc
mytray_TemporaryKey.pfx
Properties
Settings.settings
vssver.scc
Resources
icon1.ico
icon10.ico
icon11.ico
icon12.ico
icon13.ico
icon14.ico
icon15.ico
icon16.ico
icon17.ico
icon18.ico
icon19.ico
icon2.ico
icon20.ico
icon21.ico
icon22.ico
icon23.ico
icon24.ico
icon25.ico
icon26.ico
icon27.ico
icon28.ico
icon29.ico
icon3.ico
icon30.ico
icon31.ico
icon4.ico
icon5.ico
icon6.ico
icon7.ico
icon8.ico
icon9.ico
tumb.jpg
vssver.scc
vssver2.scc
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Data.OleDb;
using System.Windows.Forms;

namespace mytray
{
    /*class DataBase
    {
        OleDbConnection sqlConnection1 = null;
        public DataBase ()
        {
            connect();
        }
        ~DataBase()
        {
            if (sqlConnection1 != null && sqlConnection1.State==ConnectionState.Open)
                sqlConnection1.Close();
        }
        void connect()
        {
            string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
                +Application.StartupPath+"\\hijri.mdb";
     //       string connectionString =
         //    "Dsn=MS Access Database;dbq=C:\\BookDb.mdb;fil=MS Access;";
//connectionString="Dsn=MS Access Database;dbq=C:\BookDb.mdb;defaultdir=C:\;driverid=25;fil=MS Access;maxbuffersize=2048;pagetimeout=5;uid=admin"


           
            sqlConnection1 = new OleDbConnection(connectionString);
       //    sqlConnection1.co
          
             
        }
        public string GetShamsiDayInfo(int Day, int Month,out bool Vacation)
    {
        //connect();
            OleDbCommand cmd = new OleDbCommand();
            OleDbDataReader reader;

            cmd.CommandText = "SELECT * FROM ImpDays_Shamsi where Day=" 
                               +Day.ToString()+" AND Month="+Month.ToString();
            cmd.CommandType = CommandType.Text;
            cmd.Connection = sqlConnection1;

           sqlConnection1.Open();

            reader = cmd.ExecuteReader();
            // Data is accessible through the DataReader object here.
            string Comment="";
            Vacation = false;
            while (reader.Read())
            {
            //   string s= reader["Day"].ToString();
           //    s += reader["Month"].ToString();
            //   s += reader["Vacation"].ToString();
                Comment = reader["Comment"].ToString();
               Vacation = (bool)reader["Vacation"];
            }
            sqlConnection1.Close();
            return Comment;
        }
        public string GetGhamariDayInfo(int Day, int Month, out bool Vacation)
        {
           sqlConnection1.Open();
            //connect();
            OleDbCommand cmd = new OleDbCommand();
            OleDbDataReader reader;

            cmd.CommandText = "SELECT * FROM ImpDays_Ghamari where Day="
                               + Day.ToString() + "AND Month=" + Month.ToString();
            cmd.CommandType = CommandType.Text;
            cmd.Connection = sqlConnection1;

            //sqlConnection1.Open();

            reader = cmd.ExecuteReader();
            // Data is accessible through the DataReader object here.
            string Comment = "";
            Vacation = false;
            while (reader.Read())
            {
                //   string s= reader["Day"].ToString();
                //    s += reader["Month"].ToString();
                //   s += reader["Vacation"].ToString();
                Comment = reader["Comment"].ToString();
                Vacation = (bool)reader["Vacation"];
            }
            sqlConnection1.Close();
            return Comment;
        }
    }
     */
    class MyDataBase
    {
        
        DataSet MyDataSet = new DataSet();
        public MyDataBase()
        {
            connect();
        }
        ~MyDataBase()
        {
        }
        void connect()
        {
            OleDbConnection myAccessConn = null;
            string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
                + Application.StartupPath + "\\hijri.mdb";
            string strSelect_shamsi = "SELECT * FROM ImpDays_Shamsi";
            string strSelect_Ghamari = "SELECT * FROM ImpDays_Ghamari";
            
             try
            {
                myAccessConn = new OleDbConnection(connectionString);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: Failed to create a database connection. \n{0}", ex.Message);
                return;
            }

            ///////////////
            try
            {

                OleDbCommand myAccessCommand = new OleDbCommand(strSelect_shamsi, myAccessConn);
                OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(myAccessCommand);

                myAccessConn.Open();
                myDataAdapter.Fill(MyDataSet, "ImpDays_Shamsi");

            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: Failed to retrieve the required data from the DataBase.\n{0}", ex.Message);
                return;
            }

            try
            {

                OleDbCommand myAccessCommand = new OleDbCommand(strSelect_Ghamari, myAccessConn);
                OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(myAccessCommand);

              //  myAccessConn.Open();
                myDataAdapter.Fill(MyDataSet, "ImpDays_Ghamari");

            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: Failed to retrieve the required data from the DataBase.\n{0}", ex.Message);
                return;
            }
            finally
            {
                myAccessConn.Close();
            }

        }
       void  test()
        {
		// A dataset can contain multiple tables, so let's get them all
		// into an array:
		DataTableCollection dta = MyDataSet.Tables;
		foreach (DataTable dt in dta)
		
			Console.WriteLine("Found data table {0}", dt.TableName);
	
	    
		// The next two lines show two different ways you can get the
		// count of tables in a dataset:
		Console.WriteLine("{0} tables in data set", MyDataSet.Tables.Count);
		Console.WriteLine("{0} tables in data set", dta.Count);
		// The next several lines show how to get information on a
		// specific table by name from the dataset:
        Console.WriteLine("{0} rows in Categories table", MyDataSet.Tables["ImpDays_Shamsi"].Rows.Count);
		// The column info is automatically fetched from the database, so
		// we can read it here:
        Console.WriteLine("{0} columns in Categories table", MyDataSet.Tables["ImpDays_Shamsi"].Columns.Count);
        DataColumnCollection drc = MyDataSet.Tables["ImpDays_Shamsi"].Columns;
		int i = 0;
		foreach (DataColumn dc in drc)
		{
			// Print the column subscript, then the column's name and its
			// data type:
			Console.WriteLine("Column name[{0}] is {1}, of type {2}",i++ , dc.ColumnName, dc.DataType);
		}
        DataRowCollection dra = MyDataSet.Tables["ImpDays_Shamsi"].Rows;
		foreach (DataRow dr in dra)
		{
			// Print the CategoryID as a subscript, then the CategoryName:
			Console.WriteLine("CategoryName[{0}] is {1}", dr[0], dr[1]);
		}
      
        }

       
        public string GetShamsiDayInfo(int Day, int Month, out bool Vacation)
        {
           // DataTable DT_Shamsi=MyDataSet.Tables["ImpDays_Shamsi"];
            DataRowCollection dra = MyDataSet.Tables["ImpDays_Shamsi"].Rows;
            string Comment = "";
            Vacation = false;
 
		    foreach (DataRow dr in dra)
            {
                if((Day==(int)dr["Day"]) && (Month==(int) dr["Month"]))
                {
                    Comment = dr["Comment"].ToString();
                    Vacation = (bool)dr["Vacation"];
                }
            }
            return Comment;
        }

        public string GetGhamariDayInfo(int Day, int Month, out bool Vacation)
        {
           // DataTable DT_Shamsi=MyDataSet.Tables["ImpDays_Ghamari"];
            DataRowCollection dra = MyDataSet.Tables["ImpDays_Ghamari"].Rows;
            string Comment = "";
            Vacation = false;
 
		    foreach (DataRow dr in dra)
            {
                if((Day==(int)dr["Day"]) && (Month==(int) dr["Month"]))
                {
                    Comment = dr["Comment"].ToString();
                    Vacation = (bool)dr["Vacation"];
                }
            }
            return Comment;

        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

mohammad hajibegloo
Engineer neyshabur azad univeristy
Iran (Islamic Republic Of) Iran (Islamic Republic Of)
I had worked as programmer,project manager,web developer for more than 3 years, and have worked on programming personaly for more than 10 years.
I have worked in university as a teacher for 8 years.
my favorite langueges are : VC++,C#,ASP.NET,PHP

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 12 Mar 2012
Article Copyright 2008 by mohammad hajibegloo
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid