Esempio n. 1
0
 private void btnConfirm_Click(object sender, EventArgs e)
 {
     if (tbId.Enabled == false)
     {
         Koneksi.openConn();
         cmd = new MySqlCommand("update supplier set nama_supplier = '" + tbNama.Text + "', alamat_supplier = '" + tbAlamat.Text + "', kota_supplier = '" + tbKota.Text + "' where id_supplier='" + tbId.Text + "' ", Koneksi.conn);
         cmd.ExecuteNonQuery();
         btnCancel.Enabled  = false;
         btnConfirm.Enabled = false;
         disabletextbox();
         Koneksi.conn.Close();
     }
     else if (tbId.Text != "" && tbNama.Text != "" && tbAlamat.Text != "" && tbKota.Text != "" && tbId.TextLength == 4)
     {
         Koneksi.openConn();
         cmd = new MySqlCommand("insert into supplier values('" + tbId.Text + "','" + tbNama.Text + "','" + tbAlamat.Text + "','" + tbKota.Text + "')", Koneksi.conn);
         cmd.ExecuteNonQuery();
         disabletextbox();
         btnCancel.Enabled = false; btnConfirm.Enabled = false;
         btnNew.Enabled    = true;
         kosongitextbox();
         this.ActiveControl = btnNew;
         Koneksi.conn.Close();
     }
     else
     {
         MessageBox.Show("Data Belum Lengkap");
     }
     btnConfirm.Enabled = false;
     refreshlist();
 }
Esempio n. 2
0
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked == true)
            {
                status = "1";
            }
            else
            {
                status = "0";
            }
            Koneksi.openConn();
            da = new MySqlDataAdapter("select h.id_beli as Nomer, b.tanggaljatuhtempo as \"Jatuh Tempo\", s.nama_supplier as Supplier ,format(h.total,0,'de_DE') as Total from hutang h, beli b, supplier s where h.id_beli = b.id_beli and h.status='" + status + "' and h.id_supplier = s.id_supplier order by b.tanggaljatuhtempo asc,Nomer desc", Koneksi.conn);
            ds = new DataSet();
            da.Fill(ds);
            dataGridView1.DataSource = ds.Tables[0];
            DataGridViewColumn col;

            col = dataGridView1.Columns[0]; col.Width = 80;
            col = dataGridView1.Columns[1]; col.Width = 75;
            col = dataGridView1.Columns[2]; col.Width = 200;
            col = dataGridView1.Columns[3]; col.Width = 120;
            col = dataGridView1.Columns[3]; col.Width = 100; dataGridView1.Columns["Total"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            Koneksi.conn.Close();
            count();
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Koneksi.openConn();
            string user   = textBox1.Text;
            string pass   = textBox2.Text;
            string passdb = "";

            sql = "select password_user from user where nama_user='******'";
            try
            {
                cmd    = new MySqlCommand(sql, Koneksi.conn);
                passdb = cmd.ExecuteScalar().ToString();
                if (passdb == pass)
                {
                    sql = "select pangkat from user where nama_user='******'";
                    cmd = new MySqlCommand(sql, Koneksi.conn);
                    string    pangkat = cmd.ExecuteScalar().ToString();
                    MdiParent f       = new MdiParent();
                    f.Show();
                }
                else
                {
                    MessageBox.Show("Password Salah");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("User Salah");
            }

            Koneksi.conn.Close();
        }
Esempio n. 4
0
 private void FormPromo_Load(object sender, EventArgs e)
 {
     Koneksi.openConn();
     loadnamapromo();
     this.ActiveControl = cbSearch;
     Koneksi.conn.Close();
 }
Esempio n. 5
0
        private void cbBarang_TextChanged(object sender, EventArgs e)
        {
            try
            {
                Koneksi.openConn();
                //this.ActiveControl = tbJumlah;
                sql = "select id_barang from barang where nama_barang='" + cbBarang.Text + "'";
                cmd = new MySqlCommand(sql, Koneksi.conn);
                string id = cmd.ExecuteScalar().ToString();
                tbKodeBarang.Text = id;
                Koneksi.conn.Close();
                Koneksi.openConn();
                sql = "select satuan_barang from barang where id_barang='" + tbKodeBarang.Text + "'";
                cmd = new MySqlCommand(sql, Koneksi.conn);
                string satuan = cmd.ExecuteScalar().ToString();
                tbSatuan.Text = satuan;

                Koneksi.conn.Close();
                Koneksi.openConn();
                cmd          = new MySqlCommand("select hpp from hpp where id_barang='" + tbKodeBarang.Text + "'", Koneksi.conn);
                tbHarga.Text = cmd.ExecuteScalar().ToString();
                Koneksi.conn.Close();
            }
            catch (Exception x)
            {}
        }
Esempio n. 6
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (tbIDPromo.Text != "")
            {
                activate(); loadbarang();
                string idpromo = tbIDPromo.Text;
                tbNamaPromo.Text = cbSearch.Text;
                isidatagrid.Clear();
                cbSearch.Enabled = false; cbSearch.Text = "";
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    string nama    = dataGridView1.Rows[i].Cells[0].Value.ToString();
                    string jumlah  = dataGridView1.Rows[i].Cells[1].Value.ToString();
                    string kemasan = dataGridView1.Rows[i].Cells[2].Value.ToString();
                    string poin    = dataGridView1.Rows[i].Cells[3].Value.ToString();
                    isidatagrid.Add(nama + "-" + jumlah + "-" + kemasan + "-" + poin);
                }
                Koneksi.openConn();
                cmd = new MySqlCommand("delete from dpromo where id_promo='" + idpromo + "'", Koneksi.conn);
                cmd.ExecuteNonQuery();
                Koneksi.conn.Close();

                cbStart.Enabled = true;  cbEnd.Enabled = true; cbYear.Enabled = true;
            }
        }
