Example #1
1
 public Printer(string deviceName = "PosPrinter")
 {
     var posExplorer = new PosExplorer();
     var deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, deviceName);
     m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
     m_Printer.Open();
     m_Printer.Claim(500);
     m_Printer.DeviceEnabled = true;
     m_Printer.RecLetterQuality = true;
     m_Printer.MapMode = MapMode.Metric;
     m_Printer.ClearOutput();
 }
Example #2
0
        private static PosPrinter InitializePosPrinter(string configSettingName)
        {
            PosPrinter       result      = null;
            DeviceCollection printerList = PosPrinterDeviceCollection;

            if (printerList.Count > 0)
            {
                try
                {
#if DEBUG
                    //DeviceInfo printer = GetActiveDeviceInfo(printerList, configSettingName, true);
                    DeviceInfo printer = printerList[0];
#else
                    DeviceInfo printer = GetActiveDeviceInfo(printerList, configSettingName);
#endif
                    if (printer != null)
                    {
                        result = (PosPrinter)explorer.CreateInstance(printer);
                        result.Open();
                        result.Claim(1000);
                        result.DeviceEnabled = true;
                    }
                }
                catch (PosControlException)
                {
                    // Log error and set the active to nil
                    Logger.Error("InitializePosDevices", Strings.InitializationException);
                }
            }
            return(result);
        }
        private void SetUpPrinter()
        {
            string strLogicalName = "PosPrinter";

            try
            {
                PosExplorer posExplorer = new PosExplorer();

                DeviceInfo deviceInfo = null;
                myDevices = posExplorer.GetDevices(DeviceType.PosPrinter);
                try
                {
                    deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
                    m_Printer  = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
                }
                catch (Exception)
                {
                }

                m_Printer.Open();
            }
            catch (PosControlException)
            {
                Console.WriteLine("Failed to load printer: " + strLogicalName);
            }
        }
Example #4
0
        private void GunlukRapor_Click(object sender, EventArgs e)
        {
            string zaman = DateTime.Now.ToShortDateString();

            DialogResult Uyari = new DialogResult();

            Uyari = MessageBox.Show("TÜM GİDERLERİN RAPORU BASILACAK BU RAPOR UZUNLUĞU GİDERLERİNİZİN UZUNLUĞU KADAR OLACAKTIR. ESKİ GİDERLERİNİZİ SİLERSENİZ RAPOR DAHA KISA OLABİLİR. DEVAM EDİLSİN Mİ?", "UYARI!", MessageBoxButtons.YesNo);
            if (Uyari == DialogResult.Yes)
            {
                try
                {
                    var explorer   = new PosExplorer();
                    var deviceInfo = explorer.GetDevice(DeviceType.PosPrinter);
                    if (deviceInfo == null)
                    {
                        MessageBox.Show("BİLGİSAYARA BAĞLI YAZICI YOK YADA BAĞLANTI KURULAMADI", "ÇEKİRDEK KOD TERS MÜHENDİSLİK KORUMASI!");
                        return;
                    }
                    Yazici = (PosPrinter)explorer.CreateInstance(deviceInfo);
                    Yazici.Open();
                    Yazici.Claim(500);
                    Yazici.DeviceEnabled      = true;
                    Yazici.StatusUpdateEvent += (s, evt) =>
                    {
                        if (evt.Status == PosPrinter.StatusCoverOpen)
                        {
                            MessageBox.Show("Yazıcının kağıt kapağı açıldı");
                        }
                        if (evt.Status == PosPrinter.StatusCoverOK)
                        {
                            MessageBox.Show("Yazıcının kağıt kapağı kapandı");
                        }
                        if (evt.Status == PosPrinter.StatusJournalCartridgeEmpty)
                        {
                            MessageBox.Show("Yazıcının kartuşu bitmek üzere");
                        }
                    };
                    Yazici.PrintNormal(PrinterStation.Slip, "                          PRESTIGE CAFE                       " + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "GÜnlük Gider Raporu" + "  TARİH: " + DateTime.Now.ToShortDateString() + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
                    VeriEntities3 context = new VeriEntities3();
                    foreach (var bul in context.Giderler.Where(p => p.Tarih == zaman))
                    {
                        Yazici.PrintNormal(PrinterStation.Slip, "Gider adı: " + bul.GiderAdi + " Gider Tutarı: " + bul.GiderTutari + " Tarih: " + bul.Tarih + Environment.NewLine);
                    }
                    Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "MARKETMATİK BETA V.1.0.2 [email protected]" + Environment.NewLine);
                    Yazici.CutPaper(100);
                    MessageBox.Show("Gider Yazdırıldı.", "Kullanıcı İşlemleri");
                    this.Close();
                    formdd1.Visible = true;
                }
                catch
                {
                    MessageBox.Show("DÖNGÜSEL VERİTABANI HATASI. DATA BULUNAMADI YADA VERİTABANI BAĞLANTISI KESİLDİ.", "ÇEKİRDEK KOD ÖLÜMCÜL HATA!");
                    MessageBox.Show("LÜTFEN GELİŞTİRİCİ İLE İRTİBAT KURUN. PROGRAM SONLANICAK", "ÇEKİRDEK KOD TERS MÜHENDİSLİK KORUMASI");
                    Application.Exit();
                }
            }
        }
