Пример #1
0
        private void btnTesKoneksi_Click(object sender, EventArgs e)
        {
            const int MAX_LENGTH = 20;

            var appName = "OpenRetail Server";
            var version = string.Format("v{0}", MainProgram.currentVersion);

            var displayLine1 = string.Format("{0}{1}", StringHelper.CenterAlignment(appName.Length, MAX_LENGTH), appName);
            var displayLine2 = string.Format("{0}{1}", StringHelper.CenterAlignment(version.Length, MAX_LENGTH), version);

            System.Diagnostics.Debug.Print("displayLine1: {0}", displayLine1);
            System.Diagnostics.Debug.Print("displayLine2: {0}", displayLine2);

            if (!Utils.IsRunningUnderIDE())
            {
                GodSerialPort serialPort = null;

                if (!GodSerialPortHelper.IsConnected(serialPort, _settingPort))
                {
                    MsgHelper.MsgWarning("Koneksi ke customer display, silahkan coba port yang lain.");
                    return;
                }

                GodSerialPortHelper.SendStringToCustomerDisplay(displayLine1, displayLine2, serialPort);
            }
        }
        private const int MAX_LENGTH = 20; // maksimal karakter customer display

        private void DisplayItemProduct(ItemJualProduk itemJual)
        {
            var produk = itemJual.Produk;

            var jumlah    = itemJual.jumlah - itemJual.jumlah_retur;
            var hargaJual = itemJual.harga_setelah_diskon;

            if (produk != null)
            {
                if (!(hargaJual > 0))
                {
                    double diskon       = itemJual.diskon;
                    double diskonRupiah = 0;

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

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

                    hargaJual = GetHargaJualFix(produk, jumlah, produk.harga_jual);

                    diskonRupiah = diskon / 100 * hargaJual;
                    hargaJual   -= diskonRupiah;
                }
            }

            var subTotal = StringHelper.RightAlignment(Convert.ToString(jumlah * hargaJual), MAX_LENGTH - (jumlah.ToString().Length + hargaJual.ToString().Length + 1));

            var displayLine1 = StringHelper.FixedLength(produk.nama_produk, MAX_LENGTH);
            var displayLine2 = string.Format("{0}x{1}{2}", jumlah, hargaJual, subTotal);

            System.Diagnostics.Debug.Print("displayLine1: {0}", displayLine1);
            System.Diagnostics.Debug.Print("displayLine2: {0}", displayLine2);

            if (!Utils.IsRunningUnderIDE() && _settingCustomerDisplay.is_active_customer_display)
            {
                GodSerialPort serialPort = null;

                if (!GodSerialPortHelper.IsConnected(serialPort, _settingPort))
                {
                    return;
                }

                GodSerialPortHelper.SendStringToCustomerDisplay(displayLine1, displayLine2, serialPort);
            }
        }
        private void DisplayKembalian(string kembalian)
        {
            var displayLine1 = "Kembalian";
            var displayLine2 = StringHelper.RightAlignment(kembalian, MAX_LENGTH);

            System.Diagnostics.Debug.Print("displayLine1: {0}", displayLine1);
            System.Diagnostics.Debug.Print("displayLine2: {0}", displayLine2);

            if (!Utils.IsRunningUnderIDE() && _settingCustomerDisplay.is_active_customer_display)
            {
                GodSerialPort serialPort = null;

                if (!GodSerialPortHelper.IsConnected(serialPort, _settingPort))
                {
                    return;
                }

                GodSerialPortHelper.SendStringToCustomerDisplay(displayLine1, displayLine2, serialPort);
            }
        }
        private void DisplayKalimatPembuka()
        {
            var displayLine1 = string.Format("{0}{1}", StringHelper.CenterAlignment(_settingCustomerDisplay.opening_sentence_line1.Length, MAX_LENGTH),
                                             _settingCustomerDisplay.opening_sentence_line1);

            var displayLine2 = string.Format("{0}{1}", StringHelper.CenterAlignment(_settingCustomerDisplay.opening_sentence_line2.Length, MAX_LENGTH),
                                             _settingCustomerDisplay.opening_sentence_line2);

            System.Diagnostics.Debug.Print("displayLine1: {0}", displayLine1);
            System.Diagnostics.Debug.Print("displayLine2: {0}", displayLine2);

            if (!Utils.IsRunningUnderIDE() && _settingCustomerDisplay.is_active_customer_display)
            {
                GodSerialPort serialPort = null;

                if (!GodSerialPortHelper.IsConnected(serialPort, _settingPort))
                {
                    return;
                }

                GodSerialPortHelper.SendStringToCustomerDisplay(displayLine1, displayLine2, serialPort);
            }
        }