Esempio n. 7
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            activate(); loadbarang(); btnCancel.Enabled = false;
            string nonota = tbKodeBeli1.Text + "-" + tbKodeBeli2.Text;

            Koneksi.openConn();
            cmd = new MySqlCommand("select nama_barang,jumlah_barang from dbeli where id_beli='" + nonota + "'", Koneksi.conn);
            dr  = cmd.ExecuteReader();
            List <string> namabarang = new List <string>();
            List <string> qty        = new List <string>();

            while (dr.Read())
            {
                namabarang.Add(dr.GetString(0));
                qty.Add(dr.GetString(1));
            }
            Koneksi.conn.Close();
            Koneksi.openConn();
            for (int i = 0; i < namabarang.Count; i++)
            {
                cmd = new MySqlCommand("select id_barang from barang where nama_barang='" + namabarang[i] + "'", Koneksi.conn);
                string idbarang = cmd.ExecuteScalar().ToString();
                int    change   = Convert.ToInt32(qty[i]);
                cmd = new MySqlCommand("update stok set masuk=masuk-" + change + ", stok=stok-" + change + " where id_barang='" + idbarang + "'", Koneksi.conn);
                cmd.ExecuteNonQuery();
            }
            Koneksi.conn.Close();
            Koneksi.openConn();
            cmd = new MySqlCommand("delete from dbeli where id_beli='" + nonota + "'", Koneksi.conn);
            cmd.ExecuteNonQuery();
            cmd = new MySqlCommand("delete from beli where id_beli='" + nonota + "'", Koneksi.conn);
            cmd.ExecuteNonQuery();
            Koneksi.conn.Close();
        }
Esempio n. 8
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox1.Text != "")
         {
             Koneksi.openConn();
             sql = "select count(*) from kategori";
             cmd = new MySqlCommand(sql, Koneksi.conn);
             string temp         = cmd.ExecuteScalar().ToString();
             int    urutan       = Convert.ToInt32(temp) + 1;
             string kodekategori = urutan.ToString().PadLeft(4, '0');
             cmd = new MySqlCommand("insert into kategori values('" + kodekategori + "','" + textBox1.Text + "')", Koneksi.conn);
             cmd.ExecuteNonQuery();
             da = new MySqlDataAdapter("select nama_kategori as \"Nama Kategori\" from kategori", Koneksi.conn);
             ds = new DataSet();
             da.Fill(ds);
             dataGridView1.DataSource = ds.Tables[0];
             col                = dataGridView1.Columns[0]; col.Width = 150;
             textBox1.Text      = "";
             this.ActiveControl = textBox1;
             Koneksi.conn.Close();
         }
         else
         {
             MessageBox.Show("Kategori Tidak Boleh Kosong");
         }
     }
     catch (Exception x)
     {}
 }
