예제 #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();
 }
예제 #2
1
        public IDScanner()
        {
            explorer = new PosExplorer();
            var deviceCollection = explorer.GetDevices("Scanner");
            foreach (DeviceInfo deviceInfo in deviceCollection)
            {
                if (deviceInfo.ServiceObjectName != "Honeywell3310g")
                    continue;
                scanner = (Scanner)explorer.CreateInstance(deviceInfo);
                break;

            }
        }
예제 #3
0
        private void backgroundWorker_LightsOff(object sender, DoWorkEventArgs e)
        {
            PosExplorer explorer = new PosExplorer();
            PosCommon doorhub = null;

            var commonCollection = explorer.GetDevices("PosCommon");
            foreach (DeviceInfo deviceInfo in commonCollection)
            {
                if (deviceInfo.ServiceObjectName != "DoorHub")
                    continue;
                doorhub = (PosCommon)explorer.CreateInstance(deviceInfo);
                break;
            }
            if (doorhub == null)
            {
                MessageBox.Show("Doorhub not activated");
                return;
            }

            doorhub.Open();
            doorhub.Claim(1000);
            doorhub.DeviceEnabled = true;

            DirectIOData data = doorhub.DirectIO(1, 0, new string[] { "HexMaskGPB", "00" });

            doorhub.DeviceEnabled = false;
            doorhub.Release();
            doorhub.Close();
        }
예제 #4
0
파일: IDNFC.cs 프로젝트: cstrobbe/C4A-TVM
	public IDNFC()
	{
        explorer = new PosExplorer();
        var deviceCollection = explorer.GetDevices("RFIDScanner");
        foreach (DeviceInfo deviceInfo in deviceCollection)
        {
            if (deviceInfo.ServiceObjectName != "FeigRFID")
                continue;
            nfc = (RFIDScanner)explorer.CreateInstance(deviceInfo);
            break;
        }   
	}
예제 #5
0
파일: Printer.cs 프로젝트: cstrobbe/C4A-TVM
 public Printer()
 {
     explorer = new PosExplorer();
     var deviceCollection = explorer.GetDevices("PosPrinter");
     foreach (DeviceInfo deviceInfo in deviceCollection)
     {
         if (deviceInfo.ServiceObjectName != "VoRiMTD300Printer")
             continue;
         printer = (PosPrinter)explorer.CreateInstance(deviceInfo);
         break;
     }
 }
예제 #6
0
파일: Printer.cs 프로젝트: cstrobbe/C4A-TVM
    public Printer()
	{
        explorer = new PosExplorer();
        var deviceCollection = explorer.GetDevices();
        Console.WriteLine("DeViCe count: " + deviceCollection.Count);
        foreach (DeviceInfo deviceInfo in deviceCollection)
        {
            Console.WriteLine("devvv: " + deviceInfo.ServiceObjectName + deviceInfo.ManufacturerName);
            if (deviceInfo.ServiceObjectName != "VoRiMTD300Printer")
                continue;
            printer = (PosPrinter)explorer.CreateInstance(deviceInfo);
            break;
        }
	}
예제 #7
0
 public CashUnit()
 {
     explorer = new PosExplorer();
     if (cashUnit == null)
         {
         var deviceCollection = explorer.GetDevices("CashChanger");
         foreach (DeviceInfo deviceInfo in deviceCollection)
             {
             if (deviceInfo.ServiceObjectName != "Hoeft & Wessel Cash Unit")
                 continue;
             cashUnit = (CashChanger)explorer.CreateInstance(deviceInfo);
                 break;
             }
         }
         
 }
예제 #8
0
	public FeigRFID()
	{
        PosExplorer explorer = new PosExplorer();
        var deviceCollection = explorer.GetDevices("RFIDScanner");
        FeigRFID rfid = null;
        foreach (DeviceInfo deviceInfo in deviceCollection)
        {
            if (deviceInfo.ServiceObjectName != "FeigRFID")
                continue;
            rfid = (FeigRFID)explorer.CreateInstance(deviceInfo);
            break;
        }
        
        

        
	}
예제 #9
0
        public static Boolean checkForScanner()
        {
            Boolean check = false;

            PosExplorer explorer = new PosExplorer();
            var deviceCollection = explorer.GetDevices("Scanner");
            foreach (DeviceInfo deviceInfo in deviceCollection)
            {
                if (deviceInfo.ServiceObjectName != "Honeywell3310g")
                {
                    continue;
                }
                else
                {
                    check = true;
                }
            }
            return check;
        }
예제 #10
0
    public FeigRFID()
    {
        explorer = new PosExplorer();
        if (rfid == null)
        {
            var deviceCollection = explorer.GetDevices("RFIDScanner");
            foreach (DeviceInfo deviceInfo in deviceCollection)
            {
                if (deviceInfo.ServiceObjectName != "FeigRFID")
                    continue;
                rfid = (RFIDScanner)explorer.CreateInstance(deviceInfo);
                log.Info(deviceInfo.ToString());
                break;
            }
        }



    }
