Exemple #1
0
        public void PopulateData()
        {
            int id        = int.Parse(this.ParentForm.dataGridViewPelanggan.SelectedRows[0].Cells[0].Value.ToString());
            var pelanggan = pelangganService.Get(id);

            textBoxNamaPelanggan.Text    = pelanggan.NamaPelanggan;
            textBoxNomorKtp.Text         = pelanggan.NomorKtp;
            textBoxAlamat.Text           = pelanggan.Alamat;
            textBoxNomorTelepon.Text     = pelanggan.NoTelepon;
            comboBoxMember.SelectedValue = pelanggan.Member.Id;
            labelIdHidden.Text           = pelanggan.Id.ToString();
        }
Exemple #2
0
        private void btnHapus_Click(object sender, EventArgs e)
        {
            int id        = int.Parse(dataGridViewPelanggan.SelectedRows[0].Cells[0].Value.ToString());
            var pelanggan = pelangganService.Get(id);

            DialogResult result = MessageBox.Show("Hapus data " + pelanggan.NamaPelanggan + " ?", "Hapus", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (result == DialogResult.OK)
            {
                pelangganService.Delete(pelanggan);
                dataGridViewPelanggan.DataSource = pelangganService.Get();
            }
        }
Exemple #3
0
        private ListPelanggan()
        {
            InitializeComponent();
            pelangganService = new PelangganService();

            dataGridViewPelanggan.DataSource         = pelangganService.Get();
            dataGridViewPelanggan.Columns[0].Visible = false;
        }
Exemple #4
0
        public CariPelanggan()
        {
            InitializeComponent();
            this.ActiveControl = this.textBoxPelanggan;

            pelangganService = new PelangganService();
            dataGridViewCariPelanggan.DataSource         = pelangganService.Get();
            dataGridViewCariPelanggan.Columns[0].Visible = false;
        }
        private void btnSimpan_Click(object sender, EventArgs e)
        {
            StringBuilder sb     = new StringBuilder();
            bool          IsPass = true;

            if (string.IsNullOrEmpty(textBoxNamaPelanggan.Text))
            {
                IsPass = false;
                sb.Append("- Nama Pelanggan harus diisi \n");
            }

            if (string.IsNullOrEmpty(textBoxNomorKtp.Text))
            {
                IsPass = false;
                sb.Append("- Nomor KTP harus diisi \n");
            }

            if (string.IsNullOrEmpty(textBoxAlamat.Text))
            {
                IsPass = false;
                sb.Append("- Alamat harus diisi \n");
            }

            if (string.IsNullOrEmpty(textBoxNomorTelepon.Text))
            {
                IsPass = false;
                sb.Append("- Nomor Telepon harus diisi \n");
            }

            if (comboBoxMember.SelectedValue == null)
            {
                IsPass = false;
                sb.Append("- Member harus diisi \n");
            }

            if (!IsPass)
            {
                MessageBox.Show(sb.ToString(), "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var member = memberService.Get(int.Parse(comboBoxMember.SelectedValue.ToString()));

            var pelanggan = new Pelanggan()
            {
                NamaPelanggan = textBoxNamaPelanggan.Text,
                NomorKtp      = textBoxNomorKtp.Text,
                Alamat        = textBoxAlamat.Text,
                NoTelepon     = textBoxNomorTelepon.Text,
                MemberId      = member.Id
            };

            pelangganService.Post(pelanggan);

            this.ParentForm.dataGridViewPelanggan.DataSource = pelangganService.Get();
            this.Dispose();
        }
Exemple #6
0
        private void btnSimpan_Click(object sender, EventArgs e)
        {
            DataGridView data = this.ParentForm.dataGridViewTransaksiPenjualan;

            int row = data.Rows.Count;

            Penjualan       penjualan = new Penjualan();
            PenjualanDetail pDetail;

            for (int i = 0; i < row - 1; i++)
            {
                var kodeBarang = int.Parse(data.Rows[i].Cells[0].Value.ToString());
                var namaBarang = data.Rows[i].Cells[1].Value.ToString();
                var jumlahJual = int.Parse(data.Rows[i].Cells[2].Value.ToString());
                var hargaJual  = decimal.Parse(data.Rows[i].Cells[3].Value.ToString(), NumberStyles.Number, CultureInfo.GetCultureInfo("de"));
                var diskon     = float.Parse(data.Rows[i].Cells[4].Value.ToString(), NumberStyles.Number, CultureInfo.GetCultureInfo("de"));
                var subtotal   = decimal.Parse(data.Rows[i].Cells[5].Value.ToString(), NumberStyles.Number, CultureInfo.GetCultureInfo("de"));

                pDetail = new PenjualanDetail()
                {
                    Penjualan = penjualan,
                    BarangId  = kodeBarang,
                    Harga     = hargaJual,
                    Jumlah    = jumlahJual,
                    SubTotal  = subtotal,
                    Diskon    = diskon
                };

                penjualan.PenjualanDetails.Add(pDetail);
            }

            penjualan.KodeTransaksi  = this.ParentForm.textBoxKodeTransaksi.Text;
            penjualan.Tanggal        = DateTime.Now;
            penjualan.TotalHargaJual = decimal.Parse(labelTotal.Text, NumberStyles.Number, CultureInfo.GetCultureInfo("de"));

            var pengguna  = LoginContext.Pengguna;
            var pelanggan = pelangganService.Get(int.Parse(this.ParentForm.textBoxKodePelanggan.Text));

            penjualan.PenggunaId  = pengguna.Id;
            penjualan.PelangganId = pelanggan.Id;

            penjualanService.Post(penjualan);

            this.Dispose();
            this.ParentForm.Clear();
        }
Exemple #7
0
        private void dataGridViewCariPelanggan_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                string    id        = dataGridViewCariPelanggan.SelectedRows[0].Cells[0].Value.ToString();
                Pelanggan pelanggan = pelangganService.Get(int.Parse(id));

                this.ParentForm.textBoxKodePelanggan.Text = id;
                this.ParentForm.textBoxPelanggan.Text     = pelanggan.NamaPelanggan;

                DataGridView dgv      = ParentForm.dataGridViewTransaksiPenjualan;
                int          rowCount = dgv.Rows.Count;

                float   diskon = pelanggan.Member.Diskon;
                decimal price;
                int     n;
                decimal total = 0;

                if (rowCount > 0)
                {
                    for (int i = 0; i < rowCount - 1; i++)
                    {
                        n     = int.Parse(dgv.Rows[i].Cells[3].Value.ToString());
                        price = decimal.Parse(dgv.Rows[i].Cells[4].Value.ToString(), NumberStyles.Number, CultureInfo.GetCultureInfo("de"));
                        dgv.Rows[i].Cells[5].Value = diskon;
                        dgv.Rows[i].Cells[6].Value = ((price - (price * (decimal)(diskon / 100))) * n).ToString("N2", CultureInfo.GetCultureInfo("de"));

                        total += decimal.Parse(dgv.Rows[i].Cells[6].Value.ToString(), NumberStyles.Number, CultureInfo.GetCultureInfo("de"));
                    }
                }

                this.ParentForm.labelTotal.Text     = total.ToString("N2", CultureInfo.GetCultureInfo("de"));
                this.ParentForm.labelTerbilang.Text = Terbilang.Bilang(total) + " Rupiah";

                this.Dispose();
            }
        }
        private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                int  kodePelanggan;
                bool IsValidKodePelanggan = int.TryParse(textBoxKodePelanggan.Text, out kodePelanggan);

                float diskon;

                var pelanggan = pelangganService.Get(kodePelanggan);

                if (pelanggan != null)
                {
                    diskon = pelanggan.Member.Diskon;
                }
                else
                {
                    diskon = 0;
                }

                int    row = dataGridViewTransaksiPenjualan.Rows.Count;
                string id  = dataGridViewTransaksiPenjualan[0, row - 1].Value.ToString();

                var barang = service.FindByKodeBarang(id);

                if (barang == null)
                {
                    MessageBox.Show("Tidak ada barang dengan ID tersebut", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                var stockBarang = shuService.FindByBarangId(barang.Id);

                bool IsHabis = true;
                foreach (var d in stockBarang)
                {
                    if (d.Stock > 0)
                    {
                        IsHabis = false;
                        break;
                    }
                }

                if (IsHabis)
                {
                    MessageBox.Show("Stok barang habis", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }


                dataGridViewTransaksiPenjualan.Rows[row - 1].Cells[0].Value = barang.KodeBarang;
                dataGridViewTransaksiPenjualan.Rows[row - 1].Cells[1].Value = barang.NamaBarang;

                List <StokHargaUkuran>   shus = shuService.FindByBarangId(barang.Id);
                DataGridViewComboBoxCell cell = new DataGridViewComboBoxCell();
                cell.DataSource    = shus;
                cell.DisplayMember = "Ukuran";
                cell.ValueMember   = "Ukuran";

                dataGridViewTransaksiPenjualan.Rows[row - 1].Cells[2]       = cell;
                dataGridViewTransaksiPenjualan.Rows[row - 1].Cells[3].Value = 1;

                //dataGridViewTransaksiPenjualan.Rows[row - 1].Cells[3].Value = barang.HargaJual.ToString("N2", CultureInfo.GetCultureInfo("de"));
                dataGridViewTransaksiPenjualan.Rows[row - 1].Cells[5].Value = diskon;
                //dataGridViewTransaksiPenjualan.Rows[row - 1].Cells[5].Value = (barang.HargaJual - (barang.HargaJual * (decimal) (diskon/100) )).ToString("N2", CultureInfo.GetCultureInfo("de"));

                dataGridViewTransaksiPenjualan.Rows.Add("", "", "", "");
            }

            if (e.KeyCode == Keys.F12)
            {
                int  kodePelanggan;
                bool IsValidKodePelanggan = int.TryParse(textBoxKodePelanggan.Text, out kodePelanggan);

                float diskon;

                var pelanggan = pelangganService.Get(kodePelanggan);

                if (pelanggan != null)
                {
                    diskon = pelanggan.Member.Diskon;
                }
                else
                {
                    diskon = 0;
                }

                int row             = dataGridViewTransaksiPenjualan.Rows.Count;
                int currentRowIndex = dataGridViewTransaksiPenjualan.CurrentCell.RowIndex;

                if (row < 2 || currentRowIndex == row - 1)
                {
                    return;
                }

                if (dataGridViewTransaksiPenjualan.Rows[currentRowIndex].Cells[4].Value == null)
                {
                    MessageBox.Show("Silahkan pilih ukuran", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                int n = int.Parse(dataGridViewTransaksiPenjualan.Rows[currentRowIndex].Cells[3].Value.ToString());

                string id = dataGridViewTransaksiPenjualan[0, currentRowIndex].Value.ToString();

                var    barang = service.FindByKodeBarang(id);
                string ukuran = (dataGridViewTransaksiPenjualan.Rows[currentRowIndex].Cells[2] as DataGridViewComboBoxCell).FormattedValue.ToString();
                var    shu    = shuService.FindByBarangIdAndUkuran(barang.Id, ukuran);

                if ((n + 1) > shu.Stock)
                {
                    MessageBox.Show("Stok barang tidak memadahi", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                dataGridViewTransaksiPenjualan.Rows[currentRowIndex].Cells[3].Value = n + 1;

                n = int.Parse(dataGridViewTransaksiPenjualan.Rows[currentRowIndex].Cells[3].Value.ToString());
                decimal price = decimal.Parse(dataGridViewTransaksiPenjualan.Rows[currentRowIndex].Cells[4].Value.ToString(), NumberStyles.Number, CultureInfo.GetCultureInfo("de"));
                dataGridViewTransaksiPenjualan.Rows[currentRowIndex].Cells[6].Value = ((price - (price * (decimal)(diskon / 100))) * n).ToString("N2", CultureInfo.GetCultureInfo("de"));

                decimal total = 0;
                for (int i = 0; i < row - 1; i++)
                {
                    total += decimal.Parse(dataGridViewTransaksiPenjualan.Rows[i].Cells[6].Value.ToString(), NumberStyles.Number, CultureInfo.GetCultureInfo("de"));
                }

                labelTotal.Text     = total.ToString("N2", CultureInfo.GetCultureInfo("de"));
                labelTerbilang.Text = Terbilang.Bilang(total) + " Rupiah";

                dataGridViewTransaksiPenjualan.Refresh();
            }

            if (e.KeyCode == Keys.F11)
            {
                int  kodePelanggan;
                bool IsValidKodePelanggan = int.TryParse(textBoxKodePelanggan.Text, out kodePelanggan);

                float diskon;

                var pelanggan = pelangganService.Get(kodePelanggan);

                if (pelanggan != null)
                {
                    diskon = pelanggan.Member.Diskon;
                }
                else
                {
                    diskon = 0;
                }

                int row             = dataGridViewTransaksiPenjualan.Rows.Count;
                int currentRowIndex = dataGridViewTransaksiPenjualan.CurrentCell.RowIndex;

                if (row < 2 || currentRowIndex == row - 1)
                {
                    return;
                }

                int n = int.Parse(dataGridViewTransaksiPenjualan.Rows[currentRowIndex].Cells[3].Value.ToString());

                if (n == 1)
                {
                    return;
                }

                dataGridViewTransaksiPenjualan.Rows[currentRowIndex].Cells[3].Value = n - 1;

                n = int.Parse(dataGridViewTransaksiPenjualan.Rows[currentRowIndex].Cells[3].Value.ToString());
                decimal price = decimal.Parse(dataGridViewTransaksiPenjualan.Rows[currentRowIndex].Cells[4].Value.ToString(), NumberStyles.Number, CultureInfo.GetCultureInfo("de"));
                dataGridViewTransaksiPenjualan.Rows[currentRowIndex].Cells[6].Value = ((price - (price * (decimal)(diskon / 100))) * n).ToString("N2", CultureInfo.GetCultureInfo("de"));

                decimal total = 0;
                for (int i = 0; i < row - 1; i++)
                {
                    total += decimal.Parse(dataGridViewTransaksiPenjualan.Rows[i].Cells[6].Value.ToString(), NumberStyles.Number, CultureInfo.GetCultureInfo("de"));
                }

                labelTotal.Text     = total.ToString("N2", CultureInfo.GetCultureInfo("de"));
                labelTerbilang.Text = Terbilang.Bilang(total) + " Rupiah";

                dataGridViewTransaksiPenjualan.Refresh();
            }

            if (e.KeyCode == Keys.Delete)
            {
                //EMANG KOMEN
                //MessageBox.Show(dataGridViewTransaksiPenjualan.CurrentCell.RowIndex.ToString());
                //return;

                int row             = dataGridViewTransaksiPenjualan.Rows.Count;
                int currentRowIndex = dataGridViewTransaksiPenjualan.CurrentCell.RowIndex;

                if (row > 1 && currentRowIndex != row - 1)
                {
                    dataGridViewTransaksiPenjualan.Rows.RemoveAt(currentRowIndex);
                    //EMANG KOMEN
                    //dataGridViewTransaksiPenjualan.Rows.RemoveAt(row - 2);
                    //dataGridViewTransaksiPenjualan.Rows.Add();
                }

                decimal total = 0;
                row = dataGridViewTransaksiPenjualan.Rows.Count;

                dataGridViewTransaksiPenjualan.CurrentCell = dataGridViewTransaksiPenjualan.Rows[row - 1].Cells[0];

                for (int i = 0; i < row - 1; i++)
                {
                    total += decimal.Parse(dataGridViewTransaksiPenjualan.Rows[i].Cells[6].Value.ToString(), NumberStyles.Number, CultureInfo.GetCultureInfo("de"));
                }

                labelTotal.Text     = total.ToString("N2", CultureInfo.GetCultureInfo("de"));
                labelTerbilang.Text = Terbilang.Bilang(total) + " Rupiah";

                dataGridViewTransaksiPenjualan.Refresh();
            }

            if (e.KeyCode == Keys.F8)
            {
                int row             = dataGridViewTransaksiPenjualan.Rows.Count;
                int currentRowIndex = dataGridViewTransaksiPenjualan.CurrentCell.RowIndex;

                if (row < 2 || currentRowIndex == row - 1)
                {
                    MessageBox.Show("Tidak ada barang yang dipilih", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                ApplyHarga form = new ApplyHarga();
                form.ParentForm = this;
                form.ShowDialog();
            }

            //NO LONGER
            //if (e.KeyCode == Keys.F5)
            //{
            //    Pembayaran form = new Pembayaran();
            //    form.ParentForm = this;
            //    form.PopulateData();
            //    form.ShowDialog();
            //}

            if (e.KeyCode == Keys.F6)
            {
                CariPelanggan form = new CariPelanggan();
                form.ParentForm = this;
                form.ShowDialog();
            }

            if (e.KeyCode == Keys.F7)
            {
                CariBarang form = new CariBarang();
                form.ParentForm = this;
                form.ShowDialog();
            }
        }