Example #5
0
        public cImpresora(string nombreLogico)
        {
            try
            {
                _nombreLogico = nombreLogico;
                PosExplorer posExplorer = new PosExplorer();
                DeviceInfo  deviceInfo  = null;
                deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, _nombreLogico);
                _oPrinter  = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
                _oPrinter.Open();
                _oPrinter.Claim(1000);
                _oPrinter.DeviceEnabled = true;
                //Output by the high quality mode
                _oPrinter.RecLetterQuality = true;

                // Even if using any printers, 0.01mm unit makes it possible to print neatly.
                _oPrinter.MapMode = MapMode.Metric;
            }
            catch (PosControlException ex)
            {
                throw new Exception("Error al abrir la impresora fiscal. " + ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Error al abrir la impresora fiscal. " + ex.Message);
            }
        }
        private void ActivatePrinter(DeviceInfo selectedPrinter)
        {
            //Verifify that the selectedScanner is not null
            // and that it is not the same scanner already selected
            if (selectedPrinter != null && !selectedPrinter.IsDeviceInfoOf(activePrinter))
            {
                // Configure the new scanner
                DeactivatePrinter();

                // Activate the new scanner
                try
                {
                    activePrinter = (PosPrinter)_posexplorer.CreateInstance(selectedPrinter);
                    activePrinter.Open();
                    activePrinter.Claim(1000);
                    activePrinter.DeviceEnabled = true;

                    Helper.ShowMessage("Test successful",
                                       "Test Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (PosControlException ex)
                {
                    _logger.LogError(ex, "The application received an error", "frmHardwaresetup", "ActivatePrinter");
                    Helper.ShowMessage("The application received an error  \n" + ex.Message,
                                       "Test Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    activePrinter = null;
                }
            }
        }
Example #7
0
 /// <summary>
 /// Inicializa la intancia de la impresora
 /// </summary>
 private void InitPrinter()
 {
     if (_printer.State == ControlState.Closed)
     {
         try {
             _printer.Open();
         }catch (SystemException e)
         {
             throw new NullReferenceException(
                       "Impresora no conectada o no encontrada");
         }
     }
     if (!_printer.Claimed)
     {
         _printer.Claim(0);
     }
     if (!_printer.DeviceEnabled)
     {
         _printer.DeviceEnabled = true;
     }
     if (!_printer.RecLetterQuality)
     {
         //Si es true imprime en modo de alta resolucion, en false imprime en alta velocidad
         _printer.RecLetterQuality = true;
     }
 }
        private void cariodetamaminiode_Click(object sender, EventArgs e)
        {
            Musteriler musteriler     = new Musteriler();
            var        MusteriCariOde = db.Musteriler.Where(w => w.MusteriAdi == cariodemusteriadi.Text).FirstOrDefault();

            try
            {
                String Odeme = MusteriCariOde.MusteriBakiyesi;
                MusteriCariOde.MusteriBakiyesi = "0";
                db.SaveChanges();
                var explorer   = new PosExplorer();
                var deviceInfo = explorer.GetDevice(DeviceType.PosPrinter);
                if (deviceInfo == null)
                {
                    MessageBox.Show("BİLGİSAYARA BAĞLI YAZICI YOK YADA BAĞLANTI KURULAMADI", "ÇEKİRDEK KOD TERS MÜHENDİSLİK KORUMASI!");
                    return;
                }
                Yazici = (PosPrinter)explorer.CreateInstance(deviceInfo);
                Yazici.Open();
                Yazici.Claim(500);
                Yazici.DeviceEnabled      = true;
                Yazici.StatusUpdateEvent += (s, evt) =>
                {
                    if (evt.Status == PosPrinter.StatusCoverOpen)
                    {
                        MessageBox.Show("Yazıcının kağıt kapağı açıldı");
                    }
                    if (evt.Status == PosPrinter.StatusCoverOK)
                    {
                        MessageBox.Show("Yazıcının kağıt kapağı kapandı");
                    }
                    if (evt.Status == PosPrinter.StatusJournalCartridgeEmpty)
                    {
                        MessageBox.Show("Yazıcının kartuşu bitmek üzere");
                    }
                };
                Yazici.PrintNormal(PrinterStation.Slip, "                          PRESTIGE CAFE                       " + Environment.NewLine);
                Yazici.PrintNormal(PrinterStation.Slip, "CARİ ÖDEME BİLGİ FİŞİ" + "  TARİH: " + DateTime.Now.ToShortDateString() + Environment.NewLine);
                Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
                Yazici.PrintNormal(PrinterStation.Slip, "MÜŞTERİ ADI   : " + MusteriCariOde.MusteriAdi + Environment.NewLine);
                Yazici.PrintNormal(PrinterStation.Slip, "--------------------------------------------------------------" + Environment.NewLine);
                Yazici.PrintNormal(PrinterStation.Slip, "MÜŞTERİ CARİSİ: " + Odeme + Environment.NewLine);
                Yazici.PrintNormal(PrinterStation.Slip, "--------------------------------------------------------------" + Environment.NewLine);
                Yazici.PrintNormal(PrinterStation.Slip, "ÖDENEN MİKTAR : " + Odeme + Environment.NewLine);
                Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
                Yazici.PrintNormal(PrinterStation.Slip, "                        TEŞEKKÜR EDERİZ                       " + Environment.NewLine);
                Yazici.PrintNormal(PrinterStation.Slip, "MARKETMATİK BETA V.1.0.2 [email protected]" + Environment.NewLine);
                Yazici.CutPaper(100);
                musteriyonetimformu = new MusteriYonetimFormu();
                musteriyonetimformu.Show();
                this.Close();
            }
            catch
            {
                MessageBox.Show("DÖNGÜSEL VERİTABANI HATASI. DATA BULUNAMADI YADA VERİTABANI BAĞLANTISI KESİLDİ.", "ÇEKİRDEK KOD ÖLÜMCÜL HATA!");
                MessageBox.Show("LÜTFEN GELİŞTİRİCİ İLE İRTİBAT KURUN. PROGRAM SONLANICAK", "ÇEKİRDEK KOD TERS MÜHENDİSLİK KORUMASI");
                Application.Exit();
            }
        }
Example #9
0
        public void printReceipt(Invoice invoice, bool openDrawer = false)
        {
            // return;
            setupPrinter();
            try
            {
                m_Printer.Open();

                //Get the exclusive control right for the opened device.
                //Then the device is disable from other application.
                m_Printer.Claim(1000);


                //Enable the device.
                bool result = m_Printer.DeviceEnabled = true;

                // this call also causes the "It is not initialized" error
                //string health = m_Printer.CheckHealth(HealthCheckLevel.External);
            }
            catch (PosControlException)
            {
                //  ChangeButtonStatus();
            }
            string receiptString = Receipt40Col.GetStandardReceipt(invoice);
            string barcodeString = invoice.Id ?? "";

            while (barcodeString.Length < 8)
            {
                barcodeString = " " + barcodeString;
            }
            // int test = m_Printer.JrnLineChars


            //var file = Path.GetFullPath("Resources/logo.bmp");
            // m_Printer.PrintNormal(PrinterStation.Receipt,((char)27).ToString() + "|cA" + receiptString);
            //m_Printer.PrintBitmap(PrinterStation.Receipt, file, 300, PosPrinter.PrinterBitmapCenter);

            var headerImage = Receipt40Col.GetInvoiceHeaderBitmap();

            if (headerImage != null)
            {
                m_Printer.PrintBitmap(PrinterStation.Receipt, headerImage, 400, PosPrinter.PrinterBitmapCenter);
            }
            //m_Printer.PrintMemoryBitmap(new BitmapData());
            m_Printer.PrintNormal(PrinterStation.Receipt, receiptString);

            var footerImage = Receipt40Col.GetInvoiceFooterBitmap();

            if (footerImage != null)
            {
                m_Printer.PrintBitmap(PrinterStation.Receipt, footerImage, 400, PosPrinter.PrinterBitmapCenter);
            }
            m_Printer.PrintNormal(PrinterStation.Receipt, Receipt40Col.extraLines(8));
            if (openDrawer)
            {
                m_Printer.PrintNormal(PrinterStation.Receipt, ((char)27).ToString() + "|\x07");
            }
        }
    public static void createPos()
    {
        explorer = new PosExplorer();
        DeviceInfo receiptPrinterDevice = explorer.GetDevice("PosPrinter", Properties.Settings.Default.KitchenPrinter);   //May need to change this if you don't use a logicial name or use a different one.

        kitchenPrinter = (PosPrinter)explorer.CreateInstance(receiptPrinterDevice);
        kitchenPrinter.Open();
        kitchenPrinter.Claim(10000);
        kitchenPrinter.DeviceEnabled = true;
    }
Example #11
0
 public IReceiptPrinter GetReceiptPrinter()
 {
     if (_printer == null)
     {
         DeviceInfo printerDeviceInfo = _exp.GetDevice("PosPrinter");
         PosPrinter printer           = (PosPrinter)_exp.CreateInstance(printerDeviceInfo);
         _printer = new ReceiptPrinterWrapper(printer);
         printer.Open();
     }
     return(_printer);
 }
 private void ConnectToPrinter(PosPrinter printer)
 {
     try
     {
         printer.Open();
         printer.Claim(10000);
         printer.DeviceEnabled = true;
     }
     catch
     {
     }
 }
Example #13
0
        public Printer(string deviceName = "PosPrinter")
        {
            var posExplorer = new PosExplorer();
            var deviceInfo  = posExplorer.GetDevice(DeviceType.PosPrinter, deviceName);

            m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
            m_Printer.Open();
            m_Printer.Claim(500);
            m_Printer.DeviceEnabled    = true;
            m_Printer.RecLetterQuality = true;
            m_Printer.MapMode          = MapMode.Metric;
            m_Printer.ClearOutput();
        }
Example #14
0
 private void OpenClaimEnablePosPrinter()
 {
     try {
         PosPrinter.Open();
         PosPrinter.Claim(0);
         PosPrinter.DeviceEnabled = true;
     } catch (PosControlException e) {
         Debug.WriteLine("OpenClaimEnablePosPrinter(): {0}", e);
         if (e.ErrorCode == ErrorCode.Extended)
         {
             Debug.WriteLine("Extended: ", e.ErrorCodeExtended);
         }
     }
 }
Example #15
0
 private void open_claim_enable_printer(PosPrinter p)
 {
     try {
         p.Open();
         p.Claim(0);
         p.DeviceEnabled = true;
     } catch (PosControlException e) {
         Debug.WriteLine("Point of sale control exception: {0}", e);
         if (e.ErrorCode == ErrorCode.Extended)
         {
             Debug.WriteLine("Extended: ", e.ErrorCodeExtended);
         }
     }
 }
Example #16
0
 private void OpenPrinter()
 {
     try
     {
         SetStatusMessage("Drivers detected...Attempting to open device...");
         //Open the device
         m_Printer.Open();
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "Application received an error while trying to initialize device...",
                          "frmStartUp", "OpenPrinter");
         SetStatusMessage("Application received an error while trying open device.");
     }
 }
        private void InitPrinter()
        {
            string strLogicalName = "PosPrinter";

            try
            {
                //Create PosExplorer
                PosExplorer posExplorer = new PosExplorer();

                DeviceInfo deviceInfo = null;

                try
                {
                    deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
                    m_Printer  = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
                }
                catch (Exception)
                {
                    PrinterReady = false;
                    return;
                }

                //Open the device
                m_Printer.Open();

                //Get the exclusive control right for the opened device.
                //Then the device is disable from other application.
                m_Printer.Claim(1000);

                //Enable the device.
                m_Printer.DeviceEnabled = true;

                m_Printer.RecLetterQuality = false;

                m_Printer.MapMode = MapMode.Metric;

                PrinterReady = true;
            }
            catch (PosControlException)
            {
                PrinterReady = false;
            }
        }
Example #18
0
        private void ClaimPrinter()
        {
            //Open the device
            m_Printer.Open();

            //Get the exclusive control right for the opened device.
            //Then the device is disable from other application.
            if (!m_Printer.Claimed)
            {
                m_Printer.Claim(1000);
            }

            //Enable the device.
            m_Printer.DeviceEnabled = true;

            //<<<step3>>>--Start
            //Output by the high quality mode
            m_Printer.RecLetterQuality = true;
            m_Printer.MapMode          = MapMode.Metric;
        }
Example #19
0
        /// <summary>
        /// The processing code required in order to enable to use of service is written here.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmStep1_Load(object sender, System.EventArgs e)
        {
            //<<<step1>>>--Start
            //Use a Logical Device Name which has been set on the SetupPOS.
            string strLogicalName = "PosPrinter";

            try
            {
                //Create PosExplorer
                PosExplorer posExplorer = new PosExplorer();

                DeviceInfo deviceInfo = null;

                try
                {
                    deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
                    m_Printer  = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
                }
                catch (Exception)
                {
                    ChangeButtonStatus();
                    return;
                }

                //Open the device
                m_Printer.Open();

                //Get the exclusive control right for the opened device.
                //Then the device is disable from other application.
                m_Printer.Claim(1000);

                //Enable the device.
                m_Printer.DeviceEnabled = true;
            }
            catch (PosControlException)
            {
                ChangeButtonStatus();
            }
            //<<<step1>>>--End
        }
Example #20
0
        public bool init(bool asasynchronous)   //初始化
        {
            async = asasynchronous;
            string strLogicalName = "PosPrinter";

            try
            {
                PosExplorer posExplorer = new PosExplorer();

                DeviceInfo deviceInfo = null;

                try
                {
                    deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
                    m_Printer  = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
                }
                catch (Exception)
                {
                    //return false;
                }

                m_Printer.Open();

                m_Printer.Claim(1000);

                m_Printer.DeviceEnabled = true;

                m_Printer.RecLetterQuality = true;

                m_Printer.MapMode = MapMode.Metric;
            }
            catch (Exception ex)
            {
                System.IO.File.AppendAllText(@"C:\hot.txt", DateTime.Now.ToString() + ": " + ex.ToString() + "\r\n");
                return(false);
            }

            return(true);
        }
Example #21
0
        public void print(String PrintString)
        {

            try
            {
                string myString;

                _printer.Open();
                _printer.Claim(1000);
                _printer.AsyncMode = false; //Must be False!!!!!!!!
                _printer.DeviceEnabled = true;

                myString = PrintString.Replace("ESC", Convert.ToChar(27).ToString()) + Convert.ToChar(13).ToString() + Convert.ToChar(10).ToString();

                _printer.PrintNormal(PrinterStation.Receipt, myString);

                //_printer.PrintNormal(PrinterStation.Receipt, Convert.ToChar(13).ToString() + Convert.ToChar(10).ToString());

                //_printer.PrintNormal(PrinterStation.Receipt, Convert.ToChar(13).ToString() + Convert.ToChar(10).ToString());

                //_printer.PrintNormal(PrinterStation.Receipt, Convert.ToChar(13).ToString() + Convert.ToChar(10).ToString());

                //_printer.PrintNormal(PrinterStation.Receipt, Convert.ToChar(13).ToString() + Convert.ToChar(10).ToString());

                _printer.CutPaper(90);

                _printer.DeviceEnabled = false;
                _printer.Release();
                _printer.Close();

            }
            catch (Exception ex)
            {
               // MessageBox.Show(ex.Message);
            }

        }
Example #22
0
        private void Panel_productos_Faltantes_Bodega_Load(object sender, EventArgs e)
        {
            this.dataGrid1.CurrentCell = (DataGridViewCell)null;
            this.dataGrid1.DataSource  = (object)this.depot.MissingProducts().DefaultView;
            // setCheckAllBtn();

            try
            {
                //Create PosExplorer
                PosExplorer posExplorer = new PosExplorer();

                try
                {
                    posPrinter = posExplorer.CreateInstance(posExplorer.GetDevice(DeviceType.PosPrinter, "PosPrinter")) as PosPrinter;
                    posPrinter.Open();
                }
                catch (Exception) { }
            }
            catch (PosControlException)
            {
                //Nothing can be used.
                MessageBox.Show("No se tuvo acceso a la impresora o al cajon");
            }
        }
Example #23
0
 private static void ConnectToPrinter(PosPrinter printer)
 {
     printer.Open();
     printer.Claim(10000);
     printer.DeviceEnabled = true;
 }
Example #24
0
        public void Initialize(string printerName)
        {
            posExplorer = new PosExplorer();

            DeviceInfo deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, printerName);

            if (deviceInfo is null)
            {
                PluginHost.ThrowWarning($"指定された論理デバイス名 \"{printerName}\" は不正です。OPOS ADK でこの名前のプリンターが登録されているか確認して下さい。", "プリンター GetDevice エラー");
                return;
            }

            try
            {
                posPrinter = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
            }
            catch (Exception ex)
            {
                PluginHost.ThrowWarning($"不明なエラーが発生しました: {ex.Message}", "プリンター CreateInstance エラー");
            }

            try
            {
                posPrinter.Open();
            }
            catch (PosControlException ex)
            {
                switch (ex.ErrorCode)
                {
                case ErrorCode.Illegal:
                    if (ex.Message.Contains("invalid parameter value"))
                    {
                        PluginHost.ThrowWarning($"指定された論理デバイス名 \"{printerName}\" は不正です。OPOS ADK でこの名前のプリンターが登録されているか確認して下さい。", "プリンター Open エラー");
                    }
                    else if (ex.Message.Contains("already open"))
                    {
                        PluginHost.ThrowWarning($"接続処理に失敗しました。プリンターが他のアプリケーションで使用されている可能性があります。", "プリンター Open エラー");
                    }
                    else
                    {
                        PluginHost.ThrowWarning($"不明なエラーが発生しました:【ErrorCode: Illegal】 {ex.Message}", "プリンター Open エラー");
                    }
                    break;

                case ErrorCode.NoService:
                    PluginHost.ThrowWarning($"接続処理に失敗しました。お使いのプリンターの不具合の可能性があります。", "プリンター Open エラー");
                    break;

                default:
                    PluginHost.ThrowWarning($"不明なエラーが発生しました:【ErrorCode: {ex.ErrorCode}】 {ex.Message}", "プリンター Open エラー");
                    break;
                }
                return;
            }

            try
            {
                posPrinter.Claim(5000);
            }
            catch (PosControlException ex)
            {
                switch (ex.ErrorCode)
                {
                case ErrorCode.Closed:
                    PluginHost.ThrowWarning($"ソフトウェアの不具合です。お手数ですが開発者へご連絡下さい。ご連絡の際にはこちらのエラーコードをお伝え下さい:【CA-CO】", "プリンター Claim エラー");
                    break;

                case ErrorCode.Illegal:
                    PluginHost.ThrowWarning($"プリンターに接続出来ませんでした。", "プリンター Claim エラー");
                    break;

                case ErrorCode.Timeout:
                    PluginHost.ThrowWarning($"時間内に接続出来ませんでした。プリンターが他のアプリケーションで使用されている可能性があります。", "プリンター Claim エラー");
                    break;

                case ErrorCode.Failure:
                    PluginHost.ThrowWarning($"不明なエラーが発生しました:【ErrorCode: Failure】 {ex.Message}", "プリンター Claim エラー");
                    break;

                default:
                    PluginHost.ThrowWarning($"不明なエラーが発生しました:【ErrorCode: {ex.ErrorCode}】 {ex.Message}", "プリンター Claim エラー");
                    break;
                }
                return;
            }

            try
            {
                posPrinter.DeviceEnabled = true;

                posPrinter.MapMode          = MapMode.Dots;
                posPrinter.RecLetterQuality = true;
            }
            catch (Exception ex)
            {
                PluginHost.ThrowWarning($"不明なエラーが発生しました:【{ex.GetType().Name}】 {ex.Message}", "プリンターセットアップエラー");
            }
        }
 public void openConnection()
 {
     SesionEnt.printerEnabled = false;
     string logicalName = "PosPrinter2";
     PosExplorer posExplorer = new PosExplorer();
     DeviceInfo deviceInfo = null;
     try
     {
         deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, logicalName);
     }
     catch (Exception exceptionX)
     {
         throw exceptionX;
     }
     if (deviceInfo != null)
     {
         try
         {
             posPrinter = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
         }
         catch (Exception exceptionX)
         {
             throw exceptionX;
         }
         try
         {
             posPrinter.Open();
             posPrinter.PowerNotify = PowerNotification.Enabled;
         }
         catch (Exception exceptionX)
         {
             throw exceptionX;
         }
         if (posPrinter != null)
         {
             try
             {
                 posPrinter.Claim(1000);
             }
             catch (PosControlException posControlExceptionX)
             {
                 throw posControlExceptionX;
             }
             try
             {
                 posPrinter.DeviceEnabled = true;
             }
             catch (PosControlException posControlExceptionX)
             {
                 throw posControlExceptionX;
             }
             try
             {
                 posPrinter.RecLetterQuality = false;
                 posPrinter.MapMode = MapMode.Metric;
                 SesionEnt.posPrinter = posPrinter;
                 SesionEnt.printerEnabled = true;
             }
             catch (PosControlException posControlExceptionX)
             {
                 throw posControlExceptionX;
             }
         }
     }
 }
