Beispiel #1
0
 private void txtMinStokGudang_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (KeyPressHelper.IsEnter(e))
     {
         Simpan();
     }
 }
 private void txtNomorTransaksi_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (KeyPressHelper.IsEnter(e))
     {
         Simpan();
     }
 }
Beispiel #3
0
        private void txtSupplier_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (KeyPressHelper.IsEnter(e))
            {
                var name = ((TextBox)sender).Text;

                ISupplierBll bll            = new SupplierBll(MainProgram.isUseWebAPI, MainProgram.baseUrl, _log);
                var          listOfSupplier = bll.GetByName(name);

                if (listOfSupplier.Count == 0)
                {
                    MsgHelper.MsgWarning("Data supplier tidak ditemukan");
                    txtSupplier.Focus();
                    txtSupplier.SelectAll();
                }
                else if (listOfSupplier.Count == 1)
                {
                    _supplier        = listOfSupplier[0];
                    txtSupplier.Text = _supplier.nama_supplier;
                    KeyPressHelper.NextFocus();
                }
                else // data lebih dari satu
                {
                    var frmLookup = new FrmLookupReferensi("Data Supplier", listOfSupplier);
                    frmLookup.Listener = this;
                    frmLookup.ShowDialog();
                }
            }
        }
Beispiel #4
0
        private void txtCustomer_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (KeyPressHelper.IsEnter(e))
            {
                var customerName = ((AdvancedTextbox)sender).Text;

                ICustomerBll bll            = new CustomerBll(_log);
                var          listOfCustomer = bll.GetByName(customerName);

                if (listOfCustomer.Count == 0)
                {
                    MsgHelper.MsgWarning("Data customer tidak ditemukan");
                    txtCustomer.Focus();
                    txtCustomer.SelectAll();
                }
                else if (listOfCustomer.Count == 1)
                {
                    _customer        = listOfCustomer[0];
                    txtCustomer.Text = _customer.nama_customer;
                    KeyPressHelper.NextFocus();
                }
                else // data lebih dari satu
                {
                    var frmLookup = new FrmLookupReferensi("Data Customer", listOfCustomer);
                    frmLookup.Listener = this;
                    frmLookup.ShowDialog();
                }
            }
        }
 private void txtTelepon_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (KeyPressHelper.IsEnter(e))
     {
         Simpan();
     }
 }
        private void txtKabupatenTujuan_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (KeyPressHelper.IsEnter(e))
            {
                var kabupaten = ((AdvancedTextbox)sender).Text;

                IList <KabupatenTujuanRajaOngkir> listOfKabupaten = GetKabupatenByName <KabupatenTujuanRajaOngkir>(kabupaten);

                if (listOfKabupaten.Count == 0)
                {
                    MsgHelper.MsgWarning("Data kota/kabupaten tujuan tidak ditemukan");
                    txtKabupatenTujuan.Focus();
                    txtKabupatenTujuan.SelectAll();
                }
                else if (listOfKabupaten.Count == 1)
                {
                    _kabupatenTujuan        = listOfKabupaten[0];
                    txtKabupatenTujuan.Text = _kabupatenTujuan.nama_kabupaten;
                    KeyPressHelper.NextFocus();
                }
                else // data lebih dari satu
                {
                    var frmLookup = new FrmLookupReferensi("Data Kota/Kabupaten Tujuan", listOfKabupaten);
                    frmLookup.Listener = this;
                    frmLookup.ShowDialog();
                }
            }
        }
Beispiel #7
0
 private void txtNamaCustomer_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (KeyPressHelper.IsEnter(e))
     {
         btnCari_Click(sender, e);
     }
 }
 private void txtJenisPengeluaran_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (KeyPressHelper.IsEnter(e))
     {
         Simpan();
     }
 }
Beispiel #9
0
 private void txtKeyword_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (KeyPressHelper.IsEnter(e))
     {
         Cari();
     }
 }
