private void buttonSupplier_Click(object sender, EventArgs e) { CariSupplier form = new CariSupplier(); form.ParentForm = this; form.ShowDialog(); }
private void dataGridViewTransaksiPembelian_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { int kodeSupplier; bool IsValidKodePelanggan = int.TryParse(textBoxKodeSupplier.Text, out kodeSupplier); float diskon; var pelanggan = supplierService.Get(kodeSupplier); //if (pelanggan != null) // diskon = pelanggan.Member.Diskon; //else diskon = 0; int row = dataGridViewTransaksiPembelian.Rows.Count; string id = dataGridViewTransaksiPembelian[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; } dataGridViewTransaksiPembelian.Rows[row - 1].Cells[0].Value = barang.KodeBarang; dataGridViewTransaksiPembelian.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"; dataGridViewTransaksiPembelian.Rows[row - 1].Cells[2] = cell; dataGridViewTransaksiPembelian.Rows[row - 1].Cells[3].Value = 1; dataGridViewTransaksiPembelian.Rows[row - 1].Cells[5].Value = diskon; dataGridViewTransaksiPembelian.Rows.Add("", "", "", ""); } if (e.KeyCode == Keys.F12) { int kodeSupplier; bool IsValidKodePelanggan = int.TryParse(textBoxKodeSupplier.Text, out kodeSupplier); float diskon; var pelanggan = supplierService.Get(kodeSupplier); //if (pelanggan != null) // diskon = pelanggan.Member.Diskon; //else diskon = 0; int row = dataGridViewTransaksiPembelian.Rows.Count; int currentRowIndex = dataGridViewTransaksiPembelian.CurrentCell.RowIndex; if (row < 2 || currentRowIndex == row - 1) { return; } if (dataGridViewTransaksiPembelian.Rows[currentRowIndex].Cells[4].Value == null) { MessageBox.Show("Silahkan pilih ukuran", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } int n = int.Parse(dataGridViewTransaksiPembelian.Rows[currentRowIndex].Cells[3].Value.ToString()); string id = dataGridViewTransaksiPembelian[0, currentRowIndex].Value.ToString(); dataGridViewTransaksiPembelian.Rows[currentRowIndex].Cells[3].Value = n + 1; n = int.Parse(dataGridViewTransaksiPembelian.Rows[currentRowIndex].Cells[3].Value.ToString()); decimal price = decimal.Parse(dataGridViewTransaksiPembelian.Rows[currentRowIndex].Cells[4].Value.ToString(), NumberStyles.Number, CultureInfo.GetCultureInfo("de")); dataGridViewTransaksiPembelian.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(dataGridViewTransaksiPembelian.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"; dataGridViewTransaksiPembelian.Refresh(); } if (e.KeyCode == Keys.F11) { int kodeSupplier; bool IsValidKodePelanggan = int.TryParse(textBoxKodeSupplier.Text, out kodeSupplier); float diskon; var pelanggan = supplierService.Get(kodeSupplier); //if (pelanggan != null) // diskon = pelanggan.Member.Diskon; //else diskon = 0; int row = dataGridViewTransaksiPembelian.Rows.Count; int currentRowIndex = dataGridViewTransaksiPembelian.CurrentCell.RowIndex; if (row < 2 || currentRowIndex == row - 1) { return; } int n = int.Parse(dataGridViewTransaksiPembelian.Rows[currentRowIndex].Cells[3].Value.ToString()); if (n == 1) { return; } dataGridViewTransaksiPembelian.Rows[currentRowIndex].Cells[3].Value = n - 1; n = int.Parse(dataGridViewTransaksiPembelian.Rows[currentRowIndex].Cells[3].Value.ToString()); decimal price = decimal.Parse(dataGridViewTransaksiPembelian.Rows[currentRowIndex].Cells[4].Value.ToString(), NumberStyles.Number, CultureInfo.GetCultureInfo("de")); dataGridViewTransaksiPembelian.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(dataGridViewTransaksiPembelian.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"; dataGridViewTransaksiPembelian.Refresh(); } if (e.KeyCode == Keys.Delete) { int row = dataGridViewTransaksiPembelian.Rows.Count; int currentRowIndex = dataGridViewTransaksiPembelian.CurrentCell.RowIndex; if (row > 1 && currentRowIndex != row - 1) { dataGridViewTransaksiPembelian.Rows.RemoveAt(currentRowIndex); } decimal total = 0; row = dataGridViewTransaksiPembelian.Rows.Count; dataGridViewTransaksiPembelian.CurrentCell = dataGridViewTransaksiPembelian.Rows[row - 1].Cells[0]; for (int i = 0; i < row - 1; i++) { total += decimal.Parse(dataGridViewTransaksiPembelian.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"; dataGridViewTransaksiPembelian.Refresh(); } if (e.KeyCode == Keys.F8) { int row = dataGridViewTransaksiPembelian.Rows.Count; int currentRowIndex = dataGridViewTransaksiPembelian.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(); } if (e.KeyCode == Keys.F6) { CariSupplier form = new CariSupplier(); form.ParentForm = this; form.ShowDialog(); } if (e.KeyCode == Keys.F7) { CariBarang form = new CariBarang(); form.ParentForm = this; form.ShowDialog(); } }