Esempio n. 9
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     deactivate(); clearDatagrid();
     if (tbIDPromo.Text != "")
     {
         for (int i = 0; i < isidatagrid.Count; i++)
         {
             string[] temp = isidatagrid[i].Split('-');
             dataGridView1.Rows.Add(temp[0], temp[1], temp[2], temp[3]);
         }
         Koneksi.openConn();
         for (int i = 0; i < dataGridView1.Rows.Count; i++)
         {
             cmd = new MySqlCommand("select id_barang from barang where nama_barang='" + dataGridView1.Rows[i].Cells[0].Value.ToString() + "'", Koneksi.conn);
             string namabarang = cmd.ExecuteScalar().ToString();
             cmd = new MySqlCommand("insert into dpromo values('" + tbIDPromo.Text + "','" + namabarang + "','" + dataGridView1.Rows[i].Cells[1].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[3].Value.ToString() + "')", Koneksi.conn);
             cmd.ExecuteNonQuery();
         }
         Koneksi.conn.Close();
         cbSearch.Text    = tbNamaPromo.Text;
         tbNamaPromo.Text = "";
         deactivate();
     }
     else
     {
         tbKodeBarang.Text  = ""; cbBarang.Text = "";
         tbJumlah.Text      = "0"; tbPoin.Text = "0";
         tbIDPromo.Text     = ""; tbNamaPromo.Text = "";
         btnNew.Enabled     = true; btnEdit.Enabled = true;
         btnDelete.Enabled  = true; btnFind.Enabled = true;
         updating           = false;
         cbSearch.Enabled   = true;
         this.ActiveControl = btnNew;
     }
 }
Esempio n. 10
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            Koneksi.openConn();
            if (cbBarang.Text != "")
            {
                dataGridView1.DataSource = null;
                dataGridView1.Refresh();
                da = new MySqlDataAdapter("select b.tanggal as Tanggal, b.kode as Kode, b.id_beli as \"Nomer Nota\", s.nama_supplier as \"Customer/Supplier\", format(db.jumlah_barang,0,'de_DE') as Jumlah from beli b,supplier s,dbeli db where b.tanggal>='" + dtStart.Value.ToString("dd-MM-yy") + "' and b.tanggal<='" + dtEnd.Value.ToString("dd-MM-yy") + "' and b.kode=db.kode and b.id_beli=db.id_beli and b.id_supplier=s.id_supplier and db.nama_barang='" + cbBarang.Text + "' " +
                                          "union " +
                                          "select j.tanggal as Tanggal, j.kode as Kode, j.id_jual as \"Nomer Nota\", c.nama_customer as \"Customer/Supplier\", concat('-',format(dj.jumlah_barang,0,'de_DE')) as Jumlah from jual j,djual dj,customer c where j.tanggal>='" + dtStart.Value.ToString("dd-MM-yy") + "' and j.tanggal<='" + dtEnd.Value.ToString("dd-MM-yy") + "' and j.kode=dj.kode and j.id_jual=dj.id_jual and j.id_customer=c.id_customer and dj.nama_barang='" + cbBarang.Text + "' " +
                                          "union" +
                                          " select k.tanggal as Tanggal,  k.kode, k.id_nota, 'Supervisor', dk.jumlah from koreksistok k, dkoreksistok dk, barang b where k.id_nota=dk.id_nota and b.id_barang=dk.id_barang and b.nama_barang='" + cbBarang.Text + "' and k.tanggal>='" + dtStart.Value.ToString("dd-MM-yy") + "' and k.tanggal<='" + dtEnd.Value.ToString("dd-MM-yy") + "' order by Tanggal", Koneksi.conn);
                //da = new MySqlDataAdapter("select j.tanggal as Tanggal,j.kode as Kode, j.id_jual as \"Nomer Nota\", c.nama_customer as \"Customer/Supplier\", concat('-',format(dj.jumlah_barang,0,'de_DE')) as Jumlah from jual j,djual dj,customer c where j.tanggal>='" + dtStart.Value.ToString("dd-MM-yy") + "' and j.tanggal<='" + dtEnd.Value.ToString("dd-MM-yy") + "' and j.kode=dj.kode and j.id_jual=dj.id_jual and j.id_customer=c.id_customer and dj.nama_barang='" + cbBarang.Text + "' union select b.tanggal as Tanggal, b.kode as Kode, b.id_beli as \"Nomer Nota\", s.nama_supplier as \"Customer/Supplier\", format(db.jumlah_barang,0,'de_DE') as Jumlah from beli b,supplier s,dbeli db where b.tanggal>='" + dtStart.Value.ToString("dd-MM-yy") + "' and b.tanggal<='" + dtEnd.Value.ToString("dd-MM-yy") + "' and b.kode=db.kode and b.id_beli=db.id_beli and b.id_supplier=s.id_supplier and db.nama_barang='" + cbBarang.Text + "' union select k.tanggal as Tanggal,  k.kode, k.id_nota, 'Supervisor', dk.jumlah from koreksistok k, dkoreksistok dk, barang b where k.id_nota=dk.id_nota and b.id_barang=dk.id_barang and b.nama_barang='" + cbBarang.Text + "' and k.tanggal>='" + dtStart.Value.ToString("dd-MM-yy") + "' and k.tanggal<='" + dtEnd.Value.ToString("dd-MM-yy") + "' order by Tanggal", Koneksi.conn);
                //da = new MySqlDataAdapter("select j.tanggal as Tanggal,j.kode as Kode, j.id_jual, c.nama_customer, concat('-',format(dj.jumlah_barang,0,'de_DE')) as Jumlah from jual j,djual dj,customer c where j.tanggal between '"+dtStart.Value.ToString("yyyy-MM-dd")+"' and '"+dtEnd.Value.ToString("yyyy-MM-dd")+"' and j.kode=dj.kode and j.id_customer=c.id_customer and dj.nama_barang='Avian Cat Kayu 1 kg';", Koneksi.conn);
                ds = new DataSet();
                da.Fill(ds);
                dataGridView1.DataSource = ds.Tables[0];

                DataGridViewColumn col;
                col = dataGridView1.Columns[0]; col.Width = 65;
                col = dataGridView1.Columns[1]; col.Width = 45;
                col = dataGridView1.Columns[2]; col.Width = 80;
                col = dataGridView1.Columns[3]; col.Width = 170;
                col = dataGridView1.Columns[4]; col.Width = 60;
                col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            }
            Koneksi.conn.Close();
        }
