示例#1
0
        private void FrmUserInterface_Load(object sender, EventArgs e)
        {
            try
            {
                this.flowLayoutPnl.Controls.Clear();
                this.lblNama.Text = user.Nama;
                this.pbUser.Image = new ImageConverter().ConvertFrom(user.Pict) as Image;

                using (var dao = new BarangDAO(Setting.GetConnectionString()))
                {
                    if (dao.GetAllDataBarang().Capacity > 0)
                    {
                        listBarang = dao.GetAllDataBarang();

                        foreach (var brg in listBarang)
                        {
                            CustomCntrlBrg custom = new CustomCntrlBrg(brg);
                            this.flowLayoutPnl.Controls.Add(custom);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#2
0
        private void btn_ok_Click(object sender, EventArgs e)
        {
            try
            {
                using (var barangdao = new BarangDAO())
                {
                    foreach (var item in list)
                    {
                        Barang before = barangdao.GetDataBarangByKode(item.Kode);
                        Barang brng   = new Barang {
                            Kode  = item.Kode,
                            Nama  = item.Nama,
                            Stok  = (item.Jumlah + Int32.Parse(before.Stok)).ToString(),
                            Harga = item.Harga
                        };
                        barangdao.UpdateStok(brng);
                    }
                }

                MessageBox.Show("Success", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#3
0
        private void FrmTampilBarang_Load(object sender, EventArgs e)
        {
            using (var dao = new BarangDAO(sqlString))
            {
                if (dao.GetAllDataBarang(brg).Capacity > 0)
                {
                    this.dgvDataBarang.DataSource = null;
                    this.dgvDataBarang.DataSource = dao.GetAllDataBarang(brg);
                    this.dgvDataBarang.Columns[0].DataPropertyName = "kode";
                    this.dgvDataBarang.Columns[1].DataPropertyName = "nama";
                    this.dgvDataBarang.Columns[2].DataPropertyName = "jumlah";
                    this.dgvDataBarang.Columns[3].DataPropertyName = "harga";
                    this.dgvDataBarang.Columns[4].DataPropertyName = "Pajak";
                }
            }

            if (listOrder == null)
            {
                this.listOrder = new List <Order>();
            }

            else
            {
                this.dgvDataOrder.Rows.Clear();
                foreach (Order ord in listOrder)
                {
                    this.dgvDataOrder.Rows.Add(new string[] {
                        ord.DataBarang.Kode, ord.DataBarang.Nama, ord.DataBarang.Harga.ToString("c"),
                        ord.JumlahBeli.ToString(), $"{ord.Pajak.ToString()} %", ord.SubTotal.ToString("c")
                    });
                }
            }

            this.lblTotal.Text = temp.ToString("c");
        }
示例#4
0
 private void btnHapus_Click(object sender, EventArgs e)
 {
     using (var dao = new BarangDAO(sqlString))
     {
         dao.DeleteBarang(brg.Kode);
     }
     MessageBox.Show("Barang sudah terhapus", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
     this.Close();
 }
示例#5
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            //this.dgvMainMenu.DataSource = null;
            //this.dgvMainMenu.DataSource = frmTambah.listData;

            BarangDAO barangDAO = new BarangDAO();
            //barangDAO.Insert();

            //if (cbBarang.Text.ToString() == )
        }
示例#6
0
        private void btnSimpan_Click(object sender, EventArgs e)
        {
            if (this.txtKodeBarang.Text.Trim() == "")
            {
                MessageBox.Show("Sorry, kode barang tidak boleh kosong ...", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtKodeBarang.Focus();
            }
            else if (this.txtNamaBarang.Text.Trim() == "")
            {
                MessageBox.Show("Sorry, nama barang tidak boleh kosong ...", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtNamaBarang.Focus();
            }
            else if (this.txtJumlahBarang.Text.Trim() == "")
            {
                MessageBox.Show("Sorry, jumlah tidak boleh kosong ...", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtJumlahBarang.Focus();
            }
            else if (this.txtHargaBarang.Text.Trim() == "")
            {
                MessageBox.Show("Sorry, harga tidak boleh kosong ...", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtHargaBarang.Focus();
            }
            else
            {
                try
                {
                    using (var dao = new BarangDAO(sqlString))
                    {
                        Barang barang = new Barang
                        {
                            Kode   = this.txtKodeBarang.Text.Trim(),
                            Nama   = this.txtNamaBarang.Text.Trim(),
                            Jumlah = int.Parse(this.txtJumlahBarang.Text.Trim()),
                            Harga  = Convert.ToDecimal(this.txtHargaBarang.Text.Trim()),
                            Pajak  = int.Parse(this.txtPajak.Text.Trim())
                        };

                        if (brg != null)
                        {
                            dao.UpdateBarang(barang);
                        }
                        else
                        {
                            dao.AddBarang(barang);
                        }
                    }
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
        private void FrmEditDataBarang_Load(object sender, EventArgs e)
        {
            Barang barang = new BarangDAO().GetDataBarangByKode(_kode);

            if (barang != null)
            {
                this.txtKode.Text  = barang.Kode;
                this.txtNama.Text  = barang.Nama;
                this.txtHarga.Text = barang.Harga.ToString();
                this.txtPajak.Text = barang.Pajak.ToString();
            }
        }
示例#8
0
        private void btnSimpan_Click(object sender, EventArgs e)
        {
            using (var barangdao = new BarangDAO())
            {
                list = barangdao.GetAllDataBarang();
            }



            if (txtKode.Text.Trim() == "" || txtNama.Text.Trim() == "" || txtHarga.Text.Trim() == "" || txtPajak.Text.Trim() == "")
            {
                MessageBox.Show("Tolong isi semua data yang diperlukan!", "Kosong", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (txtKode.Text.Length > 4)
            {
                MessageBox.Show("Kode Barang tidak boleh melebihi 4 karakter!", "Kode Barang", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (txtNama.Text.Length > 50)
            {
                MessageBox.Show("Nama tidak boleh melebihi 50 karakter !", "Nama Terlalu Panjang", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (Decimal.Parse(txtPajak.Text) > 100)
            {
                MessageBox.Show("Pajak tidak boleh melebihi 100%", "Pajak Melebihi Batas", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (list.Find(i => i.Kode.ToLower().ToString().Trim() == txtKode.Text.Trim().ToLower()) != null)
            {
                MessageBox.Show("Kode barang invalid ! Coba kode lain!", "Kode Invalid", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                try
                {
                    using (var barangdao = new BarangDAO())
                    {
                        barangdao.Insert(new Barang
                        {
                            Kode  = txtKode.Text,
                            Nama  = txtNama.Text,
                            Harga = Double.Parse(txtHarga.Text),
                            Pajak = Decimal.Parse(txtPajak.Text)
                        });
                    }
                    MessageBox.Show("Penambahan Barang Berhasil", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        private void FrmEditDataBarang_Load(object sender, EventArgs e)
        {
            Barang barang = new BarangDAO().GetDataBarangByKode(_kode);

            if (barang != null)
            {
                this.txtKode.Text   = barang.Kode;
                this.txtNama.Text   = barang.Nama;
                this.txtHarga.Text  = barang.Harga;
                this.cboSatuan.Text = barang.Satuan;
                this.txtStok.Text   = barang.Stok;
            }
        }
示例#10
0
        private void FrmAdminInterface_Load(object sender, EventArgs e)
        {
            try
            {
                this.lblAdmin.Text     = admin.Nama;
                this.pictureBox1.Image = new ImageConverter().ConvertFrom(admin.Pict) as Image;

                using (var dao = new BarangDAO(Setting.GetConnectionString()))
                {
                    this.dgvDataBarang.DataSource = null;
                    this.dgvDataBarang.DataSource = dao.GetAllDataBarang();
                    this.dgvDataBarang.Columns[0].DataPropertyName        = nameof(Barang.Kode);
                    this.dgvDataBarang.Columns[1].DataPropertyName        = nameof(Barang.Nama);
                    this.dgvDataBarang.Columns[2].DataPropertyName        = nameof(Barang.Jumlah);
                    this.dgvDataBarang.Columns[2].DefaultCellStyle.Format = "n0";
                    this.dgvDataBarang.Columns[3].DataPropertyName        = nameof(Barang.Harga);
                    this.dgvDataBarang.Columns[3].DefaultCellStyle.Format = "c0";
                }

                using (var dao = new AkunDAO(Setting.GetConnectionString()))
                {
                    this.dgvDataMember.DataSource = null;
                    this.dgvDataMember.DataSource = dao.GetAllDataAccount();
                    this.dgvDataMember.Columns[0].DataPropertyName        = nameof(Akun.Username);
                    this.dgvDataMember.Columns[1].DataPropertyName        = nameof(Akun.Nama);
                    this.dgvDataMember.Columns[2].DataPropertyName        = nameof(Akun.Total);
                    this.dgvDataMember.Columns[2].DefaultCellStyle.Format = "c0";
                }

                using (var dao = new PenjualanDAO(Setting.GetConnectionString()))
                {
                    this.dgvDataOrder.DataSource = null;
                    listData = dao.SejarahPenjualan(null, Setting.GetConnectionString());

                    foreach (Penjualan jual in listData)
                    {
                        this.dgvDataOrder.Rows.Add(new string[]
                        {
                            jual.NoOrder.ToString(), jual.Tanggal.ToShortDateString(), jual.DataBarang.Kode,
                            jual.DataBarang.Nama, jual.DataAkun.Nama, jual.DataBarang.Harga.ToString("c0"), jual.Quantity.ToString("n0"), jual.Total.ToString("c0")
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 private void FrmTampilBarang_Load(object sender, EventArgs e)
 {
     using (var dao = new BarangDAO(sqlString))
     {
         if (dao.GetAllDataBarang().Capacity > 0)
         {
             this.dataGridView1.DataSource = null;
             this.dataGridView1.DataSource = dao.GetAllDataBarang();
             this.dataGridView1.Columns[0].DataPropertyName = "kode";
             this.dataGridView1.Columns[1].DataPropertyName = "nama";
             this.dataGridView1.Columns[2].DataPropertyName = "harga";
             this.dataGridView1.Columns[3].DataPropertyName = "jumlah";
         }
     }
 }
示例#12
0
 private void FrmDgvResupply_Load(object sender, EventArgs e)
 {
     try
     {
         using (var dao = new BarangDAO())
         {
             this.dgvData.DataSource = dao.GetAllDataBarang();
             this.dgvData.Columns[0].DataPropertyName = "kode";
             this.dgvData.Columns[1].DataPropertyName = "nama";
             this.dgvData.Columns[2].DataPropertyName = "harga";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
示例#13
0
 private void FrmTambahBarang_Load(object sender, EventArgs e)
 {
     if (brg != null)
     {
         this.txtKodeBarang.Text    = brg.Kode;
         this.txtKodeBarang.Enabled = false;
         this.txtNamaBarang.Text    = brg.Nama;
         this.txtJumlahBarang.Text  = Convert.ToInt32(brg.Jumlah).ToString();
         this.txtHargaBarang.Text   = Convert.ToDecimal(brg.Harga).ToString();
     }
     else
     {
         var dao = new BarangDAO(sqlString);
         this.txtKodeBarang.Text    = dao.GetKodeBarangBerikutnya();
         this.txtKodeBarang.Enabled = false;
         this.btnHapus.Visible      = false;
     }
 }
示例#14
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         using (var barangdao = new BarangDAO())
         {
             barangdao.Delete(dgv1.CurrentCell.Value.ToString());
         }
         MessageBox.Show("Barang berhasil dihapus!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         btnRefresh_Click(null, null);
     }
 }
示例#15
0
        private void btnOrder_Click(object sender, EventArgs e)
        {
            DSPenjualan ds = new DSPenjualan();

            if (MessageBox.Show("Apakah anda yakin membeli barang ini ?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                foreach (Penjualan jual in listPenjualan)
                {
                    var row = ds.Penjualan.NewPenjualanRow();
                    row.NoOrder      = jual.NoOrder;
                    row.NamaBarang   = jual.DataBarang.Nama;
                    row.NamaCustomer = jual.DataAkun.Nama;
                    row.Quantity     = jual.Quantity.ToString();
                    row.Tanggal      = jual.Tanggal.ToShortDateString();
                    row.SubTotal     = jual.Total.ToString("n0");
                    row.Total        = $"Rp. {tempTotalHrg.ToString("n0")}";
                    ds.Penjualan.AddPenjualanRow(row);

                    _result = new PenjualanDAO(Setting.GetConnectionString()).AddPenjualan(jual) > 0;

                    using (var dao = new BarangDAO(Setting.GetConnectionString()))
                    {
                        dao.UpdateQuantity(jual.DataBarang, jual.Quantity);
                    }

                    using (var dao = new AkunDAO(Setting.GetConnectionString()))
                    {
                        dao.UpdateTotal(jual.DataAkun, jual.Total);
                    }
                }

                FrmReceipt frmReceipt = new FrmReceipt(ds);
                frmReceipt.ShowDialog();


                MessageBox.Show("Order telah diproses.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                this.Close();
            }
        }
示例#16
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (this.dgvDataBarang.SelectedRows.Count > 0 && MessageBox.Show("Hapus Item Data Terpilih ?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         try
         {
             using (var dao = new BarangDAO(Setting.GetConnectionString()))
             {
                 if (dao.DeleteBarang(this.dgvDataBarang.SelectedRows[0].Cells[0].Value.ToString().Trim()) > 0)
                 {
                     FrmAdminInterface_Load(null, null);
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
示例#17
0
        private void txtKodeBarang_Leave(object sender, EventArgs e)
        {
            this.dgvDataBarang.DataSource = null;
            using (var dao = new BarangDAO(Setting.GetConnectionString()))
            {
                this.dgvDataBarang.DataSource = dao.GetAllDataBarang(new Barang
                {
                    Nama   = this.txtNamaBarang.Text.Trim(),
                    Kode   = this.txtKodeBarang.Text.Trim(),
                    Gambar = null,
                    Harga  = 0,
                    Jumlah = 0,
                }, int.Parse(this.txtJumlahMin.Text, System.Globalization.NumberStyles.AllowThousands), int.Parse(this.txtJumlahMax.Text, System.Globalization.NumberStyles.AllowThousands), int.Parse(this.txtHargaMin.Text, System.Globalization.NumberStyles.AllowThousands), int.Parse(this.txtHargaMax.Text, System.Globalization.NumberStyles.AllowThousands));
            }

            this.dgvDataBarang.Columns[0].DataPropertyName = nameof(Barang.Kode);
            this.dgvDataBarang.Columns[1].DataPropertyName = nameof(Barang.Nama);
            this.dgvDataBarang.Columns[2].DataPropertyName = nameof(Barang.Jumlah);
            this.dgvDataBarang.Columns[3].DataPropertyName = nameof(Barang.Harga);
        }
示例#18
0
 private void btnSimpan_Click(object sender, EventArgs e)
 {
     try
     {
         using (var barangdao = new BarangDAO())
         {
             barangdao.Insert(new Barang {
                 Kode  = txtKode.Text,
                 Nama  = txtNama.Text,
                 Harga = Double.Parse(txtHarga.Text),
                 Pajak = Int32.Parse(txtPajak.Text)
             });
         }
         MessageBox.Show("Penambahan Barang Berhasil", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#19
0
        private void Form1_Load(object sender, EventArgs e)
        {
            listBelanja = new List <Belanja>();
            Form1_Resize(null, null);
            try
            {
                using (var barangdao = new BarangDAO())
                {
                    listBrg = barangdao.GetAllDataBarang();
                }

                dgv1.DataSource = listBrg;
                dgv1.Columns[0].DataPropertyName = "Kode";
                dgv1.Columns[1].DataPropertyName = "Nama";
                dgv1.Columns[2].DataPropertyName = "Harga";
                dgv1.Columns[3].DataPropertyName = "Pajak";
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#20
0
 private void tbNamaBrg_Leave(object sender, EventArgs e)
 {
     if (tbNamaBrg.Text.Trim().Equals(""))
     {
         this.tbNamaBrg.Focus();
     }
     else
     {
         BarangDAO dao = new BarangDAO(Setting.GetConnectionString());
         result = dao.GetNamaBarang(tbNamaBrg.Text);
         if (result == null)
         {
             MessageBox.Show("Maaf, Barang tidak ditemukan", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.tbNamaBrg.Text = null;
             this.tbNamaBrg.Focus();
         }
         else
         {
             this.tbHarga.Text = result.HargaBarang;
         }
     }
 }
示例#21
0
        private void FrmTampilBarang_Load(object sender, EventArgs e)
        {
            using (var dao = new BarangDAO(sqlString))
            {
                if (dao.GetAllDataBarang().Count >= 0)
                {
                    this.dgvDataBarang.DataSource = null;
                    this.dgvDataBarang.DataSource = dao.GetAllDataBarang();
                    this.dgvDataBarang.Columns[0].DataPropertyName        = nameof(Barang.Kode);
                    this.dgvDataBarang.Columns[1].DataPropertyName        = nameof(Barang.Nama);
                    this.dgvDataBarang.Columns[2].DataPropertyName        = nameof(Barang.Jumlah);
                    this.dgvDataBarang.Columns[3].DataPropertyName        = nameof(Barang.Harga);
                    this.dgvDataBarang.Columns[3].DefaultCellStyle.Format = "c";
                    this.dgvDataBarang.Columns[4].DataPropertyName        = nameof(Barang.Pajak);
                }
            }

            if (listOrder == null)
            {
                this.listOrder = new List <Order>();
            }

            else
            {
                this.dgvDataOrder.Rows.Clear();
                foreach (Order ord in listOrder)
                {
                    this.dgvDataOrder.Rows.Add(new string[] {
                        ord.DataBarang.Kode, ord.DataBarang.Nama, ord.DataBarang.Harga.ToString("c"),
                        ord.JumlahBeli.ToString(), $"{ord.Pajak.ToString()} %", ord.SubTotal.ToString("c")
                    });
                }
            }

            this.lblTotal.Text = temp.ToString("c");
        }
示例#22
0
 private void txtKode_Leave(object sender, EventArgs e)
 {
     using (var dao = new BarangDAO(sqlString))
     {
         if ((brg = dao.GetDataBarangByKode(this.txtKode.Text)) != null)
         {
             this.txtNama.Text  = brg.Nama;
             this.txtHarga.Text = brg.Harga.ToString();
             this.txtStock.Text = brg.Jumlah.ToString();
             this.txtPajak.Text = brg.Pajak.ToString();
         }
         else
         {
             this.txtKode.Text   = "";
             this.txtHarga.Text  = "";
             this.txtJumlah.Text = "";
             this.txtNama.Text   = "";
             this.txtPajak.Text  = "";
             this.txtStock.Text  = "";
             this.txtKode.Focus();
             this.label3.Visible = true;
         }
     }
 }