Example #26
0
        //prepare printer
        private void prepare()
        {
            string strLogicalName = "PosPrinter";
            try
            {
                PosExplorer posExplorer = new PosExplorer();

                DeviceInfo deviceInfo = null;

                try
                {
                    deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
                    m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
                }
                catch (Exception e)
                {
                    Console.WriteLine("error2");
                    Console.WriteLine(e);
                }

                m_Printer.Open();

                m_Printer.Claim(1000);

                m_Printer.DeviceEnabled = true;

            }

            catch (PosControlException e)
            {
                Console.WriteLine("error3");
                Console.WriteLine(e);
            }

            finally
            {
                //release();
            }
        }
Example #27
0
        //public Printer(POS.Data.SQLiteHelper Helper)  //打印
        //{
        //    //mSQLiteHelper = Helper;
        //    //mForm = form;
        //}
        public bool init(bool asasynchronous)   //初始化
        {
            async = asasynchronous;
            //Use a Logical Device Name which has been set on the SetupPOS.
            string strLogicalName = "PosPrinter";

            try
            {
                //Create PosExplorer
                PosExplorer posExplorer = new PosExplorer();

                DeviceInfo deviceInfo = null;

                try
                {
                    deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
                    m_Printer  = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
                }
                catch (Exception)
                {
                    //ChangeButtonStatus(false);

                    /*
                     * System.IO.File.AppendAllText(@"C:\POS_Log.txt", "Printer.cs:init():" +
                     *  DateTime.Now.ToString() + exception.ToString() + "\r\n");
                     */
                    return(false);
                }


                //<<<step10>>>--Start
                //Register OutputCompleteEvent
                //AddErrorEvent(m_Printer);

                //Register OutputCompleteEvent
                // AddStatusUpdateEvent(m_Printer);


                //Open the device
                m_Printer.Open();

                //Get the exclusive control right for the opened device.
                //Then the device is disable from other application.
                m_Printer.Claim(1000);
                //Enable the device.
                m_Printer.DeviceEnabled = true;

                //Output by the high quality mode
                m_Printer.RecLetterQuality = true;


                // Even if using any printers, 0.01mm unit makes it possible to print neatly.
                m_Printer.MapMode = MapMode.Metric;
            }
            catch (PosControlException ex)
            {
                //ChangeButtonStatus(false);

                /*
                 * System.IO.File.AppendAllText(@"C:\POS_Log.txt", DateTime.Now.ToString() +
                 *  "Printer.cs:init():" + ex.ToString() + "\r\n");
                 */
                System.IO.File.AppendAllText(@"C:\hot.txt", DateTime.Now.ToString() + ": " + ex.ToString() + "\r\n");
                return(false);
            }
            //<<<step1>>>--End
            return(true);
        }
