Di susun oleh :
Brian Pattiwael (672009204)
Gilang Dwi Satyo (672008206)
Marco Liklikwatil (682008059)
Latar belakang
Dalam melakukan
kegiatan operasional sehari-harinya mulai dari proses pengisisan rental,pengelolaan, pencatatan, sampai dengan
pembayaran transaksi penyewaan kendaraan bermotor masi dilakukan secara. Maka dari itu system
yan g kami buat dapat mendukung operasional
dalm pengisian data penyewaan kendaraan ber motor. Dengan menggunakan C#.Net kami mebuat aplikasi
system pendataan penyewaan kendaraan
bermotor.
Penjelasan program :
Form 1 Login:
jika login sudah di isi maka akan muncul Form ke 2
Gambar .Form Login
Form 2 : Form pendataan form pendataan terdiri dari Id
Pelangan ,Nama,Alamat,No Tlp,Jenis sewa , Plat no,waktu sewa,mulai sewa,selesai
sewa,DP kemudian ada pemilihan hasil scan KTP atau ID card lainya.. kemudian
ada button input data,edit,delete,search.
Fungsi dari button.
Input : untuk
menginputkan data ke data base .
Edit : digunakan
untuk mengupdate data ke dalam data base . dengan cara mengklik draw header
pada data great view maka data akan di tampilkan dan kemudian data akan di edit
sesuai dengan kebutuhan.
Delete : digunakan
untuk menghapus data dari data base.
Reset : digunakan untuk mengosongkan data pada
form pengisian data
Search : Untuk mencari atau menampilkan dta yang suda di inputkan
Gambar. Form pendaftaran
Pada button search akan memunculkan form data search .search
dilakukan berdasarkan 2 kategori yaitu nama dan jenis kendaraan ..
Source code :
namespace WindowsFormsApplication1
{
public partial class Form3 : Form
{
String connectionSQL = "host=localhost;database=db_pv;uid=root;password=";
public Form3()
{
InitializeComponent();
MySqlConnection db = new
MySqlConnection(connectionSQL);
MySqlCommand comand = db.CreateCommand();
db.Open();
dataGridView1.Columns.Clear();
MySqlDataAdapter Adapter = new MySqlDataAdapter("SELECT `id` , `Nama` , `Alamat` , `no.tlv` , `id
jaminan` , `jenis_sewa` , `plat_nomor` , `waktu_sewa` , `mulai_sewa` ,
`selesai_sewa` , `dp`FROM `tbl_sewa`", db);
DataSet dbtr = new
DataSet();
Adapter.Fill(dbtr);
dataGridView1.DataSource = dbtr.Tables[0];
}
private void
Form3_Load(object sender, EventArgs e)
{
}
private void
button1_Click(object sender, EventArgs e)
{
MySqlConnection db = new
MySqlConnection(connectionSQL);
MySqlCommand comand = db.CreateCommand();
db.Open();
dataGridView1.Columns.Clear();
string tpd = "";
if
(comboBox1.SelectedIndex == 0){
tpd = "SELECT `id` , `Nama` , `Alamat`
, `no.tlv` , `id jaminan` , `jenis_sewa` , `plat_nomor` , `waktu_sewa` ,
`mulai_sewa` , `selesai_sewa` , `dp`FROM `tbl_sewa` WHERE `Nama` = '"
+ textBox1.Text + "'";
}else if(comboBox1.SelectedIndex
== 1){
if(comboBox2.SelectedIndex == 0){
tpd = "SELECT `id` , `Nama` , `Alamat`
, `no.tlv` , `id jaminan` , `jenis_sewa` , `plat_nomor` , `waktu_sewa` ,
`mulai_sewa` , `selesai_sewa` , `dp`FROM `tbl_sewa` WHERE `jenis_sewa` =
'mobil'";
}else if(comboBox2.SelectedIndex
== 1){
tpd = "SELECT `id` , `Nama` , `Alamat`
, `no.tlv` , `id jaminan` , `jenis_sewa` , `plat_nomor` , `waktu_sewa` , `mulai_sewa`
, `selesai_sewa` , `dp`FROM `tbl_sewa` WHERE `jenis_sewa` = 'motor'";
}
}
MySqlDataAdapter Adapter = new MySqlDataAdapter(""+tpd+"",
db);
DataSet dbtr = new
DataSet();
Adapter.Fill(dbtr);
dataGridView1.DataSource = dbtr.Tables[0];
}
private void
button2_Click(object sender, EventArgs e)
{
Form2 fd = new Form2();
fd.Show();
this.Visible = false;
}
private void
comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.SelectedIndex == 1)
{
comboBox2.Visible = true;
}
else if (comboBox1.SelectedIndex
== 0)
{
comboBox2.Visible = false;
}
}
}
}
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
String connectionSQL = "host=localhost;database=db_pv;uid=root;password=";
public Form1()
{
InitializeComponent();
}
private Boolean
statusLogin(string nama, string pass)
{
MySqlConnection db = new
MySqlConnection(connectionSQL);
db.Open();
MySqlCommand dbcmd = db.CreateCommand();
string sql = "select
user,pass from user";
dbcmd.CommandText = sql;
MySqlDataReader reader = dbcmd.ExecuteReader();
// membaca data user name dan password
while (reader.Read())
{
if ((reader.GetString(0).ToString() ==
nama) && (reader.GetString(1).ToString() == pass))
{
return true;
//mengembalikan nilai 'true' jika benar
}
}
db.Close();
return false;
}
private void
button1_Click(object sender, EventArgs e)
{
if (statusLogin(textBox1.Text, textBox2.Text) == true)
{
Form2 fd = new
Form2();
fd.Show();
this.Visible = false;
}
else
{
MessageBox.Show("Username atau password salah");
}
}
}
}
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
String connectionSQL = "host=localhost;database=db_pv;uid=root;password=";
public Form2()
{
InitializeComponent();
tpldata();
DirectoryInfo dir = null;
if (!Directory.Exists("d:\\ktp"))
{
dir = Directory.CreateDirectory("d:\\ktp");
}
pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.id;
}
public void tpldata()
{
MySqlConnection db = new
MySqlConnection(connectionSQL);
MySqlCommand comand = db.CreateCommand();
db.Open();
dataGridView1.Columns.Clear();
MySqlDataAdapter Adapter = new MySqlDataAdapter("SELECT `id` , `Nama` , `Alamat` , `no.tlv` , `id
jaminan` , `jenis_sewa` , `plat_nomor` , `waktu_sewa` , `mulai_sewa` ,
`selesai_sewa` , `dp`FROM `tbl_sewa`", db);
DataSet dbtr = new
DataSet();
Adapter.Fill(dbtr);
dataGridView1.DataSource = dbtr.Tables[0];
}
private void
dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
}
private void
Form2_Load(object sender, EventArgs e)
{
}
private void
groupBox1_Enter(object sender, EventArgs e)
{
}
private void
btn_pfoto_Click(object sender, EventArgs e)
{
openFileDialog1.InitialDirectory = " C:\\
";
openFileDialog1.Filter = "All
Files|*.*|JPEGs|*.jpg|JPEGs|*.jpeg|Bitmaps|*.bmp|GIFs|*.gif";
openFileDialog1.FilterIndex = 2;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.BorderStyle = BorderStyle.None;
}
}
private void
btn_input_Click(object sender, EventArgs e)
{
MySqlConnection db = new
MySqlConnection(connectionSQL);
MySqlCommand comand = db.CreateCommand();
db.Open();
string id = txt_idpinjam.Text;
string alamat = txt_alamat.Text;
string tlp = txt_notlp.Text;
string nama = txt_nama.Text;
string idjmin = textBox1.Text;
string pno = txt_platno.Text;
string lsewa = txt_lmasewa.Text;
string dp = txt_dp.Text;
string
jnis = "";
string pbx = "";
string lamapinjam = "";
string mulaisewa = "";
string selesaisewa = "";
if ((txt_idpinjam.Text == "")
|| (txt_nama.Text == "") ||
(txt_alamat.Text == "") ||
(txt_platno.Text == "") ||
(txt_ms_jam.Text == "") ||
(txt_ms_menit.Text == ""))
{
MessageBox.Show("data belum lengkap");
}
else
{
if (cmb_JnsSewa.SelectedIndex == 0){
jnis = "mobil";
}else {
jnis = "motor";
}
if (rb_hari.Checked == true)
{
lamapinjam = "" +
txt_lmasewa.Text + " hari ";
}
else {
lamapinjam = "" +
txt_lmasewa + " jam ";
}
if (cmb_ms_wktu.SelectedIndex == 1)
{
mulaisewa = "" +
txt_ms_jam.Text + ":" +
txt_ms_menit.Text + " AM";
}
else {
mulaisewa = "" +
txt_ms_jam.Text + ":" +
txt_ms_menit.Text + " PM";
}
if (cmb_ls_waktu.SelectedIndex == 0)
{
selesaisewa = "" +
txt_ls_jam.Text + ":" +
txt_ls_menit.Text + " AM";
}
else {
selesaisewa = "" +
txt_ls_jam.Text + ":" +
txt_ls_menit.Text + " PM";
}
if (pictureBox1.Image == global::WindowsFormsApplication1.Properties.Resources.id)
{
pbx = "";
}
else {
pbx = "tr"+id+"";
pictureBox1.Image.Save("d:\\ktp\\"+pbx+".jpg");
}
try {
comand.CommandText = "INSERT INTO
`db_pv`.`tbl_sewa` (`id` ,`Nama` ,`Alamat` ,`no.tlv` ,`id jaminan`
,`jenis_sewa` ,`plat_nomor` ,`waktu_sewa` ,`mulai_sewa` ,`selesai_sewa` ,`dp`
,`ktp`)VALUES ('" + id + "',
'" + nama + "', '" +
alamat + "', '" + tlp + "', '" + idjmin + "', '" + jnis + "',
'" + pno + "', '" +
lamapinjam + "', '" +mulaisewa +"', '" +selesaisewa+ "', '" + dp + "',
'" + pbx + ".jpg');";
comand.ExecuteNonQuery();
}
catch (MySqlException
m)
{
MessageBox.Show(m.Message);
}
pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.id;
lb_ms.Text = "";
lb_ss.Text = "";
lb_ws.Text = "";
tpldata();
txt_alamat.Text = "";
txt_dp.Text = "";
txt_idpinjam.Text = "";
txt_lmasewa.Text = "";
txt_ls_jam.Text = "";
txt_ls_menit.Text = "";
txt_ms_jam.Text = "";
txt_ms_menit.Text = "";
txt_nama.Text = "";
txt_notlp.Text = "";
txt_platno.Text = "";
textBox1.Text = "";
}
}
private void
txt_idpinjam_TextChanged(object sender, EventArgs e)
{
}
private void
btn_edit_Click(object sender, EventArgs e)
{
MySqlConnection db = new
MySqlConnection(connectionSQL);
MySqlCommand comand = db.CreateCommand();
db.Open();
string id = txt_idpinjam.Text;
string alamat = txt_alamat.Text;
string tlp = txt_notlp.Text;
string nama = txt_nama.Text;
string idjmin = textBox1.Text;
string pno = txt_platno.Text;
string lsewa = txt_lmasewa.Text;
string dp = txt_dp.Text;
string jnis = "";
string pbx = "";
string lamapinjam = "";
string mulaisewa = "";
string selesaisewa = "";
if ((txt_idpinjam.Text == "")
|| (txt_nama.Text == "") ||
(txt_alamat.Text == "") ||
(txt_platno.Text == "") ||
(txt_ms_jam.Text == "") ||
(txt_ms_menit.Text == ""))
{
MessageBox.Show("data belum lengkap");
}
else
{
if (cmb_JnsSewa.SelectedIndex == 0)
{
jnis = "mobil";
}
else
{
jnis = "motor";
}
if (rb_hari.Checked == true)
{
lamapinjam = "" +
txt_lmasewa.Text + " hari ";
}
else
{
lamapinjam = "" +
txt_lmasewa + " jam ";
}
if (cmb_ms_wktu.SelectedIndex == 1)
{
mulaisewa = "" +
txt_ms_jam.Text + ":" +
txt_ms_menit.Text + " AM";
}
else
{
mulaisewa = "" +
txt_ms_jam.Text + ":" +
txt_ms_menit.Text + " PM";
}
if (cmb_ls_waktu.SelectedIndex == 0)
{
selesaisewa = "" +
txt_ls_jam.Text + ":" +
txt_ls_menit.Text + " AM";
}
else
{
selesaisewa = "" +
txt_ls_jam.Text + ":" +
txt_ls_menit.Text + " PM";
}
if (pictureBox1.Image == global::WindowsFormsApplication1.Properties.Resources.id)
{
pbx = "";
}
else
{
pbx = "tr" + id + "";
pictureBox1.Image.Save("d:\\ktp\\"
+ pbx + ".jpg");
}
try
{
comand.CommandText = "UPDATE
`db_pv`.`tbl_sewa` SET `Nama` = '"+nama+"',`Alamat`
= '"+alamat+"',`no.tlv` = '"+tlp+"',`id jaminan` = '"+idjmin+"',`jenis_sewa` = '"+jnis+"',`waktu_sewa` = '"+lsewa+"',`mulai_sewa` = '"+mulaisewa+"',`selesai_sewa` = '"+selesaisewa+"',`dp` = '"+dp+"',
`ktp` = '"+pbx+".jpg' WHERE (
`tbl_sewa`.`id`) = '"+id+"'";
comand.ExecuteNonQuery();
}
catch (MySqlException
m)
{
MessageBox.Show(m.Message);
}
pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.id;
lb_ms.Text = "";
lb_ss.Text = "";
lb_ws.Text = "";
tpldata();
txt_alamat.Text = "";
txt_dp.Text = "";
txt_idpinjam.Text = "";
txt_lmasewa.Text = "";
txt_ls_jam.Text = "";
txt_ls_menit.Text = "";
txt_ms_jam.Text = "";
txt_ms_menit.Text = "";
txt_nama.Text = "";
txt_notlp.Text = "";
txt_platno.Text = "";
textBox1.Text = "";
}
}
private void
textBox1_TextChanged(object sender, EventArgs e)
{
}
private void
dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
{
}
private void
dataGridView1_RowHeaderMouseClick(object
sender, DataGridViewCellMouseEventArgs e)
{
txt_idpinjam.Enabled = false;
btn_input.Enabled = false;
txt_idpinjam.Text =
dataGridView1.Rows[e.RowIndex].Cells[0].Value as
string;
txt_nama.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value as string;
txt_alamat.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value as string;
txt_notlp.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value as string;
textBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value as string;
txt_platno.Text = dataGridView1.Rows[e.RowIndex].Cells[6].Value as string;
lb_ws.Text = dataGridView1.Rows[e.RowIndex].Cells[7].Value as string;
lb_ms.Text = dataGridView1.Rows[e.RowIndex].Cells[8].Value as string;
lb_ss.Text = dataGridView1.Rows[e.RowIndex].Cells[9].Value as string;
txt_dp.Text =
dataGridView1.Rows[e.RowIndex].Cells[10].Value as
string;
if (dataGridView1.Rows[e.RowIndex].Cells[5].Value as string == "mobil")
{
cmb_JnsSewa.SelectedIndex = 0;
}
else
{
cmb_JnsSewa.SelectedIndex = 1;
}
MySqlConnection db = new
MySqlConnection(connectionSQL);
db.Open();
MySqlCommand dbcmd = db.CreateCommand();
string sql = "SELECT
`ktp` FROM `tbl_sewa` WHERE `id` = '" + txt_idpinjam.Text + "'";
dbcmd.CommandText = sql;
MySqlDataReader reader = dbcmd.ExecuteReader();
string ktp = "";
if (reader.Read())
{
ktp = reader.GetString(0).ToString();
}
db.Close();
if (ktp != "")
{
if (File.Exists("d:\\ktp\\" + ktp + ""))
{
pictureBox1.Image = Image.FromFile("d:\\ktp\\" + ktp + "");
}
else
{
pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.id;
}
}
else
{
pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.id;
}
}
private void
btn_reset_Click(object sender, EventArgs e)
{
pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.id;
lb_ms.Text = "";
lb_ss.Text = "";
lb_ws.Text = "";
btn_input.Enabled = true;
txt_idpinjam.Enabled = true;
txt_alamat.Text = "";
txt_dp.Text = "";
txt_idpinjam.Text = "";
txt_lmasewa.Text = "";
txt_ls_jam.Text = "";
txt_ls_menit.Text = "";
txt_ms_jam.Text = "";
txt_ms_menit.Text = "";
txt_nama.Text = "";
txt_notlp.Text = "";
txt_platno.Text = "";
textBox1.Text = "";
}
private void
btn_dlt_Click(object sender, EventArgs e)
{
MySqlConnection db = new
MySqlConnection(connectionSQL);
MySqlCommand comand = db.CreateCommand();
db.Open();
try
{
comand.CommandText = "DELETE FROM
`tbl_sewa` WHERE `tbl_sewa`.`id` = '" +txt_idpinjam.Text+ "'";
comand.ExecuteNonQuery();
}
catch (MySqlException
m)
{
MessageBox.Show(m.Message);
}
pictureBox1.Image = global::WindowsFormsApplication1.Properties.Resources.id;
lb_ms.Text = "";
lb_ss.Text = "";
lb_ws.Text = "";
tpldata();
btn_input.Enabled = true;
txt_idpinjam.Enabled = true;
txt_alamat.Text = "";
txt_dp.Text = "";
txt_idpinjam.Text = "";
txt_lmasewa.Text = "";
txt_ls_jam.Text = "";
txt_ls_menit.Text = "";
txt_ms_jam.Text = "";
txt_ms_menit.Text = "";
txt_nama.Text = "";
txt_notlp.Text = "";
txt_platno.Text = "";
textBox1.Text = "";
}
private void
btn_search_Click(object sender, EventArgs e)
{
Form3 fs = new Form3();
fs.Show();
this.Visible = false;
}
}
}
namespace WindowsFormsApplication1
{
partial class Form1
{
/// <summary>
/// Required designer
variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources
being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise,
false.</param>
protected override void Dispose(bool
disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region
Windows Form Designer generated code
/// <summary>
/// Required method for
Designer support - do not modify
/// the contents of this
method with the code editor.
/// </summary>
private void
InitializeComponent()
{
this.button1 = new
System.Windows.Forms.Button();
this.textBox1 = new
System.Windows.Forms.TextBox();
this.textBox2 = new
System.Windows.Forms.TextBox();
this.label1 = new
System.Windows.Forms.Label();
this.label2 = new
System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Location
= new System.Drawing.Point(169,
89);
this.button1.Name = "button1";
this.button1.Size = new
System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Login";
this.button1.UseVisualStyleBackColor
= true;
this.button1.Click += new
System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new
System.Drawing.Point(92, 28);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new
System.Drawing.Size(152, 20);
this.textBox1.TabIndex = 1;
//
// textBox2
//
this.textBox2.Location = new
System.Drawing.Point(92, 63);
this.textBox2.Name = "textBox2";
this.textBox2.PasswordChar = '*';
this.textBox2.Size = new
System.Drawing.Size(152, 20);
this.textBox2.TabIndex = 2;
this.textBox2.UseSystemPasswordChar = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new
System.Drawing.Point(12, 31);
this.label1.Name = "label1";
this.label1.Size = new
System.Drawing.Size(66, 13);
this.label1.TabIndex = 3;
this.label1.Text = "User
Name :";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new
System.Drawing.Point(13, 66);
this.label2.Name = "label2";
this.label2.Size = new
System.Drawing.Size(59, 13);
this.label2.TabIndex = 4;
this.label2.Text = "Password
:";
//
// Form1
//
this.AutoScaleDimensions = new
System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new
System.Drawing.Size(264, 124);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button
button1;
private System.Windows.Forms.TextBox
textBox1;
private System.Windows.Forms.TextBox
textBox2;
private System.Windows.Forms.Label
label1;
private System.Windows.Forms.Label
label2;
}
}
Kesimpulan
Dengan
aplikasi ini dapat mempermudah managemen
data penyewaan yang selama in di lakukan secara manual.
Link
download : http://www.mediafire.com/?8r1zgsj72x1zjze