void refresh_pelanggan() { SqlConnection conn = konn.GetConn(); { try { conn.Open(); cmd = new SqlCommand("Select * From tbl_pelanggan", conn); ds = new DataSet(); da = new SqlDataAdapter(cmd); da.Fill(ds, "tbl_pelanggan"); dataGridView_Pelanggan2.DataSource = ds; dataGridView_Pelanggan2.DataMember = "tbl_pelanggan"; dataGridView_Pelanggan2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView_Pelanggan2.AllowUserToAddRows = false; dataGridView_Pelanggan2.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { conn.Close(); } } }
//4. Membuat prosedur refresh_barang public void refresh_barang() { SqlConnection conn = konn.GetConn(); { try { conn.Open(); cmd = new SqlCommand("SELECT * FROM tbl_barang", conn); ds = new DataSet(); da = new SqlDataAdapter(cmd); da.Fill(ds, "tbl_barang"); dataGridView_barang.DataSource = ds; dataGridView_barang.DataMember = "tbl_barang"; dataGridView_barang.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView_barang.AllowUserToAddRows = false; dataGridView_barang.Refresh(); } catch (Exception e) { MessageBox.Show(e.ToString()); } finally { conn.Close(); } } }//tutup prosedur refresh_pelanggan
//prosedr awal private void awal() { //panggil prosedur bersih Bersih(); //mennaktifkan data grid penjualan DataGridPenjualan.Enabled = false; SqlConnection conn = konn.GetConn(); { try { conn.Open(); cmd = new SqlCommand("select * from kwitansi order by NomorKwitansi desc", conn); ds = new DataSet(); da = new SqlDataAdapter(cmd); da.Fill(ds, "kwitansi"); DataGridPenjualan.DataSource = ds; DataGridPenjualan.DataMember = "kwitansi"; DataGridPenjualan.Refresh(); } catch (Exception e) { MessageBox.Show(e.ToString()); } finally { conn.Close(); } } }
private void awal() { clear(); SqlConnection conn = konn.GetConn(); { try { conn.Open(); cmd = new SqlCommand("select * from vw_penjualan order by NoKwitansi DESC", conn); ds = new DataSet(); da = new SqlDataAdapter(cmd); da.Fill(ds, "vw_penjualan"); dataGridView_transaksi.DataSource = ds; dataGridView_transaksi.DataMember = "vw_penjualan"; dataGridView_transaksi.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView_transaksi.AllowUserToAddRows = false; dataGridView_transaksi.Refresh(); } catch (Exception e) { MessageBox.Show(e.ToString()); } finally { conn.Close(); } } }
public void Awal() { //panggil procedure bersih didalam procedure awal bersih(); SqlConnection conn = konn.GetConn(); { try { conn.Open(); //buka sql server, buat view penjualan cmd = new SqlCommand("SELECT * FROM vw_penjualan ORDER BY NoKwitansi DESC", conn); ds = new DataSet(); da = new SqlDataAdapter(cmd); da.Fill(ds, "vw_penjualan"); dataGridView_transaksi.DataSource = ds; dataGridView_transaksi.DataMember = "vw_penjualan"; dataGridView_transaksi.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView_transaksi.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { conn.Close(); } groupBox_transaksi.Enabled = false; } }
//7. membuat prosedur awal private void awal() { //panggil prosedur bersih di dalam prosedur awal bersih(); SqlConnection conn = konn.GetConn(); { try { conn.Open(); //buka microsoft sqlserver, membuat view penjualan cmd = new SqlCommand("SELECT * FROM vw_penjualan order by NoKwitansi DESC", conn); ds = new DataSet(); da = new SqlDataAdapter(cmd); da.Fill(ds, "vw_penjualan"); dataGridView_transaksi.DataSource = ds; dataGridView_transaksi.DataMember = "vw_penjualan"; dataGridView_transaksi.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView_transaksi.AllowUserToAddRows = false; dataGridView_transaksi.Refresh(); } catch (Exception e) { MessageBox.Show(e.ToString()); } finally { conn.Close(); } groupBox_transaksi.Enabled = false; //menonaktifkan groupbox data penjualan } }
private void btnLogin_Click(object sender, EventArgs e) { //7. SqlDataReader reader = null; SqlConnection conn = konn.GetConn(); conn.Open(); cmd = new SqlCommand("select * from tbl_admin where Username = '******' and Password = '******'", conn); cmd.ExecuteNonQuery(); reader = cmd.ExecuteReader(); if (reader.Read()) { MessageBox.Show("Login Berhasil", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); FMenuUtama.mdiobj.Menu_Master.Enabled = true; FMenuUtama.mdiobj.Menu_Transaksi.Enabled = true; FMenuUtama.mdiobj.Tool_Pegawai.Enabled = true; FMenuUtama.mdiobj.Tool_Barang.Enabled = true; FMenuUtama.mdiobj.Tool_Pemakaian.Enabled = true; FMenuUtama.mdiobj.Tool_Pengembalian.Enabled = true; FMenuUtama.mdiobj.logoutToolStripMenuItem.Enabled = true; FMenuUtama.mdiobj.loginToolStripMenuItem.Enabled = false; this.Close(); } else { MessageBox.Show("Username atau Password Salah !", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning); bersih(); } conn.Close(); }
//5. private void awal() { bersih(); dataGridPengembalian.Enabled = false; SqlConnection conn = konn.GetConn(); { try { conn.Open(); cmd = new SqlCommand("select * from tbl_pengembalian order by NoPengembalian desc", conn); ds = new DataSet(); da = new SqlDataAdapter(cmd); da.Fill(ds, "tbl_pengembalian"); dataGridPengembalian.DataSource = ds; dataGridPengembalian.DataMember = "tbl_pengembalian"; dataGridPengembalian.Refresh(); } catch (Exception e) { MessageBox.Show(e.ToString()); } finally { conn.Close(); } } }
public string Auto(String NamaTabel, String Kode, String Id) { string kode = ""; int a, x, cek = 0; string angka = null; string sql = "SELECT * FROM " + NamaTabel + " ORDER BY SUBSTRING(" + Id + ",3,6) ASC"; try { SqlCommand command = new SqlCommand(); command.Connection = konn.GetConn(); command.Connection.Open(); command.CommandType = CommandType.Text; command.CommandText = sql; SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { cek++; angka = reader.GetString(0).ToString().Substring(2, 4); } command.Connection.Close(); if (cek != 0) { x = Int32.Parse(angka); a = x + 1; if (a >= 1 && a < 10) { kode = Kode + "-" + "000" + a; } else if (a >= 10 && a < 100) { kode = Kode + "-" + "00" + a; } else if (a >= 100 && a < 1000) { kode = Kode + "-" + "0" + a; } else if (a >= 1000 && a < 10000) { kode = Kode + "-" + "" + a; } else if (a >= 10000) { MessageBox.Show("Error", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Kode Habis", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { kode = Kode + "-" + "0001"; } } catch (SqlException e) { MessageBox.Show("" + e); } return(kode); }
public DataSet getData() { DataSet dts = new DataSet(); try { string sql = "SELECT * FROM tbl_bbm"; SqlCommand command = new SqlCommand(); command.Connection = konn.GetConn(); command.CommandType = CommandType.Text; command.CommandText = sql; SqlDataAdapter data = new SqlDataAdapter(command); data.Fill(dts, "tbl_bbm"); }//try catch (Exception e) { MessageBox.Show("get\n" + e.ToString()); }//catch return(dts); }//getData
//membuat prosedur atur pelanggan void refresh_pelanggan() { SqlConnection conn = konn.GetConn(); try { conn.Open(); cmd = new SqlCommand("select * from pelanggan", conn); ds = new DataSet(); da = new SqlDataAdapter(cmd); da.Fill(ds, "pelanggan"); ListPelanggan.DataSource = ds; ListPelanggan.DataMember = "pelanggan"; ListPelanggan.Refresh(); } catch (Exception e) { MessageBox.Show(e.ToString()); } finally { conn.Close(); } }
//prosedur refresh barang void refresh_barang() { SqlConnection conn = konn.GetConn(); try { conn.Open(); cmd = new SqlCommand("select * from barang", conn); ds = new DataSet(); da = new SqlDataAdapter(cmd); da.Fill(ds, "barang"); DataGridBarang.DataSource = ds; DataGridBarang.DataMember = "barang"; DataGridBarang.Refresh(); } catch (Exception e) { MessageBox.Show(e.ToString()); } finally { conn.Close(); } }
void refresh_barang() { SqlConnection conn = konn.GetConn(); { try { conn.Open(); cmd = new SqlCommand("select * from tbl_barang", conn); ds = new DataSet(); da = new SqlDataAdapter(cmd); da.Fill(ds, "tbl_barang"); ///<sumary> ///data gird view /// </sumary> dataGridView_barang.DataSource = ds; dataGridView_barang.DataMember = "tbl_barang"; dataGridView_barang.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView_barang.AllowUserToAddRows = false; dataGridView_barang.Refresh(); } catch (Exception e) { MessageBox.Show(e.ToString()); } finally { conn.Close(); } } }
//5. void cetak void cetak() { SqlConnection conn = konn.GetConn(); { conn.Open(); da = new SqlDataAdapter("select * from tbl_pelanggan order by IdPelanggan asc", conn); ds = new DataSet(); da.Fill(ds, "tbl_barang"); report_pelanggan myreport = new report_pelanggan(); myreport.SetDataSource(ds); crystalReportViewer1.ReportSource = myreport; crystalReportViewer1.Refresh(); } }
private void FCetakTanggalPakai_Load(object sender, EventArgs e) { //4. SqlConnection conn = konn.GetConn(); conn.Open(); da = new SqlDataAdapter("select * from View_Pemakaian where Tanggal = '" + FLaporan.objLaporan.dtpPerTanggalPakai.Text + "'", conn); ds = new DataSet(); da.Fill(ds, "View_Pemakaian"); Laporan.LaporanTanggalPakai myReportTanggalPakai = new Laporan.LaporanTanggalPakai(); myReportTanggalPakai.SetDataSource(ds); reportTanggalPakai.ReportSource = myReportTanggalPakai; reportTanggalPakai.Refresh(); }
//8. void cetak void cetak() { SqlConnection conn = konn.GetConn(); { conn.Open(); da = new SqlDataAdapter("select * from vw_cetaktransaksi where NoKwitansi = '" + text_kwitansi + "'", conn); ds = new DataSet(); da.Fill(ds, "vw_cetaktransaksi"); report_transaksi myreport = new report_transaksi(); myreport.SetDataSource(ds); crystalReportViewer1.ReportSource = myreport; crystalReportViewer1.Refresh(); } }
private void FCetakPengembalian_Load(object sender, EventArgs e) { //4. SqlConnection conn = konn.GetConn(); conn.Open(); da = new SqlDataAdapter("select * from View_Pengembalian where NoPengembalian = '" + FPengembalian.objPengembalian.txtNoPengembalian.Text + "'", conn); ds = new DataSet(); da.Fill(ds, "View_Pengembalian"); Laporan.LaporanKembali myReportKembali = new Laporan.LaporanKembali(); myReportKembali.SetDataSource(ds); crystalReportKembali.ReportSource = myReportKembali; crystalReportKembali.Refresh(); }
private void FCetakStokBarang_Load(object sender, EventArgs e) { //4. SqlConnection conn = konn.GetConn(); conn.Open(); da = new SqlDataAdapter("select * from tbl_barang", conn); ds = new DataSet(); da.Fill(ds, "tbl_barang"); Laporan.LaporanBarang myReportStokBrg = new Laporan.LaporanBarang(); myReportStokBrg.SetDataSource(ds); crystalReportStokBrg.ReportSource = myReportStokBrg; crystalReportStokBrg.Refresh(); }
void CetakLaporanPelanggan() { SqlConnection conn = konn.GetConn(); { conn.Open(); da = new SqlDataAdapter("SELECT * FROM tbl_pelanggan ORDER BY IDPelanggan ASC ", conn); ds = new DataSet(); da.Fill(ds, "tbl_pelanggan"); report_pelanggan myreport_plgn = new report_pelanggan(); myreport_plgn.SetDataSource(ds); crystalReportViewer1.ReportSource = myreport_plgn; crystalReportViewer1.Refresh(); conn.Close(); } }
void CetakLaporanBarang() { SqlConnection conn = konn.GetConn(); { conn.Open(); da = new SqlDataAdapter("SELECT * FROM tbl_barang ORDER BY KodeBarang ASC", conn); ds = new DataSet(); da.Fill(ds, "tbl_barang"); report_barang myreport = new report_barang(); myreport.SetDataSource(ds); crystalReportViewer1.ReportSource = myreport; crystalReportViewer1.Refresh(); conn.Close(); } }
//6. void Refresh_Pegawai() { SqlConnection conn = konn.GetConn(); try { conn.Open(); cmd = new SqlCommand("SELECT * FROM tbl_pegawai", conn); ds = new DataSet(); da = new SqlDataAdapter(cmd); da.Fill(ds, "tbl_pegawai"); listPegawai.DataSource = ds; listPegawai.DataMember = "tbl_pegawai"; listPegawai.Refresh(); } catch (Exception e) { MessageBox.Show(e.ToString()); } finally { conn.Close(); } }
private void crystalReportViewer1_Load(object sender, EventArgs e) { //load kwitansi berdasarkan nomorkwitansi SqlConnection conn = konn.GetConn(); conn.Open(); da = new SqlDataAdapter("select * from View_Kwitansi where NomorKwitansi = '" + FTransaksi.ObjTransaksi.TxtNoKwitansi.Text + "'", conn); ds = new DataSet(); da.Fill(ds, "View_Kwitansi"); //memanggil report cetak kwitansi Laporan.CetakKwitansi myReport = new Laporan.CetakKwitansi(); myReport.SetDataSource(ds); crystalReportViewer1.ReportSource = myReport; crystalReportViewer1.Refresh(); }
void CetakLaporanTranskasi() { SqlConnection conn = konn.GetConn(); { conn.Open(); da = new SqlDataAdapter("SELECT * FROM vw_CetakTransaksi WHERE NoKwitansi = '" + text_kwitansi + "' ", conn); //da = new SqlDataAdapter("SELECT * FROM vw_CetakTransaksi ", conn); ds = new DataSet(); da.Fill(ds, "vw_CetakTransaksi"); report_transaksi myreport_trns = new report_transaksi(); myreport_trns.SetDataSource(ds); crystalReportViewer1.ReportSource = myreport_trns; crystalReportViewer1.Refresh(); conn.Close(); } }
private void BtnLogin_Click(object sender, EventArgs e) { //coding button login SqlDataReader reader = null; SqlConnection conn = konn.GetConn(); conn.Open(); cmd = new SqlCommand("select * from tbl_login where username = '******' and password = '******'", conn); cmd.ExecuteNonQuery(); reader = cmd.ExecuteReader(); //jika user dan password benar if (reader.Read()) { MessageBox.Show("Login Berhasil", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); FMenuUtama.mdiobj.MenuMaster.Enabled = true; FMenuUtama.mdiobj.MenuTransaction.Enabled = true; FMenuUtama.mdiobj.submenu_logout.Enabled = true; FMenuUtama.mdiobj.submenu_login.Enabled = false; FMenuUtama.mdiobj.ToolCustomer.Enabled = true; FMenuUtama.mdiobj.ToolItems.Enabled = true; FMenuUtama.mdiobj.ToolTransaction.Enabled = true; //form login keluar this.Close(); } //jika user atau password salah else { MessageBox.Show("Username atau Password Salah !!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtUserName.Text = ""; TxtPassword.Text = ""; TxtUserName.Focus(); } //tutup koneksi conn.Close(); }
private void button_masuk_Click(object sender, EventArgs e) { SqlConnection conn = konn.GetConn(); conn = konn.GetConn(); try { conn.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM tbl_pengguna where nama_pengguna='" + textBox_namaPengguna.Text + "'and kata_sandi='" + textBox_kataSandi.Text + "'", conn); dr = cmd.ExecuteReader(); int count = 0; while (dr.Read()) { count += 1; } if (count == 1) { MessageBox.Show("Anda Berhasil Login!", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information); //File Tool Strip Aktif menuUtama.MenuUtama.fileToolStripMenuItem.Enabled = true; menuUtama.MenuUtama.logOutToolStripMenuItem.Enabled = true; menuUtama.MenuUtama.exitToolStripMenuItem.Enabled = true; //Transaksi Tool Strip Aktif menuUtama.MenuUtama.transaksiToolStripMenuItem.Enabled = true; menuUtama.MenuUtama.transaksiToolStripMenuItem1.Enabled = true; //Master Tool Strip Aktif menuUtama.MenuUtama.masterToolStripMenuItem.Enabled = true; menuUtama.MenuUtama.bBMToolStripMenuItem.Enabled = true; menuUtama.MenuUtama.pOMPAToolStripMenuItem.Enabled = true; menuUtama.MenuUtama.pENGELUARANToolStripMenuItem.Enabled = true; //Laporan Tool Strip Aktif menuUtama.MenuUtama.laporanToolStripMenuItem.Enabled = true; this.Close(); } else if ((textBox_namaPengguna.Text == "") && (textBox_kataSandi.Text == "")) { MessageBox.Show("Harap isi Username dan Password terlebih dahulu !", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning); Bersih_Enable(); textBox_namaPengguna.Focus(); } else if (textBox_namaPengguna.Text == "") { MessageBox.Show("Harap isi Username terlebih dahulu !", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning); Bersih_Enable(); textBox_namaPengguna.Focus(); } else if (textBox_kataSandi.Text == "") { MessageBox.Show("Harap isi Password terlebih dahulu !", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning); Bersih_Enable(); textBox_namaPengguna.Focus(); } else { MessageBox.Show("Username / Password yang anda inputkan salah !", "Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning); Bersih_Enable(); textBox_namaPengguna.Focus(); } conn.Close(); } catch (Exception x) { MessageBox.Show(x.ToString()); } }