Beispiel #10
0
 private void txtPlafonPiutang_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (KeyPressHelper.IsEnter(e))
     {
         Simpan();
     }
 }
Beispiel #11
0
 private void txtSaldoAwal_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (KeyPressHelper.IsEnter(e))
     {
         btnLogin_Click(sender, e);
     }
 }
Beispiel #12
0
 private void chkAktif_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (KeyPressHelper.IsEnter(e))
     {
         KeyPressHelper.NextFocus();
     }
 }
Beispiel #13
0
 private void txtBayarTunai_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (KeyPressHelper.IsEnter(e))
     {
         KeyPressHelper.NextFocus();
         KeyPressHelper.NextFocus();
     }
 }
 private void txtKeterangan_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (KeyPressHelper.IsEnter(e))
     {
         gridControl.Focus();
         GridListControlHelper.SetCurrentCell(gridControl, 1, 2); // fokus ke kolom nama produk
     }
 }
 private void gridList_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (KeyPressHelper.IsEnter(e))
     {
         if (base.IsButtonPilihEnabled)
         {
             Pilih();
         }
     }
 }
        private void txtKodeProduk_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (KeyPressHelper.IsEnter(e))
            {
                var keyword = ((AdvancedTextbox)sender).Text;

                IProdukBll produkBll = new ProdukBll(MainProgram.isUseWebAPI, MainProgram.baseUrl, _log);
                this._produk = produkBll.GetByKode(keyword);

                if (this._produk == null)
                {
                    var listOfProduk = produkBll.GetByName(keyword);

                    if (listOfProduk.Count == 0)
                    {
                        MsgHelper.MsgWarning("Data produk tidak ditemukan");
                        txtKodeProduk.Focus();
                        txtKodeProduk.SelectAll();

                        ResetBarcode();
                    }
                    else if (listOfProduk.Count == 1)
                    {
                        this._produk = listOfProduk[0];

                        SetDataProduk(this._produk);
                        PreviewBarcode();
                    }
                    else // data lebih dari satu, tampilkan form lookup
                    {
                        var frmLookup = new FrmLookupReferensi("Data Produk", listOfProduk);
                        frmLookup.Listener = this;
                        frmLookup.ShowDialog();
                    }
                }
                else
                {
                    SetDataProduk(this._produk);
                    PreviewBarcode();
                }
            }
        }
Beispiel #17
0
        private void txtCustomer_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (KeyPressHelper.IsEnter(e))
            {
                var customerName = ((AdvancedTextbox)sender).Text;

                if (customerName.Length == 0)
                {
                    ShowMessage("Nama pelanggan tidak boleh kosong", true);
                    return;
                }

                ICustomerBll bll            = new CustomerBll(_log);
                var          listOfCustomer = bll.GetByName(customerName);

                if (listOfCustomer.Count == 0)
                {
                    ShowMessage("Data pelanggan tidak ditemukan", true);

                    txtCustomer.Focus();
                    txtCustomer.SelectAll();
                }
                else if (listOfCustomer.Count == 1)
                {
                    _customer        = listOfCustomer[0];
                    txtCustomer.Text = _customer.nama_customer;

                    ShowMessage("");
                    lblStatusBar.Text = lblStatusBar.Text.Replace("Cari Pelanggan", "Reset Pelanggan");

                    KeyPressHelper.NextFocus();
                }
                else // data lebih dari satu
                {
                    var frmLookup = new FrmLookupReferensi("Data Pelanggan", listOfCustomer);
                    frmLookup.Listener = this;
                    frmLookup.ShowDialog();
                }
            }
        }