Example #28
0
        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult Uyari = new DialogResult();

            Uyari = MessageBox.Show("ŞUANA KADARKİ SATIŞ RAPORU ÇIKARTILACAK DEVAM EDİLSİN Mİ?", "UYARI!", MessageBoxButtons.YesNo);
            if (Uyari == DialogResult.Yes)
            {
                try
                {
                    var    ekle       = db.KasaGunlukToplam.Where(p => p.Tarih == Tarih).FirstOrDefault();
                    double giderler   = double.Parse(ekle.Giderler);
                    double kar        = double.Parse(ekle.Kar);
                    double ciro       = double.Parse(ekle.Ciro);
                    double duskar     = kar - giderler;
                    double dusciro    = ciro - giderler;
                    var    explorer   = new PosExplorer();
                    var    deviceInfo = explorer.GetDevice(DeviceType.PosPrinter);
                    if (deviceInfo == null)
                    {
                        MessageBox.Show("BİLGİSAYARA BAĞLI YAZICI YOK YADA BAĞLANTI KURULAMADI", "ÇEKİRDEK KOD TERS MÜHENDİSLİK KORUMASI!");
                        return;
                    }
                    Yazici = (PosPrinter)explorer.CreateInstance(deviceInfo);
                    Yazici.Open();
                    Yazici.Claim(500);
                    Yazici.DeviceEnabled      = true;
                    Yazici.StatusUpdateEvent += (s, evt) =>
                    {
                        if (evt.Status == PosPrinter.StatusCoverOpen)
                        {
                            MessageBox.Show("Yazıcının kağıt kapağı açıldı");
                        }
                        if (evt.Status == PosPrinter.StatusCoverOK)
                        {
                            MessageBox.Show("Yazıcının kağıt kapağı kapandı");
                        }
                        if (evt.Status == PosPrinter.StatusJournalCartridgeEmpty)
                        {
                            MessageBox.Show("Yazıcının kartuşu bitmek üzere");
                        }
                    };
                    Yazici.PrintNormal(PrinterStation.Slip, "                          Marketmatik                         " + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "GÜNLÜK SATIŞ RAPORU" + "  TARİH: " + DateTime.Now.ToShortDateString() + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "TOPLAM SATIŞ: " + ekle.Ciro + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "TOPLAM KAR  : " + ekle.Kar + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "BUGÜN TOPLAM GİDER: " + giderler.ToString() + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "BUGÜNKÜ KAR'DAN  GİDERİN DÜŞÜMÜ: " + duskar.ToString() + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "BUGÜNKÜ CİRO'DAN  GİDERİN DÜŞÜMÜ: " + dusciro.ToString() + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "----MALİ DEĞERİ YOKTUR---" + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "MARKETMATİK BETA V.1.0.2 [email protected]" + Environment.NewLine);
                    Yazici.CutPaper(100);
                    MessageBox.Show("RAPOR BAŞARIYLA YAZDIRILDI", "UYARI!");
                }
                catch
                {
                    MessageBox.Show("Slip Basılamadı", "Hata");
                }
            }
        }
