Exemplo n.º 1
0
        private void InitGridList()
        {
            var gridListProperties = new List <GridListControlProperties>();

            gridListProperties.Add(new GridListControlProperties {
                Header = "No", Width = 30
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Tanggal", Width = 100
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Tempo", Width = 100
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Nota", Width = 100
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Customer", Width = 230
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Keterangan", Width = 350
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Piutang", Width = 130
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Sisa Piutang", Width = 130
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Cetak Nota/Label", Width = 80
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = ""
            });

            GridListControlHelper.InitializeGridListControl <JualProduk>(this.gridList, _listOfJual, gridListProperties);

            // merge header kolom cetak nota/label
            this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, 9, 0, 10));

            if (_listOfJual.Count > 0)
            {
                this.gridList.SetSelected(0, true);
            }

            this.gridList.Grid.PushButtonClick += delegate(object sender, GridCellPushButtonClickEventArgs e)
            {
                if (e.RowIndex > 0)
                {
                    var index = e.RowIndex - 1;

                    switch (e.ColIndex)
                    {
                    case 9:     // cetak nota jual
                        using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0)))
                        {
                            var jual = _listOfJual[index];

                            if (this._pengaturanUmum.is_printer_mini_pos)
                            {
                                if (MsgHelper.MsgKonfirmasi("Apakah proses pencetakan ingin dilanjutkan ?"))
                                {
                                    CetakNotaMiniPOS(jual);
                                }
                            }
                            else
                            {
                                var frmCetakNota = new FrmPreviewNotaPenjualan("Preview Nota Penjualan", jual);
                                frmCetakNota.ShowDialog();
                            }
                        }

                        break;

                    case 10:     // cetak label nota jual
                        using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0)))
                        {
                            var jual = _listOfJual[index];

                            var frmCetakLabelNota = new FrmPreviewLabelNotaPenjualan("Preview Label Nota Penjualan", jual);
                            frmCetakLabelNota.ShowDialog();
                        }

                        break;

                    default:
                        break;
                    }
                }
            };

            this.gridList.Grid.QueryCellInfo += delegate(object sender, GridQueryCellInfoEventArgs e)
            {
                if (_listOfJual.Count > 0)
                {
                    if (e.RowIndex > 0)
                    {
                        var rowIndex = e.RowIndex - 1;

                        if (rowIndex < _listOfJual.Count)
                        {
                            double totalNota = 0;

                            var jual = _listOfJual[rowIndex];
                            if (jual != null)
                            {
                                totalNota = jual.grand_total;
                            }


                            var isRetur           = jual.retur_jual_id != null;
                            var oldStyleBackColor = e.Style.BackColor;

                            if (isRetur)
                            {
                                e.Style.BackColor = Color.Red;
                            }

                            switch (e.ColIndex)
                            {
                            case 2:
                                e.Style.HorizontalAlignment = GridHorizontalAlignment.Center;
                                e.Style.CellValue           = DateTimeHelper.DateToString(jual.tanggal);
                                break;

                            case 3:
                                e.Style.HorizontalAlignment = GridHorizontalAlignment.Center;
                                e.Style.CellValue           = DateTimeHelper.DateToString(jual.tanggal_tempo);
                                break;

                            case 4:
                                e.Style.CellValue = jual.nota;
                                break;

                            case 5:
                                if (jual.Customer != null)
                                {
                                    e.Style.CellValue = jual.Customer.nama_customer;
                                }

                                break;

                            case 6:
                                e.Style.CellValue = jual.keterangan;
                                break;

                            case 7:
                                e.Style.HorizontalAlignment = GridHorizontalAlignment.Right;
                                e.Style.CellValue           = NumberHelper.NumberToString(totalNota);
                                break;

                            case 8:
                                e.Style.HorizontalAlignment = GridHorizontalAlignment.Right;
                                e.Style.CellValue           = NumberHelper.NumberToString(totalNota - jual.total_pelunasan);
                                break;

                            case 9:     // button hapus
                                e.Style.HorizontalAlignment = GridHorizontalAlignment.Center;
                                e.Style.CellType            = GridCellTypeName.PushButton;
                                e.Style.BackColor           = oldStyleBackColor;
                                e.Style.Description         = "Cetak Nota";
                                break;

                            case 10:     // button hapus
                                e.Style.HorizontalAlignment = GridHorizontalAlignment.Center;
                                e.Style.CellType            = GridCellTypeName.PushButton;
                                e.Style.BackColor           = oldStyleBackColor;
                                e.Style.Description         = "Cetak Label Nota";
                                break;

                            default:
                                break;
                            }

                            // we handled it, let the grid know
                            e.Handled = true;
                        }
                    }
                }
            };
        }
        private void InitGridList()
        {
            var gridListProperties = new List <GridListControlProperties>();

            gridListProperties.Add(new GridListControlProperties {
                Header = "No", Width = 30
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Tanggal", Width = 100
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Tempo", Width = 100
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Nota", Width = 100
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Customer", Width = _pengaturanUmum.jenis_printer == JenisPrinter.InkJet ? 180 : 260
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Keterangan", Width = 350
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Piutang", Width = 100
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Sisa Piutang", Width = 100
            });
            gridListProperties.Add(new GridListControlProperties {
                Header = "Histori Pembayaran", Width = 80
            });

            if (_pengaturanUmum.jenis_printer == JenisPrinter.InkJet)
            {
                gridListProperties.Add(new GridListControlProperties {
                    Header = "Cetak Nota/Label", Width = 80
                });
                gridListProperties.Add(new GridListControlProperties {
                    Header = ""
                });
            }
            else
            {
                gridListProperties.Add(new GridListControlProperties {
                    Header = "Cetak Nota", Width = 80
                });
            }

            GridListControlHelper.InitializeGridListControl <JualProduk>(this.gridList, _listOfJual, gridListProperties, false, rowHeight: 40);

            if (_pengaturanUmum.jenis_printer == JenisPrinter.InkJet)
            {
                // merge header kolom cetak nota/label
                this.gridList.Grid.CoveredRanges.Add(GridRangeInfo.Cells(0, 10, 0, 11));
            }

            if (_listOfJual.Count > 0)
            {
                this.gridList.SetSelected(0, true);
            }

            this.gridList.Grid.PushButtonClick += delegate(object sender, GridCellPushButtonClickEventArgs e)
            {
                if (e.RowIndex > 0)
                {
                    var index = e.RowIndex - 1;

                    switch (e.ColIndex)
                    {
                    case 9:     // histori pembayaran
                        using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0)))
                        {
                            var jual = _listOfJual[index];

                            IPembayaranPiutangProdukBll bll = new PembayaranPiutangProdukBll(_log);
                            var listOfHistoriPembayaran     = bll.GetHistoriPembayaran(jual.jual_id);

                            if (listOfHistoriPembayaran.Count > 0)
                            {
                                var frmHistoriPembayaran = new FrmLookupHistoriPembayaran("Histori Pembayaran Piutang", jual, listOfHistoriPembayaran);
                                frmHistoriPembayaran.ShowDialog();
                            }
                            else
                            {
                                MsgHelper.MsgInfo("Belum ada informasi histori pembayaran");
                            }
                        }

                        break;

                    case 10:     // cetak nota jual
                        using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0)))
                        {
                            var jual = _listOfJual[index];

                            switch (this._pengaturanUmum.jenis_printer)
                            {
                            case JenisPrinter.DotMatrix:
                                if (MsgHelper.MsgKonfirmasi("Apakah proses pencetakan ingin dilanjutkan ?"))
                                {
                                    CetakNotaDotMatrix(jual);
                                }
                                break;

                            case JenisPrinter.MiniPOS:
                                if (MsgHelper.MsgKonfirmasi("Apakah proses pencetakan ingin dilanjutkan ?"))
                                {
                                    CetakNotaMiniPOS(jual);
                                }
                                break;

                            default:
                                var frmCetakNota = new FrmPreviewNotaPenjualan("Preview Nota Penjualan", jual);
                                frmCetakNota.ShowDialog();
                                break;
                            }
                        }

                        break;

                    case 11:     // cetak label nota jual
                        using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0)))
                        {
                            var jual = _listOfJual[index];

                            var frmCetakLabelNota = new FrmPreviewLabelNotaPenjualan("Preview Label Nota Penjualan", jual);
                            frmCetakLabelNota.ShowDialog();
                        }

                        break;

                    default:
                        break;
                    }
                }
            };

            this.gridList.Grid.QueryCellInfo += delegate(object sender, GridQueryCellInfoEventArgs e)
            {
                if (_listOfJual.Count > 0)
                {
                    if (e.RowIndex > 0)
                    {
                        var rowIndex = e.RowIndex - 1;

                        if (rowIndex < _listOfJual.Count)
                        {
                            double totalNota = 0;

                            var jual = _listOfJual[rowIndex];
                            if (jual != null)
                            {
                                totalNota = jual.grand_total;
                            }


                            var isRetur           = jual.retur_jual_id != null;
                            var oldStyleBackColor = e.Style.BackColor;

                            if (isRetur)
                            {
                                e.Style.BackColor = Color.Red;
                            }

                            switch (e.ColIndex)
                            {
                            case 1:
                                var noUrut = (_pageNumber - 1) * _pageSize + e.RowIndex;
                                e.Style.CellValue           = noUrut;
                                e.Style.HorizontalAlignment = GridHorizontalAlignment.Center;
                                break;

                            case 2:
                                e.Style.HorizontalAlignment = GridHorizontalAlignment.Center;
                                e.Style.CellValue           = DateTimeHelper.DateToString(jual.tanggal);
                                break;

                            case 3:
                                e.Style.HorizontalAlignment = GridHorizontalAlignment.Center;
                                e.Style.CellValue           = DateTimeHelper.DateToString(jual.tanggal_tempo);
                                break;

                            case 4:
                                e.Style.CellValue = jual.nota;
                                break;

                            case 5:
                                if (jual.Customer != null)
                                {
                                    SetWilayahCustomer(jual.Customer);
                                    e.Style.CellValue = jual.Customer.nama_customer;
                                }

                                break;

                            case 6:
                                e.Style.CellValue = jual.keterangan;
                                break;

                            case 7:
                                e.Style.HorizontalAlignment = GridHorizontalAlignment.Right;
                                e.Style.CellValue           = NumberHelper.NumberToString(totalNota);
                                break;

                            case 8:
                                e.Style.HorizontalAlignment = GridHorizontalAlignment.Right;
                                e.Style.CellValue           = NumberHelper.NumberToString(totalNota - jual.total_pelunasan);
                                break;

                            case 9:     // button history pembayaran
                                e.Style.Enabled             = jual.tanggal_tempo != null;
                                e.Style.HorizontalAlignment = GridHorizontalAlignment.Center;
                                e.Style.CellType            = GridCellTypeName.PushButton;
                                e.Style.BackColor           = oldStyleBackColor;
                                e.Style.Description         = "Cek Histori";

                                break;

                            case 10:     // button cetak nota
                                e.Style.Enabled             = jual.Customer != null;
                                e.Style.HorizontalAlignment = GridHorizontalAlignment.Center;
                                e.Style.CellType            = GridCellTypeName.PushButton;
                                e.Style.BackColor           = oldStyleBackColor;
                                e.Style.Description         = "Cetak Nota";
                                break;

                            case 11:     // button cetak label nota
                                if (_pengaturanUmum.jenis_printer == JenisPrinter.InkJet)
                                {
                                    e.Style.Enabled             = jual.Customer != null;
                                    e.Style.HorizontalAlignment = GridHorizontalAlignment.Center;
                                    e.Style.CellType            = GridCellTypeName.PushButton;
                                    e.Style.BackColor           = oldStyleBackColor;
                                    e.Style.Description         = "Cetak Label Nota";
                                }

                                break;

                            default:
                                break;
                            }

                            // we handled it, let the grid know
                            e.Handled = true;
                        }
                    }
                }
            };
        }