1. Mainform.cs - Appendix (735.9Kb)
Listing Program
/* * Created by SharpDevelop.
- User: hp mini
- Date: 25/03/2014
- Time: 10:14
* To change this template use Tools | Options | Coding |
Edit Standard Headers.- /
System;
using using System.Collections.Generic;
System.Drawing;
using
System.Windows.Forms;
using namespace absensi_ilkom
{
/// < summary> /// Description of MainForm.
/// < /summary> public partial class MainForm : Form
{ ()
public MainForm
{
// // The InitializeComponent() call is required for Windows Forms designer support.
// InitializeComponent (); // // : Add constructor code after the
TODO InitializeComponent() call.
//
}
void ( object sender, EventArgs e)
Button1Click
{ absen_hadir hadir = ();
new absen_hadir
hadir. ();
Show
();
this. Hide
}
void ( object sender, EventArgs e)
Button3Click
{ admin user = ();
new admin
user. Show (); ();
this. Hide
} } }
/* * Created by SharpDevelop.
- User: hp mini
- Date: 25/03/2014
- Time: 10:24
- To change this template use Tools | Options | Coding | Edit Standard Headers.
- /
using System;
System.Drawing;
using
System.Windows.Forms;
using
System.Collections.Generic;
using using System.Drawing.Imaging;
AForge.Video;
using
AForge.Video.DirectShow;
using
System.IO;
using
MySql.Data;
using using MySql.Data.MySqlClient;
System.Drawing.Drawing2D;
using namespace absensi_ilkom
{
delegate void ( object sender public ResizeInfoEventHandler
, ResizeInfoEventArgs e);
public delegate void CropInfoEventHandler ( object sender,
CropInfoEventArgs e);
/// < summary> /// Description of absen_hadir.
/// < /summary> partial class absen_hadir : Form public
{ cropX;
private int
cropY;
private int private int cropHeight;
cropWidth;
private int
resizeWidth;
private int private int resizeHeight;
Image img;
private public event CropInfoEventHandler cropOK; event ResizeInfoEventHandler resizeOK; public
MySqlConnection connect
public
= new MySqlConnection ( "server=localhost;port=3306;database=ab
sensi_ilkom;User Id=root" );
MySqlCommand command = ();
public new MySqlCommand
public MySqlCommand command2 = new MySqlCommand (); private MySqlDataReader reader; private MySqlDataReader reader2;FilterInfoCollection VideoCaptureDevice; VideoCaptureDevice FinalVideoSource; i,j,k;
int string nama = "" ; string nip = "" ; string jabatan = "" ; string date = "" ;
[,] target1 = [
1 , 40 ] {{ 1 , 1 , 1 , 1 , 1 ,- 1 ,- 1 ,- 1 ,- int new int
1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,-
1 ,-
1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 , 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 , 1 }};[,] target2 = [
1 , 40 ] {{- 1 ,- 1 ,- 1 , 1 ,- 1 , 1 ,- 1 ,- int new int
1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,-
1 ,-
1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 , 1 , 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 , 1 , 1 }};[,] target3 = [
1 , 40 ] {{- 1 ,- 1 , 1 ,- 1 ,- 1 ,- 1 , 1 ,- int new int
1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,-
1 ,-
1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 , 1 , 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 , 1 , 1 , 1 }};[,] target4 = [
1 , 40 ] {{- 1 ,- 1 , 1 , 1 ,- 1 ,- 1 ,- int new int
1 , 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 , 1 , 1 ,- 1 ,- 1 , 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 ,- 1 , 1 , 1 , 1 , 1 }};
training a = ();
new training
()
public absen_hadir
{
// // The InitializeComponent() call is required for Windows Forms designer support.
//
();
InitializeComponent try
{ connect. Open (); command.Connection = connect; }
(MySqlException ex)
catch
{ MessageBox. (ex.Message);
Show
}
//
// TODO : Add constructor code after the
InitializeComponent() call.//
}
void ( object sender, NewFram
FinalVideoSource_NewFrame
eEventArgs eventArgs) { Bitmap image = (Bitmap)eventArgs.Frame. Clone (); Bitmap image3 = new Bitmap (image, 300 , 300 ); pictureBox1.Image = (image3);
new Bitmap
}
void crop_fungsi ()
{ cropOK += (infoForm_cropO
new CropInfoEventHandler
K);
110 ; this.cropX =
50 ; this.cropY =
100 ;
this.cropHeight = this.cropWidth =
70 ;
CropInfoEventArgs cropEventArgs = new CropInfoEventArgs ( this.cropX, this.cropY, this.cropHeig ht,
this.cropWidth);
(cropEventArgs);
this. CropInfoOK
}
void () resize_fungsi
{ resizeOK += (infoForm_r
new ResizeInfoEventHandler
esizeOK);
this.resizeHeight = 100 ; 100 ; this.resizeWidth =
ResizeInfoEventArgs resizeEventArgs = new ResizeInfoEventArgs ( this.resizeHeight, this.resizeWidth );
(resizeEventArgs);
this. ResizeInfoOK
}
void infoForm_resizeOK ( object sender, ResizeInfoEvent
Args e) { img = this. resizeImage (img, new Size (e.Width, e.Height));
();
this. setPicBoxImage
}
private Image resizeImage (Image imgToResize, Size
size) { sourceWidth = imgToResize.Width;
int
int sourceHeight = imgToResize.Height;
nPercent = ;
float
nPercentW = ;
float float nPercentH = ;
nPercentW = (( )size.Width / ( )sourceWidth);
float float
nPercentH = (( float )size.Height / ( float )sourceHeight);
(nPercentH < nPercentW)
if
nPercent = nPercentH;
else
nPercent = nPercentW; destWidth = 100 ;
int
destHeight = 100 ;
int
Bitmap b = (destWidth, destHeight);
new Bitmap
Graphics g = Graphics. ((Image)b);
FromImage
g.InterpolationMode = InterpolationMode.HighQualityBicubic; g. (imgToResize, , , destWidth, destHei
DrawImage
ght);
g. Dispose ();
return (Image)b;
}
void ( object sender, CropInfoEventArgs infoForm_cropOK
e) { img = (img, (e.X, e.Y, e.Width, e.Heig
this. cropImage new Rectangle
ht)); ();
this. setPicBoxImage
}
void () private setPicBoxImage
{
this.pictureBox1.Image = img;
(img.Height < pictureBox1.Height && img.Width
if
< pictureBox1.Width) {
this.pictureBox1.SizeMode =
PictureBoxSizeMode.CenterImage; }
else
{
//this.lblPicMode.Text = "Zoom";
}
//this.updateImgInfo();
} Image (Image img, Rectangle
private cropImage
cropArea) { Bitmap bmpImage = new Bitmap (img); Bitmap bmpCrop = bmpImage. (cropArea, bmpImage.PixelFormat);
Clone
return (Image)(bmpCrop);
}
virtual void (CropInfoEventArgs protected CropInfoOK
eventArgs) {
if ( this.cropOK != null)
{ (
this. cropOK this, eventArgs);
} }
virtual void (ResizeInfoEventAr protected ResizeInfoOK
gs eventArgs) {
if ( this.resizeOK != null)
{ (
this. resizeOK this, eventArgs);
} }
//ambil gambar
void Button1Click ( object sender, EventArgs e)
{ {
try
if (FinalVideoSource.IsRunning){
FinalVideoSource. ();
Stop
//pictureBox1.Image = new Bitmap(500,300);
} Bitmap gambarCapture = (pictureBox1.Image, 300 , 300 );
new Bitmap
(!System.IO.Directory. ( "F:\\Skripsi\
if Exists
\Proyek\\absensi_ilkom\\foto\\webcam" )){System.IO.Directory. ( "F:\\
CreateDirectory
Skripsi\\Proyek\\absensi_ilkom\\foto\\webcam" );
}
string [] fileGambar =
System.IO.Directory. ( "F:\\Skripsi\\Proyek\\absensi_il
GetFiles
kom\\foto\\webcam" );
gambarCapture. ( "F:\\Skripsi\\Proyek\\abse
Save
nsi_ilkom\\foto\\webcam" +(fileGambar.Length + 1 ). () +ToString
".jpg" , ImageFormat.Jpeg);
pictureBox1.ImageLocation = @"F:\\Skripsi\\Proyek\\absensi_ilkom\\foto\\webcam" +(fileGa mbar.Length+
1 ). ToString ()+ ".jpg" ; this.img =
Image. (pictureBox1.ImageLocation);
FromFile
}
catch (Exception ex){
MessageBox. ( "Tekan Tombol Mulai terlebih
Show
dahulu" );
} }
void ( object sender, EventArgs e)
Absen_hadirLoad
{ FinalVideoSource = new VideoCaptureDevice (); VideoCaptureDevice = (FilterCategory.VideoInputDevice);
new FilterInfoCollection //jamku = DateTime.Now;
timer1.Enabled = ;
true
}
void PictureBox1Click ( object sender, EventArgs e)
{ }
void MulaiClick ( object sender, EventArgs e)
{ (!FinalVideoSource.IsRunning)
if
{ FinalVideoSource = ();
new VideoCaptureDevice
FinalVideoSource
= (VideoCaptureDevice[ ].MonikerString)
new VideoCaptureDevice
; FinalVideoSource.NewFrame += new NewFrameEven
(FinalVideoSource_NewFrame);
tHandler
FinalVideoSource. ();
Start
} } VideoSourcePlayer data = ();
new VideoSourcePlayer
void Zoom_inClick ( object sender, EventArgs e)
{ pictureBox1.ImageLocation = "F:\\Skripsi\\Proyek\\absensi_ilkom\\foto\\tari.jpg" ; }
void ( object sender, EventArgs e)
Button2Click
{ {
try crop_fungsi ();
();
resize_fungsi
[] temp1 = [ 400000 ];
int new int
[] temp2 = [ 400000 ];
int new int
int [] temp3 = new int [ 400000 ];
[] temp4 = [ 400000 ];
int new int
[,] W_total = [ 10000 ,
40 ]; int new int int [,] W1 = new int [ 10000 , 40 ];
[,] W2 = [ 10000 ,
40 ]; int new int
[,] W3 = [ 10000 ,
40 ]; int new int
[,] W4 = [ 10000 ,
40 ]; int new int
StreamWriter h = ( @"F:\\Skripsi\\Proyek\\absensi_ilkom\\hasi
new StreamWriter l.txt" , ); false
StreamReader baca1 = ( "F:\\Skripsi\\Proyek\\absensi_ilkom\\W1.tx
new StreamReader t" );
StreamReader baca2 = new StreamReader ( "F:\\Skripsi\\Proyek\\absensi_ilkom\\W2.tx
t" );
StreamReader baca3 = ( "F:\\Skripsi\\Proyek\\absensi_ilkom\\W3.tx
new StreamReader t" );
StreamReader baca4 = ( "F:\\Skripsi\\Proyek\\absensi_ilkom\\W4.tx
new StreamReader t" );
temp1 = a. ambil_bobot (baca1); temp2 = a. ambil_bobot (baca2); temp3 = a. (baca3);
ambil_bobot
temp4 = a. (baca4);
ambil_bobot
int x= ;(i= ; i< 10000 ; i++)
for
{
for (j= ; j< 40 ; j++)
{ W1[i,j] = temp1[x];
W2[i,j] = temp2[x]; W3[i,j] = temp3[x]; W4[i,j] = temp4[x]; x++; W_total[i,j] = W1[i,j] + W2[i,j] + W3[i,j] + W4[i,j]; } }
[,] uji = [
1 , 10000 ]; int new int int [,] hasil = new int [ 1 , 40 ];
Bitmap gbr = (Bitmap)pictureBox1.Image; Bitmap grey; Bitmap biner; grey = a. (gbr);
konversi_grayscale
biner = a. konversi_biner (grey); uji = a. (biner);
input //perkalian uji n bobot
(i= ; i<
1 ; i++)
for{ (k= ; k<
40 ; k++) for
{ hasil[i,k] = ; (j= ; j< 10000 ; j++)
for
{ hasil[i,k] = hasil[i,k] + (uji[i,j] * W_total[j,k]); } } }
(i= ; i<
1 ; i++)
for{
for (k= ; k< 40 ; k++)
{ (hasil[i,k] > )
if
hasil[i,k] =
1 ; else if (hasil[i,k] <= )
hasil[i,k] = -
1 ;
h. (hasil[i,k]+ "\t" );
Write
}
h. (h.NewLine);
Write
}
h. ();
Close
hasil1 = ;
int int hasil2 = ; int hasil3 = ;
hasil4 = ;
int
(i= ; i<
1 ; i++)
for{ (k= ; k<
40 ; k++) for
{
if (hasil[i,k] == target1[i,k]){
hasil1++; }
(hasil[i,k] == target2[i,k]){
if
hasil2++; }
(hasil[i,k] == target3[i,k]){
if
hasil3++; }
(hasil[i,k] == target4[i,k]){
if
hasil4++; } } }
(hasil1 ==
40 )
if{ command.Connection = connect; command.CommandText = "SELECT * from
data_pegawai where NIM = '131401001'" ;
reader = command. ();
ExecuteReader
(reader. ())
if Read
{ nama = reader. (
1 );
GetString
nip = reader. ( );
GetString
jabatan = reader. GetString (
2 );
(DialogResult.OK ==
if
MessageBox. ( "Berhasil absen \nNama : " +nama+ "\nNIM :
Show
" +nip+ "\nStambuk : " +jabatan+ "" , "Informasi" , MessageBoxButtons.OK))
{ ();
this. Show
} } connect. Close (); connect. ();
Open
command2.Connection = connect; command2.CommandText = "SELECT * from
absen" ;
reader2 = command2. ();
ExecuteReader
//string nip2 = "";
while (reader2. Read ())
{ date = reader2. (
1 );
GetString
//nip2 = reader2.GetString(0);
} connect. Close (); connect. ();
Open
if ((date ==
DateTime.Today. ()))
ToLongDateString
{
string pulang= "" ;
command2.CommandText = "select * from
absen where NIM = '131401001' AND Tanggal = '" +date+ "';" ; reader2 = command2. ();
ExecuteReader
(reader2. ())
while Read
{ pulang = reader2. (
3 );
GetString
} connect. Close (); connect. ();
Open
(pulang == "" ){
if
command.CommandText = "UPDATE
absen SET Pulang = '" +DateTime.Now. ()+ "'
ToLongTimeString
where Tanggal = '" +date+ "' AND NIM = '131401001';" ;
command. ();
ExecuteReader
} }
{
else
command.CommandText = "INSERT INTO
absen(NIM, Tanggal, Datang, Pulang) VALUES ('" +nip+ "','" +DateTime.Today. ()+ "','" +DateTim
ToLongDateString
e.Now. ()+ "','');" ;
ToLongTimeString
command. ();
ExecuteReader
} }
(hasil2 ==
40 ) else if
{ command.Connection = connect; command.CommandText = "SELECT * from
data_pegawai where NIM = '121401113'" ;
reader = command. ();
ExecuteReader
(reader. ())
if Read
{ nama = reader. (
1 );
GetString
nip = reader. GetString ( ); jabatan = reader. (
2 );
GetString
(DialogResult.OK ==
if
MessageBox. Show ( "Berhasil absen \nNama : " +nama+ "\nNIM :
" +nip+ "\nStambuk : " +jabatan+ "" , "Informasi" , MessageBoxButtons.OK))
{ ();
this. Show
} } connect. Close (); connect. ();
Open
command2.Connection = connect; command2.CommandText = "SELECT * from
absen" ;
reader2 = command2. ();
ExecuteReader
while (reader2. Read ())
{ date = reader2. (
1 ); GetString
} connect. ();
Close
connect. ();
Open
if ((date ==
DateTime.Today. ()))
ToLongDateString
{
string pulang= "" ;
command2.CommandText = "select * from
absen where Tanggal = '" +date+ "';" ;
reader2 = command2. ();
ExecuteReader
(reader2. ())
while Read
{
if (reader2. GetString ( ) == "1214 01113" )
{ pulang = reader2. GetString (
3 ); break ;
} (reader2. ( ) !=
else if GetString "121401113" ){
pulang = "ada" ;
break ;
} } connect. ();
Close
connect. ();
Open
if (pulang == "" ){
command.CommandText = "UPDATE
absen SET Pulang = '" +DateTime.Now. ()+ "'
ToLongTimeString
where Tanggal = '" +date+ "' AND NIM = '121401113';" ;
command. ExecuteReader (); }
(pulang == "ada" ){
else if
command.CommandText = "INSERT
INTO absen(NIM, Tanggal, Datang, Pulang) VALUES ('" +nip+ "','" +DateTime.Today. ToLongDateString ()+ "','" +DateTim
e.Now. ()+ "','');" ;
ToLongTimeString
command. ();
ExecuteReader
} }
{
else
command.CommandText = "INSERT INTO
absen(NIM, Tanggal, Datang, Pulang) VALUES ('" +nip+ "','" +DateTime.Today. ToLongDateString ()+ "','" +DateTim
e.Now. ()+ "','');" ;
ToLongTimeString
command. ();
ExecuteReader
} }
(hasil3 ==
40 ) else if
{ command.Connection = connect; command.CommandText = "SELECT * from data_pegawai where NIM = '101401069'" ;
reader = command. ();
ExecuteReader
(reader. ())
if Read
{ nama = reader. GetString (
1 );
nip = reader. ( );
GetString
jabatan = reader. (
2 );
GetString
if (DialogResult.OK ==
MessageBox. ( "Berhasil absen \nNama : " +nama+ "\nNIM :
Show
" +nip+ "\nStambuk : " +jabatan+ "" , "Informasi" , MessageBoxButtons.OK))
{
this. Show ();
} } connect. ();
Close
connect. ();
Open
command2.Connection = connect; command2.CommandText = "SELECT * from
absen" ;
reader2 = command2. ();
ExecuteReader
while (reader2. Read ())
{ date = reader2. (
1 );
GetString
} connect. Close (); connect. ();
Open
if ((date ==
DateTime.Today. ()))
ToLongDateString
{
string pulang= "" ;
command2.CommandText = "select * from
absen where Tanggal = '" +date+ "';" ;
reader2 = command2. ();
ExecuteReader
(reader2. ())
while Read
{
if (reader2. GetString ( ) == "1014 01069" )
{ pulang = reader2. GetString (
3 ); break ;
} (reader2. ( ) !=
else if GetString "101401069" ){
pulang = "ada" ;
break ;
} } connect. ();
Close connect. ();
Open
if (pulang == "" ){
command.CommandText = "UPDATE
absen SET Pulang = '" +DateTime.Now. ()+ "'
ToLongTimeString
where Tanggal = '" +date+ "' AND NIM = '101401069';" ;
command. ();
ExecuteReader
} (pulang == "ada" ){
else if
command.CommandText = "INSERT
INTO absen(NIM, Tanggal, Datang, Pulang) VALUES ('" +nip+ "','" +DateTime.Today. ()+ "','" +DateTim
ToLongDateString
e.Now. ()+ "','');" ;
ToLongTimeString
command. ();
ExecuteReader
} }
{
else
command.CommandText = "INSERT INTO
absen(NIM, Tanggal, Datang, Pulang) VALUES ('" +nip+ "','" +DateTime.Today. ()+ "','" +DateTim
ToLongDateString
e.Now. ()+ "','');" ;
ToLongTimeString
command. ();
ExecuteReader
} }
else if (hasil4 == 40 )
{ command.Connection = connect; command.CommandText = "SELECT * from
data_pegawai where NIM = '111401126'" ;
reader = command. ();
ExecuteReader
(reader. ())
if Read
{ nama = reader. (
1 );
GetString
nip = reader. ( );
GetString
jabatan = reader. (
2 );
GetString
if (DialogResult.OK ==
MessageBox. ( "Berhasil absen \nNama : " +nama+ "\nNIM :
Show
" +nip+ "\nStambuk : " +jabatan+ "" , "Informasi" , MessageBoxButtons.OK))
{ ();
this. Show
} } connect. ();
Close
connect. ();
Open
command2.Connection = connect; command2.CommandText = "SELECT * from
absen" ;
reader2 = command2. ();
ExecuteReader
(reader2. ())
while Read
{ date = reader2. (
1 );
GetString
} connect. ();
Close
connect. Open (); ((date ==
if
DateTime.Today. ()))
ToLongDateString
{
string pulang= "" ;
command2.CommandText = "select * from
absen where Tanggal = '" +date+ "';" ;
reader2 = command2. ();
ExecuteReader
while (reader2. Read ())
{ (reader2. ( ) == "1114
if GetString 01126" )
{ pulang = reader2. (
3 );
GetString
break ;
} (reader2. ( ) !=
else if GetString "111401126" ){
pulang = "ada" ;
break ;
} } connect. ();
Close
connect. ();
Open
(pulang == "" ){
if
command.CommandText = "UPDATE
absen SET Pulang = '" +DateTime.Now. ToLongTimeString ()+ "' where Tanggal = '" +date+ "' AND NIM = '111401126';" ;
command. ();
ExecuteReader
}
else if (pulang == "ada" ){
command.CommandText = "INSERT
INTO absen(NIM, Tanggal, Datang, Pulang) VALUES ('" +nip+ "','" +DateTime.Today. ()+ "','" +DateTim
ToLongDateString
e.Now. ()+ "','');" ;
ToLongTimeString
command. ExecuteReader (); } }
{
else
command.CommandText = "INSERT INTO
absen(NIM, Tanggal, Datang, Pulang) VALUES ('" +nip+ "','" +DateTime.Today. ()+ "','" +DateTim
ToLongDateString
e.Now. ()+ "','');" ;
ToLongTimeString
command. ExecuteReader (); } }
{
else
MessageBox. ( "Maaf, Sistem tidak dapat
Show mengenali Anda" );
} baca1. ();
Close
baca2. ();
Close
baca3. Close (); baca4. ();
Close
}
catch (Exception ex){
MessageBox. ( "Tekan Tombol Mulai Terlebih
Show
Dahulu,\n Lalu Tekan Tombol Ambil Gambar" );
} }
void ( object sender, EventArgs e)
Timer1Tick
{ label9.Text = DateTime.Now.Hour. ();
ToString
label10.Text = DateTime.Now.Minute. ToString (); label11.Text = DateTime.Now.Second. ();
ToString
}
void ( object sender, EventArgs e)
Button3Click
{ MainForm utama = ();
new MainForm
utama. ();
Show
this. Hide (); //pictureBox1.ImageLocation = "F:\\Skripsi\\Proyek\\absensi_ilkom\\foto2\\uji.jpg";
}
void ( object sender, EventArgs e)
Button4Click
{ panel3. Hide (); }
void ( object sender, EventArgs e)
Button5Click
{ }
void ( object sender, PaintEventArgs
PictureBox1Paint
e) { Rectangle a = ( 110 ,
50 ,
70 , 100 ); //x,y,h,w
new RectanglePen b= new Pen (Color.Crimson,
1 );
e.Graphics. DrawRectangle (b, a); } }
public class CropInfoEventArgs : EventArgs
{ X;
public int public int Y;
Height;
public int
Width;
public int
( x, y, height,
public CropInfoEventArgs int int int in t width)
{
this.X = x; this.Y = y; this.Height = height; this.Width = width;
} }
class ResizeInfoEventArgs : EventArgs
public{
public int Height;
Width;
public int
( height, width)
public ResizeInfoEventArgs int int
{
this.Height = height; this.Width = width;
} } }
/* * Created by SharpDevelop.
- User: hp mini
- Date: 14/05/2014
- Time: 13:47
* To change this template use Tools | Options | Coding |
Edit Standard Headers.- /
System;
using
System.Drawing;
using using System.Windows.Forms;
MySql.Data;
using
MySql.Data.MySqlClient;
using namespace absensi_ilkom
{
/// < summary> /// Description of admin.
/// < /summary> public partial class admin : Form
{ MySqlConnection connect
public
= ( "server=localhost;port=3306;database=ab
new MySqlConnection sensi_ilkom;User Id=root" );
MySqlCommand command = ();
public new MySqlCommand
MySqlDataReader reader;
private public admin ()
{
// // The InitializeComponent() call is required for Windows Forms designer support.
//
();
InitializeComponent try
{ connect. ();
Open
command.Connection = connect; }
(MySqlException ex)
catch
{ MessageBox. Show (ex.Message); }
//
// : Add constructor code after the
TODO InitializeComponent() call.//
}
void PelatihanClick ( object sender, EventArgs e)
{ training latih = ();
new training
latih. ();
Show
();
this. Hide
}
void ( object sender, EventArgs e)
MasukClick
{
string nomor = nip.Text; string pass = password.Text;
command.Connection = connect; command.CommandText = "SELECT * from admin" ; reader = command. ();
ExecuteReader
(reader. ())
if Read
{ (nomor == reader. ( ))
if GetString
{ (pass == reader. (
1 )) if GetString
{ panel3.Visible = false ; }
else
{ MessageBox. ( "password salah" );
Show
} }
else
{ MessageBox. ( "NIP tidak ada" );
Show
} } connect. ();
Close
}
void ( object sender, EventArgs e) AdminLoad
{
}
void ( object sender, EventArgs e)
RekapClick
{ rekap_data re = new rekap_data (); re. ();
Show
();
this. Hide
}
void ( object sender, EventArgs e)
DataClick
{ }
void ( object sender, EventArgs e)
Button1Click
{ panel4. ();
Hide
}
void ( object sender, EventArgs e)
Button2Click
{ data_pegawai peg = ();
new data_pegawai
peg. Show (); ();
this. Show
} } }
/* * Created by SharpDevelop.
- User: hp mini
- Date: 24/05/2014
- Time: 21:11
* To change this template use Tools | Options | Coding |
Edit Standard Headers.- /
System;
using using System.Drawing;
System.Windows.Forms;
using
MySql.Data.MySqlClient;
using
MySql.Data;
using using System.Data;
absensi_ilkom
namespace
{
/// < summary> /// Description of data_pegawai.
/// < /summary> partial class data_pegawai : Form public
{
public MySqlConnection connect
= new MySqlConnection ( "server=localhost;port=3306;database=ab
sensi_ilkom;User Id=root" );
MySqlCommand command= ();
public new MySqlCommand
()
public data_pegawai
{
// // The InitializeComponent() call is required for Windows Forms designer support.
//
();
InitializeComponent
{
try
connect. Open (); command.Connection=connect; }
(MySqlException ex){
catch
MessageBox. (ex.Message);
Show
}
string data = "SELECT * FROM data_pegawai" ;
(data);
loadData //
// : Add constructor code after the
TODO InitializeComponent() call.
//
}
void ( string data) loadData
{ DataTable table = new DataTable (); command.CommandText = data; MySqlDataAdapter adapter = (command);
new MySqlDataAdapter
adapter. Fill (table); dataGridView1.Columns. ();
Clear
dataGridView1.DataSource = table; dataGridView1.Columns[ ].Width = 120 ; dataGridView1.Columns[
1 ].Width = 150 ;
dataGridView1.Columns[
2 ].Width = 183 ; //dataGridView1.Columns[1].HeaderText = "NIP";
}
void ( object sender, Dat
DataGridView1CellContentClick
aGridViewCellEventArgs e) { }
void Button1Click ( object sender, EventArgs e)
{ admin adm = ();
new admin
adm. ();
Show
adm.panel3. Hide (); adm.panel4. ();
Hide
();
this. Hide
}
//cari void ( object sender, EventArgs e)
Button2Click
{
string indeks =
comboBox1.SelectedIndex. ();
ToString
string sql= "" ; string key = textBox1.Text;
(indeks == "0" )
if
{ sql = "SELECT * FROM data_pegawai WHERE NIP
LIKE '%" +key+ "%'" ;
} (indeks == "1" )
if
{ sql = "SELECT * FROM data_pegawai WHERE Nama
LIKE '%" +key+ "%'" ;
} (indeks == "2" )
if
{ sql = "SELECT * FROM data_pegawai WHERE
Stambuk LIKE '%" +key+ "%'" ;
} (sql);
loadData
} } }
/* * Created by SharpDevelop.
- User: hp mini
- Date: 25/05/2014
- Time: 5:55
* To change this template use Tools | Options | Coding |
Edit Standard Headers.- /
using System;
System.Drawing;
using
System.Windows.Forms;
using
MySql.Data.MySqlClient;
using using MySql.Data;
System.Data;
using
absensi_ilkom
namespace
{
/// < summary> /// Description of rekap_data. /// <
/summary> partial class rekap_data : Form public
{ MySqlConnection connect
public
= ( "server=localhost;port=3306;database=ab
new MySqlConnection sensi_ilkom;User Id=root" ); public MySqlCommand command= new MySqlCommand (); public MySqlDataReader reader;
MySqlDataReader reader2;
public
()
public rekap_data
{
// // The InitializeComponent() call is required for Windows Forms designer support.
//
();
InitializeComponent
try {
connect. ();
Open
command.Connection=connect; }
catch (MySqlException ex){
MessageBox. (ex.Message);
Show
}
string data = "select * from absen" ;
(data);
LoadData
//
// : Add constructor code after the
TODO InitializeComponent() call.//
}
void ( string sql)
LoadData
{ DataTable table = new DataTable (); command.CommandText = sql; MySqlDataAdapter adapter = (command);
new MySqlDataAdapter
adapter. Fill (table); dataGridView1.Columns. ();
Clear
dataGridView1.DataSource = table; }
void ( object sender, EventArgs e)
LihatClick
{
string sql = "" ; string nama =
nama_pegawai.SelectedIndex. ();
ToString
string month = bulan.SelectedIndex. ();ToString
if (nama == "0" )
{ (month == "0" )
if
{ sql = "SELECT * FROM absen WHERE Tanggal
LIKE '%Januari%' AND NIM = '131401001'" ;
} (month == "1" )
if
{ sql = "SELECT * FROM
absen WHERE Tanggal LIKE '%Februari%' AND NIM = '131401001'" ;
} (month == "2" )
if
{ sql = "SELECT * FROM absen WHERE Tanggal
LIKE '%Maret%' AND NIM = '131401001'" ;
} (month == "3" )
if
{ sql = "SELECT * FROM absen WHERE Tanggal
LIKE '%April%' AND NIM = '131401001'" ;
} (month == "4" )
if
{ sql = "SELECT * FROM absen WHERE Tanggal
LIKE '%Mei%' AND NIM = '131401001'" ;
} (month == "5" )
if
{ sql = "SELECT * FROM absen WHERE Tanggal
LIKE '%Juni%' AND NIM = '131401001'" ;
} (month == "6" )
if
{ sql = "SELECT * FROM absen WHERE Tanggal
LIKE '%Juli%' AND NIM = '131401001'" ;
} (month == "7" )
if
{ sql = "SELECT * FROM absen WHERE Tanggal
LIKE '%Agustus%' AND NIM = '131401001'" ;
} (month == "8" )
if
{ sql = "SELECT * FROM absen WHERE Tanggal
LIKE '%September%' AND NIM = '131401001'" ;
}
if (month == "9" )
{ sql = "SELECT * FROM absen WHERE Tanggal
LIKE '%Oktober%' AND NIM = '131401001'" ;
} (month == "10" )
if
{ sql = "SELECT * FROM absen WHERE Tanggal
LIKE '%November%' AND NIM = '131401001'" ;
} (month == "11" )
if
{ sql = "SELECT * FROM absen WHERE Tanggal
LIKE '%Desember%' AND NIM = '131401001'" ;
} }
else if (nama == "1" )
{ (month == "0" )
if
{ sql = "SELECT * FROM absen WHERE Tanggal
LIKE '%Januari%' AND NIM = '121401113'" ;
} (month == "1" )
if
{ sql = "SELECT * FROM absen WHERE Tanggal
LIKE '%Februari%' AND NIM = '121401113'" ;
} (month == "2" )
if
{ sql = "SELECT * FROM absen WHERE Tanggal
LIKE '%Maret%' AND NIM = '121401113'" ;
} (month == "3" )
if
{ sql = "SELECT * FROM absen WHERE Tanggal
LIKE '%April%' AND NIM = '121401113'" ;
} (month == "4" )
if
{ sql = "SELECT * FROM absen WHERE Tanggal