Example #29
0
        private void button4_Click(object sender, EventArgs e)  //Peşin Ödeme
        {
            if (KONTROL == true)
            {
                try
                {
                    var ekle  = db.KasaGunlukToplam.Where(p => p.Tarih == Tarih).FirstOrDefault();
                    var ekle1 = db.KasaAylik.Where(p => p.Tarih == Ay).FirstOrDefault();

                    double Oncekikar   = double.Parse(ekle.Kar);
                    double kartopla    = Oncekikar + AnlikKar;
                    double OncekiCiro  = double.Parse(ekle.Ciro);
                    double Cirotopla   = OncekiCiro + AnlikCiro;
                    double aykar       = double.Parse(ekle1.KasaAylikKar);
                    double ayciro      = double.Parse(ekle1.KasaAylikCiro);
                    double aykartopla  = kartopla + aykar;
                    double aycirotopla = Cirotopla + ayciro;
                    ekle1.KasaAylikCiro = aycirotopla.ToString();
                    ekle1.KasaAylikKar  = aykartopla.ToString();
                    ekle.Ciro           = Cirotopla.ToString();
                    ekle.Kar            = kartopla.ToString();
                    db.SaveChanges();
                    var explorer   = new PosExplorer();
                    var deviceInfo = explorer.GetDevice(DeviceType.PosPrinter);
                    if (deviceInfo == null)
                    {
                        MessageBox.Show("BİLGİSAYARA BAĞLI YAZICI YOK YADA BAĞLANTI KURULAMADI", "ÇEKİRDEK KOD TERS MÜHENDİSLİK KORUMASI!");
                        return;
                    }
                    Yazici = (PosPrinter)explorer.CreateInstance(deviceInfo);
                    Yazici.Open();
                    Yazici.Claim(500);
                    Yazici.DeviceEnabled      = true;
                    Yazici.StatusUpdateEvent += (s, evt) =>
                    {
                        if (evt.Status == PosPrinter.StatusCoverOpen)
                        {
                            MessageBox.Show("Yazıcının kağıt kapağı açıldı");
                        }
                        if (evt.Status == PosPrinter.StatusCoverOK)
                        {
                            MessageBox.Show("Yazıcının kağıt kapağı kapandı");
                        }
                        if (evt.Status == PosPrinter.StatusJournalCartridgeEmpty)
                        {
                            MessageBox.Show("Yazıcının kartuşu bitmek üzere");
                        }
                    };
                    Yazici.PrintNormal(PrinterStation.Slip, "                          Marketmatik                         " + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "PEŞİN ÖDEME SATIŞ FİŞİ" + "  TARİH: " + DateTime.Now.ToShortDateString() + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
                    for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                    {
                        if (i == 100)
                        {
                            i = 0;
                            return;
                        }
                        Yazici.PrintNormal(PrinterStation.Slip, dataGridView1.Rows[i].Cells[1].Value.ToString() + " ---- " + dataGridView1.Rows[i].Cells[2].Value.ToString() + Environment.NewLine);
                    }
                    Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "TOPLAM TUTAR: " + ToplamTutarTextBox.Text + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "----MALİ DEĞERİ YOKTUR---" + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "MARKETMATİK BETA V.1.0.2 [email protected]" + Environment.NewLine);
                    Yazici.CutPaper(100);
                    KONTROL = false;
                }
                catch
                {
                    MessageBox.Show("Slip Basılamadı", "Hata");
                }
            }
            else
            {
                MessageBox.Show("Alışveriş Sepetinde Ürün Yokken, Peşin Ödeme Yapılamaz!", "Genel Hata");
            }
        }
