Professional Documents
Culture Documents
BESAR
VNET
DISUSUN OLEH
/*
* Created by SharpDevelop.
* User: YPR
* Date: 7/16/2021
* Time: 2:37 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using MySql.Data.MySqlClient;
namespace perhotelan
{
/// <summary>
/// Description of Koneksi.
/// </summary>
public class Koneksi
{
string pegawai = "server=localhost; database=perhotelan; uid=root; pwd=";
public MySqlConnection conn;
- Koneksi Pengunjung
/*
* Created by SharpDevelop.
* User: YPR
* Date: 7/16/2021
* Time: 3:26 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using MySql.Data.MySqlClient;
namespace perhotelan
{
/// <summary>
/// Description of KoneksiPengunjung.
/// </summary>
public class KoneksiPengunjung
{
string pengunjung = "server=localhost; database=perhotelan; uid=root; pwd=";
public MySqlConnection conn;
- Main form
/*
* Created by SharpDevelop.
* User: YPR
* Date: 7/16/2021
* Time: 2:05 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Data;
namespace perhotelan
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form
{
Koneksi sambung;
DialogResult result;
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void DataKaryawanToolStripMenuItemClick(object sender, EventArgs e)
{
Pegawai pegawai = new Pegawai();
pegawai.Show();
}
void TesKoneksiToolStripMenuItemClick(object sender, EventArgs e)
{
sambung = new Koneksi();
try{
sambung.buka();
MessageBox.Show("Berhasil Koneksi Ke Database","informasi");
}catch(MySqlException ex)
{
switch(ex.Number){
case 0 : {MessageBox.Show("Koneksi Gagal ","Konfirmasi");
}break;
case 1045 : { MessageBox.Show("Username Atau Password Salah","Konfirmasi");
}break;
}
}
}
void PengunToolStripMenuItemClick(object sender, EventArgs e)
{
Pengunjung pengunjung = new Pengunjung();
pengunjung.Show();
}
}
}
- Pegawai
/*
* Created by SharpDevelop.
* User: YPR
* Date: 7/16/2021
* Time: 2:49 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using MySql.Data.MySqlClient;
namespace perhotelan
{
/// <summary>
/// Description of Pegawai.
/// </summary>
public partial class Pegawai : Form
{
MySqlCommand query;
Koneksi sambung;
MySqlDataAdapter adapter;
string sql;
DataTable tabel;
public Pegawai()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void TampilDalamTabel()
{
ViewData tampilkan = new ViewData();
DataTable tabel = new DataTable();
tabel = tampilkan.bacasemua();
dataGridView1.DataSource = tabel;
}
}
}
- Pengunjung
/*
* Created by SharpDevelop.
* User: YPR
* Date: 7/16/2021
* Time: 3:26 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Data;
using MySql.Data.MySqlClient;
namespace perhotelan
{
/// <summary>
/// Description of Pengunjung.
/// </summary>
public partial class Pengunjung : Form
{
MySqlCommand query;
Koneksi sambung;
MySqlDataAdapter adapter;
string sql;
DataTable tabel;
public Pengunjung()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void TampilDalamTabel()
{
ViewDataPengunjung tampilkan = new ViewDataPengunjung();
DataTable tabel = new DataTable();
tabel = tampilkan.bacasemua();
dataGridView1.DataSource = tabel;
}
}
void Button1Click(object sender, EventArgs e)
{
TampilDalamTabel();
}
void Button2Click(object sender, EventArgs e)
{
simpan();
TampilDalamTabel();
}
void Button3Click(object sender, EventArgs e)
{
hapus();
TampilDalamTabel();
}
void Button4Click(object sender, EventArgs e)
{
editdata();
TampilDalamTabel();
}
void DataGridView1CellContentClick(object sender, DataGridViewCellEventArgs e)
{
DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];
textBox1.Text = row.Cells["id"].Value.ToString();
textBox2.Text = row.Cells["nama"].Value.ToString();
textBox3.Text = row.Cells["umur"].Value.ToString();
textBox4.Text = row.Cells["jenis_kelamin"].Value.ToString();
textBox5.Text = row.Cells["alamat"].Value.ToString();
textBox6.Text = row.Cells["no_kamar"].Value.ToString();
}
void Button5Click(object sender, EventArgs e)
{
string nama=textBox8.Text;
ViewCariPengunjung cari = new ViewCariPengunjung();
DataTable tabel = new DataTable();
tabel = cari.tampilkanpencarian(nama);
dataGridView1.DataSource = tabel;
}
}
}
- View cari
/*
* Created by SharpDevelop.
* User: YPR
* Date: 7/16/2021
* Time: 3:17 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Data;
namespace perhotelan
{
/// <summary>
/// Description of ViewCari.
/// </summary>
public class ViewCari
{
MySqlCommand query;
Koneksi sambung;
MySqlDataAdapter adapter;
string sql;
DataTable tabel;
/*
* Created by SharpDevelop.
* User: YPR
* Date: 7/16/2021
* Time: 3:34 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Data;
namespace perhotelan
{
/// <summary>
/// Description of ViewCariPengunjung.
/// </summary>
public class ViewCariPengunjung
{
MySqlCommand query;
Koneksi sambung;
MySqlDataAdapter adapter;
string sql;
DataTable tabel;
- View data
/*
* Created by SharpDevelop.
* User: YPR
* Date: 7/16/2021
* Time: 2:55 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Data;
namespace perhotelan
{
/// <summary>
/// Description of ViewData.
/// </summary>
public partial class ViewData : Form
{
MySqlCommand query;
Koneksi sambung;
MySqlDataAdapter adapter;
string sql;
DataTable tabel;
/*
* Created by SharpDevelop.
* User: YPR
* Date: 7/16/2021
* Time: 3:28 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Data;
namespace perhotelan
{
/// <summary>
/// Description of ViewDataPengunjung.
/// </summary>
public class ViewDataPengunjung
{
MySqlCommand query;
Koneksi sambung;
MySqlDataAdapter adapter;
string sql;
DataTable tabel;
- Output