Beispiel #18
0
        private void txtNotaJual_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (KeyPressHelper.IsEnter(e))
            {
                if (this._customer == null || txtCustomer.Text.Length == 0)
                {
                    MsgHelper.MsgWarning("Maaf isian data belum lengkap !");
                    txtCustomer.Focus();

                    return;
                }

                var nota = ((TextBox)sender).Text;

                IJualProdukBll bll        = new JualProdukBll(_log);
                var            listOfJual = bll.GetNotaCustomer(this._customer.customer_id, nota);

                if (listOfJual.Count == 0)
                {
                    MsgHelper.MsgWarning("Data nota jual tidak ditemukan");
                    txtNotaJual.Focus();
                    txtNotaJual.SelectAll();
                }
                else if (listOfJual.Count == 1)
                {
                    _jual           = listOfJual[0];
                    _jual.item_jual = bll.GetItemJual(_jual.jual_id).ToList();

                    txtNotaJual.Text = _jual.nota;
                    KeyPressHelper.NextFocus();
                }
                else // data lebih dari satu
                {
                    var frmLookup = new FrmLookupNota("Data Nota Penjualan", listOfJual);
                    frmLookup.Listener = this;
                    frmLookup.ShowDialog();
                }
            }
        }
        private void txtNotaBeli_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (KeyPressHelper.IsEnter(e))
            {
                if (this._supplier == null || txtSupplier.Text.Length == 0)
                {
                    MsgHelper.MsgWarning("Maaf isian data belum lengkap !");
                    txtSupplier.Focus();

                    return;
                }

                var nota = ((TextBox)sender).Text;

                IBeliProdukBll bll        = new BeliProdukBll(_log);
                var            listOfBeli = bll.GetNotaSupplier(this._supplier.supplier_id, nota);

                if (listOfBeli.Count == 0)
                {
                    MsgHelper.MsgWarning("Data nota beli tidak ditemukan");
                    txtNotaBeli.Focus();
                    txtNotaBeli.SelectAll();
                }
                else if (listOfBeli.Count == 1)
                {
                    _beli           = listOfBeli[0];
                    _beli.item_beli = bll.GetItemBeli(_beli.beli_produk_id).ToList();

                    txtNotaBeli.Text = _beli.nota;
                    KeyPressHelper.NextFocus();
                }
                else // data lebih dari satu
                {
                    var frmLookup = new FrmLookupNota("Data Nota Pembelian", listOfBeli);
                    frmLookup.Listener = this;
                    frmLookup.ShowDialog();
                }
            }
        }
        private void txtNamaProduk_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (KeyPressHelper.IsEnter(e))
            {
                var keyword = ((AdvancedTextbox)sender).Text;

                IProdukBll produkBll = new ProdukBll(_log);
                this._produk = produkBll.GetByKode(keyword);

                if (this._produk == null)
                {
                    var listOfProduk = produkBll.GetByName(keyword);

                    if (listOfProduk.Count == 0)
                    {
                        MsgHelper.MsgWarning("Data produk tidak ditemukan");
                        txtNamaProduk.Focus();
                        txtNamaProduk.SelectAll();
                    }
                    else if (listOfProduk.Count == 1)
                    {
                        this._produk = listOfProduk[0];

                        FillListProduk(this._produk);
                    }
                    else // data lebih dari satu
                    {
                        var frmLookup = new FrmLookupReferensi("Data Produk", listOfProduk);
                        frmLookup.Listener = this;
                        frmLookup.ShowDialog();
                    }
                }
                else
                {
                    FillListProduk(this._produk);
                }
            }
        }
 private void txtNamaDropshipper_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (KeyPressHelper.IsEnter(e))
         btnCari_Click(sender, e);
 }
        private void gridControl_CurrentCellKeyDown(object sender, KeyEventArgs e)
        {
            if (KeyPressHelper.IsEnter(e))
            {
                var grid = (GridControl)sender;

                var rowIndex = grid.CurrentCell.RowIndex;
                var colIndex = grid.CurrentCell.ColIndex;

                JenisPengeluaran jenisPengeluaran = null;

                switch (colIndex)
                {
                case 2:     // pencarian berdasarkan nama jenis pengeluaran

                    GridCurrentCell cc         = grid.CurrentCell;
                    var             namaProduk = cc.Renderer.ControlValue.ToString();

                    IJenisPengeluaranBll bll   = new JenisPengeluaranBll(MainProgram.isUseWebAPI, MainProgram.baseUrl, _log);
                    var listOfJenisPengeluaran = bll.GetByName(namaProduk);

                    if (listOfJenisPengeluaran.Count == 0)
                    {
                        MsgHelper.MsgWarning("Data jenis pengeluaran tidak ditemukan");
                        GridListControlHelper.SelectCellText(grid, rowIndex, colIndex);
                    }
                    else if (listOfJenisPengeluaran.Count == 1)
                    {
                        jenisPengeluaran = listOfJenisPengeluaran[0];

                        if (!IsExist(jenisPengeluaran.jenis_pengeluaran_id))
                        {
                            SetItemJenisPengeluaran(grid, rowIndex, colIndex, jenisPengeluaran);
                            grid.Refresh();
                            RefreshTotal();

                            GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1);
                        }
                        else
                        {
                            MsgHelper.MsgWarning("Data jenis pengeluaran sudah diinputkan");
                            GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex);
                        }
                    }
                    else     // data lebih dari satu, tampilkan form lookup
                    {
                        _rowIndex = rowIndex;
                        _colIndex = colIndex;

                        var frmLookup = new FrmLookupReferensi("Data Jenis Pengeluaran", listOfJenisPengeluaran);
                        frmLookup.Listener = this;
                        frmLookup.ShowDialog();
                    }

                    break;

                case 3:
                    GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1);
                    break;

                case 4:
                    if (grid.RowCount == rowIndex)
                    {
                        _listOfItemPengeluaran.Add(new ItemPengeluaranBiaya());
                        grid.RowCount = _listOfItemPengeluaran.Count;
                    }

                    GridListControlHelper.SetCurrentCell(grid, rowIndex + 1, 2);     // fokus ke kolom kode produk
                    break;

                default:
                    break;
                }
            }
        }
