public void Ok(object sender, object data)
        {
            if (data is ItemBeliProduk) // pencarian produk baku
            {
                var itemBeli = (ItemBeliProduk)data;
                var produk   = itemBeli.Produk;

                if (!IsExist(produk.produk_id))
                {
                    SetItemProduk(this.gridControl, _rowIndex, itemBeli, itemBeli.jumlah - itemBeli.jumlah_retur, itemBeli.harga);
                    this.gridControl.Refresh();
                    RefreshTotal();

                    GridListControlHelper.SetCurrentCell(this.gridControl, _rowIndex, _colIndex + 1);

                    RefreshTotal();
                }
                else
                {
                    MsgHelper.MsgWarning("Data produk sudah diinputkan");
                    GridListControlHelper.SelectCellText(this.gridControl, _rowIndex, _colIndex);
                }
            }
            else if (data is Supplier) // pencarian Customer
            {
                this._supplier   = (Supplier)data;
                txtSupplier.Text = this._supplier.nama_supplier;
                KeyPressHelper.NextFocus();
            }
            else if (data is BeliProduk) // pencarian data jual
            {
                IBeliProdukBll bll = new BeliProdukBll(_log);

                this._beli           = (BeliProduk)data;
                this._beli.item_beli = bll.GetItemBeli(this._beli.beli_produk_id).ToList();
                txtNotaBeli.Text     = this._beli.nota;

                KeyPressHelper.NextFocus();
            }
        }
        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();
                }
            }
        }
Exemple #3
0
        private void gridControl_CurrentCellKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                var grid = (GridControl)sender;

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

                switch (colIndex)
                {
                case 2:     // kolom nota
                    if (this._supplier == null || txtSupplier.Text.Length == 0)
                    {
                        MsgHelper.MsgWarning("Nama supplier belum diinputkan");
                        txtSupplier.Focus();
                        return;
                    }

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

                    IList <BeliProduk> listOfBeli = null;
                    IBeliProdukBll     bll        = new BeliProdukBll(MainProgram.isUseWebAPI, MainProgram.baseUrl, _log);

                    if (nota.Length > 0)     // menampilkan nota kredit berdasarkan nota
                    {
                        listOfBeli = bll.GetNotaKreditByNota(this._supplier.supplier_id, nota);
                    }
                    else
                    {
                        listOfBeli = bll.GetNotaKreditBySupplier(this._supplier.supplier_id, false);
                    }

                    if (listOfBeli.Count == 0)
                    {
                        MsgHelper.MsgWarning("Data pembelian kredit tidak ditemukan");
                        GridListControlHelper.SelectCellText(grid, rowIndex, colIndex);
                    }
                    else if (listOfBeli.Count == 1)
                    {
                        var beli = listOfBeli[0];

                        if (!IsExist(beli.nota))
                        {
                            SetItemBayar(grid, rowIndex, colIndex, beli);
                            grid.Refresh();

                            GridListControlHelper.SetCurrentCell(grid, rowIndex, 5);     // kolom pembayaran
                        }
                        else
                        {
                            MsgHelper.MsgWarning("Data pembayaran sudah diinputkan");
                            GridListControlHelper.SelectCellText(grid, rowIndex, colIndex);
                        }
                    }
                    else     // data nota lebih dari satu, tampilkan di form lookup
                    {
                        _rowIndex = rowIndex;
                        _colIndex = colIndex;

                        var frmLookup = new FrmLookupNota("Data Nota Pembelian", listOfBeli);
                        frmLookup.Listener = this;
                        frmLookup.ShowDialog();
                    }

                    break;

                case 6:     // keterangan
                    if (grid.RowCount == rowIndex)
                    {
                        _listOfItemPembayaranHutang.Add(new ItemPembayaranHutangProduk());
                        grid.RowCount = _listOfItemPembayaranHutang.Count;
                    }

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

                default:
                    break;
                }
            }
        }
        private void LoadItemBeli(BeliProduk beliProduk)
        {
            IBeliProdukBll bll = new BeliProdukBll(_log);

            _beli.item_beli = bll.GetItemBeli(_beli.beli_produk_id).ToList();
        }