Académique Documents
Professionnel Documents
Culture Documents
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.Data.SqlClient;
namespace CUSTOMER
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
this.customerTableAdapter.Fill(this.kantinAmikomDataSet1.customer);
resetdata ();
showdata ();
}
int num;
bool isNum = int.TryParse(txtvoucher.Text.ToString(), out num);
if (!isNum)
{
MessageBox.Show("isi voucher harus angka","Peringatan");
goto berhenti;
}
con.Open();
SqlCommand cmd = new SqlCommand ();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into customer values ('" + txtid.Text + "','" +
txtnama.Text + "'," + int.Parse(txtvoucher.Text) + ")";
cmd.ExecuteNonQuery();
con.Close();
showdata();
resetdata();
berhenti:
;
}
con.Open();
SqlCommand cmd = new SqlCommand ();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "update customer set namaCustomer = '" + txtid.Text + "',
nominalIsi=" +
txtvoucher.Text + "Where idcustomer = '" + txtid.Text + "'";
cmd.ExecuteNonQuery();
con.Close();
showdata();
resetdata();
berhenti:
;
}
con.Open();
SqlCommand cmd = new SqlCommand ();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "delete from customer where idcustomer = '" + txtid.Text + "'";
cmd.ExecuteNonQuery();
con.Close();
showdata();
resetdata();
berhenti:
;
}
}
}
Data menu
Lisiting program :
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.Data.SqlClient;
namespace Data_Menu
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int num;
bool isNum = int.TryParse(txtharga.Text.ToString(), out num);
if (!isNum)
{
MessageBox.Show("isi harga harus angka","Peringatan");
goto berhenti;
}
con.Open();
SqlCommand cmd = new SqlCommand ();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into menu values ('" + txtid.Text + "','" +
txtmenu.Text + "'," + int.Parse(txtharga.Text) + ")";
cmd.ExecuteNonQuery();
con.Close();
showdata();
resetdata();
berhenti:
;
}
Store procedure
Buat query procedure di sql server
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.Data.SqlClient;
namespace Stored_Procedure
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
idmenu.Value=txtid.Text;
namamenu.Value=txtnama.Text;
harga.Value=txtharga.Text;
cmd.Parameters.Add(idmenu);
cmd.Parameters.Add(namamenu);
cmd.Parameters.Add(harga);
cmd.ExecuteNonQuery();
con.Close();
showdata();
resetdata();
}
idmenu.Value = txtid.Text;
cmd.Parameters.Add(idmenu);
cmd.ExecuteNonQuery();
con.Close();
showdata();
}
}
}
Data pengguna
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.Data.SqlClient;
namespace Data_Pengguna
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
try
{
for (int x = 0; x < wordArray.Length; x++)
{
char[] buffer = wordArray[x].ToCharArray();
for (int i = 0; i < buffer.Length; i++)
{
char letter = buffer[i];
letter = (char)(letter + shift);
catch (Exception e)
{
MessageBox.Show(e.ToString());
return null;
}
}
con.Open();
SqlCommand cmd = new SqlCommand ();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into admin values ('" + txtuser.Text + "','" +
tekscipher + "')";
cmd.ExecuteNonQuery();
con.Close();
showdata();
resetdata();
berhenti:
;
}
con.Open();
SqlCommand cmd = new SqlCommand ();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "update into set password='" + tekscipher + "'where userid='"
+
txtuser.Text + "'";
cmd.ExecuteNonQuery();
con.Close();
showdata();
resetdata();
berhenti:
;
}
con.Open();
SqlCommand cmd = new SqlCommand ();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "delete from admin where userid='" + txtuser.Text + "'";
cmd.ExecuteNonQuery();
con.Close();
showdata();
resetdata();
berhenti:
;
}
}
}
Form login
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.Data.SqlClient;
namespace form_login
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
try
{
for (int x = 0; x < wordArray.Length; x++)
{
char[] buffer = wordArray[x].ToCharArray();
for (int i = 0; i < buffer.Length; i++)
{
char letter = buffer[i];
letter = (char)(letter + shift);
catch (Exception e)
{
MessageBox.Show(e.ToString());
return null;
}
}
private void Form1_Load(object sender, EventArgs e)
{
con.Close();
SqlCommand cmd = new SqlCommand("selest * from admin where userid-'" +
txtuser.Text + "' and password= '" + tekscipher + "'", con);
con.Open();
SqlDataReader rd = cmd.ExecuteReader();
if (rd.HasRows)
{
rd.Read();
Form1 frm_menu = new Form1();
frm_menu.Show();
}
else
{
MessageBox.Show("User id atau password tidak valid", "Peringatan");
txtuser.Text = "";
txtpwd.Text = "";
txtuser.Focus();
rd.Close();
}
berhenti:
;
}
}
}
}
Listing program :
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 tampilan
{
public partial class form1 : Form
{
public form1()
{
InitializeComponent();
}
}
}
}