Beispiel #23
0
        private void gridControl_CurrentCellKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F4)
            {
                Shortcut(sender, e);
                return;
            }

            if (KeyPressHelper.IsEnter(e))
            {
                if (lblKembalian.Text.Length > 0)
                {
                    lblKembalian.Text = "";
                }

                var grid = (GridControl)sender;

                var rowIndex = grid.CurrentCell.RowIndex;
                var colIndex = grid.CurrentCell.ColIndex;

                IProdukBll      bll    = new ProdukBll(_log);
                Produk          produk = null;
                GridCurrentCell cc;

                switch (colIndex)
                {
                case 2:     // kode produk
                    cc = grid.CurrentCell;
                    var kodeProduk = cc.Renderer.ControlValue.ToString();

                    if (kodeProduk.Length == 0)     // kode produk kosong
                    {
                        // fokus ke kolom nama produk
                        GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1);
                    }
                    else
                    {
                        // pencarian berdasarkan kode produk
                        produk = bll.GetByKode(kodeProduk);

                        if (produk == null)
                        {
                            ShowMessage("Data produk tidak ditemukan", true);
                            GridListControlHelper.SelectCellText(grid, rowIndex, colIndex);
                            return;
                        }

                        if (!_pengaturanUmum.is_stok_produk_boleh_minus)
                        {
                            if (produk.is_stok_minus)
                            {
                                ShowMessage("Maaf stok produk tidak boleh minus", true);
                                GridListControlHelper.SelectCellText(grid, rowIndex, colIndex);
                                return;
                            }
                        }

                        ShowMessage("");

                        double diskon = 0;

                        if (_customer != null)
                        {
                            diskon = _customer.diskon;
                        }

                        if (!(diskon > 0))
                        {
                            var diskonProduk = GetDiskonJualFix(produk, 1, produk.diskon);
                            diskon = diskonProduk > 0 ? diskonProduk : produk.Golongan.diskon;
                        }

                        ItemJualProduk itemJual = null;

                        // cek item produk sudah diinputkan atau belum ?
                        var itemProduk = GetExistItemProduk(produk.produk_id);

                        if (itemProduk != null)     // sudah ada, tinggal update jumlah
                        {
                            var index = _listOfItemJual.IndexOf(itemProduk);

                            UpdateItemProduk(grid, index);
                            cc.Renderer.ControlText = string.Empty;

                            itemJual = _listOfItemJual[index];
                        }
                        else
                        {
                            SetItemProduk(grid, rowIndex, produk, diskon: diskon);
                            itemJual = _listOfItemJual[rowIndex - 1];

                            if (grid.RowCount == rowIndex)
                            {
                                _listOfItemJual.Add(new ItemJualProduk());
                                grid.RowCount = _listOfItemJual.Count;
                            }
                        }

                        grid.Refresh();
                        RefreshTotal();
                        DisplayItemProduct(itemJual);

                        if (_pengaturanUmum.is_tampilkan_keterangan_tambahan_item_jual)
                        {
                            // fokus ke kolom keterangan
                            GridListControlHelper.SetCurrentCell(grid, rowIndex, 4);
                        }
                        else
                        {
                            if (_pengaturanUmum.is_fokus_input_kolom_jumlah)
                            {
                                GridListControlHelper.SetCurrentCell(grid, rowIndex, 5);     // fokus ke kolom jumlah
                            }
                            else
                            {
                                GridListControlHelper.SetCurrentCell(grid, _listOfItemJual.Count, 2);     // pindah kebaris berikutnya
                            }
                        }
                    }

                    break;

                case 3:     // pencarian berdasarkan nama produk

                    cc = grid.CurrentCell;
                    var namaProduk = cc.Renderer.ControlValue.ToString();

                    if (namaProduk.Length == 0)
                    {
                        ShowMessage("Nama produk tidak boleh kosong", true);
                        GridListControlHelper.SelectCellText(grid, rowIndex, colIndex);
                        return;
                    }

                    var listOfProduk = bll.GetByName(namaProduk, false);

                    if (listOfProduk.Count == 0)
                    {
                        ShowMessage("Data produk tidak ditemukan", true);
                        GridListControlHelper.SelectCellText(grid, rowIndex, colIndex);
                    }
                    else if (listOfProduk.Count == 1)
                    {
                        ShowMessage("");
                        produk = listOfProduk[0];

                        IHargaGrosirBll hargaGrosirBll = new HargaGrosirBll(_log);
                        produk.list_of_harga_grosir = hargaGrosirBll.GetListHargaGrosir(produk.produk_id).ToList();

                        if (!_pengaturanUmum.is_stok_produk_boleh_minus)
                        {
                            if (produk.is_stok_minus)
                            {
                                ShowMessage("Maaf stok produk tidak boleh minus", true);
                                GridListControlHelper.SelectCellText(grid, rowIndex, colIndex);
                                return;
                            }
                        }

                        double diskon = 0;

                        if (_customer != null)
                        {
                            diskon = _customer.diskon;
                        }

                        if (!(diskon > 0))
                        {
                            var diskonProduk = GetDiskonJualFix(produk, 1, produk.diskon);
                            diskon = diskonProduk > 0 ? diskonProduk : produk.Golongan.diskon;
                        }

                        ItemJualProduk itemJual = null;

                        // cek item produk sudah diinputkan atau belum ?
                        var itemProduk = GetExistItemProduk(produk.produk_id);

                        if (itemProduk != null)     // sudah ada, tinggal update jumlah
                        {
                            var index = _listOfItemJual.IndexOf(itemProduk);

                            UpdateItemProduk(grid, index);
                            cc.Renderer.ControlText = string.Empty;

                            itemJual = _listOfItemJual[index];
                        }
                        else
                        {
                            SetItemProduk(grid, rowIndex, produk, diskon: diskon);

                            itemJual = _listOfItemJual[rowIndex - 1];

                            if (grid.RowCount == rowIndex)
                            {
                                _listOfItemJual.Add(new ItemJualProduk());
                                grid.RowCount = _listOfItemJual.Count;
                            }
                        }

                        grid.Refresh();
                        RefreshTotal();
                        DisplayItemProduct(itemJual);

                        if (_pengaturanUmum.is_tampilkan_keterangan_tambahan_item_jual)
                        {
                            // fokus ke kolom keterangan
                            GridListControlHelper.SetCurrentCell(grid, rowIndex, 4);
                        }
                        else
                        {
                            if (_pengaturanUmum.is_fokus_input_kolom_jumlah)
                            {
                                GridListControlHelper.SetCurrentCell(grid, rowIndex, 5);     // fokus ke kolom jumlah
                            }
                            else
                            {
                                GridListControlHelper.SetCurrentCell(grid, _listOfItemJual.Count, 2);     // pindah kebaris berikutnya
                            }
                        }
                    }
                    else     // data lebih dari satu
                    {
                        ShowMessage("");
                        _rowIndex = rowIndex;
                        _colIndex = colIndex;

                        var frmLookup = new FrmLookupReferensi("Data Produk", listOfProduk);
                        frmLookup.Listener = this;
                        frmLookup.ShowDialog();
                    }

                    break;

                case 4:     // keterangan
                    if (grid.RowCount == rowIndex)
                    {
                        _listOfItemJual.Add(new ItemJualProduk());
                        grid.RowCount = _listOfItemJual.Count;
                    }

                    if (_pengaturanUmum.is_fokus_input_kolom_jumlah)
                    {
                        GridListControlHelper.SetCurrentCell(grid, rowIndex, 5);     // fokus ke kolom jumlah
                    }
                    else
                    {
                        GridListControlHelper.SetCurrentCell(grid, _listOfItemJual.Count, 2);     // pindah kebaris berikutnya
                    }

                    break;

                case 5:     // jumlah
                    if (!_pengaturanUmum.is_stok_produk_boleh_minus)
                    {
                        gridControl_CurrentCellValidated(sender, new EventArgs());

                        var itemJual = _listOfItemJual[rowIndex - 1];
                        produk = itemJual.Produk;

                        var isValidStok = (produk.sisa_stok - itemJual.jumlah) >= 0;

                        if (!isValidStok)
                        {
                            ShowMessage("Maaf stok produk tidak boleh minus", true);
                            GridListControlHelper.SelectCellText(grid, rowIndex, colIndex);

                            return;
                        }
                    }

                    if (grid.RowCount == rowIndex)
                    {
                        _listOfItemJual.Add(new ItemJualProduk());
                        grid.RowCount = _listOfItemJual.Count;
                    }

                    GridListControlHelper.SetCurrentCell(grid, _listOfItemJual.Count, 2);     // pindah kebaris berikutnya
                    break;

                case 6:     // diskon
                    if (grid.RowCount == rowIndex)
                    {
                        _listOfItemJual.Add(new ItemJualProduk());
                        grid.RowCount = _listOfItemJual.Count;
                    }

                    GridListControlHelper.SetCurrentCell(grid, _listOfItemJual.Count, 2);
                    break;

                case 7:
                    if (grid.RowCount == rowIndex)
                    {
                        _listOfItemJual.Add(new ItemJualProduk());
                        grid.RowCount = _listOfItemJual.Count;
                    }

                    GridListControlHelper.SetCurrentCell(grid, _listOfItemJual.Count, 2);     // fokus ke kolom kode produk
                    break;

                default:
                    break;
                }
            }
        }