Esempio n. 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            string search = textBox1.Text;

            loadlistbarang();
            Koneksi.openConn();
            if (comboBox1.Text == "ID")
            {
                da = new MySqlDataAdapter("select b.id_barang as \"ID Barang\", b.nama_barang as \"Nama Barang\", format(s.stok,0,'de_DE') as Stok, b.satuan_barang as Satuan, format(b.harga_barang,0,'de_DE') as Harga, b.nama_kategori as \"Nama Kategori\", b.deskripsi as Deskripsi, b.status as Status, format(h.hpp,0,'de_DE') as HPP from barang b, stok s, hpp h where b.id_barang=h.id_barang and s.id_barang=b.id_barang and b.id_barang like '%" + search + "%' and b.status='Aktif'", Koneksi.conn);
                ds = new DataSet();
                da.Fill(ds);
                dataGridView1.DataSource = ds.Tables[0];
            }
            else if (comboBox1.Text == "NAMA")
            {
                da = new MySqlDataAdapter("select b.id_barang as \"ID Barang\", b.nama_barang as \"Nama Barang\", format(s.stok,0,'de_DE') as Stok, b.satuan_barang as Satuan, format(b.harga_barang,0,'de_DE') as Harga, b.nama_kategori as \"Nama Kategori\", b.deskripsi as Deskripsi, b.status as Status, format(h.hpp,0,'de_DE') as HPP from barang b, stok s, hpp h where b.id_barang=h.id_barang and s.id_barang=b.id_barang and b.nama_barang like '%" + search + "%' and b.status='Aktif' ", Koneksi.conn);
                ds = new DataSet();
                da.Fill(ds);
                dataGridView1.DataSource = ds.Tables[0];
            }
            else if (comboBox1.Text == "KATEGORI")
            {
                try
                {
                    da = new MySqlDataAdapter("select b.id_barang as \"ID Barang\", b.nama_barang as \"Nama Barang\", format(s.stok,0,'de_DE') as Stok, b.satuan_barang as Satuan, format(b.harga_barang,0,'de_DE') as Harga, b.nama_kategori as \"Nama Kategori\", b.deskripsi as Deskripsi, b.status as Status, format(h.hpp,0,'de_DE') as HPP from barang b, stok s, hpp h where b.id_barang=h.id_barang and s.id_barang=b.id_barang and b.nama_kategori='" + textBox1.Text + "' and b.status='Aktif' ", Koneksi.conn);
                    ds = new DataSet();
                    da.Fill(ds);
                    dataGridView1.DataSource = ds.Tables[0];
                }
                catch (Exception x)
                {}
            }
            settingdatagrid();
            Koneksi.conn.Close();
        }