예제 #11
0
        public ScannerManager()
        {
            checkTimer = new System.Windows.Threading.DispatcherTimer();
            checkTimer.Interval = new TimeSpan(0, 0, 2);
            checkTimer.Tick += checkTimer_Tick;
               explorer = new PosExplorer();
            scannerList = explorer.GetDevices(DeviceType.Scanner);
            try
            {
                foreach (DeviceInfo di in scannerList)
                {
                    if (di.ServiceObjectName == "USBHHScanner")
                    {
                        activeScanner = (Scanner)explorer.CreateInstance(di);
                        break;
                    }
                }

            }
            catch (PosException) { }
        }
예제 #12
0
        private void SetPrinter(string strLogicalName)
        {
            try
            {
                //Create PosExplorer
                PosExplorer posExplorer = new PosExplorer();

                DeviceInfo deviceInfo = null;

                try
                {
                    //if (m_Printer != null || m_Printer.State == ControlState.Error)
                    if (m_Printer != null)
                    {
                        ReleasePrinter();
                    }
                    deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
                    m_Printer  = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
                    if (m_Printer != null)
                    {
                        ClaimPrinter();
                        HavePrinter = true;
                    }
                    //if (m_Printer.Claimed) m_Printer.Release();
                }
                catch (Exception)
                {
                    HavePrinter = false;
                    m_Printer   = null;
                    //ChangeButtonStatus();
                    //return;
                }
            }
            catch (PosControlException)
            {
                HavePrinter = false;
                //ChangeButtonStatus();
            }
        }
예제 #13
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);
        }
예제 #14
0
        protected void ButtonScan_Click(object sender, EventArgs e)
        {
        //Diese beiden Zeilen scannen einen Barcode ein und speichern die eingescannten Daten in Data
             // Data = scanner.scan();
           
        //Diese Zeilen erstellen ein Ticket mit den eingegebenen Parametern und drucken dieses aus
            //Bitmap ticket = Printer.generateTicket("Single Ticket", "Duri", "Jatinegara","10.000 Rp.");
            //Printer printer = new Printer();
            //printer.printTicket(ticket);

        //IDNFC scanner = new IDNFC();
            PosExplorer explorer = new PosExplorer();
            
            string devices = "";

            FeigRFID rfid = new FeigRFID();
            
            rfid.Open();
            rfid.Claim(1000);
            rfid.DeviceEnabled = true;
            Label1.Text = "finished";
           
        }
예제 #15
0
        /// <summary>
        /// Opens the scanner.
        /// </summary>
        /// <param name="name">The name of the scanner.</param>
        /// <exception cref="Microsoft.PointOfService.PosControlException"></exception>
        void OpenScanner(string name)
        {
            PosExplorer exp = new PosExplorer();

            foreach (DeviceInfo dev in exp.GetDevices(DeviceType.Scanner))
            {
                if (dev.LogicalNames.Contains <string>(name))
                {
                    s_objScanner = exp.CreateInstance(dev) as Scanner;
                    break;
                }
            }

            if (s_objScanner != null)
            {
                lock (s_objScanner)
                {
                    s_objScanner.ErrorEvent += new DeviceErrorEventHandler(OnErrorEvent);
                    s_objScanner.DataEvent  += new DataEventHandler(OnDataEvent);

                    s_objScanner.Open();

                    //configuration dependent setting!
                    if (bDecodeData)
                    {
                        s_objScanner.DecodeData = true;
                    }
                }

                scannerData = string.Empty;
                evtWaitScannerData.Reset();
            }
            else
            {
                throw new PosControlException(String.Format("The scanner {0} is not available!", name), ErrorCode.NoHardware);
            }
        }
예제 #16
0
        private void Panel_Inicio_Load(object sender, EventArgs e)
        {
            if (Turno.shiftActive)
            {
                this.setGroupBoxInfo();
            }


            //<<<step1>>>--Start
            //Use a Logical Device Name which has been set on the SetupPOS.
            string strLogicalName = "CashDrawer";

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

                DeviceInfo deviceInfo = null;

                try
                {
                    deviceInfo = posExplorer.GetDevice(DeviceType.CashDrawer, strLogicalName);
                    m_Drawer   = (CashDrawer)posExplorer.CreateInstance(deviceInfo);
                }
                catch (Exception)
                {
                    //Nothing can be used.
                    return;
                }
            }
            catch (PosControlException)
            {
                //Nothing can be used.
                //Nothing can be used.
            }
            //<<<step1>>>--End
        }
