카테고리 보관물: Programming

C# 모니터 On OFF 처리

using System.Runtime.InteropServices;  //  using 추가
	// 모니터 On/Off 관련  선언 
	public  int WM_SYSCOMMAND = 0x0112;
	public int SC_MONITORPOWER = 0xF170;
	const int MONITOR_ON = -1;
	const int MONITOR_OFF = 2;
	const int MONITOR_STANBY = 1;
        // dll 참조 
	[DllImport("user32.dll")]   
	private static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);
	SendMessage(this.Handle.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF); 
        // 모니터 OFF
	SendMessage(this.Handle.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON);
        // 모니터 ON

C# SQLite Code Sample

P_20151127-092339

using System.Data.SQLite;   //  추가
string gsFilePath = System.IO.Directory.GetCurrentDirectory();
//  현재 디렉토리 가져오기 위함
// select sample
 
			string Conn = gsFilePath + "/Test.db";
			String dbConnection = String.Format("Data Source={0}", Conn);
			SQLiteConnection dbcon = new SQLiteConnection(dbConnection);
			dbcon.Open();
			SQLiteCommand qry = new SQLiteCommand("SELECT * FROM Test order by seq desc  limit 1", dbcon);
			DataTable dattbl = new DataTable();
			SQLiteDataReader reader = qry.ExecuteReader();
			dattbl.Load(reader);
			reader.Close();
			if (dattbl.Rows.Count > 0)
			{
				string Temp1= dattbl.Rows[0][0].ToString();
				int Temp2= int.Parse(dattbl.Rows[0][1].ToString());
				string Temp3= dattbl.Rows[0][2].ToString();
				string Temp4= dattbl.Rows[0][3].ToString();
				intTemp5= int.Parse(dattbl.Rows[0][4].ToString());
                         }
// insert sample
			string tempQry = string.Empty;
			try
			{
				string Conn = gsFilePath + "/Test2.db";
				String dbConnection = String.Format("Data Source={0}", Conn);
				SQLiteConnection dbcon = new SQLiteConnection(dbConnection);
				dbcon.Open();
				SQLiteCommand qry = new SQLiteCommand(" insert into WIRE (pt_no, SEQ, Wire_Code 
                                                                  ,Wire_nm, Wire_gram ) values(" + temA + ptno + temAE +																														                  
                                                                                            temA + seq + temAE +																														         
                                                                                            temA + Wire_Code + temAE +																														    
                                                                                            temA + Wire_nm + temAE +																														    
                                                                                            temA + Wire_gram + temA +																																
                                                                                            ")", dbcon);
				qry.ExecuteNonQuery();
				dbcon.Close();
			}
			catch (Exception)
			{
				throw;
			}
		}
// insert sample
 
			string tempQry = string.Empty;
 
			string Conn = gsFilePath + "/TEST2.db";
			String dbConnection = String.Format("Data Source={0}", Conn);
			SQLiteConnection dbcon = new SQLiteConnection(dbConnection);
			dbcon.Open();
			SQLiteCommand qry = new SQLiteCommand("delete from Table ", dbcon);			
			qry.ExecuteNonQuery();
			dbcon.Close();