Esempio n. 12
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string tglnow = tbTanggal.Text;

            string[] splittgl        = tglnow.Split('-');
            string   insertedtanggal = splittgl[2] + "-" + splittgl[1] + "-" + splittgl[0];

            //insert into table koreksistok
            Koneksi.openConn();
            cmd = new MySqlCommand("insert into koreksistok values('AS','" + tbKodeNota1.Text + "-" + tbKodeNota2.Text + "','" + insertedtanggal + "','" + tbKeterangan.Text + "')", Koneksi.conn);
            cmd.ExecuteNonQuery();
            Koneksi.conn.Close();

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                string namabarang = dataGridView1.Rows[i].Cells[0].Value.ToString();
                string jumlah     = dataGridView1.Rows[i].Cells[1].Value.ToString();

                //get id barang per item
                Koneksi.openConn();
                cmd = new MySqlCommand("select id_barang from barang where nama_barang='" + namabarang + "'", Koneksi.conn);
                string idbarang = cmd.ExecuteScalar().ToString();
                Koneksi.conn.Close();

                //insert into table dkoreksistok
                Koneksi.openConn();
                cmd = new MySqlCommand("insert into dkoreksistok values('" + tbKodeNota1.Text + "-" + tbKodeNota2.Text + "','" + idbarang + "','" + jumlah + "')", Koneksi.conn);
                cmd.ExecuteNonQuery();
                Koneksi.conn.Close();

                //update table stok
                int stok, masuk, keluar;
                if (Convert.ToInt32(jumlah) < 0)
                {
                    //masuk penjualan & update keluar
                    Koneksi.openConn();
                    int qty = Convert.ToInt32(jumlah) * -1;
                    cmd = new MySqlCommand("update stok set keluar=keluar+'" + qty + "' where id_barang='" + idbarang + "'", Koneksi.conn);
                    cmd.ExecuteNonQuery();
                    Koneksi.conn.Close();
                }
                else
                {
                    //masuk pembelian & update masuk
                    Koneksi.openConn();
                    cmd = new MySqlCommand("update stok set masuk=masuk+'" + jumlah + "'  where id_barang='" + idbarang + "'", Koneksi.conn);
                    cmd.ExecuteNonQuery();
                    Koneksi.conn.Close();
                }
                //ganti stok
                Koneksi.openConn();
                cmd = new MySqlCommand("update stok set stok=stok+'" + jumlah + "' where id_barang='" + idbarang + "'", Koneksi.conn);
                cmd.ExecuteNonQuery();
                Koneksi.conn.Close();

                //deactivate
                deactivate();
                cleardatagrid();
            }
        }
Esempio n. 13
0
 private void cbBarang_TextChanged(object sender, EventArgs e)
 {
     try
     {
         Koneksi.openConn();
         tbDiskon1.Text     = "0.00"; tbDiskon2.Text = "0.00";
         this.ActiveControl = tbJumlah;
         sql = "select id_barang from barang where nama_barang='" + cbBarang.Text + "'";
         cmd = new MySqlCommand(sql, Koneksi.conn);
         string id = cmd.ExecuteScalar().ToString();
         tbKodeBarang.Text = id;
         sql = "select harga_barang from barang where id_barang='" + tbKodeBarang.Text + "'";
         cmd = new MySqlCommand(sql, Koneksi.conn);
         string harga = cmd.ExecuteScalar().ToString();
         tbHarga.Text = harga;
         sql          = "select satuan_barang from barang where id_barang='" + tbKodeBarang.Text + "'";
         cmd          = new MySqlCommand(sql, Koneksi.conn);
         string satuan = cmd.ExecuteScalar().ToString();
         tbSatuan.Text = satuan;
         string[] temp     = tbHarga.Text.Split('.');
         string   gabungan = "";
         foreach (string a in temp)
         {
             gabungan = gabungan + a;
         }
         hitungtotalperbarang(tbJumlah.Text, gabungan, tbDiskon1.Text, tbDiskon2.Text);
         Koneksi.conn.Close();
     }
     catch (Exception x)
     {
     }
 }
Esempio n. 14
0
        public void generatekodejual(string jenis, string tahunbulan)
        {
            DateTime date    = DateTime.Now;
            string   tanggal = date.Day.ToString();
            string   bulan   = date.Month.ToString();
            string   tahun   = date.Year.ToString();

            tanggal = tanggal.PadLeft(2, '0');
            bulan   = bulan.PadLeft(2, '0');
            string thn         = tahun.Substring(2, 2);
            string tanggalfull = tanggal + "-" + bulan + "-" + thn;

            tbTanggal.Text   = tanggalfull;
            tbKodeJual1.Text = thn + bulan;
            Koneksi.openConn();
            sql = "select count(*) from jual where kode='" + jenis + "' and substr(id_jual,1,4)='" + tahunbulan + "';";
            cmd = new MySqlCommand(sql, Koneksi.conn);
            string temp = cmd.ExecuteScalar().ToString();

            Koneksi.conn.Close();
            int    urutan   = Convert.ToInt32(temp) + 1;
            string kodejual = urutan.ToString().PadLeft(4, '0');

            tbKodeJual2.Text = kodejual;
            tbKodeJual.Text  = jenis;
        }
