Пример #1
0
        public void Ok(object sender, object data)
        {
            if (data is BeliProduk) // pencarian nota
            {
                var beli = (BeliProduk)data;

                if (!IsExist(beli.nota))
                {
                    SetItemBayar(this.gridControl, _rowIndex, _colIndex + 1, beli);
                    this.gridControl.Refresh();

                    GridListControlHelper.SetCurrentCell(this.gridControl, _rowIndex, 5); // kolom pembayaran
                }
                else
                {
                    MsgHelper.MsgWarning("Data nota sudah diinputkan");
                    GridListControlHelper.SelectCellText(this.gridControl, _rowIndex, _colIndex);
                }
            }
            else if (data is Supplier) // pencarian supplier
            {
                this._supplier   = (Supplier)data;
                txtSupplier.Text = this._supplier.nama_supplier;
                KeyPressHelper.NextFocus();
            }
        }
Пример #2
0
        public void Ok(object sender, object data)
        {
            if (data is Produk) // pencarian produk baku
            {
                var produk = (Produk)data;

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

                    SetItemProduk(this.gridControl, _rowIndex, _colIndex + 1, produk, diskon: diskon);
                    this.gridControl.Refresh();
                    RefreshTotal();

                    GridListControlHelper.SetCurrentCell(this.gridControl, _rowIndex, _colIndex + 1);
                }
                else
                {
                    MsgHelper.MsgWarning("Data produk sudah diinputkan");
                    GridListControlHelper.SelectCellText(this.gridControl, _rowIndex, _colIndex);
                }
            }
            else if (data is Customer) // pencarian customer
            {
                this._customer   = (Customer)data;
                txtCustomer.Text = this._customer.nama_customer;
                KeyPressHelper.NextFocus();
            }
        }
        public void Ok(object sender, object data)
        {
            if (data is JualProduk) // pencarian nota
            {
                var jual = (JualProduk)data;

                if (!IsExist(jual.nota))
                {
                    SetItemBayar(this.gridControl, _rowIndex, _colIndex + 1, jual);
                    this.gridControl.Refresh();

                    GridListControlHelper.SetCurrentCell(this.gridControl, _rowIndex, 5); // kolom pembayaran
                }
                else
                {
                    MsgHelper.MsgWarning("Data nota sudah diinputkan");
                    GridListControlHelper.SelectCellText(this.gridControl, _rowIndex, _colIndex);
                }
            }
            else if (data is Customer) // pencarian customer
            {
                this._customer   = (Customer)data;
                txtCustomer.Text = this._customer.nama_customer;
                KeyPressHelper.NextFocus();
            }
        }
        public void Ok(object sender, object data)
        {
            if (data is Produk) // pencarian produk baku
            {
                var produk = (Produk)data;

                if (!IsExist(produk.produk_id))
                {
                    SetItemProduk(this.gridControl, _rowIndex, _colIndex + 1, produk);
                    this.gridControl.Refresh();
                    RefreshTotal();

                    GridListControlHelper.SetCurrentCell(this.gridControl, _rowIndex, _colIndex + 1);
                }
                else
                {
                    MsgHelper.MsgWarning("Data produk sudah diinputkan");
                    GridListControlHelper.SelectCellText(this.gridControl, _rowIndex, _colIndex);
                }
            }
            else if (data is Supplier) // pencarian supplier
            {
                this._supplier   = (Supplier)data;
                txtSupplier.Text = this._supplier.nama_supplier;
                KeyPressHelper.NextFocus();
            }
        }