예제 #17
0
        public void PrintToPos()
        {
            PosExplorer explorer = null;
            DeviceInfo  _device;
            PosPrinter  _oposPrinter;
            string      LDN = "";

            explorer     = new PosExplorer();
            _device      = explorer.GetDevice(DeviceType.PosPrinter, LDN);
            _oposPrinter = (PosPrinter)explorer.CreateInstance(_device);
            _oposPrinter.Open();
            _oposPrinter.Claim(10000);
            _oposPrinter.DeviceEnabled = true;
            // normal print
            //_oposPrinter.PrintNormal(PrinterStation.Receipt, "yourprintdata");
            // pulse the cash drawer pin  pulseLength-> 1 = 100ms, 2 = 200ms, pin-> 0 = pin2, 1 = pin5
            // _oposPrinter.PrintNormal(PrinterStation.Receipt, (char)16 + (char)20 + (char)1 + (char)pin + (char)pulseLength);

            // cut the paper
            //_oposPrinter.PrintNormal(PrinterStation.Receipt, (char)29 + (char)86 + (char)66);

            // print stored bitmap
            //_oposPrinter.PrintNormal(PrinterStation.Receipt, (char)29 + (char)47 + (char)0);
        }
예제 #18
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");
            }
        }
예제 #19
0
 protected void DesignSwitch_Click(object sender, EventArgs e)
 {
     PosExplorer explorer = new PosExplorer();
     FeigRFID rfid = new FeigRFID();
     rfid.scanNFC();
 }