Esempio n. 15
0
        private void btnCount_Click(object sender, EventArgs e)
        {
            string tahun = cbTahun.Text;
            string start = cbStart.Text;

            //declare datatable
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Nama", typeof(string)));
            dt.Columns.Add(new DataColumn("Nomer", typeof(string)));
            dt.Columns.Add(new DataColumn("Total", typeof(Int32)));
            dt.Columns.Add(new DataColumn("Tanggal", typeof(DateTime)));

            Koneksi.openConn();
            cmd = new MySqlCommand("select s.nama_supplier as Nama, h.id_beli as ID, h.total, b.tanggaljatuhtempo as Tanggal from hutang h, supplier s, beli b where h.id_supplier=s.id_supplier and b.id_beli=h.id_beli and tanggal>='01-" + start + "-" + tahun + "' and tanggal<='31-" + start + "-" + tahun + "' order by Nama asc, ID asc", Koneksi.conn);
            dr  = cmd.ExecuteReader();
            while (dr.Read())
            {
                dt.Rows.Add(dr.GetString(0), dr.GetString(1), dr.GetString(2), dr.GetString(3));
            }
            Koneksi.conn.Close();

            LaporanHutang lh = new LaporanHutang();

            lh.Database.Tables["Piutang"].SetDataSource(dt);
            lh.SetParameterValue("start", Function.getMonth(start));
            lh.SetParameterValue("tahun", "20" + tahun);

            ReportViewer v = new ReportViewer();

            v.crvTransaksi.ReportSource = null;
            v.crvTransaksi.ReportSource = lh;
            v.Show();
        }
Esempio n. 16
0
        private void cbSearch_TextChanged(object sender, EventArgs e)
        {
            try
            {
                Koneksi.openConn();
                cmd            = new MySqlCommand("select id_promo from promo where nama='" + cbSearch.Text + "' ", Koneksi.conn);
                tbIDPromo.Text = cmd.ExecuteScalar().ToString();
                Koneksi.conn.Close();
                Koneksi.openConn();
                da = new MySqlDataAdapter("select b.nama_barang as \"Nama Barang\", d.jumlah as Jumlah,b.satuan_barang as Satuan ,d.poin as Poin from barang b, dpromo d where d.id_barang=b.id_barang and d.id_promo='" + tbIDPromo.Text + "'", Koneksi.conn);
                ds = new DataSet();
                da.Fill(ds);
                clearDatagrid();
                settingdatagrid();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    dataGridView1.Rows.Add(ds.Tables[0].Rows[i][0].ToString(), ds.Tables[0].Rows[i][1].ToString(), ds.Tables[0].Rows[i][2].ToString(), ds.Tables[0].Rows[i][3].ToString());
                }
                Koneksi.conn.Close();
                Koneksi.openConn();
                cmd = new MySqlCommand("select * from promo where id_promo='" + tbIDPromo.Text + "'", Koneksi.conn);
                dr  = cmd.ExecuteReader();
                while (dr.Read())
                {
                    tbPeriodePromo.Text = dr.GetString(2) + " - " + dr.GetString(3) + ", " + dr.GetString(4);

                    cbStart.Text = dr.GetString(2);
                    cbEnd.Text   = dr.GetString(3);
                    cbYear.Text  = dr.GetString(4);
                }
                Koneksi.conn.Close();
            }
            catch (Exception x)
            {}
        }
Esempio n. 17
0
 private void button1_Click(object sender, EventArgs e)
 {
     button1.Enabled = false; btnUpdate.Enabled = false;
     Koneksi.openConn();
     cmd = new MySqlCommand("delete from user where nama_user='******'", Koneksi.conn);
     cmd.ExecuteNonQuery();
     Koneksi.conn.Close();
     load();
 }
Esempio n. 18
0
 public void load()
 {
     Koneksi.openConn();
     da = new MySqlDataAdapter("select nama_user as Username, password_user as Pass, pangkat as Pangkat from user", Koneksi.conn);
     ds = new DataSet();
     da.Fill(ds);
     dataGridView1.DataSource = ds.Tables[0];
     Koneksi.conn.Close();
 }
Esempio n. 19
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     btnUpdate.Enabled = false; button1.Enabled = false;
     Koneksi.openConn();
     cmd = new MySqlCommand("update user set password_user ='******', nama_user='******' where nama_user='******'", Koneksi.conn);
     cmd.ExecuteNonQuery();
     Koneksi.conn.Close();
     load();
 }
Esempio n. 20
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     Koneksi.openConn();
     cmd = new MySqlCommand("insert into user values('" + tbUser.Text + "','" + tbPass.Text + "','" + tbPangkat.Text + "')", Koneksi.conn);
     cmd.ExecuteNonQuery();
     Koneksi.conn.Close();
     button1.Enabled = false; btnUpdate.Enabled = false;
     load();
 }