Пример #5
0
        private void gridControl_CurrentCellValidated(object sender, EventArgs e)
        {
            var grid = (GridControl)sender;

            GridCurrentCell cc = grid.CurrentCell;

            var itemPembayaran  = _listOfItemPembayaranHutang[cc.RowIndex - 1];
            var beli            = itemPembayaran.BeliProduk;
            var isValidSisaNota = true;

            if (beli != null)
            {
                switch (cc.ColIndex)
                {
                case 5:     // kolom pembayaran
                    itemPembayaran.nominal = NumberHelper.StringToDouble(cc.Renderer.ControlValue.ToString());
                    beli.total_pelunasan   = itemPembayaran.nominal + beli.total_pelunasan_old;
                    isValidSisaNota        = beli.sisa_nota >= 0;

                    if (!isValidSisaNota)
                    {
                        beli.total_pelunasan -= itemPembayaran.nominal;

                        MsgHelper.MsgWarning("Maaf, jumlah pembayaran melebihi sisa hutang");

                        GridListControlHelper.SetCurrentCell(grid, cc.RowIndex, cc.ColIndex);
                        GridListControlHelper.SelectCellText(grid, cc.RowIndex, cc.ColIndex);

                        break;
                    }
                    else
                    {
                        GridListControlHelper.SetCurrentCell(grid, cc.RowIndex, cc.ColIndex + 1);
                    }

                    break;

                case 6:     // kolom keterangan
                    itemPembayaran.keterangan = cc.Renderer.ControlValue.ToString();
                    break;

                default:
                    break;
                }

                SetItemBayar(grid, cc.RowIndex, cc.ColIndex, beli, itemPembayaran.nominal, itemPembayaran.keterangan);
                grid.Refresh();
                RefreshTotal();
            }
        }
        public void Ok(object sender, object data)
        {
            if (data is JenisPengeluaran) // pencarian jenis pengeluaran
            {
                var jenisPengeluaran = (JenisPengeluaran)data;

                if (!IsExist(jenisPengeluaran.jenis_pengeluaran_id))
                {
                    SetItemJenisPengeluaran(this.gridControl, _rowIndex, _colIndex + 1, jenisPengeluaran);
                    this.gridControl.Refresh();
                    RefreshTotal();

                    GridListControlHelper.SetCurrentCell(this.gridControl, _rowIndex, _colIndex + 1);
                }
                else
                {
                    MsgHelper.MsgWarning("Data jenis pengeluaran sudah diinputkan");
                    GridListControlHelper.SelectCellText(this.gridControl, _rowIndex, _colIndex);
                }
            }
        }
        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();
            }
        }
Пример #8
0
        public void Ok(object sender, object data)
        {
            if (data is ItemJualProduk) // pencarian produk baku
            {
                var itemJual = (ItemJualProduk)data;
                var produk   = itemJual.Produk;

                if (!IsExist(produk.produk_id))
                {
                    SetItemProduk(this.gridControl, _rowIndex, itemJual, itemJual.jumlah - itemJual.jumlah_retur, itemJual.harga_jual);
                    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 Customer) // pencarian customer
            {
                this._customer   = (Customer)data;
                txtCustomer.Text = this._customer.nama_customer;
                KeyPressHelper.NextFocus();
            }
            else if (data is JualProduk) // pencarian data jual
            {
                IJualProdukBll bll = new JualProdukBll(_log);

                this._jual           = (JualProduk)data;
                this._jual.item_jual = bll.GetItemJual(this._jual.jual_id).ToList();
                txtNotaJual.Text     = this._jual.nota;

                KeyPressHelper.NextFocus();
            }
        }
        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;
                }
            }
        }
Пример #10
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;
                }
            }
        }