예제 #20
0
        /// <summary>
        /// Gets a list of the OPOS printers and loads any saved settings.
        /// </summary>
        public FormMain()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //Load Connection settings
            StoreIDtextBox.Text = Properties.Settings.Default.store_id;
            PasswordTextBox.Text = Properties.Settings.Default.password;
               WebServiceTextBox.Text = Properties.Settings.Default.WebService;

            //Load printer settings.
            RegistryKey rKey = Registry.LocalMachine;
            try
            {
                rKey = rKey.OpenSubKey("HARDWARE\\DEVICEMAP\\SERIALCOMM");
                string[] values;
                values = rKey.GetValueNames();
                for (int i = 0; i < values.GetLength(0); i++)
                {
                    string comValue = rKey.GetValue(values[i]).ToString();
                    cbPort.Items.Add(comValue);

                    if (comValue == Properties.Settings.Default.COMPort)
                    {
                        cbPort.SelectedItem = comValue;

                        //Start sniffing as well;

                        SniffSwitch();

                        // Hide the form to the system tray.
                        this.WindowState = FormWindowState.Minimized;

                        this.ShowInTaskbar = false;
                    }
                    else
                    {
                        cbPort.SelectedIndex = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            try
            {
                posExplorer = new PosExplorer(this);

                DeviceCollection devices = posExplorer.GetDevices(DeviceType.PosPrinter, DeviceCompatibilities.Opos);
                foreach (DeviceInfo deviceInfo in devices)
                {
                    printerList.Add(deviceInfo);
                    OPOSListcomboBox.Items.Add(deviceInfo.ServiceObjectName);
                }

                for (int i = 0; i < OPOSListcomboBox.Items.Count; i++)
                {
                    object o = OPOSListcomboBox.Items[i];
                    string displayText = o.ToString();

                    if (displayText == Properties.Settings.Default.OPOSPrinter)
                    {
                        OPOSListcomboBox.SelectedItem = displayText;
                    }
                    else
                    {
                        OPOSListcomboBox.SelectedIndex = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

               //Default Ad
                 DefaultAdTextBox.Text = Properties.Settings.Default.DefaultAd;

            //Load Loyalty Settings
            SendSalesDataCheckBox.Checked = Properties.Settings.Default.sendSalesData;

            DPDBTextBox.Text = Properties.Settings.Default.DPDBLocation;
            syncCustomersCheckBox.Checked = Properties.Settings.Default.syncCustomersOnStartup;

            if (Properties.Settings.Default.POSSoftware == "MYOB")
            {
                MYOBRadioButton.Checked = true;
                MicrosoftRMSRadioButton.Checked = false;
                ToggleSoftwarePanels(true);

                RMDBTextBox.Text = Properties.Settings.Default.RMDBLocation;

                if (!String.IsNullOrEmpty(RMDBTextBox.Text) && !String.IsNullOrEmpty(DPDBTextBox.Text))
                {
                    if (syncCustomersCheckBox.Checked)
                    {
                        SyncCustomers();
                    }

                    if (SendSalesDataCheckBox.Checked)
                    {
                        ProcessUnsentDockets();
                    }
                }
                else
                {
                    RewardsErrorLabel.Text = "Check RetailManager database location";
                }

                    Cat1Cat2RadioButton.Checked = Properties.Settings.Default.CategoriesOnly;
                    DepCat1RadioButton.Checked = !Properties.Settings.Default.CategoriesOnly;
            }
            else if (Properties.Settings.Default.POSSoftware == "Microsoft")
            {
                MYOBRadioButton.Checked = false;
                MicrosoftRMSRadioButton.Checked = true;
                ToggleSoftwarePanels(false);

                MicrosoftLocationTextBox.Text = Properties.Settings.Default.POSServerLocation;
                MicrosoftDBTextBox.Text = Properties.Settings.Default.POSServerDBName;
                MicrosoftUserTextBox.Text = Properties.Settings.Default.POSServerUser;
                MicrosoftPasswordTextBox.Text = Properties.Settings.Default.POSServerPassword;
                    ReceiptIdentifiersTextBox.Text = Properties.Settings.Default.ReceiptIdentifiers;
                    TransactionCaptionTextBox.Text = Properties.Settings.Default.TransactionCaption;

                if (TestSQLConnection(MicrosoftLocationTextBox.Text, MicrosoftDBTextBox.Text ,MicrosoftUserTextBox.Text, MicrosoftPasswordTextBox.Text) && !String.IsNullOrEmpty(DPDBTextBox.Text))
                {
                         if (syncCustomersCheckBox.Checked)
                         {
                              SyncCustomers();
                         }

                         if (SendSalesDataCheckBox.Checked)
                         {
                              ProcessUnsentDockets();
                         }
                }
                else
                {
                    RewardsErrorLabel.Text = "Check SQL Server database connection";
                }
            }
        }
예제 #21
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}", "プリンターセットアップエラー");
            }
        }
예제 #22
0
        public void SetDisplay(bool IsMarquee, bool IsStartUp, string DefaultMessage = null, string Upval = null, string Downval = null)
        {
            try
            {
                int Wdh     = 0;
                var valdown = "";
                if (IsStartUp)
                {
                    try { RemoveDisplay(); }
                    catch
                    { }
                    try
                    {
                        string      strLogicalName = "LineDisplay";
                        PosExplorer posExplorer    = null;
                        try
                        {
                            posExplorer = new PosExplorer();
                        }
                        catch (Exception ex)
                        {
                        }
                        deviceInfo = posExplorer.GetDevice(DeviceType.LineDisplay, strLogicalName);
                        m_Display  = (LineDisplay)posExplorer.CreateInstance(deviceInfo);
                        m_Display.Open();
                        m_Display.Claim(1000);
                        m_Display.DeviceEnabled = true;
                    }
                    catch { }
                    valdown = DefaultMessage;
                    Wdh     = Encoding.GetEncoding(932).GetByteCount(valdown);
                    m_Display.CharacterSet = 932;
                    m_Display.CreateWindow(1, 0, 1, 20, 1, Wdh);
                    if (!IsMarquee)
                    {
                        try
                        {
                            m_Display.MarqueeType = DisplayMarqueeType.None;
                        }
                        catch { }
                    }
                    else
                    {
                        m_Display.MarqueeFormat     = DisplayMarqueeFormat.Walk;
                        m_Display.MarqueeType       = DisplayMarqueeType.Init;
                        m_Display.MarqueeRepeatWait = 1000;
                        m_Display.MarqueeUnitWait   = 100;
                        m_Display.DisplayText(valdown, DisplayTextMode.Normal);
                        m_Display.MarqueeType = DisplayMarqueeType.Left;
                    }
                }
                else
                {
                    Wdh = 20;
                    try
                    {
                        try
                        {
                            RemoveDisplay();
                        }
                        catch
                        { }
                        try
                        {
                            string      strLogicalName = "LineDisplay";
                            PosExplorer posExplorer    = null;
                            try
                            {
                                posExplorer = new PosExplorer();
                            }
                            catch (Exception ex)
                            {
                            }
                            deviceInfo = posExplorer.GetDevice(DeviceType.LineDisplay, strLogicalName);
                            m_Display  = (LineDisplay)posExplorer.CreateInstance(deviceInfo);
                            m_Display.Open();
                            m_Display.Claim(1000);
                            m_Display.DeviceEnabled = true;
                        }
                        catch { }

                        //m_Display.CreateWindow(1,0,1,20,1,20);
                        //RemoveDisplay();
                        m_Display.CharacterSet = 932;
                        var i = Encoding.GetEncoding(932).GetByteCount(Downval);
                        var j = Encoding.GetEncoding(932).GetByteCount(Upval);
                        m_Display.DisplayTextAt(0, (m_Display.Columns - j), Upval, DisplayTextMode.Normal);
                        m_Display.DisplayTextAt(1, (m_Display.Columns - i), Downval, DisplayTextMode.Normal);
                        //PutSecond(i,Downval);
                    }
                    catch
                    {
                        // m_Display.DisplayText(Upval, DisplayTextMode.Normal);
                    }
                }
            }
            catch (PosControlException pe)
            {
            }
            //End:
            //{
            //    //  m_Display
            //    //   deviceInfo =
            //    //
            //}
        }
예제 #23
0
        private void siparisYazdir_Click(object sender, EventArgs e)
        {
            FileInfo fisAyarInfo = new FileInfo(fisDosyasi);

            if (fisAyarInfo.Length == 0)
            {
                functions.hataMesajiGoster("İlk Önce Fiş Ayarları Yapmanız Gerekmektedir !");
                fisAyarları.close = true;
                functions.formKapatAc(new fisAyarları());
            }
            else
            {
                if (siparisListView.Items.Count > 0)
                {
                    PosPrinter  posPrinter;
                    PosExplorer explorer   = new PosExplorer();
                    DeviceInfo  deviceInfo = explorer.GetDevice(DeviceType.PosPrinter);
                    posPrinter = (PosPrinter)explorer.CreateInstance(deviceInfo);
                    posPrinter.Open();
                    posPrinter.Claim(500);
                    posPrinter.DeviceEnabled = true;
                    posPrinter.PrintNormal(PrinterStation.Slip, string.Format("\t\t{0}{1}", sAdi.ToUpper(), Environment.NewLine));
                    posPrinter.PrintNormal(PrinterStation.Slip, string.Format("\t\t{0}{1}\t\t\t{2}{1}", adres, Environment.NewLine, ilIlce));
                    posPrinter.PrintNormal(PrinterStation.Slip, string.Format("\t\t{0}\t{1}{2}", vDaire.ToUpper(), vNo, Environment.NewLine));
                    posPrinter.PrintNormal(PrinterStation.Slip, string.Format("{0}   TARİH:\t{1}{0}   SAAT :\t{2}", Environment.NewLine, DateTime.Now.ToString().Split(' ')[0], DateTime.Now.ToString().Split(' ')[1]));
                    posPrinter.PrintNormal(PrinterStation.Slip, string.Format("{0}   -----------------------------------------------------------------------------{0}", Environment.NewLine));
                    posPrinter.PrintNormal(PrinterStation.Slip, string.Format("  ÜRÜN ADI\t\tÜRÜN ADEDİ\t\tÜRÜN FİYATI{0}{0}", Environment.NewLine));
                    for (int i = 0; i < siparisListView.Items.Count; i++)
                    {
                        if (siparisListView.Items[i].SubItems[0].Text.Length > 15)
                        {
                            siparisAdi = siparisListView.Items[i].SubItems[0].Text.Substring(0, 16);
                        }
                        else if (siparisListView.Items[i].SubItems[0].Text.Length < 15)
                        {
                            for (int j = 0; j < 15 - siparisListView.Items[i].SubItems[0].Text.Length; j++)
                            {
                                siparisAdi += " ";
                            }
                        }
                        siparisAdi = siparisListView.Items[i].SubItems[0].Text + siparisAdi;
                        posPrinter.PrintNormal(PrinterStation.Slip, string.Format("  {0}\t\t{1}\t\t\t{2}{3}", siparisAdi, siparisListView.Items[i].SubItems[1].Text, siparisListView.Items[i].SubItems[2].Text, Environment.NewLine));
                        siparisAdi = null;
                    }
                    posPrinter.PrintNormal(PrinterStation.Slip, string.Format("{0}{0}   -----------------------------------------------------------------------------{0}", Environment.NewLine));
                    posPrinter.PrintNormal(PrinterStation.Slip, string.Format("\tTOPLAM FİYAT:\t{0}", label2.Text));
                    posPrinter.CutPaper(100);
                    //posPrinter.Close();
                    FileInfo fi = new FileInfo(siparisDoc);
                    if (fi.Length > 0)
                    {
                        JObject siparis = JObject.Parse(File.ReadAllText(siparisDoc));
                        int     count   = siparis.Count;
                        for (int i = 0; i < siparisListView.Items.Count; i++)
                        {
                            siparis.Add(new JProperty((i + 1 + count).ToString(), new JObject(new JProperty("urunAdi", siparisListView.Items[i].SubItems[0].Text), new JProperty("urunAdedi", siparisListView.Items[i].SubItems[1].Text), new JProperty("urunFiyat", siparisListView.Items[i].SubItems[2].Text.Split(' ')[0]), new JProperty("saat", DateTime.Now.ToString().Split(' ')[1]))));
                        }
                        dosyayaYaz(siparis);
                    }
                    else
                    {
                        JObject obje = new JObject();
                        for (int i = 0; i < siparisListView.Items.Count; i++)
                        {
                            obje.Add(new JProperty((i + 1).ToString(), new JObject(new JProperty("urunAdi", siparisListView.Items[i].SubItems[0].Text), new JProperty("urunAdedi", siparisListView.Items[i].SubItems[1].Text), new JProperty("urunFiyat", siparisListView.Items[i].SubItems[2].Text.Split(' ')[0]), new JProperty("saat", DateTime.Now.ToString().Split(' ')[1]))));
                        }
                        dosyayaYaz(obje);
                    }
                    siparisListView.Items.Clear();
                    siparisSayisi = null;
                    label2.Text   = "0 ₺";
                }
            }
        }
예제 #24
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");
                }
            }
        }
