Exemplo n.º 1
0
        private void OpenCashDrawer()
        {
            //<<<step1>>>--Start
            //When outputting to a printer,a mouse cursor becomes like a hourglass.
            Cursor.Current = Cursors.WaitCursor;
            //btnOpen.Enabled = false;

            try
            {
                //Open the drawer by using the "OpenDrawer" method.
                m_Drawer.OpenDrawer();

                // Wait during open drawer.
                while (m_Drawer.DrawerOpened == false)
                {
                    System.Threading.Thread.Sleep(100);
                }

                //When the drawer is not closed in ten seconds after opening, beep until it is closed.
                //If  that method is executed, the value is not returned until the drawer is closed.
                m_Drawer.WaitForDrawerClose(10000, 2000, 100, 1000);

                //btnOpen.Enabled = true;

                Cursor.Current = Cursors.Default;
            }
            catch (PosControlException)
            {
            }
            catch (NullReferenceException)
            {
            }
            //<<<step1>>>---End
        }
Exemplo n.º 2
0
        public void OpenCashDrawer(bool IsWaited = false)
        {
            try
            {
                string strLogicalName = "CashDrawer";

                //PosExplorerを生成します。
                PosExplorer posExplorer = new PosExplorer();

                DeviceInfo deviceInfo = null;

                deviceInfo = posExplorer.GetDevice(DeviceType.CashDrawer, strLogicalName);
                m_Drawer   = (CashDrawer)posExplorer.CreateInstance(deviceInfo);
                try
                {
                    // m_Drawer.DeviceEnabled = true;
                }
                catch { }
                m_Drawer.Open();

                m_Drawer.Claim(1000);

                //デバイスを使用可能(動作できる状態)にします。

                m_Drawer.DeviceEnabled = true;
            }
            catch (PosControlException)
            {
            }
            m_Drawer.OpenDrawer();

            // ドロワーが開いている間、待ちます。

            while (m_Drawer.DrawerOpened == false)
            {
                System.Threading.Thread.Sleep(100);
            }

            //開いてから10秒間経っても閉じられない場合はビープ音を断続的に鳴らします。

            //このメソッドを実行すると、ドロワーが閉じられるまで処理が戻ってこないので注意してください。

            if (IsWaited)
            {
                m_Drawer.WaitForDrawerClose(10000, 2000, 100, 1000);
            }

            try
            {
                CloseCashDrawer();
            }
            catch
            {
                try
                {
                    m_Drawer = null;
                }
                catch { }
            }
        }
Exemplo n.º 3
0
 private void WaitForDrawerCloseButton_Click(object sender, System.EventArgs e)
 {
     try
     {
         Cursor old = Cursor.Current;
         Cursor.Current = Cursors.WaitCursor;
         try
         {
             drawer.WaitForDrawerClose(Int32.Parse(BeepTimeouttextBox.Text),
                                       Int32.Parse(BeepFrequencytextBox.Text),
                                       Int32.Parse(BeepDurationtextBox.Text),
                                       Int32.Parse(BeepDelaytextBox.Text));
         }
         finally
         {
             Cursor.Current = old;
         }
     }
     catch (Exception ae)
     {
         ShowException(ae);
     }
 }