Example #30
0
        public void Initialize(PosPrinter mPrinter)
        {
            PosExplorer posExplorer    = null;
            DeviceInfo  deviceInfo     = null;
            string      strLogicalName = "Printer";

            try
            {
                //Create PosExplorer
                posExplorer = new PosExplorer();

                try
                {
                    deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
                }
                catch (Exception e)
                {
                    mSend("当前系统中不止一台Printer设备,请设置默认的Printer类型打印机. 打印机异常");
                    mSend("前往 C:\\Program Files\\epson\\OPOS for .NET\\SetupPOS,运行 Epson.opos.tm.setpos.exe ,更改默认实例名为'Printer'");
                    System.IO.File.AppendAllText(@"C:\hot.txt", DateTime.Now.ToString() + ": " + e.ToString() + "\r\n");
                    return;
                }
                try
                {
                    mPrinter = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
                }
                catch (Exception e)
                {
                    mSend("创建PosPrinter设备实例失败.打印机异常");
                    mSend("前往 C:\\Program Files\\epson\\OPOS for .NET\\SetupPOS,运行 Epson.opos.tm.setpos.exe ,检查默认实例名是否为'Printer'");
                    System.IO.File.AppendAllText(@"C:\hot.txt", DateTime.Now.ToString() + ": " + e.ToString() + "\r\n");
                    return;
                }

                AddErrorEvent(mPrinter);
                AddStatusUpdateEvent(mPrinter);

                //Open the device
                try
                {
                    mPrinter.Open();
                }
                catch (PosControlException e)
                {
                    System.IO.File.AppendAllText(@"C:\hot.txt", DateTime.Now.ToString() + ": " + e.ToString() + "\r\n");
                    if (e.ErrorCode == ErrorCode.Illegal)
                    {
                        mSend("打印机已经被打开! 打印机故障");
                    }
                    else
                    {
                        mSend("打开打印机失败! 打印机故障");
                    }
                    return;
                }

                //Get the exclusive control right for the opened device.
                //Then the device is disable from other application.
                try
                {
                    mPrinter.Claim(1000);
                }
                catch (Exception e)
                {
                    mSend("请检查打印机电源、连接线及退出其他正在占用打印机的程序,并稍后重试 打印机故障");
                    System.IO.File.AppendAllText(@"C:\hot.txt", DateTime.Now.ToString() + ": " + e.ToString() + "\r\n");
                    return;
                }

                //Enable the device.
                try
                {
                    mPrinter.DeviceEnabled = true;
                }
                catch (Exception e)
                {
                    mSend("试图使能打印机失败 打印机故障");
                    System.IO.File.AppendAllText(@"C:\hot.txt", DateTime.Now.ToString() + ": " + e.ToString() + "\r\n");
                    return;
                }

                try
                {
                    //Output by the high quality mode
                    mPrinter.RecLetterQuality = true;


                    // Even if using any printers, 0.01mm unit makes it possible to print neatly.
                    mPrinter.MapMode = MapMode.Metric;
                }
                catch (Exception e)
                {
                    System.IO.File.AppendAllText(@"C:\hot.txt", DateTime.Now.ToString() + ": " + e.ToString() + "\r\n");
                    return;
                }
            }
            catch (Exception ex)
            {
                System.IO.File.AppendAllText(@"C:\hot.txt", DateTime.Now.ToString() + ": " + ex.ToString() + "\r\n");
                return;
            }

            try
            {
                mPrinter.DeviceEnabled = false;
                mPrinter.Release();
            }
            catch (PosControlException)
            {
            }
            finally
            {
                mPrinter.Close();
            }
            mSend("打印机正常!");
        }
 private void SatisiBitir_Click(object sender, EventArgs e)
 {
     if (form1.KONTROL == true)
     {
         try
         {
             var    ekle1      = db.KasaAylik.Where(p => p.Tarih == Ay).FirstOrDefault();
             var    ekle       = db.KasaGunlukToplam.Where(p => p.Tarih == Tarih).FirstOrDefault();
             var    Bul        = db.Musteriler.Where(w => w.MusteriAdi == SecAra.Text).FirstOrDefault();
             double Oncekikar  = double.Parse(ekle.Kar);
             double kartopla   = Oncekikar + form1.AnlikKar;
             double OncekiCiro = double.Parse(ekle.Ciro);
             double Cirotopla  = OncekiCiro + form1.AnlikCiro;
             ekle.Ciro = Cirotopla.ToString();
             ekle.Kar  = kartopla.ToString();
             double aykar       = double.Parse(ekle1.KasaAylikKar);
             double ayciro      = double.Parse(ekle1.KasaAylikCiro);
             double aykartopla  = kartopla + aykar;
             double aycirotopla = Cirotopla + ayciro;
             ekle1.KasaAylikCiro = aycirotopla.ToString();
             ekle1.KasaAylikKar  = aykartopla.ToString();
             db.SaveChanges();
             OncekiBakiye.Text          = Bul.MusteriBakiyesi;
             MusteriOncekiBakiyeToplami = double.Parse(OncekiBakiye.Text);
             MusteriYeniBakiyeToplam    = MusteriOncekiBakiyeToplami + AnlikSatisToplam;
             var explorer   = new PosExplorer();
             var deviceInfo = explorer.GetDevice(DeviceType.PosPrinter);
             if (deviceInfo == null)
             {
                 MessageBox.Show("BİLGİSAYARA BAĞLI YAZICI YOK YADA BAĞLANTI KURULAMADI", "ÇEKİRDEK KOD TERS MÜHENDİSLİK KORUMASI!");
                 return;
             }
             Yazici = (PosPrinter)explorer.CreateInstance(deviceInfo);
             Yazici.Open();
             Yazici.Claim(500);
             Yazici.DeviceEnabled      = true;
             Yazici.StatusUpdateEvent += (s, evt) =>
             {
                 if (evt.Status == PosPrinter.StatusCoverOpen)
                 {
                     MessageBox.Show("Yazıcının kağıt kapağı açıldı");
                 }
                 if (evt.Status == PosPrinter.StatusCoverOK)
                 {
                     MessageBox.Show("Yazıcının kağıt kapağı kapandı");
                 }
                 if (evt.Status == PosPrinter.StatusJournalCartridgeEmpty)
                 {
                     MessageBox.Show("Yazıcının kartuşu bitmek üzere");
                 }
             };
             Yazici.PrintNormal(PrinterStation.Slip, "                          PRESTIGE CAFE                       " + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "VERESİYE ÖDEME SATIŞ FİŞİ" + "  TARİH: " + DateTime.Now.ToShortDateString() + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "MÜŞTERİ ADI: " + Bul.MusteriAdi + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "MÜŞTERİ ÖNCEKİ BAKİYESİ: " + Bul.MusteriBakiyesi + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "MÜŞTERİ SATIŞ SONRAKİ BAKİYESİ: " + MusteriYeniBakiyeToplam.ToString() + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
             for (int i = 0; i < form1.dataGridView1.Rows.Count - 1; i++)
             {
                 if (i == 100)
                 {
                     i = 0;
                     return;
                 }
                 Yazici.PrintNormal(PrinterStation.Slip, form1.dataGridView1.Rows[i].Cells[1].Value.ToString() + " ---- " + form1.dataGridView1.Rows[i].Cells[2].Value.ToString() + Environment.NewLine);
             }
             Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "TOPLAM TUTAR: " + form1.ToplamTutarTextBox.Text + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "----MALİ DEĞERİ YOKTUR---" + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "MARKETMATİK BETA V.1.0.2 [email protected]" + Environment.NewLine);
             Yazici.CutPaper(100);
             Bul.MusteriBakiyesi = MusteriYeniBakiyeToplam.ToString();
             db.SaveChanges();
         }
         catch
         {
             MessageBox.Show("Veritabanı Hatası", "Kritik Sistem Hatası");
         }
     }
     else
     {
         MessageBox.Show("Alışveriş Sepetinde Ürün Yokken, Peşin Ödeme Yapılamaz!", "Genel Hata");
     }
     form1.KONTROL = false;
     form1.dataGridView1.Rows.Clear();
     form1.sayac                   = 0;
     form1.SonucToplam             = 0;
     form1.AnlikSatisToplam        = 0;
     form1.AnlikCiro               = 0;
     form1.AnlikKar                = 0;
     form1.ToplamTutarTextBox.Text = "";
     this.Close();
     form1.Visible = true;
 }
 private void raporcikar_Click(object sender, EventArgs e)
 {
     if (secilenay == 0)
     {
         MessageBox.Show("RAPOR ÇIKARILACAK BİR AY SEÇİLMEDİ! ÖNCE BİR AY SEÇİN!", "KULLANICI HATASI");
     }
     else
     {
         DialogResult Uyari = new DialogResult();
         Uyari = MessageBox.Show("SEÇİLEN AYIN RAPORU ÇIKARILACAK DEVAM EDİLSİN Mİ?", "UYARI!", MessageBoxButtons.YesNo);
         if (Uyari == DialogResult.Yes)
         {
             Double AylikKar         = double.Parse(aylikkar.Text);
             double AylikCiro        = double.Parse(aylikciro.Text);
             double AylikGider       = double.Parse(aylikgider.Text);
             double GiderdusKar      = AylikKar - AylikGider;
             double GiderdusCiro     = AylikCiro - AylikGider;
             Double AylikciroMusteri = AylikCiro - MusteriBorcu;
             double Aylikkarmusteri  = AylikKar - MusteriBorcu;
             var    explorer         = new PosExplorer();
             var    deviceInfo       = explorer.GetDevice(DeviceType.PosPrinter);
             if (deviceInfo == null)
             {
                 MessageBox.Show("BİLGİSAYARA BAĞLI YAZICI YOK YADA BAĞLANTI KURULAMADI", "ÇEKİRDEK KOD TERS MÜHENDİSLİK KORUMASI!");
                 return;
             }
             Yazici = (PosPrinter)explorer.CreateInstance(deviceInfo);
             Yazici.Open();
             Yazici.Claim(500);
             Yazici.DeviceEnabled      = true;
             Yazici.StatusUpdateEvent += (s, evt) =>
             {
                 if (evt.Status == PosPrinter.StatusCoverOpen)
                 {
                     MessageBox.Show("Yazıcının kağıt kapağı açıldı");
                 }
                 if (evt.Status == PosPrinter.StatusCoverOK)
                 {
                     MessageBox.Show("Yazıcının kağıt kapağı kapandı");
                 }
                 if (evt.Status == PosPrinter.StatusJournalCartridgeEmpty)
                 {
                     MessageBox.Show("Yazıcının kartuşu bitmek üzere");
                 }
             };
             Yazici.PrintNormal(PrinterStation.Slip, "                          PRESTIGE CAFE                       " + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "AYLIK SATIŞ RAPORU" + "  TARİH: " + DateTime.Now.ToShortDateString() + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "TOPLAM CİRO: " + aylikciro.Text + " TL" + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "TOPLAM KAR  : " + aylikkar.Text + " TL" + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "AYLIK TOPLAM GİDER: " + aylikgider.Text + " TL" + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "AYLIK KAR'DAN  GİDERİN DÜŞÜMÜ: " + GiderdusKar.ToString() + " TL" + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "AYLIK CİRO'DAN  GİDERİN DÜŞÜMÜ: " + GiderdusCiro.ToString() + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "TOPLAM MÜŞTERİ BORCU: " + musteriborclari.Text + " TL" + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "AYLIK CİRO'DAN MÜŞTERİ BORUCU DÜŞÜMÜ: " + AylikciroMusteri.ToString() + " TL" + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "AYLIK KAR'DAN MÜŞTERİ BORUCU DÜŞÜMÜ: " + Aylikkarmusteri.ToString() + " TL" + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "----MALİ DEĞERİ YOKTUR---" + Environment.NewLine);
             Yazici.PrintNormal(PrinterStation.Slip, "MARKETMATİK BETA V.1.0.2 [email protected]" + Environment.NewLine);
             Yazici.CutPaper(100);
             MessageBox.Show("RAPOR YAZDIRILDI", "UYARI!");
             this.Close();
             form234.Visible = true;
         }
     }
 }