예제 #25
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");
            }
        }
예제 #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();
            }
        }
예제 #27
0
 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;
             }
         }
     }
 }
예제 #28
0
        public static Boolean checkForPrinter()
        {
            Boolean check = false;

            PosExplorer explorer = new PosExplorer();
            var deviceCollection = explorer.GetDevices("PosPrinter");
            foreach (DeviceInfo deviceInfo in deviceCollection)
            {
                if (deviceInfo.ServiceObjectName != "VoRiMTD300Printer")
                {
                    continue;
                }
                else
                {
                    check = true;
                }
            }
            return check;
        }
        private void cariodegirilentutarkadarode_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;
                double odenentutar = double.Parse(cariodeodenentutar.Text);
                double borc        = double.Parse(Odeme);
                double sonuc;
                string odenenpara;
                if (odenentutar >= borc || odenentutar <= 0)
                {
                    MessageBox.Show("ÖDENEN TUTAR BORÇTAN FAZLA VEYA AZ OLAMAZ!", "KULLANICI HATASI!");
                }
                else
                {
                    sonuc      = borc - odenentutar;
                    odenenpara = sonuc.ToString();
                    MusteriCariOde.MusteriBakiyesi = odenenpara;
                    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İ ESKİ CARİSİ : " + Odeme + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "--------------------------------------------------------------" + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "ÖDENEN MİKTAR       : " + cariodeodenentutar.Text + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "--------------------------------------------------------------" + Environment.NewLine);
                    Yazici.PrintNormal(PrinterStation.Slip, "KALAN CARİ          : " + odenenpara + 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();
            }
        }
