Senin, 27 Mei 2013

Perhitungan Reklame GUI C++



Coding 15
Source Code: Perhitungan Reklame



 

tambahkan kode ini pada button1
 String^ username="Royan";
                      String^ password="1234";
                      //pengandaian if
                      //jika nilai inputan ditextbox1=username dan textBox2=password
                      if((username=textBox1->Text)&&(password==textBox2->Text))

                      {
                      MessageBox::Show("Selamat anda berhasil Login");
                      this->Visible=false;//form 1 disembunyikan
                      Form^ form = gcnew Form2();
                      form->Show();//untuk menampilkan form2
                      //this->Close();
                      
                      }
                      else
                      {
                      MessageBox::Show("Login Gagal");//menampilkan pesan gagal
                      }


Tambahkan kode ini pada posisi paling atas/header

//untuk memanggil Form2
#include"Form2.h"

 Tambahkan kode ini pada button 2

private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
                      this->Close();
               }







 Kemudian isikan kode dibawah ini pada combobox 1 / cbjenis 

       private: System::Void comboBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
                            if((cbjenis->Text=="Sponsor")||(cbjenis->Text=="Peragaan"))
                            {
                            txtsatuan->Text="Perkegiatan";
                            }
                            else if(cbjenis->Text=="Rombong")
                            {
                            txtsatuan->Text="Unit";
                            }
                            else if (cbjenis->Text=="Balon Udara")
                                    txtsatuan->Text="Perbuah";
                            else if (cbjenis->Text=="Film/Slide")
                                    txtsatuan->Text="Rol";
                            else
                            {
                            txtsatuan->Text="M2";
                            }


                            //kode untuk menampilkan Nilai NJOPR pada txtnjopr
                             if(cbjenis->Text=="Megatron")
                            {
                            txtnjopr->Text="750000";
                            lblmasaizin->Text="2 Tahun";
                            }
                             else if(cbjenis->Text=="Video wall")
                            {
                            txtnjopr->Text="500000";
                            lblmasaizin->Text="2 Tahun";
                            }
                             else if(cbjenis->Text=="Dynamic Board")
                            {
                            txtnjopr->Text="300000";
                            lblmasaizin->Text="2 Tahun";
                            }
                             else if(cbjenis->Text=="Billboard")
                            {
                            txtnjopr->Text="100000";
                            lblmasaizin->Text="2 Tahun";
                            }
                             else if(cbjenis->Text=="Papan Produk")
                            {
                            txtnjopr->Text="60000";
                            lblmasaizin->Text="2 Tahun";
                            }
                            else if(cbjenis->Text=="Papan Merk Toko")
                            {
                            txtnjopr->Text="40000";
                            lblmasaizin->Text="2 Tahun";
                            }
                             else if(cbjenis->Text=="Tin Plate")
                            {
                            txtnjopr->Text="15000";
                            lblmasaizin->Text="2 Tahun";
                            }
                            else if(cbjenis->Text=="Baligo")
                            {
                            txtnjopr->Text="17500";
                            lblmasaizin->Text="1 Bulan";
                            }
                             else if(cbjenis->Text=="Neon Box")
                             {
                            txtnjopr->Text="75000";
                            lblmasaizin->Text="2 Tahun";
                            }
                             else if(cbjenis->Text=="Kain")
                            {
                            txtnjopr->Text="3000";
                            lblmasaizin->Text="1 Minggu";
                            }
                              else if(cbjenis->Text=="Spanduk/Baligo/Umbul")
                            {
                            txtnjopr->Text="7500";
                            lblmasaizin->Text="1 Bulan";
                            }
                              else if(cbjenis->Text=="Poster/Tempelan")
                            {
                            txtnjopr->Text="2500";
                             lblmasaizin->Text="1 Bulan";
                            }
                               else if(cbjenis->Text=="Flaig chain")
                            {
                            txtnjopr->Text="4000";
                             lblmasaizin->Text="1 Bulan";
                            }
                               else if(cbjenis->Text=="Selebaran/Brosur")
                            {
                            txtnjopr->Text="2500";
                             lblmasaizin->Text="1 Bulan";
                            }
                                    else if(cbjenis->Text=="Kendaraan Berjalan")
                            {
                            txtnjopr->Text="70000";
                             lblmasaizin->Text="2 Tahun";
                            }

                                      else if(cbjenis->Text=="Rombong")
                            {
                            txtnjopr->Text="150000";
                             lblmasaizin->Text="2 Tahun";
                            }
                                      else if(cbjenis->Text=="Balon Udara")
                            {
                            txtnjopr->Text="150000";
                             lblmasaizin->Text="1 Minggu";
                            }
                                           else if(cbjenis->Text=="Film/Slide")
                            {
                            txtnjopr->Text="50000";
                             lblmasaizin->Text="1 minggu";
                            }
                                           else if(cbjenis->Text=="Peragaan")
                            {
                            txtnjopr->Text="50000";
                              lblmasaizin->Text="1 hari";
                            }
                                             else if(cbjenis->Text=="Sponsor")
                            {
                            txtnjopr->Text="25000";
                             lblmasaizin->Text="1 Hari";
                            }
                      }

Masukan kode dibawah ini pada txtsatuan