Пример #11
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 gridControl_CurrentCellKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (this._beli == null || txtNotaBeli.Text.Length == 0)
                {
                    MsgHelper.MsgWarning("Maaf isian data belum lengkap !");
                    txtNotaBeli.Focus();

                    return;
                }

                var grid = (GridControl)sender;

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

                GridCurrentCell cc;

                ItemBeliProduk itemBeli;

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

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

                    if (kodeProduk.Length == 0)
                    {
                        GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1);
                    }
                    else
                    {
                        itemBeli = this._beli.item_beli.Where(f => f.Produk.kode_produk.ToLower() == kodeProduk.ToLower() && f.jumlah > f.jumlah_retur)
                                   .SingleOrDefault();

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

                        _isValidKodeProduk = true;

                        if (!IsExist(itemBeli.produk_id))
                        {
                            SetItemProduk(grid, rowIndex, itemBeli, itemBeli.jumlah - itemBeli.jumlah_retur, itemBeli.harga);
                            grid.Refresh();

                            RefreshTotal();

                            GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 2);
                        }
                        else
                        {
                            GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 2);
                        }
                    }

                    break;

                case 3:     // nama produk

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

                    if (!_isValidKodeProduk)
                    {
                        var listOfItemBeli = this._beli.item_beli.Where(f => f.Produk.nama_produk.ToLower().Contains(namaProduk.ToLower()) && f.jumlah > f.jumlah_retur)
                                             .ToList();

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

                            if (!IsExist(itemBeli.produk_id))
                            {
                                SetItemProduk(grid, rowIndex, itemBeli, itemBeli.jumlah - itemBeli.jumlah_retur, itemBeli.harga);
                                grid.Refresh();

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

                            var frmLookup = new FrmLookupItemNota("Item Pembelian", listOfItemBeli);
                            frmLookup.Listener = this;
                            frmLookup.ShowDialog();
                        }
                    }

                    break;

                case 4:
                    _isValidJumlahRetur = false;

                    try
                    {
                        cc = grid.CurrentCell;
                        double jumlahRetur = NumberHelper.StringToDouble(cc.Renderer.ControlValue.ToString(), true);

                        var jumlahJual = _listOfItemRetur[rowIndex - 1].jumlah;
                        if (jumlahRetur <= jumlahJual)
                        {
                            _isValidJumlahRetur = true;
                            GridListControlHelper.SetCurrentCell(grid, rowIndex, colIndex + 1);
                        }
                        else
                        {
                            MsgHelper.MsgWarning("Maaf, jumlah retur tidak boleh melebihi jumlah jual");
                        }
                    }
                    catch
                    {
                    }

                    break;

                case 5:
                    if (grid.RowCount == rowIndex)
                    {
                        _listOfItemRetur.Add(new ItemReturBeliProduk());
                        grid.RowCount = _listOfItemRetur.Count;
                    }

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

                default:
                    break;
                }
            }
        }
Пример #13
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;
                }
            }
        }
Пример #14
0
        public void Ok(object sender, object data)
        {
            // filter berdasarkan data
            if (data is Produk) // pencarian produk baku
            {
                var produk = (Produk)data;

                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(this.gridControl, _rowIndex, 3);
                        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(this.gridControl, index);
                    this.gridControl.GetCellRenderer(_rowIndex, _colIndex).ControlText = string.Empty;

                    itemJual = _listOfItemJual[index];
                }
                else
                {
                    SetItemProduk(this.gridControl, _rowIndex, produk, diskon: diskon);
                    itemJual = _listOfItemJual[_rowIndex - 1];

                    if (this.gridControl.RowCount == _rowIndex)
                    {
                        _listOfItemJual.Add(new ItemJualProduk());
                        this.gridControl.RowCount = _listOfItemJual.Count;
                    }
                }

                this.gridControl.Refresh();
                RefreshTotal();
                DisplayItemProduct(itemJual);

                if (_pengaturanUmum.is_tampilkan_keterangan_tambahan_item_jual)
                {
                    // fokus ke kolom keterangan
                    GridListControlHelper.SetCurrentCell(this.gridControl, _rowIndex, 4);
                }
                else
                {
                    if (_pengaturanUmum.is_fokus_input_kolom_jumlah)
                    {
                        GridListControlHelper.SetCurrentCell(this.gridControl, _rowIndex, 5); // fokus ke kolom jumlah
                    }
                    else
                    {
                        if (itemProduk != null)
                        {
                            GridListControlHelper.SetCurrentCell(this.gridControl, _rowIndex, 2); // fokus ke kolom kode
                        }
                        else
                        {
                            GridListControlHelper.SetCurrentCell(this.gridControl, _rowIndex + 1, 2); // fokus kebaris berikutnya
                        }
                    }
                }
            }
            else if (data is Customer) // pencarian customer
            {
                this._customer   = (Customer)data;
                txtCustomer.Text = this._customer.nama_customer;

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

                KeyPressHelper.NextFocus();
            }
            else if (data is JualProduk) // pembayaran
            {
                var jual = (JualProduk)data;

                if (_pengaturanUmum.is_auto_print)
                {
                    if (_isCetakStruk)
                    {
                        switch (_pengaturanUmum.jenis_printer)
                        {
                        case JenisPrinter.DotMatrix:
                            CetakNotaDotMatrix(_jual);
                            break;

                        case JenisPrinter.MiniPOS:
                            CetakNotaMiniPOS(_jual);
                            break;

                        default:
                            // do nothing
                            break;
                        }
                    }
                }

                var kembalian = Math.Abs(jual.jumlah_bayar - jual.grand_total);
                DisplayKembalian(NumberHelper.NumberToString(kembalian));
                tmrDisplayKalimatPenutup.Enabled = true;

                lblKembalian.Text = string.Format("Kembalian: {0}", NumberHelper.NumberToString(kembalian));

                ResetTransaksi(false);
            }
            else // filter bardasarkan nama form
            {
                var frmName = sender.GetType().Name;

                switch (frmName)
                {
                case "FrmHapusItemTransaksi":
                    var noTransaksi = (int)((dynamic)data).noTransaksi;

                    var itemJual = _listOfItemJual[noTransaksi - 1];
                    itemJual.entity_state = EntityState.Deleted;

                    _listOfItemJual.Remove(itemJual);

                    gridControl.RowCount = _listOfItemJual.Count();
                    gridControl.Refresh();

                    RefreshTotal();

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

                default:
                    break;
                }
            }
        }