예제 #30
0
        public MainForm()
        {
            Panel panelParent = new Panel();
            panelParent.Parent = this;
            panelParent.Dock = DockStyle.Fill;

            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            stateTimer.Tick += new EventHandler(stateTimer_Tick);

            Output.Parent = panelParent;
            panel1.Parent = panelParent;
            panel1.Dock = DockStyle.Left;

            // Create the ToolTip and associate with the Form container.
            toolTip1.ShowAlways = true;
            toolTip1.InitialDelay = 300;
            toolTip1.ReshowDelay = 0;
            toolTip1.SetToolTip(DeviceTree, "");
            
            try
            {
                this.Closed += new System.EventHandler(this.Form1_Closed);
                
                cbCompatibilityLevel.Items.Clear();
                cbCompatibilityLevel.Items.AddRange(Enum.GetNames(typeof(DeviceCompatibilities)));
                cbCompatibilityLevel.Text = DeviceCompatibilities.OposAndCompatibilityLevel1.ToString();
                cbCompatibilityLevel.SelectedIndexChanged += new EventHandler(cbCompatibilityLevel_SelectedIndexChanged);

                cbBinaryConversion.Items.Clear();
                cbBinaryConversion.Items.AddRange(Enum.GetNames(typeof(BinaryConversion)));
               
                
                posExplorer = new PosExplorer(this);
                posExplorer.DeviceAddedEvent += new DeviceChangedEventHandler(root_OnDeviceAdded);
                posExplorer.DeviceRemovedEvent += new DeviceChangedEventHandler(root_OnDeviceRemoved);

                RefreshDeviceTree(false);
                DeviceTree.CollapseAll();
                SetButtonState();

                stateTimer.Interval = 500;
                stateTimer.Start();

                DeviceTree.AfterSelect += new TreeViewEventHandler(DeviceTree_AfterSelect);
                DeviceTree.MouseMove += new MouseEventHandler(DeviceTree_MouseMove);
            }
            catch(Exception ae)
            {
                ShowException(ae);
            }
        }
예제 #31
0
 public void Event_Mehtod()
 {
     explorer = new PosExplorer();
     explorer.DeviceAddedEvent += new DeviceChangedEventHandler(explorer_DeviceAddedEvent);
 }
예제 #32
0
        /// <summary>
        /// How to use "PosExplorer" sample2.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExample2_Click(object sender, System.EventArgs e)
        {
            try
            {
                //Create PosExplorer
                PosExplorer      posExplorer = new PosExplorer();
                DeviceInfo       deviceInfo  = null;
                DeviceCollection deviceCollection;

                //Get DeviceCollection use device categoly
                deviceCollection = posExplorer.GetDevices(DeviceType.PosPrinter);
                string[] astrLogicalNames;

                Hashtable hashDevice = new Hashtable(0);
                foreach (DeviceInfo devInfo in deviceCollection)
                {
                    //if the device name is registered.
                    if (devInfo.LogicalNames.Length > 0)
                    {
                        astrLogicalNames = devInfo.LogicalNames;
                        for (int i = 0; i < astrLogicalNames.Length; i++)
                        {
                            if (!hashDevice.ContainsKey(astrLogicalNames[i]))
                            {
                                m_PosCommon = (PosCommon)posExplorer.CreateInstance(devInfo);

                                //Use Legacy Opos
                                //if(m_PosCommon.Compatibility.Equals(DeviceCompatibilities.Opos))
                                //Use Opos for .Net
                                if (m_PosCommon.Compatibility.Equals
                                        (DeviceCompatibilities.CompatibilityLevel1))
                                {
                                    try
                                    {
                                        //Register hashtable key:LogicalName,Value:DeviceInfo
                                        hashDevice.Add(astrLogicalNames[i], devInfo);
                                    }
                                    catch (Exception)
                                    {
                                    }
                                }
                            }
                        }
                    }
                }

                deviceInfo = (DeviceInfo)hashDevice[m_strLogicalName];

                m_PosCommon = (PosCommon)posExplorer.CreateInstance(deviceInfo);

                //Open the device
                m_PosCommon.Open();

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

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

                //CheckHealth.
                m_PosCommon.CheckHealth(Microsoft.PointOfService.HealthCheckLevel.Interactive);

                //Close device
                m_PosCommon.Close();
            }
            catch (Exception)
            {
            }
        }