private: System::Void txtsatuan_TextChanged(System::Object^  sender, System::EventArgs^  e) {

                      if(txtsatuan->Text=="M2")
                      {
                      txtluas->Visible=true;
                      txtluas->Text="";
                      }
                      else
                      {
                      txtluas->Text="1";
                      txtluas->Visible=false;
                      
                      }
               }


Masukan kode dibawah ini pada cbindexjalan

private: System::Void cbindexjalan_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
             if(cbindexjalan->Text=="A")
                      {
                      txtindexjalan->Text="50";
                      }
                      else if(cbindexjalan->Text=="B")
                      {
                      txtindexjalan->Text="40";
                      }
                      else if(cbindexjalan->Text=="C")
                      {
                      txtindexjalan->Text="30";
                      }
                       else
                      {
                      txtindexjalan->Text="20";
                      }
               }

 Masukan kode dibawah ini pada button1

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

                      /*
                      perhitungan pajak reklame = luas * NJOPR * indexjalan * pajak 25%
                      pendidikan 25% NJOPR
                      dalam Ruangan 75% NJOPR

                                           */
                    
                     if((txtluas->Text=="0")||(txtbanyak->Text=="0"))
                     {
                     txtpajakreklame->Text="";
                     MessageBox::Show("Masukan nilainya diatas 0");
                    
                     }

                       if ((cbjenis->Text=="")|| (txtsatuan->Text=="") ||(txtnjopr->Text=="")||(cbmasaizin->Text=="")||(cbposisi->Text=="")||(cbfungsi->Text=="")||(cbindexjalan->Text=="")||(txtindexjalan->Text=="")||(txtluas->Text=="")||(txtbanyak->Text==""))
                       {
                       MessageBox::Show("Isi Semua data terlebih dahulu");

                       }
                       else
                       {
                        int luas,njopr,indexjalan,masaizin,banyak;
                      double pajakreklame;
                      luas = int::Parse(txtluas->Text);
                      njopr = int::Parse(txtnjopr->Text);
                      indexjalan = int::Parse(txtindexjalan->Text);
                      masaizin = int::Parse(cbmasaizin->Text);
                      banyak = int::Parse(txtbanyak->Text);
                      if((cbposisi->Text=="Luar Ruangan")&&(cbfungsi->Text=="Komersial"))
                      {
                      pajakreklame = Convert::ToDouble(luas * njopr *masaizin * indexjalan * 0.25 *banyak  ) ;
                      txtpajakreklame->Text = pajakreklame.ToString();
                      }
                       else if ((cbposisi->Text=="Luar Ruangan")&&(cbfungsi->Text=="Pendidikan/Sosial"))
                       {
                        pajakreklame = Convert::ToDouble(luas * njopr *masaizin * indexjalan * 0.25 * 0.25 *banyak) ;
                            txtpajakreklame->Text = pajakreklame.ToString();
                      }
                      else if ((cbposisi->Text=="Dalam Ruangan")&&(cbfungsi->Text=="Komersial"))
                      {
                        pajakreklame = Convert::ToDouble(luas * njopr *masaizin * indexjalan * 0.25 * 0.75 *banyak) ;
                            txtpajakreklame->Text = pajakreklame.ToString();
                      }
                       else
                       {
                        pajakreklame = Convert::ToDouble(luas * njopr *masaizin * indexjalan * 0.25 * 0.75 * 0.25 *banyak) ;
                            txtpajakreklame->Text = pajakreklame.ToString();
                      }
                       }
               }
private: System::Void Form2_Load(System::Object^  sender, System::EventArgs^  e) {

                    
               }

Masukan kode dibawah ini pada button2 / btbatal


private: System::Void btbatal_Click(System::Object^  sender, System::EventArgs^  e) {
                     
             
                      this->Close();
                    
               }

Masukan kode dibawah ini pada txtluas dan evenya diganti dengan KeyPress

private: System::Void txtluas_KeyPress(System::Object^  sender, System::Windows::Forms::KeyPressEventArgs^  e) {
                       if ((e->KeyChar < '0') || (e->KeyChar > '9'))
                     {
                           if(e->KeyChar != char(8)){
                                  e->KeyChar = '\0';
                           }

                     }
               }


Masukan kode dibawah ini pada txtbanyak dan evenya diganti dengan KeyPress

private: System::Void txtbanyak_KeyPress(System::Object^  sender, System::Windows::Forms::KeyPressEventArgs^  e) {
                      if ((e->KeyChar < '0') || (e->KeyChar > '9'))
                     {
                           if(e->KeyChar != char(8)){
                                  e->KeyChar = '\0';
                           }

                     }
               }
};
}

Deskripsi singkat:
Desain Form1
Toolbox
Properties Name
TextBox1
TextBox1
TextBox2
TextBox1
Button1
Button1
Desain Form2
Toolbox
Properties Name
ComboBox1
Cbjenis
TextBox1
Txtsatuan
TextBox2
Txtnjopr
ComboBox2
Cbmasaizin
ComboBox3
Cbposisi
ComboBox4
Cbindexjalan
TextBox3
Txtindexjalan
TextBox4
Txtluas
TextBox5
Txtbanyak
TextBox6
Txtpajakreklame
Button1
Bthitung
Button2
Btbatal


Video program

0 komentar:

Posting Komentar