ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
Pemrograman visual
1. UAS Pemrograman Visual
“C# - Database”
Oleh :
Andriyan Dwi P. (115623003)
D3 MANAJEMEN INFORMATIKA A
JURUSAN TEKNIK ELEKTRO
FAKULTAS TEKNIK
UNIVERSITAS NEGERI SURABAYA
2013
2. [LAPORAN UAS PEMROGRAMAN VISUAL] Kamis, 20 Juni 2013
1 | P a g e
SOAL UJIAN
1. Buat aplikasi yang menghasilkan ouput di bawah ini ;
a) ******* b) *
****** **
***** ***
**** ****
*** *****
** ******
* *******
c) ******* d)* *
****** ** **
***** *** ***
**** **** ****
*** ***** *****
** ****** ******
* **************
**
***
****
*****
******
*******
2. Buat aplikasi database yang terdiri dari form Login,form input
data(tambah,edit,simpan,delete,batal) database yang digunakan : mysql, sqlserver
express, posgresql
Nb : soal no.2 semakin lengkap aplikasinya semakin baik nilainya.
3. [LAPORAN UAS PEMROGRAMAN VISUAL] Kamis, 20 Juni 2013
2 | P a g e
No.1)
CONSOLE
a. Source code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UAS_no1
{
class a
{
static void Main(string[] args)
{
string lagi;
do
{
int a, i, j;
Console.WriteLine("Berapa Baris Bintang ?");
a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("-----------------------------");
for (i = a; i >= 1; i--)
{
for (j = i; j >= 1; j--)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.Write("Apakah Anda ingin lagi ?[y/t] n");
lagi = Convert.ToString(Console.ReadLine());
} while (lagi == "y" || lagi == "Y");
}
}
}
Screenshoot :
4. [LAPORAN UAS PEMROGRAMAN VISUAL] Kamis, 20 Juni 2013
3 | P a g e
b. Source code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UAS_1b
{
class b
{
static void Main(string[] args)
{
string lagi;
do
{
int a, i, j;
Console.WriteLine("Berapa Baris Bintang ?");
a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("-----------------------------");
for (i = 1; i <= a; i++)
{
for (j = 1; j <= i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.Write("Apakah Anda ingin lagi ?[y/t] n");
lagi = Convert.ToString(Console.ReadLine());
} while (lagi == "y" || lagi == "Y");
}
}
}
Screenshoot :
5. [LAPORAN UAS PEMROGRAMAN VISUAL] Kamis, 20 Juni 2013
4 | P a g e
c. Source code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UAS_1c
{
class c
{
static void Main(string[] args)
{
string lagi;
do
{
int a, i, j;
Console.WriteLine("Berapa Baris Bintang ?");
a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("-----------------------------");
for (i = a; i >= 1; i--)
{
for (j = i; j >= 1; j--)
{
Console.Write("*");
}
Console.WriteLine();
}
for (i = 1; i <= a; i++)
{
for (j = 1; j <= i; j++)
{
Console.Write("*");
}
Console.WriteLine();
}
Console.Write("Apakah Anda ingin lagi ?[y/t] n");
lagi = Convert.ToString(Console.ReadLine());
} while (lagi == "y" || lagi == "Y");
}
}
}
Screenshoot :
6. [LAPORAN UAS PEMROGRAMAN VISUAL] Kamis, 20 Juni 2013
5 | P a g e
d. Source code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UAS_1d
{
class d
{
static void Main(string[] args)
{
string lagi;
do
{
int a, i, j;
Console.WriteLine("Berapa Baris Bintang ?");
a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("-----------------------------");
{
int b, c, d;
d = 1; c = a - 1;
Console.Write("n");
for (i = 0; i < a * 2 - 1; i++)
{
if (i < a)
{
for (j = 0; j < a * 2 - 1; j++)
{
b = a - c;
if ((j < b) || (j >= (b + 2 * c - 1)))
{
Console.Write("*");
}
else
{
Console.Write(" ");
}
}
c = c - 1;
}
Console.WriteLine();
}
}
Console.Write("Apakah Anda ingin lagi ?[y/t] n");
lagi = Convert.ToString(Console.ReadLine());
} while (lagi == "y" || lagi == "Y");
}
}
}
7. [LAPORAN UAS PEMROGRAMAN VISUAL] Kamis, 20 Juni 2013
6 | P a g e
Screenshoot :
WINDOWS FORM
Source code :
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 UAS_no1
{
public partial class UAS_1 : Form
{
public UAS_1()
{
InitializeComponent();
}
int a, i, j;
private void btnReset_Click(object sender, EventArgs e)
{
txtBaris.ResetText();
richTxtHasil.ResetText();
}
private void btnA_Click(object sender, EventArgs e)
{
a = System.Convert.ToInt32(txtBaris.Text);
for (i = a; i >= 1; i--)
{
for (j = i; j >= 1; j--)
{
richTxtHasil.AppendText("*");
}
8. [LAPORAN UAS PEMROGRAMAN VISUAL] Kamis, 20 Juni 2013
7 | P a g e
richTxtHasil.AppendText(Environment.NewLine);
}
}
private void btnB_Click(object sender, EventArgs e)
{
a = System.Convert.ToInt32(txtBaris.Text);
for (i = 1; i <= a; i++)
{
for (j = 1; j <= i; j++)
{
richTxtHasil.AppendText("*");
}
richTxtHasil.AppendText(Environment.NewLine);
}
}
private void btnC_Click(object sender, EventArgs e)
{
a = System.Convert.ToInt32(txtBaris.Text);
for (i = a; i >= 1; i--)
{
for (j = i; j >= 1; j--)
{
richTxtHasil.AppendText("*");
}
richTxtHasil.AppendText(Environment.NewLine);
}
for (i = 1; i <= a; i++)
{
for (j = 1; j <= i; j++)
{
richTxtHasil.AppendText("*");
}
richTxtHasil.AppendText(Environment.NewLine);
}
}
private void btnD_Click(object sender, EventArgs e)
{
int b, c, d;
d = 1; c = a - 1;
a = System.Convert.ToInt32(txtBaris.Text);
Console.Write("n");
for (i = 0; i < a * 2 - 1; i++)
{
if (i < a)
{
for (j = 0; j < a * 2 - 1; j++)
{
b = a - c;
if ((j < b) || (j >= (b + 2 * c - 1)))
{
richTxtHasil.AppendText("*");
}
else
{
richTxtHasil.AppendText(" ");
9. [LAPORAN UAS PEMROGRAMAN VISUAL] Kamis, 20 Juni 2013
8 | P a g e
}
}
c = c - 1;
}
richTxtHasil.AppendText(Environment.NewLine);
}
}
}
}
Screenshoot :
10. [LAPORAN UAS PEMROGRAMAN VISUAL] Kamis, 20 Juni 2013
9 | P a g e
No. 2) Database : MySQL
LOGIN
Source Code :
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;
using MySql.Data.MySqlClient;
namespace UAS_no2
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
txtPassword.PasswordChar = '*';
txtPassword.MaxLength = 9;
}
private void btnLogin_Click(object sender, EventArgs e)
{
try
{
string myConnection =
"datasource=localhost;port=3306;username=root;password=";
11. [LAPORAN UAS PEMROGRAMAN VISUAL] Kamis, 20 Juni 2013
10 | P a g e
MySqlConnection myConn = new MySqlConnection(myConnection);
MySqlCommand SelectCommand = new MySqlCommand("select * from
visual.login where username='" + this.txtUsername.Text + "' and password='" +
this.txtPassword.Text + "' ;", myConn);
MySqlDataReader myReader;
myConn.Open();
myReader = SelectCommand.ExecuteReader();
int count = 0;
while (myReader.Read())
{
count = count + 1;
}
if (count == 1)
{
MessageBox.Show("Username dan password Anda benar");
this.Hide();
MenuUtama f2 = new MenuUtama();
f2.ShowDialog();
}
else if (count > 1)
{
MessageBox.Show("Duplicate Username dan Password . . . Access
denied");
}
else
{
MessageBox.Show("Username dan password Anda Salah. . . Please try
again !");
myConn.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnReset_Click(object sender, EventArgs e)
{
txtUsername.ResetText();
txtPassword.ResetText();
}
private void Login_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult dialog = MessageBox.Show("Beneran sudah selesai nie ? hhe",
"Exit", MessageBoxButtons.YesNo);
if (dialog == DialogResult.Yes)
{
Application.Exit();
}
else if (dialog == DialogResult.No)
12. [LAPORAN UAS PEMROGRAMAN VISUAL] Kamis, 20 Juni 2013
11 | P a g e
{
e.Cancel = true;
}
}
}
}
Screenshoot :
Setelah berhasil melakukan proses login, user akan langsung masuk ke Form Menu Utama,
dimana pada form ini proses Insert, Update, Delete dan proses menampilkan data terjadi.
Menu Utama
Source Code :
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;
using System.IO;
using MySql.Data.MySqlClient;
13. [LAPORAN UAS PEMROGRAMAN VISUAL] Kamis, 20 Juni 2013
12 | P a g e
namespace UAS_no2
{
public partial class MenuUtama : Form
{
public MenuUtama()
{
InitializeComponent();
fillCombo();
load_table();
Load_chart();
}
string kelamin;
void Load_chart()
{
string constring =
"datasource=localhost;port=3306;username=root;password=";
string lihat = "select * from visual.biodata;";
MySqlConnection conDatabase = new MySqlConnection(constring);
MySqlCommand cmdLihat = new MySqlCommand(lihat, conDatabase);
MySqlDataReader myReader;
try
{
conDatabase.Open();
myReader = cmdLihat.ExecuteReader();
while (myReader.Read())
{
this.chart1.Series["Umur"].Points.AddXY(myReader.GetString("fname"),
myReader.GetString("Umur"));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
void fillCombo()
{
string constring =
"datasource=localhost;port=3306;username=root;password=";
string lihat = "select * from visual.biodata;";
MySqlConnection conDatabase = new MySqlConnection(constring);
MySqlCommand cmdLihat = new MySqlCommand(lihat, conDatabase);
MySqlDataReader myReader;
try
{
conDatabase.Open();
myReader = cmdLihat.ExecuteReader();
14. [LAPORAN UAS PEMROGRAMAN VISUAL] Kamis, 20 Juni 2013
13 | P a g e
while (myReader.Read())
{
string sNama = myReader.GetString("fname");
comboBox1.Items.Add(sNama);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
void load_table()
{
string constring =
"datasource=localhost;port=3306;username=root;password=";
string lihat = "select idbiodata as 'ID', fname as 'First Name', lname as
'Last Name', Umur, gender as 'Jenis Kelamin', tanggallahir as 'Tanggal Lahir' from
visual.biodata;";
MySqlConnection conDatabase = new MySqlConnection(constring);
MySqlCommand cmdLihat = new MySqlCommand(lihat, conDatabase);
try
{
MySqlDataAdapter sda = new MySqlDataAdapter();
sda.SelectCommand = cmdLihat;
DataTable dbdataset = new DataTable();
sda.Fill(dbdataset);
BindingSource bSource = new BindingSource();
bSource.DataSource = dbdataset;
dataGridView1.DataSource = bSource;
sda.Update(dbdataset);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnSimpan_Click(object sender, EventArgs e)
{
byte[] imageBt= null;
FileStream fstream = new FileStream(this.txtImage_loc.Text, FileMode.Open,
FileAccess.Read);
BinaryReader br = new BinaryReader(fstream);
imageBt = br.ReadBytes((int)fstream.Length);
string constring =
"datasource=localhost;port=3306;username=root;password=";
string insert = "insert into visual.biodata
(idbiodata,fname,lname,umur,gender,tanggallahir,gambar)"+