Esempio n. 21
0
 private void tbId_TextChanged(object sender, EventArgs e)
 {
     if (tbId.TextLength == 4)
     {
         this.ActiveControl = tbNama;
     }
     Koneksi.openConn();
     sql = "select nama_supplier from supplier where id_supplier='" + tbId.Text + "'";
     cmd = new MySqlCommand(sql, Koneksi.conn);
     try
     {
         string nama = cmd.ExecuteScalar().ToString();
         lbStatus.Text      = "Unavailable";
         btnConfirm.Enabled = false;
     }
     catch (Exception)
     {
         lbStatus.Text      = "Available";
         btnConfirm.Enabled = true;
     }
     Koneksi.conn.Close();
     if (FormFindSupplier.index != -1 && newbtn == false)
     {
         Koneksi.openConn();
         cmd = new MySqlCommand("select * from supplier where id_supplier='" + tbId.Text + "'", Koneksi.conn);
         dr  = cmd.ExecuteReader();
         while (dr.Read())
         {
             tbNama.Text   = dr.GetString(1);
             tbAlamat.Text = dr.GetString(2);
             tbKota.Text   = dr.GetString(3);
         }
         Koneksi.conn.Close();
         Koneksi.openConn();
         try
         {
             cmd = new MySqlCommand("select sum(totalbeli) from beli where id_supplier='" + tbId.Text + "' group by id_supplier", Koneksi.conn);
             tbTotalBeli.Text = Function.separator(cmd.ExecuteScalar().ToString());
         }
         catch (Exception)
         {
             tbTotalBeli.Text = "0";
         }
         Koneksi.conn.Close();
         Koneksi.openConn();
         try
         {
             cmd           = new MySqlCommand("select sum(total) from hutang where id_supplier='" + tbId.Text + "' group by id_supplier", Koneksi.conn);
             tbHutang.Text = Function.separator(cmd.ExecuteScalar().ToString());
         }
         catch (Exception)
         {
             tbHutang.Text = "0";
         }
     }
 }
Esempio n. 22
0
 private void tbId_TextChanged(object sender, EventArgs e)
 {
     cekstatus();
     if (FormFindBarang.index != -1 && newbarang == false)
     {
         try
         {
             Koneksi.openConn();
             cmd = new MySqlCommand("select * from barang where id_barang='" + tbId.Text + "' ", Koneksi.conn);
             MySqlDataReader dr;
             dr = cmd.ExecuteReader();
             string kategori = "";
             while (dr.Read())
             {
                 tbNama.Text      = dr.GetString(1);
                 tbKemasan.Text   = dr.GetString(2);
                 tbHarga.Text     = dr.GetString(3);
                 kategori         = dr.GetString(4);
                 tbDeskripsi.Text = dr.GetString(5);
             }
             cmd             = new MySqlCommand("select nama_kategori from kategori where id_kategori='" + kategori + "'", Koneksi.conn);
             cbKategori.Text = cmd.ExecuteScalar().ToString();
             cmd             = new MySqlCommand("select * from stok where id_barang='" + tbId.Text + "'", Koneksi.conn);
             MySqlDataReader drr;
             drr = cmd.ExecuteReader();
             while (drr.Read())
             {
                 tbMasuk.Text  = drr.GetString(1);
                 tbKeluar.Text = drr.GetString(2);
                 tbStok.Text   = drr.GetString(3);
             }
             Koneksi.conn.Close();
         }
         catch (Exception x)
         {
         }
     }
     else
     {
         Koneksi.openConn();
         sql = "select nama_barang from barang where id_barang='" + tbId.Text + "'";
         cmd = new MySqlCommand(sql, Koneksi.conn);
         try
         {
             string nama = cmd.ExecuteScalar().ToString();
             lbStatus.Text      = "Unavailable";
             btnConfirm.Enabled = false;
         }
         catch (Exception)
         {
             lbStatus.Text      = "Available";
             btnConfirm.Enabled = true;
         }
         Koneksi.conn.Close();
     }
 }
Esempio n. 23
0
 public void loaddata()
 {
     Koneksi.openConn();
     da = new MySqlDataAdapter("select id_barang as \"ID Barang\", nama_barang as \"Nama Barang\", satuan_barang as Satuan, format(harga_barang,0,'de_DE') as Harga, nama_kategori as \"Nama Kategori\", deskripsi as Deskripsi, status as Status from barang where status='Tidak Aktif' order by id_barang", Koneksi.conn);
     ds = new DataSet();
     da.Fill(ds);
     dataGridView1.DataSource = null;
     dataGridView1.DataSource = ds.Tables[0];
     Koneksi.conn.Close();
 }
Esempio n. 24
0
 private void btnConfirm_Click(object sender, EventArgs e)
 {
     Koneksi.openConn();
     cmd = new MySqlCommand("update hpp set hpp='" + tbHpp.Text.Replace(".", "") + "' where id_barang='" + tbKodeBarang.Text + "'", Koneksi.conn);
     cmd.ExecuteNonQuery();
     cmd        = new MySqlCommand("select hpp from hpp where id_barang='" + tbKodeBarang.Text + "'", Koneksi.conn);
     tbHpp.Text = Function.separator(cmd.ExecuteScalar().ToString());
     Koneksi.conn.Close();
     MessageBox.Show("Berhasil Update");
 }