Beispiel #24
0
        private void gridControl_CurrentCellKeyDown(object sender, KeyEventArgs e)
        {
            if (KeyPressHelper.IsEnter(e))
            {
                var grid = (GridControl)sender;

                var rowIndex = grid.CurrentCell.RowIndex;
                var colIndex = grid.CurrentCell.ColIndex;

                IProdukBll      bll    = new ProdukBll(_log);
                Produk          produk = null;
                GridCurrentCell cc;

                switch (colIndex)
                {
                case 2:     // kode produk
                    _isValidKodeProduk = false;

                    cc = grid.CurrentCell;
                    var kodeProduk = cc.Renderer.ControlValue.ToString();

                    if (kodeProduk.Length == 0)     // kode produk kosong
                    {
                        // fokus ke kolom nama produk
                        GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1);
                    }
                    else
                    {
                        // pencarian berdasarkan kode produk
                        produk = bll.GetByKode(kodeProduk);

                        if (produk == null)
                        {
                            MsgHelper.MsgWarning("Data produk tidak ditemukan");
                            GridListControlHelper.SelectCellText(grid, rowIndex, colIndex);
                            return;
                        }

                        _isValidKodeProduk = true;

                        if (!IsExist(produk.produk_id))
                        {
                            double diskon = produk.diskon > 0 ? produk.diskon : produk.Golongan.diskon;

                            SetItemProduk(grid, rowIndex, colIndex, produk, diskon: diskon);
                            grid.Refresh();
                            RefreshTotal();

                            GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 2);
                        }
                        else
                        {
                            MsgHelper.MsgWarning("Data produk sudah diinputkan");
                            GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex);
                        }
                    }

                    break;

                case 3:     // pencarian berdasarkan nama produk

                    cc = grid.CurrentCell;
                    var namaProduk = cc.Renderer.ControlValue.ToString();

                    if (!_isValidKodeProduk)
                    {
                        var listOfProduk = bll.GetByName(namaProduk);

                        if (listOfProduk.Count == 0)
                        {
                            MsgHelper.MsgWarning("Data produk tidak ditemukan");
                            GridListControlHelper.SelectCellText(grid, rowIndex, colIndex);
                        }
                        else if (listOfProduk.Count == 1)
                        {
                            produk = listOfProduk[0];

                            if (!IsExist(produk.produk_id))
                            {
                                double diskon = produk.diskon > 0 ? produk.diskon : produk.Golongan.diskon;

                                SetItemProduk(grid, rowIndex, colIndex, produk, diskon: diskon);
                                grid.Refresh();
                                RefreshTotal();

                                GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1);
                            }
                            else
                            {
                                MsgHelper.MsgWarning("Data produk sudah diinputkan");
                                GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex);
                            }
                        }
                        else     // data lebih dari satu
                        {
                            _rowIndex = rowIndex;
                            _colIndex = colIndex;

                            var frmLookup = new FrmLookupReferensi("Data Produk", listOfProduk);
                            frmLookup.Listener = this;
                            frmLookup.ShowDialog();
                        }
                    }
                    else
                    {
                        GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1);
                    }

                    break;

                case 4:     // jumlah
                case 5:     // diskon
                    GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1);
                    break;

                case 6:
                    if (grid.RowCount == rowIndex)
                    {
                        _listOfItemJual.Add(new ItemJualProduk());
                        grid.RowCount = _listOfItemJual.Count;
                    }

                    GridListControlHelper.SetCurrentCell(grid, rowIndex + 1, 2);     // fokus ke kolom kode produk
                    break;

                default:
                    break;
                }
            }
        }