예제 #33
0
        public void SetDisplay(bool IsMarquee, bool IsStartUp, string Upval = null, string Downval = null)
        {
            //m_Display = null;
            //deviceInfo = null;
            // m_Display.ClearText();
            //try { RemoveDisplay(); }
            //catch { }

            if (m_Display != null)
            {
                m_Display.ClearText();
                return;
            }
            string      strLogicalName = "LineDisplay";
            PosExplorer posExplorer    = null;

            try
            {
                posExplorer = new PosExplorer();
            }
            catch (Exception ex)
            {
                goto End;
            }
            if (m_Display == null)
            {
                if (deviceInfo == null)
                {
                    deviceInfo = posExplorer.GetDevice(DeviceType.LineDisplay, strLogicalName);
                }
                m_Display = (LineDisplay)posExplorer.CreateInstance(deviceInfo);
                m_Display.Open();
                m_Display.Claim(1000);
                m_Display.DeviceEnabled = true;
            }

            try
            {
                int Wdh     = 0;
                var valdown = "";
                if (IsStartUp)
                {
                    valdown = GetMessages();
                    Wdh     = Encoding.GetEncoding(932).GetByteCount(valdown);
                    m_Display.CharacterSet = 932;
                    m_Display.CreateWindow(1, 0, 1, 20, 1, Wdh);
                    m_Display.DisplayText(valdown, DisplayTextMode.Normal);


                    if (!IsMarquee)
                    {
                        m_Display.MarqueeType = DisplayMarqueeType.None;
                    }
                    else
                    {
                        m_Display.MarqueeFormat     = DisplayMarqueeFormat.Walk;
                        m_Display.MarqueeType       = DisplayMarqueeType.Init;
                        m_Display.MarqueeRepeatWait = 1000;
                        m_Display.MarqueeUnitWait   = 100;
                        m_Display.MarqueeType       = DisplayMarqueeType.Left;
                    }
                }
                else
                {
                    Wdh = 20;
                    m_Display.CreateWindow(1, 0, 1, 20, 1, Wdh);
                    m_Display.DisplayTextAt(1, (m_Display.Columns - Downval.Length), Downval, DisplayTextMode.Normal);
                }
            }
            catch (PosControlException pe)
            {
            }
End:
            {
                //  m_Display
                //   deviceInfo =
                //
            }
        }
예제 #34
0
 public Form1()
 {
     InitializeComponent();
     explorer = new PosExplorer(this);
     explorer.DeviceAddedEvent += new DeviceChangedEventHandler(explorer_DeviceAddedEvent);
 }
예제 #35
0
 public PosDeviceHelper(Form frm)
 {
     _posExplorer  = new PosExplorer(frm);
     iTimeOut      = 1000;
     sNumberFormat = "1000";
 }
 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;
         }
     }
 }
예제 #37
0
 public POSDeviceManager(IMessageBus messageBus)
 {
     _messageBus = messageBus;
     //TODO: provide an ISynchronizeInvoke to the PosExplorer.
     _exp = new PosExplorer();
 }
예제 #38
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("打印机正常!");
        }
예제 #39
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);
        }
 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;
 }