Пример #15
0
        public void Ok(object sender, object data)
        {
            // filter berdasarkan data
            if (data is Produk) // pencarian produk baku
            {
                var produk = (Produk)data;

                if (!_pengaturanUmum.is_stok_produk_boleh_minus)
                {
                    if (produk.is_stok_minus)
                    {
                        ShowMessage("Maaf stok produk tidak boleh minus", true);
                        GridListControlHelper.SelectCellText(this.gridControl, _rowIndex, 3);
                        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(this.gridControl, _rowIndex, _colIndex + 1, produk, diskon: diskon);
                this.gridControl.Refresh();
                RefreshTotal();

                if (this.gridControl.RowCount == _rowIndex)
                {
                    _listOfItemJual.Add(new ItemJualProduk());
                    this.gridControl.RowCount = _listOfItemJual.Count;
                }

                if (_pengaturanUmum.is_fokus_input_kolom_jumlah)
                {
                    GridListControlHelper.SetCurrentCell(this.gridControl, _rowIndex, 4); // fokus ke kolom jumlah
                }
                else
                {
                    GridListControlHelper.SetCurrentCell(this.gridControl, _rowIndex + 1, 2); // pindah kebaris berikutnya
                }
            }
            else if (data is Customer) // pencarian customer
            {
                this._customer   = (Customer)data;
                txtCustomer.Text = this._customer.nama_customer;

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

                KeyPressHelper.NextFocus();
            }
            else if (data is JualProduk) // pembayaran
            {
                var jual = (JualProduk)data;

                if (_pengaturanUmum.is_auto_print)
                {
                    if (_isCetakStruk)
                    {
                        switch (_pengaturanUmum.jenis_printer)
                        {
                        case JenisPrinter.DotMatrix:
                            CetakNotaDotMatrix(_jual);
                            break;

                        case JenisPrinter.MiniPOS:
                            CetakNotaMiniPOS(_jual);
                            break;

                        default:
                            // do nothing
                            break;
                        }
                    }
                }

                var kembalian = Math.Abs(jual.jumlah_bayar - jual.grand_total);
                lblKembalian.Text = string.Format("Kembalian: {0}", NumberHelper.NumberToString(kembalian));

                ResetTransaksi(false);
            }
            else // filter bardasarkan nama form
            {
                var frmName = sender.GetType().Name;

                switch (frmName)
                {
                case "FrmHapusItemTransaksi":
                    var noTransaksi = (int)((dynamic)data).noTransaksi;

                    var itemJual = _listOfItemJual[noTransaksi - 1];
                    itemJual.entity_state = EntityState.Deleted;

                    _listOfItemJual.Remove(itemJual);

                    gridControl.RowCount = _listOfItemJual.Count();
                    gridControl.Refresh();

                    RefreshTotal();

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

                default:
                    break;
                }
            }
        }
Пример #16
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;
                }
            }
        }