-
Notifications
You must be signed in to change notification settings - Fork 0
/
Buku.cs
73 lines (63 loc) · 1.95 KB
/
Buku.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Aplikasi_Perpustakaan
{
public partial class Buku : Form
{
public Buku()
{
InitializeComponent();
}
public void nav(object sender, EventArgs e)
{
Page page = new Page();
this.Hide();
page.Move(sender, e);
}
private void Buku_FormClosing(object sender, FormClosingEventArgs e)
{
Application.Exit();
}
private void Buku_Load(object sender, EventArgs e)
{
lbl_nama.Text = Login.nama;
btn_user.Visible = Login.permission;
panel4.Visible = Login.permission;
panel_admin.Visible = !Login.permission;
}
private void btn_simpan_Click(object sender, EventArgs e)
{
string jenis = txt_jenis.Text.ToString();
string nama = txt_nama.Text.ToString();
if (!string.IsNullOrEmpty(jenis) || !string.IsNullOrEmpty(nama))
{
string sql = "INSERT INTO [dbo].[buku] (Nama, Jenis) VALUES (@nama, @jenis)";
SqlCommand cmd = new SqlCommand(sql, Navigasi.cnn);
cmd.Parameters.AddWithValue("@nama", nama);
cmd.Parameters.AddWithValue("@nama", jenis);
try
{
Page.EXECUTE(cmd);
MessageBox.Show("Buku Berhasil Tersimpan");
}
catch(Exception)
{
MessageBox.Show("Simpan Data Gagal");
}
}
else
{
MessageBox.Show("Tolong Isi Semua Kolom");
}
}
}
}