예제 #41
0
        public void Initialize()  //初始化
        {
            lock (mInitializeLock)
            {
                string strLogicalName = "PosPrinter";

                if (mInitialized)
                {
                    return;
                }

                PosExplorer posExplorer = null;
                try
                {
                    posExplorer = new PosExplorer();
                }
                catch (Exception e)
                {
                    System.Console.WriteLine(e.InnerException.ToString());
                }

                DeviceInfo deviceInfo = null;
                try
                {
                    deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
                }
                catch (Exception getDeviceEx)
                {
                    Console.WriteLine("当前系统中不止一台PosPrinter设备,请设置默认的PosPrinter类型打印机.", "打印机异常");
                    System.IO.File.AppendAllText(LogTxt,
                                                 "PrintHelper.Initialize():" + DateTime.Now.ToString() + getDeviceEx.ToString() + "\r\n");
                    OutputOverHandle();
                    InitialError(getDeviceEx, "请运行: 开始 -> 程序 -> EPSON OPOS ADK for .NET -> SetupPOS for OPOS.NET\n" +
                                 "检查PosPrinter打印机配置,然后重启打印机");
                    return;
                }
                try
                {
                    mPrinter = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
                }
                catch (Exception createInstanceEx)
                {
                    Console.WriteLine("创建PosPrinter设备实例失败.", "打印机异常");
                    System.IO.File.AppendAllText(LogTxt,
                                                 "PrintHelper.Initialize():" + DateTime.Now.ToString() + createInstanceEx.ToString() + "\r\n");
                    OutputOverHandle();

                    InitialError(createInstanceEx,
                                 "请运行: 开始 -> 程序 -> EPSON OPOS ADK for .NET -> SetupPOS for OPOS.NET\n" +
                                 "检查PosPrinter打印机配置,然后重启打印机");
                    return;
                }

                AddOutputCompleteEvent(mPrinter);
                AddErrorEvent(mPrinter);
                AddStatusUpdateEvent(mPrinter);

                try
                {
                    mPrinter.Open();
                }
                catch (PosControlException openEx)
                {
                    System.IO.File.AppendAllText(LogTxt,
                                                 "PrintHelper.Initialize():" + DateTime.Now.ToString() + openEx.ToString() + "\r\n");
                    if (openEx.ErrorCode == ErrorCode.Illegal)
                    {
                        Console.WriteLine("打印机已经被打开!", "打印机故障");
                    }
                    else
                    {
                        Console.WriteLine("打开打印机失败!", "打印机故障");
                    }
                    OutputOverHandle();
                    InitialError(openEx);
                    return;
                }
                try
                {
                    mPrinter.Claim(1000);
                }
                catch (PosControlException claimEx)
                {
                    System.Diagnostics.Debug.WriteLine(claimEx.ToString());
                    System.IO.File.AppendAllText(LogTxt,
                                                 "PrintHelper.Initialize():" + DateTime.Now.ToString() + claimEx.ToString() + "\r\n");
                    Console.WriteLine("请检查打印机电源、连接线及退出其他正在占用打印机的程序,并稍后重试",
                                      "打印机故障");
                    OutputOverHandle();
                    InitialError(claimEx);
                    return;
                }
                try
                {
                    mPrinter.DeviceEnabled = true;
                }
                catch (PosControlException enabledEx)
                {
                    System.Diagnostics.Debug.WriteLine(enabledEx.ToString());
                    System.IO.File.AppendAllText(LogTxt,
                                                 "PrintHelper.Initialize():" + DateTime.Now.ToString() + enabledEx.ToString() + "\r\n");
                    Console.WriteLine("试图使能打印机失败", "打印机故障");
                    OutputOverHandle();
                    InitialError(enabledEx);
                    return;
                }

                try
                {
                    mPrinter.RecLetterQuality = true;
                    mPrinter.MapMode          = MapMode.Metric;
                }
                catch (PosControlException setModeEx)
                {
                    System.Diagnostics.Debug.WriteLine(setModeEx.ToString());
                    System.IO.File.AppendAllText(LogTxt,
                                                 "PrintHelper.Initialize():" + DateTime.Now.ToString() + setModeEx.ToString() + "\r\n");
                    OutputOverHandle();
                    InitialError(setModeEx);
                    return;
                }
                mInitialized = true;
            }
        }
예제 #42
0
        //public void printReceipt(InvoiceLine[] giftCards)
        //{
        //    try
        //    {
        //        // 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();
        //        }
        //        foreach (var invoiceLine in giftCards)
        //        {
        //            string receiptString = Receipt40Col.GetStandardReceipt(invoiceLine);
        //            // 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);
        //            m_Printer.PrintNormal(PrinterStation.Receipt, receiptString);
        //            m_Printer.PrintNormal(PrinterStation.Receipt, Receipt40Col.extraLines(8));
        //            Thread.Sleep(3000);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        ErrorLogging.logError(ex);
        //    }
        //}
        //public void printReceipt(Buyback buyback, 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);
        //        string receiptString = Receipt40Col.GetStandardReceipt(buyback);
        //        string barcodeString = buyback.Id.ToString();
        //        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);
        //        m_Printer.PrintNormal(PrinterStation.Receipt, receiptString);
        //        m_Printer.PrintNormal(PrinterStation.Receipt, Receipt40Col.extraLines(8));
        //        if (openDrawer)
        //            m_Printer.PrintNormal(PrinterStation.Receipt, ((char)27).ToString() + "|\x07");
        //    }
        //    catch (Exception ex)
        //    {
        //        ErrorLogging.logError(ex);
        //    }
        //}
        void setupPrinter()
        {
            //Create PosExplorer
            var posExplorer = new PosExplorer();
            var devices = posExplorer.GetDevices("PosPrinter");
            DeviceInfo deviceInfo = null;

            try
            {
                var printerName = ConfigurationManager.AppSettings["ReceiptPrinter"];

                deviceInfo = devices.OfType<DeviceInfo>().FirstOrDefault(x => x.ServiceObjectName.Contains(printerName)) ??
                             devices.OfType<DeviceInfo>().FirstOrDefault(x => x.ServiceObjectName.Contains("Star"));
                // this call returns a valid object
                var p = posExplorer.CreateInstance(deviceInfo);

                m_Printer = (PosPrinter) p; // posExplorer.CreateInstance(deviceInfo);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                //   ChangeButtonStatus();
                return;
            }
        }
예제 #43
-2
파일: Printer.cs 프로젝트: fhoner/Kasse
        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;
            }
        }