Beispiel #25
0
        private void gridControl_CurrentCellKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F4)
            {
                Shortcut(sender, e);
                return;
            }

            if (KeyPressHelper.IsEnter(e))
            {
                if (lblKembalian.Text.Length > 0)
                {
                    lblKembalian.Text = "";
                }

                var grid = (GridControl)sender;

                var rowIndex = grid.CurrentCell.RowIndex;
                var colIndex = grid.CurrentCell.ColIndex;

                IProdukBll      bll    = new ProdukBll(_log);
                Produk          produk = null;
                GridCurrentCell cc;

                switch (colIndex)
                {
                case 2:     // kode produk
                    cc = grid.CurrentCell;
                    var kodeProduk = cc.Renderer.ControlValue.ToString();

                    if (kodeProduk.Length == 0)     // kode produk kosong
                    {
                        // fokus ke kolom nama produk
                        GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1);
                    }
                    else
                    {
                        // pencarian berdasarkan kode produk
                        produk = bll.GetByKode(kodeProduk);

                        if (produk == null)
                        {
                            ShowMessage("Data produk tidak ditemukan");
                            GridListControlHelper.SelectCellText(grid, rowIndex, colIndex);
                            return;
                        }

                        if (!_pengaturanUmum.is_stok_produk_boleh_minus)
                        {
                            if (produk.is_stok_minus)
                            {
                                ShowMessage("Maaf stok produk tidak boleh minus", true);
                                GridListControlHelper.SelectCellText(grid, rowIndex, colIndex);
                                return;
                            }
                        }

                        ShowMessage("");

                        double diskon = 0;

                        if (_customer != null)
                        {
                            diskon = _customer.diskon;
                        }

                        if (!(diskon > 0))
                        {
                            var diskonProduk = GetDiskonJualFix(produk, 1, produk.diskon);
                            diskon = diskonProduk > 0 ? diskonProduk : produk.Golongan.diskon;
                        }

                        SetItemProduk(grid, rowIndex, colIndex, produk, diskon: diskon);
                        grid.Refresh();
                        RefreshTotal();

                        if (grid.RowCount == rowIndex)
                        {
                            _listOfItemJual.Add(new ItemJualProduk());
                            grid.RowCount = _listOfItemJual.Count;
                        }

                        GridListControlHelper.SetCurrentCell(grid, rowIndex + 1, 2);     // pindah kebaris berikutnya
                    }

                    break;

                case 3:     // pencarian berdasarkan nama produk

                    cc = grid.CurrentCell;
                    var namaProduk = cc.Renderer.ControlValue.ToString();

                    var listOfProduk = bll.GetByName(namaProduk);

                    if (listOfProduk.Count == 0)
                    {
                        ShowMessage("Data produk tidak ditemukan");
                        GridListControlHelper.SelectCellText(grid, rowIndex, colIndex);
                    }
                    else if (listOfProduk.Count == 1)
                    {
                        ShowMessage("");
                        produk = listOfProduk[0];

                        if (!_pengaturanUmum.is_stok_produk_boleh_minus)
                        {
                            if (produk.is_stok_minus)
                            {
                                ShowMessage("Maaf stok produk tidak boleh minus", true);
                                GridListControlHelper.SelectCellText(grid, rowIndex, colIndex);
                                return;
                            }
                        }

                        double diskon = 0;

                        if (_customer != null)
                        {
                            diskon = _customer.diskon;
                        }

                        if (!(diskon > 0))
                        {
                            var diskonProduk = GetDiskonJualFix(produk, 1, produk.diskon);
                            diskon = diskonProduk > 0 ? diskonProduk : produk.Golongan.diskon;
                        }

                        SetItemProduk(grid, rowIndex, colIndex, produk, diskon: diskon);
                        grid.Refresh();
                        RefreshTotal();

                        if (grid.RowCount == rowIndex)
                        {
                            _listOfItemJual.Add(new ItemJualProduk());
                            grid.RowCount = _listOfItemJual.Count;
                        }

                        GridListControlHelper.SetCurrentCell(grid, rowIndex + 1, 2); // pindah kebaris berikutnya
                    }
                    else                                                             // data lebih dari satu
                    {
                        ShowMessage("");
                        _rowIndex = rowIndex;
                        _colIndex = colIndex;

                        var frmLookup = new FrmLookupReferensi("Data Produk", listOfProduk);
                        frmLookup.Listener = this;
                        frmLookup.ShowDialog();
                    }

                    break;

                case 4:     // jumlah
                case 5:     // diskon
                    GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1);
                    break;

                case 6:
                    if (grid.RowCount == rowIndex)
                    {
                        _listOfItemJual.Add(new ItemJualProduk());
                        grid.RowCount = _listOfItemJual.Count;
                    }

                    GridListControlHelper.SetCurrentCell(grid, _listOfItemJual.Count, 2);     // fokus ke kolom kode produk
                    break;

                default:
                    break;
                }
            }
        }