0

Laporan dan Aplikasi rental menggunakan C sharp/ C# (7)

Posted by jujur on 3:29 PM

Psoude-Code


Form rental

===============
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace index
{
   public partial class rental : Form
   {
       private string sql=null;
       private DataTable tauto = new DataTable();
       private kon koneksi = new kon();
       private DataTable trental = new DataTable();
       private double grand;
       private string op;
       private Boolean kontrol;
       public rental( string x, string y)
       {
           InitializeComponent();
           op = y;
      }
       private string tambah0(string x){
           if(int.Parse(x) < 10){
               x="0"+x;
           }
       return x;
       }
       private void kode_otomatis()
       {
           string tahun = DateTimeOffset.Now.Year.ToString();
           string bulan = tambah0(DateTimeOffset.Now.Month.ToString());
           string tanggal = tambah0(DateTimeOffset.Now.Day.ToString());
           string kode = "rent-" + tanggal + "-" + bulan + "-" + tahun;
           string temp;
           int naik;
           sql = "select no_sewa from rental order by no_sewa desc";
           trental = koneksi.tampil_data(sql);
           if (trental.Rows.Count == 0)
           {
               kode = kode + "-0001";
           }
           else
           {
               sql = "select no_sewa from rental where tanggal like'%"+tahun+"-"+bulan+"-"+tanggal+"%' order  by no_sewa desc";
               trental = koneksi.tampil_data(sql);
               if (trental.Rows.Count==0)
                   {
                       kode = kode + "-0001";
                   }else{
                       temp = trental.Rows[0].ItemArray.GetValue(0).ToString();
                       naik = int.Parse(temp.Substring(16, 4));
                       naik++;
                       if (naik < 10)
                       {
                           kode = kode + "-000" + naik;
                       }
                       else if (naik < 100)
                       {
                           kode = kode + "-00" + naik;
                       }
                       else if (naik < 1000)
                       {
                           kode = kode + "-0" + naik;
                       }
                       else
                       {
                           kode = kode + "-" + naik;
                       }
                   }
           }
           kode_rental.Text = kode;
           kode_rental.Enabled = false;
           trental = null;
       }
       private void isi_cb()
       {
           sql = "select * from mobil where status ='Tersedia'";
           trental = koneksi.tampil_data(sql);
           int pos = 0;
           while (pos < trental.Rows.Count)
           {
               cbmobil.Items.Add(trental.Rows[pos].ItemArray.GetValue(0).ToString());
               pos++;
           }
           trental = null;
           sql = "select*from sopir where status='Tersedia'";
           trental = koneksi.tampil_data(sql);
           pos = 0;
           while (pos < trental.Rows.Count)
           {
               cbsopir.Items.Add(trental.Rows[pos].ItemArray.GetValue(1).ToString());
               pos++;
           }

       }
       private void auto()
       {
           if (txtpelanggan.Text == "")
           {
               dgautocomplete.Visible = false;
           }
           else
           {
               sql = "select idplg,nama from pelanggan where idplg like'%" + txtpelanggan.Text + "%'";
               tauto = koneksi.tampil_data(sql);
               if (tauto.Rows.Count == 0)
               {
                   dgautocomplete.Visible = false;
               }
               else
               {
                   dgautocomplete.Visible = true;
                   dgautocomplete.DataSource = tauto;
                   dgautocomplete.Columns[1].Width = 180;
               }
           }
       }
       public void inisialisasi()
       {
           cbmobil.Text = "";
           cbsopir.Text = "";
           txtharga.Text = "";
           txtharga.Enabled = false;
           txtpelanggan.Text = "";
           txtlamasewa.Text = "";
           txtpelanggan.Enabled = true;
           cbsopir.Items.Clear();
           cbmobil.Items.Clear();
           namapelanggan.Text = "";
           merk.Text = "";
           kontrol = false;
           grand_total_string.Text = "Rp. 0";
           grand = 0;
           dgautocomplete.Visible = false;
           kode_otomatis();
           isi_cb();

       }
       private void rental_Load(object sender, EventArgs e)
       {
           inisialisasi();
       }

       private void reset_Click(object sender, EventArgs e)
       {
           inisialisasi();
       }

       private void txtpelanggan_KeyUp(object sender, KeyEventArgs e)
       {
           auto();
       }

       private void dgautocomplete_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
       {
           txtpelanggan.Text = dgautocomplete.SelectedCells[0].Value.ToString();
           namapelanggan.Text = dgautocomplete.SelectedCells[1].Value.ToString();
           txtpelanggan.Enabled = false;
           dgautocomplete.Visible = false;
       }

       private void proses_Click(object sender, EventArgs e)
       {
           if (txtpelanggan.Text == "")
           {
               MessageBox.Show("Id pelanggan belum terisi", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
           }
           else
           {
               if (namapelanggan.Text == "")
               {
                   MessageBox.Show("Nama Pelanggan belum terisi", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
               }
               else
               {
                   sql = "select*from mobil where id='" + cbmobil.Text + "'";
                   if (cbmobil.Text == ""||koneksi.tampil_data(sql).Rows.Count ==0)
                   {
                       MessageBox.Show("Pilih Mobil yang ingin di rental terlebih dahulu", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   }
                   else
                   {
                       if (txtlamasewa.Text == "")
                       {
                           MessageBox.Show("Lama penyewan belum terisi", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                       }
                       else
                       {
                           string [] pelanggan= new String[6];
                           int lama;
                           Double[] harga = new Double[2];
                           pelanggan[0] = txtpelanggan.Text;
                           pelanggan[1] = namapelanggan.Text;
                           pelanggan[2] = cbmobil.Text;
                           pelanggan[3] = cbsopir.Text;
                           pelanggan[4] = kode_rental.Text;
                           pelanggan[5] = op;
                           harga[0] = double.Parse(txtharga.Text);
                           harga[1] = grand;
                           lama = int.Parse(txtlamasewa.Text);
                           pembayaran fpembayaran = new pembayaran(pelanggan, harga, lama);
                           fpembayaran.init = this;
                           fpembayaran.ShowDialog();


                       }
                   }
               }
           }
       }

       private void txtlamasewa_KeyUp(object sender, KeyEventArgs e)
       {
           double x;
           int y;
           if (txtlamasewa.Text != ""&& txtharga.Text!="")
           {
               x = double.Parse(txtharga.Text);
               y = int.Parse(txtlamasewa.Text);
               if (!kontrol)
               {
                   grand = x * y;
               }
               else
               {
                   sql = "select nama from sopir where nama ='" + cbsopir.Text + "'";
                   trental = koneksi.tampil_data(sql);
                   if (trental.Rows.Count != 0)
                   {
                       grand = ((x * y) + (y * 100000));
                       kontrol = true;
                   }
                   else
                   {
                       grand = x * y;
                   }

               }
               grand_total_string.Text = "Rp. " + grand.ToString("###,###");
           }
           else
           {
               grand_total_string.Text = "Rp. 0";
           }
       }

       private void cbmobil_TextChanged(object sender, EventArgs e)
       {
           string temp;
           sql = "select*from mobil where id ='" + cbmobil.Text + "'";
           trental =koneksi.tampil_data(sql);
           if (trental.Rows.Count != 0)
           {
               temp = trental.Rows[0].ItemArray.GetValue(4).ToString();
               merk.Text = trental.Rows[0].ItemArray.GetValue(1).ToString();
               sql = "select *from harga_sewa where golongan='" + temp + "'";
               txtharga.Text = koneksi.tampil_data(sql).Rows[0].ItemArray.GetValue(2).ToString();
               txtharga.Enabled = false;
               double x;
               int y;
               if (txtlamasewa.Text != "")
               {
                   x = double.Parse(txtharga.Text);
                   y = int.Parse(txtlamasewa.Text);
                   if (!kontrol)
                   {
                       grand = x * y;
                   }
                   else
                   {
                       sql = "select nama from sopir where nama ='" + cbsopir.Text + "'";
                       trental = koneksi.tampil_data(sql);
                       if (trental.Rows.Count != 0)
                       {
                           grand = ((x * y) + (y * 100000));
                           kontrol = true;
                       }
                       else
                       {
                           grand = x * y;
                       }

                   }
                   grand_total_string.Text = "Rp. " + grand.ToString("###,###");
               }
               else
               {
                   grand_total_string.Text = "Rp. 0";
               }
           }
           else
           {
               merk.Text = "";
               txtharga.Text = "";
               grand_total_string.Text = "Rp.0";
           }
       }

       private void cbsopir_TextChanged(object sender, EventArgs e)
       {
           if (!kontrol)
           {
               if (txtlamasewa.Text != "")
               {
                   sql = "select nama from sopir where nama ='" + cbsopir.Text + "'";
                   trental = koneksi.tampil_data(sql);
                   if (trental.Rows.Count != 0)
                   {
                       grand = grand + (100000 * int.Parse(txtlamasewa.Text));
                       grand_total_string.Text = "Rp. " + grand.ToString("###,###");
                       kontrol = true;
                   }
               }
               else
               {
                   kontrol = true;
               }
           }
           if ((kontrol)&&(cbsopir.Text == "")&&(txtlamasewa.Text !=""))
           {
               grand = grand - (100000 * int.Parse(txtlamasewa.Text));
               grand_total_string.Text = "Rp. " + grand.ToString("###,###");
               kontrol = false;
           }

       }
  }
}

Form pengembalian

=====================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace index
{
   public partial class pengembalian : Form
   {
       private String sql,harus_kembali = null;
       private kon koneksi = new kon();
       private DataTable trental = new DataTable();
       private Double denda, pembayaran, sosok, uang_muka, harga_sewa,grand_total,sisa;
       private int lama;
       public pengembalian()
       {
           InitializeComponent();
       }
       private void inisialisasi()
       {
           lbl_denda.Text = "";
           lbl_harga.Text = "";
           lbl_id.Text = "";
           lbl_lama.Text = "";
           lbl_nama.Text = "";
           lbl_sosok.Text = "Rp.0";
           lbl_sisa.Text = "Rp.0";
           txt_bayar.Text = "";
           denda = 0;
           pembayaran = 0;
           sosok = 0;
           uang_muka = 0;
           txt_bayar.Enabled = true;
           harga_sewa = 0;
           grand_total = 0;
           lbl_plat.Text = "";
           lbl_sopir.Text = "";
           lbl_uangmuka.Text = "";
           lbl_tanggal.Text = "";
           cbfaktur.Text = "Pilih No Faktur";
           cbfaktur.Items.Clear();
           isi_faktur();
       }

       private void isi_faktur()
       {
           sql = "select*from rental where back='N' order by no_sewa asc";
           trental = koneksi.tampil_data(sql);
           int pos = 0;
           while (pos < trental.Rows.Count)
           {
               cbfaktur.Items.Add(trental.Rows[pos].ItemArray.GetValue(0).ToString());
               pos++;
           }
           trental = null;
       }

       private void pengembalian_Load(object sender, EventArgs e)
       {
           inisialisasi();
       }
       private int jumlah_tanggal(int x,int y){
           int z;
            if(x < 8){
                if(x==2){
                    if( y % 4==0){
                        z = 29;
                    }else{
                        z= 28;
                        }
                }else if(x % 2 ==0 && x!=2){
                    z =30;
                }else{
                    z= 31;
                }
            }else{
                if(x % 2 ==0){
                    z =31;
                }else{
                    z=30;
                }
            }
           return z;
       }
            
                    
       private void Panjang_denda(string x)
       {
           int jarak_tahun, jarak_bulan, jarak_tanggal,total_jarak;
           jarak_tahun =  int.Parse(x.Substring(6, 4));
           jarak_tahun = DateTimeOffset.Now.Year - jarak_tahun;
           if (jarak_tahun > 0)
           {
               jarak_tahun = int.Parse(x.Substring(6, 4));
               jarak_bulan = int.Parse(x.Substring(0, 2)) ;
               jarak_tanggal = int.Parse(x.Substring(3, 2));
               total_jarak = jumlah_tanggal(jarak_bulan, jarak_tahun) - jarak_tanggal;
               jarak_bulan++;
               while (jarak_tahun <= DateTimeOffset.Now.Year)
               {
                   while (jarak_bulan <= 12)
                   {
                       total_jarak = total_jarak + jumlah_tanggal(jarak_bulan, jarak_tahun);
                       jarak_bulan++;
                   }
                   jarak_bulan = 1;
                   jarak_tahun = jarak_tahun + 1;
                   while (jarak_bulan <= DateTimeOffset.Now.Month)
                   {
                       if (jarak_bulan == DateTimeOffset.Now.Month)
                       {
                           total_jarak = total_jarak + DateTimeOffset.Now.Day;
                           jarak_bulan++;
                       }
                       else
                       {
                           total_jarak = total_jarak + jumlah_tanggal(jarak_bulan, jarak_tahun);
                           jarak_bulan++;
                       }
                   }
                   jarak_tahun++;
               }
           }
           else if (DateTimeOffset.Now.Month - int.Parse(x.Substring(0, 2)) > 0)
           {
               jarak_tanggal = int.Parse(x.Substring(3, 2));
               jarak_bulan = int.Parse(x.Substring(0, 2));
               jarak_tahun = int.Parse(x.Substring(6, 4));
               if (jarak_tahun - DateTimeOffset.Now.Year > 0)
               {
                   total_jarak = 0;
               }
               else
               {
                   total_jarak = jumlah_tanggal(jarak_bulan, jarak_tahun) - jarak_tanggal;
                   jarak_bulan++;
                   while (jarak_bulan <= DateTimeOffset.Now.Month)
                   {
                       if (jarak_bulan == DateTimeOffset.Now.Month)
                       {
                           total_jarak = total_jarak + DateTimeOffset.Now.Day;
                           jarak_bulan++;
                       }
                       else
                       {
                           total_jarak = total_jarak + jumlah_tanggal(jarak_bulan, jarak_tahun);
                           jarak_bulan++;
                       }
                   }
               }
           }
           else if (DateTimeOffset.Now.Day - int.Parse(x.Substring(3, 2)) > 0)
           {
               jarak_tanggal = int.Parse(x.Substring(3, 2));
               jarak_bulan = int.Parse(x.Substring(0, 2));
               jarak_tahun = int.Parse(x.Substring(6, 4));
               if (jarak_bulan - DateTimeOffset.Now.Month > 0)
               {
                   total_jarak = 0;
               }
               else
               {
                   total_jarak = DateTimeOffset.Now.Day - jarak_tanggal;
               }
           }
           else
           {
               total_jarak = 0;
           }
           denda = total_jarak;
      }
       private string bulan_indo(string x){
           string bulan = "";
           switch(x){
               case "1"    : bulan = "Januari";
                             break;
               case "2"    : bulan = "Februari";
                             break;
               case "3"    : bulan = "Maret";
                             break;
               case "4"    : bulan = "April";
                             break;
               case "5"    : bulan ="Mei";
                             break;
               case "6"    : bulan ="Juni";
                             break;
               case "7"    : bulan ="Juli";
                             break;
               case "8"    : bulan = "Agustus";
                             break;
               case "9"    : bulan = "September";
                             break;
               case "10"   : bulan = "Oktober";
                             break;
               case "11"   : bulan = "November";
                             break;
               case "12"   : bulan = "Desember";
                             break;
           }
           return bulan;
       }

       private void cbfaktur_TextChanged(object sender, EventArgs e)
       {
           if (cbfaktur.Text != "")
           {
               sql = "select*from rental where no_sewa ='" + cbfaktur.Text + "'";
               trental = koneksi.tampil_data(sql);
               if (trental.Rows.Count != 0)
               {
                   String tempbulan, temptanggal, temptahun, tampung;
                   Double temp = 0;
                   int pos = 0;
                   int next = 0;
                   lbl_tanggal.Text = trental.Rows[0].ItemArray.GetValue(1).ToString();
                   next = lbl_tanggal.Text.IndexOf("/", pos);
                   tempbulan = lbl_tanggal.Text.Substring(pos, next - pos);
                   pos = next + 1;
                   next = lbl_tanggal.Text.IndexOf("/", pos);
                   temptanggal = lbl_tanggal.Text.Substring(pos, next - pos);
                   temptahun = lbl_tanggal.Text.Substring(next + 1, 4);
                   lbl_tanggal.Text = temptanggal + " " + bulan_indo(tempbulan) + " " + temptahun;
                   lbl_plat.Text = trental.Rows[0].ItemArray.GetValue(4).ToString();
                   lbl_sopir.Text = trental.Rows[0].ItemArray.GetValue(2).ToString();
                   lbl_lama.Text = trental.Rows[0].ItemArray.GetValue(6).ToString();
                   lama = int.Parse(lbl_lama.Text);
                   lbl_harga.Text = trental.Rows[0].ItemArray.GetValue(8).ToString();
                   lbl_uangmuka.Text = trental.Rows[0].ItemArray.GetValue(7).ToString();
                   uang_muka = double.Parse(trental.Rows[0].ItemArray.GetValue(7).ToString());
                   harga_sewa = double.Parse(trental.Rows[0].ItemArray.GetValue(8).ToString());
                   harus_kembali = trental.Rows[0].ItemArray.GetValue(10).ToString();
                   pos = 0;
                   next = harus_kembali.IndexOf("/", pos);
                   tempbulan = harus_kembali.Substring(pos, next - pos);
                   pos = next + 1;
                   next = harus_kembali.IndexOf("/", pos);
                   temptanggal = harus_kembali.Substring(pos, next - pos);
                   temptahun = harus_kembali.Substring(next + 1, 4);
                   if (int.Parse(tempbulan) < 10)
                   {
                       tempbulan = "0" + tempbulan;
                   }
                   if (int.Parse(temptanggal) < 10)
                   {
                       temptanggal = "0" + temptanggal;
                   }
                   harus_kembali = tempbulan + "-" + temptanggal + "-" + temptahun;
                   Panjang_denda(harus_kembali);
                   sql = "select kode_mobil from mobil where id='" + lbl_plat.Text + "'";
                   tampung = koneksi.tampil_data(sql).Rows[0].ItemArray.GetValue(0).ToString();
                   sql = "select harga from harga_sewa where golongan='" + tampung + "'";
                   temp = double.Parse(koneksi.tampil_data(sql).Rows[0].ItemArray.GetValue(0).ToString());
                   if (lbl_sopir.Text != "-")
                   {
                       denda = (denda * temp) + (denda * 100000);
                       lbl_denda.Text = denda.ToString("###,###");
                   }
                   else
                   {
                       denda = denda * temp;
                       lbl_denda.Text = denda.ToString("###,###");
                   }
                    sisa= (harga_sewa-uang_muka) + denda;
                   if (sisa > 0)
                   {
                       lbl_sisa.Text = "Rp. " +sisa.ToString("###,###");
                   }
                   else
                   {
                       lbl_sisa.Text = "Rp.0";
                   }
                   lbl_nama.Text = trental.Rows[0].ItemArray.GetValue(5).ToString();
                   sql = "Select idplg from pelanggan where nama='" + lbl_nama.Text + "'";
                   lbl_id.Text = koneksi.tampil_data(sql).Rows[0].ItemArray.GetValue(0).ToString();
                   grand_total = double.Parse(trental.Rows[0].ItemArray.GetValue(8).ToString()) + denda;
                   if (denda == 0 && sisa == 0)
                   {
                       txt_bayar.Text = "0";
                       txt_bayar.Enabled = false;
                   }
                   else
                   {
                       txt_bayar.Text = "";
                       txt_bayar.Enabled = true;
                   }
                   cbfaktur.Enabled = false;
               }
               else
               {
                   inisialisasi();
               }
           }
           else
           {
               inisialisasi();
           }
       }

       private void reset_Click(object sender, EventArgs e)
       {
           inisialisasi();
           cbfaktur.Enabled = true;
       }

       private void proses_Click(object sender, EventArgs e)
       {
           if ((cbfaktur.Text == "Pilih No Faktur") || (lbl_id.Text==""))
           {
               MessageBox.Show("Anda belum memilih Faktur sewa", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
           }
           else if (txt_bayar.Text == "")
           {
               MessageBox.Show("Anda belum menginputkan Pembayaran pelanggan", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
           }
           else if (sosok < 0)
           {
               MessageBox.Show("Pembayaran tidak mencukupi", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
           }
           else
           {
               pembayaran = (pembayaran - sosok) + uang_muka;
               sql = "Update mobil set status='Tersedia' where id='" + lbl_plat.Text + "'";
               koneksi.dml(sql);
               sql = "update sopir set status='Tersedia' where nama='" + lbl_sopir.Text + "'";
               koneksi.dml(sql);
               sql = "Update rental set denda='" + denda + "',uang_muka='" + pembayaran + "', sisa_bayar='0',back='Y' where no_sewa ='" + cbfaktur.Text + "'";
               koneksi.dml(sql);
               MessageBox.Show("Proses pengembalian telah selesai", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
               inisialisasi();
               cbfaktur.Enabled = true;
           }
       }

       private void txt_bayar_KeyPress(object sender, KeyPressEventArgs e)
       {
           if (!char.IsNumber(e.KeyChar) && e.KeyChar != (char)8)
           {
               e.Handled = true;
           }
       }

       private void txt_bayar_KeyUp(object sender, KeyEventArgs e)
       {
           if (txt_bayar.Text != "")
           {
               double temp;
               pembayaran = double.Parse(txt_bayar.Text);
               temp = sisa - pembayaran;
               sosok = pembayaran - sisa;
               if (sosok > 0)
               {
                   lbl_sosok.Text = "Rp. " + sosok.ToString("###,###");
               }
               else
               {
                   lbl_sosok.Text = "Rp. 0";
               }
               if (temp > 0)
               {
                   lbl_sisa.Text = "Rp. " + temp.ToString("###,###");
               }
               else
               {
                   lbl_sisa.Text = "Rp. 0";
               }
               txt_bayar.Text = pembayaran.ToString("###,###");
               txt_bayar.SelectionStart = txt_bayar.Text.Length + 1;
           }
           else
           {
               lbl_sisa.Text = "Rp. " + sisa.ToString("###,###");
           }
       }

       private void lbl_uangmuka_TextChanged(object sender, EventArgs e)
       {
           if (lbl_uangmuka.Text != "")
           {
               double temp;
               temp = double.Parse(lbl_uangmuka.Text);
               lbl_uangmuka.Text = temp.ToString("###,###");
           }
       }

       private void lbl_denda_TextChanged(object sender, EventArgs e)
       {
           if (lbl_denda.Text != "")
           {
               double temp;
               temp = double.Parse(lbl_denda.Text);
               lbl_denda.Text = temp.ToString("###,###");
           }
       }

       private void lbl_harga_TextChanged(object sender, EventArgs e)
       {
           if (lbl_harga.Text != "")
           {
               double temp;
               temp = double.Parse(lbl_harga.Text);
               lbl_harga.Text = temp.ToString("###,###");
           }
       }
   }
}


Form pembayaran

===================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace index
{
   public partial class pembayaran : Form
   {
       private String[] pelanggan = new String[6];
       private Double[] Harga = new Double[2];
       private int lama;
       private Double uang_muka,sisa_bayar;
       private String sql = null;
       private kon koneksi = new kon();
       private String tanggal,bulan,tahun;
       public rental init;

       public pembayaran(String[] x, Double[] y, int z)
       {
           InitializeComponent();
           pelanggan = x;
           Harga = y;
           lama = z;
       }

       private void inisialisasi()
       {
           grandtotal.Text = Harga[1].ToString("###,###");
           uangmuka.Text = "";
           sisa.Text = "0";
           atur_tanggal();
      }

       private void atur_tanggal()
       {
           int temp,tempbul,temhun;
           if (DateTimeOffset.Now.Month < 8)
           {
               if (DateTimeOffset.Now.Month == 2)
               {
                   if (DateTimeOffset.Now.Year % 4 == 0)
                   {
                       if (DateTimeOffset.Now.Day + lama > 29)
                       {
                           temp = lama - (29 - DateTimeOffset.Now.Day);
                           tempbul = DateTimeOffset.Now.Month + 1;
                           temhun = DateTimeOffset.Now.Year;
                       }
                       else
                       {
                           temp = DateTimeOffset.Now.Day + lama;
                           tempbul = DateTimeOffset.Now.Month;
                           temhun = DateTimeOffset.Now.Year;
                       }
                   }
                   else
                   {
                       if (DateTimeOffset.Now.Day + lama > 28)
                       {
                           temp = lama - (28 - DateTimeOffset.Now.Day);
                           tempbul = DateTimeOffset.Now.Month + 1;
                           temhun = DateTimeOffset.Now.Year;
                       }
                       else
                       {
                           temp = DateTimeOffset.Now.Day + lama;
                           tempbul = DateTimeOffset.Now.Month;
                           temhun = DateTimeOffset.Now.Year;
                       }
                   }
               }
               else if ((DateTimeOffset.Now.Month % 2 == 0) && (DateTimeOffset.Now.Month != 2))
               {
                   if (DateTimeOffset.Now.Day + lama > 30)
                   {
                       temp = lama - (30 - DateTimeOffset.Now.Day);
                       tempbul = DateTimeOffset.Now.Month + 1;
                       temhun = DateTimeOffset.Now.Year;
                   }
                   else
                   {
                       temp = DateTimeOffset.Now.Day + lama;
                       tempbul = DateTimeOffset.Now.Month;
                       temhun = DateTimeOffset.Now.Year;
                   }
               }
               else
               {
                   if (DateTimeOffset.Now.Day + lama > 31)
                   {
                       temp = lama - (31 - DateTimeOffset.Now.Day);
                       tempbul = DateTimeOffset.Now.Month + 1;
                       temhun = DateTimeOffset.Now.Year;
                   }
                   else
                   {
                       temp = DateTimeOffset.Now.Day + lama;
                       tempbul = DateTimeOffset.Now.Month;
                       temhun = DateTimeOffset.Now.Year;
                   }
               }
           }
           else
           {
               if (DateTimeOffset.Now.Month == 12)
               {
                   if (DateTimeOffset.Now.Day + lama > 31)
                   {
                       temp = lama - (31 - DateTimeOffset.Now.Day);
                       tempbul = 1;
                       temhun = DateTimeOffset.Now.Year+1;

                   }
                   else
                   {
                       temp = DateTimeOffset.Now.Day + lama;
                       tempbul = DateTimeOffset.Now.Month;
                       temhun = DateTimeOffset.Now.Year;
                   }
               }else if ((DateTimeOffset.Now.Month % 2 == 0)&& (DateTimeOffset.Now.Month !=12))
               {
                   if (DateTimeOffset.Now.Day + lama > 31)
                   {
                       temp = lama - (31 - DateTimeOffset.Now.Day);
                       tempbul = DateTimeOffset.Now.Month + 1;
                       temhun = DateTimeOffset.Now.Year;
                   }
                   else
                   {
                       temp = DateTimeOffset.Now.Day + lama;
                       tempbul = DateTimeOffset.Now.Month;
                       temhun = DateTimeOffset.Now.Year;
                   }
               }
               else
               {
                   if (DateTimeOffset.Now.Day + lama > 30)
                   {
                       temp = lama - (30 - DateTimeOffset.Now.Day);
                       tempbul = DateTimeOffset.Now.Month + 1;
                       temhun = DateTimeOffset.Now.Year;
                   }
                   else
                   {
                       temp = DateTimeOffset.Now.Day + lama;
                       tempbul = DateTimeOffset.Now.Month + 1;
                       temhun = DateTimeOffset.Now.Year;
                   }
               }
           }
           if (temp < 10)
           {
               tanggal = "0" + temp;
           }
           else
           {
               tanggal = temp.ToString();
           }
           if (tempbul < 10)
           {
               bulan = "0" + tempbul;
           }
           else
           {
               bulan = tempbul.ToString();
           }
           tahun = temhun.ToString();
       }
       private void pembayaran_Load(object sender, EventArgs e)
       {
           inisialisasi();
       }

       private void uangmuka_KeyPress(object sender, KeyPressEventArgs e)
       {
           if (!char.IsNumber(e.KeyChar) && e.KeyChar != (char)8)
                   {
                       e.Handled = true;
                   }
       }

       private void uangmuka_KeyUp(object sender, KeyEventArgs e)
       {

           if (uangmuka.Text != "")
           {
               uang_muka = double.Parse(uangmuka.Text);
               uangmuka.Text = uang_muka.ToString("###,###");
               uangmuka.SelectionStart = uangmuka.Text.Length + 1;
               sisa_bayar = Harga[1] - uang_muka;
               if (sisa_bayar < 0)
               {
                   sisa.Text = "0";
                   sisa_bayar = 0;
               }
               else
               {
                   sisa.Text = sisa_bayar.ToString("###,###");
               }
           }
       }

       private void selesai_Click(object sender, EventArgs e)
       {
           string harus_kembali = tahun+"-"+bulan+"-"+tanggal;
           string sekarang = DateTimeOffset.Now.Year + "-" + DateTimeOffset.Now.Month + "-" + DateTimeOffset.Now.Day;
           string ganti_sop;
           double sosok;
           if (pelanggan[3] == "")
           {
               ganti_sop = "-";
           }
           else
           {
               ganti_sop = pelanggan[3];
           }
           if (uangmuka.Text == "")
           {
               MessageBox.Show("Uang muka belum di inputkan ", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
           }
           else
           {
               sql = "update mobil set status='Order' where id='" + pelanggan[2] + "'";
               koneksi.dml(sql);
               if (pelanggan[3] != "")
               {
                   sql = " update sopir set status ='Ordered' where nama ='" + pelanggan[3] + "'";
                   koneksi.dml(sql);
               }
               sql = " select * from pelanggan where idplg ='" + pelanggan[0] + "'";
                   if (koneksi.tampil_data(sql).Rows.Count == 0)
                   {
                       sql = " insert into pelanggan (idplg, nama) values('" + pelanggan[0] + "','" + pelanggan[1] + "')";
                       koneksi.dml(sql);
                   }
                   else
                   {
                       sql = "update pelanggan set  nama='" + pelanggan[1] + "' where idplg='" + pelanggan[0] + "'";
                       koneksi.dml(sql);
                   }
               sql = " insert into rental (no_sewa, tanggal, sopir,operator, id_mobil, pelanggan, lama_rental, uang_muka, harga_sewa, sisa_bayar, kembali, denda, back) Values('" + pelanggan[4] + "','" + sekarang + "','" + ganti_sop + "','" + pelanggan[5] + "','" + pelanggan[2] + "','" + pelanggan[1] + "','" + lama + "','" + uang_muka + "','" +Harga[1] + "','" + sisa_bayar + "','" + harus_kembali + "','0','N')";
               koneksi.dml(sql);
               if (Harga[1] - uang_muka < 0)
               {
                   sosok = uang_muka - Harga[1];
                   MessageBox.Show("Proses telah selesai, Kembalian ke pelanggan sebesarRp."+sosok.ToString("###,###"),"Information",MessageBoxButtons.OK,MessageBoxIcon.Information);
                   init.inisialisasi();
                   this.Close();
               }else{
               MessageBox.Show("Proses telah selesai", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
               init.inisialisasi();
                this.Close();
               }
           }
                   
       }
   }
}

Form ubah_pass

==================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace index
{
   public partial class ubah_pass : Form
   {
       private kon koneksi = new kon();
       private String sql = null;
       private kripto encript = new kripto();
       public ubah_pass(string x)
       {
           InitializeComponent();
           username.Text = x;

       }

       private void inisialisasi()
       {
           oldpass.Text = "";
           newpass.Text = "";
           ulangpass.Text = "";
           oldpass.Focus();
       }
       private void ubah_pass_Load(object sender, EventArgs e)
       {
           inisialisasi();
       }

       private void button1_Click(object sender, EventArgs e)
       {
           if (oldpass.Text == "")
           {
               MessageBox.Show("Password lama belum di inputkan", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
               oldpass.Focus();
           }
           else if (newpass.Text == "")
           {
               MessageBox.Show("Password baru belum di inputkan", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
               newpass.Focus();
           }
           else if (ulangpass.Text == "")
           {
               MessageBox.Show("Ulang password belum di inputkan", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
               ulangpass.Focus();
           }
           else if (newpass.Text != ulangpass.Text)
           {
               MessageBox.Show("Password baru dengan ulang password tidak sama silahkan ulangi", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
               ulangpass.Text = "";
               ulangpass.Focus();
           }
           else
           {
               sql = "select * from operator where id ='" + username.Text + "' and password ='" + encript.enkripsi(oldpass.Text) + "'";
               if (koneksi.tampil_data(sql).Rows.Count == 0)
               {
                   MessageBox.Show("Update Gagal, password lama tidak cocok", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   inisialisasi();
               }
               else
               {
                   sql = "update operator set password='" + encript.enkripsi(newpass.Text) + "' where id='" + username.Text + "'";
                   koneksi.dml(sql);
                   MessageBox.Show("Password telah di perbaharui", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   this.Close();
               }
           }
       }

       private void ulangpass_KeyDown(object sender, KeyEventArgs e)
       {
           if(e.KeyCode == Keys.Enter){
               button1_Click(sender, e);
           }
       }

      

   }
}

Form report

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace index
{
   public partial class report : Form
   {
       public report()
       {
           InitializeComponent();
       }

       private void report_Load(object sender, EventArgs e)
       {
           this.rentalTableAdapter.Fill(this.rentreport.rental);

           this.reportViewer1.RefreshReport();
       }

       private void report_FormClosing(object sender, FormClosingEventArgs e)
       {
           reportViewer1.LocalReport.ReleaseSandboxAppDomain();
       }
   }
}


Next untuk melihat tampilan

0 Comments

Copyright Jujur Soaloon Sitangang Lipan All rights reserved. Theme by Sitanggang. | Bloggerized by Soalparna.