Ejemplo n.º 1
0
        private void ShowEntryProduk()
        {
            var isGrant = RolePrivilegeHelper.IsHaveHakAkses("mnuProduk", _pengguna);

            if (!isGrant)
            {
                MsgHelper.MsgWarning("Maaf Anda tidak mempunyai otoritas untuk mengakses menu ini");
                return;
            }

            IGolonganBll golonganBll    = new GolonganBll(_log);
            var          listOfGolongan = golonganBll.GetAll();

            Golongan golongan = null;

            if (listOfGolongan.Count > 0)
            {
                golongan = listOfGolongan[0];
            }

            IProdukBll produkBll      = new ProdukBll(_log);
            var        frmEntryProduk = new FrmEntryProduk("Tambah Data Produk", golongan, listOfGolongan, produkBll);

            frmEntryProduk.Listener = this;
            frmEntryProduk.ShowDialog();
        }
        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();
                }
            }
        }
Ejemplo n.º 3
0
        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);
                }
            }
        }
Ejemplo n.º 4
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;
                }
            }
        }
Ejemplo n.º 5
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;
                }
            }
        }
Ejemplo n.º 6
0
        private void LoadInfoMinimalStokProduk()
        {
            IProdukBll bll = new ProdukBll(_log);

            MainProgram.listOfMinimalStokProduk = bll.GetInfoMinimalStok();
        }
Ejemplo n.º 7
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;
                }
            }
        }