Esempio n. 25
0
 private void DeletedPromo_Load(object sender, EventArgs e)
 {
     Koneksi.openConn();
     da = new MySqlDataAdapter("select id_promo as ID, nama as Nama,start as Start,end as End, tahun as Tahun from promo where status='1'", Koneksi.conn);
     ds = new DataSet();
     da.Fill(ds);
     dataGridView1.DataSource = null;
     dataGridView1.DataSource = ds.Tables[0];
     Koneksi.conn.Close();
 }
Esempio n. 26
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     Koneksi.openConn();
     da = new MySqlDataAdapter("select p.kode as Kode, p.id_jual as Nomor, j.tanggaljatuhtempo as \"Jatuh Tempo\", c.nama_customer as Customer ,format(p.total,0,'de_DE') as Total, format(p.dibayarkan,0,'de_DE') as Dibayarkan from piutang p, jual j, customer c where p.kode = j.kode and p.id_jual = j.id_jual and p.id_customer = c.id_customer and p.status='" + status + "'  and c.nama_customer like '%" + tbSearch.Text + "%' order by j.tanggaljatuhtempo asc,Nomor desc", Koneksi.conn);
     ds = new DataSet();
     da.Fill(ds);
     dataGridView1.DataSource = ds.Tables[0];
     settingdatagrid();
     Koneksi.conn.Close(); count();
 }
Esempio n. 27
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string id = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();

            Koneksi.openConn();
            cmd = new MySqlCommand("update barang set status='Aktif' where id_barang='" + id + "'", Koneksi.conn);
            cmd.ExecuteNonQuery();
            Koneksi.conn.Close();
            loaddata();
        }
Esempio n. 28
0
 private void FormNotaSupplier_Load(object sender, EventArgs e)
 {
     Koneksi.openConn();
     da = new MySqlDataAdapter("select kode as Kode, id_beli as \"Nomer Nota\", tanggal as Tanggal, format(totalbeli,0,'de_DE') as Total from beli where id_supplier='" + FormSupplier.idsupp + "' order by id_beli desc", Koneksi.conn);
     ds = new DataSet();
     da.Fill(ds);
     dataGridView1.DataSource = ds.Tables[0];
     dataGridView1.Columns["Total"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
     Koneksi.conn.Close();
 }
Esempio n. 29
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     Koneksi.openConn();
     enabletextbox();
     kosongitextbox();
     btnCancel.Enabled  = true;
     btnConfirm.Enabled = true;
     this.ActiveControl = tbId;
     Koneksi.conn.Close();
 }
Esempio n. 30
0
 private void tbId_TextChanged(object sender, EventArgs e)
 {
     Koneksi.openConn();
     sql = "select nama_customer from customer where id_customer='" + tbId.Text + "'";
     cmd = new MySqlCommand(sql, Koneksi.conn);
     try
     {
         string nama = cmd.ExecuteScalar().ToString();
         lbStatus.Text      = "Unavailable";
         btnConfirm.Enabled = false;
     }
     catch (Exception)
     {
         lbStatus.Text      = "Available";
         btnConfirm.Enabled = true;
     }
     Koneksi.conn.Close();
     if (FormFindCustomer.index != -1 && newbtn == false)
     {
         Koneksi.openConn();
         cmd = new MySqlCommand("select * from customer where id_customer='" + tbId.Text + "'", Koneksi.conn);
         dr  = cmd.ExecuteReader();
         while (dr.Read())
         {
             tbNama.Text   = dr.GetString(1);
             tbAlamat.Text = dr.GetString(2);
             tbKota.Text   = dr.GetString(3);
             tbStatus.Text = dr.GetString(4);
             tbTelp.Text   = dr.GetString(5);
         }
         Koneksi.conn.Close();
         Koneksi.openConn();
         try
         {
             cmd = new MySqlCommand("select sum(totaljual) from jual where id_customer='" + tbId.Text + "' group by id_customer", Koneksi.conn);
             tbTotalBeli.Text = Function.separator(cmd.ExecuteScalar().ToString());
         }
         catch (Exception)
         {
             tbTotalBeli.Text = "0";
         }
         Koneksi.conn.Close();
         Koneksi.openConn();
         try
         {
             cmd           = new MySqlCommand("select sum(total-dibayarkan) from piutang where id_customer='" + tbId.Text + "' group by id_customer", Koneksi.conn);
             tbHutang.Text = Function.separator(cmd.ExecuteScalar().ToString());
         }
         catch (Exception)
         {
             tbHutang.Text = "0";
         }
         Koneksi.conn.Close();
     }
 }