Example #33
-2
        public Printer(string logicalName, bool connect)
        {
            instance = this;
            if (connect)
            {
                this.profile = null;
                this.deviceStatus = PrintDeviceStatus.Properly;
                this.PrintStatus = PrintStatus.Stopped;

                try
                {
                    DeviceInfo deviceInfo = null;
                    PosExplorer posExplorer = new PosExplorer();
                    deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, logicalName);
                    device = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
                    device.Open();
                    device.Claim(1000);
                    device.AsyncMode = false;
                    device.DeviceEnabled = true;

                    device.StatusUpdateEvent += Device_StatusUpdateEvent;
                    device.ErrorEvent += (a, b) => { WriteLog("ERROR - " + b.ToString()); };
                    WriteLog("");
                    WriteLog("Drucker initialisiert; Status: " + device.State + device);
                    if (device.RecNearEnd) Device_StatusUpdateEvent(this, new StatusUpdateEventArgs(25));
                    this.connected = connect;
                }
                catch (Exception ex)
                {
                    string s = ex.Source;
                    try
                    {
                        if (device != null)
                            device.Release();
                    }
                    catch { }
                    throw new Exception("Verbindung zum Drucker fehlgeschlagen.", ex);
                }
            }
            else
            {
                this.connected = false;
                this.PrintStatus = PrintStatus.Stopped;
                this.deviceStatus = PrintDeviceStatus.Properly;
            }
        }