POS消费机C井例子代码(3)

POS消费机C井例子代码

 

 

 

 

 

详细代码

 

 

 

 

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data ;

 


//广州荣士电子有限公司,联系电话020-82318861,82322852,定制13826029618 网址http://www.icmcu.com

namespace POS机C井例子代码
{
 /// <summary>
 /// Form3 的摘要说明。
 /// </summary>
 public class Form3 : System.Windows.Forms.Form
 {
  private System.Windows.Forms.Label label1;
  private System.Windows.Forms.Label label2;
  private System.Windows.Forms.Label label3;
  private System.Windows.Forms.TextBox textBox1;
  private System.Windows.Forms.ProgressBar progressBar1;
  private System.Windows.Forms.Button button1;
  private System.Windows.Forms.Button button2;
  private System.Windows.Forms.Button button3;
  private System.Windows.Forms.Button button4;
  private System.Windows.Forms.Button button5;
  private System.Windows.Forms.Button button6;
  private System.Windows.Forms.Button button7;
  private System.Windows.Forms.Button button8;
  private System.Windows.Forms.Button button9;
  private System.Windows.Forms.ListView listView1;
  private Microsoft.VisualBasic.Compatibility.VB6.DriveListBox driveListBox1;
  private System.Windows.Forms.TextBox textBox2;
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;

  public Form3()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }

  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if(components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows 窗体设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
   this.label1 = new System.Windows.Forms.Label();
   this.label2 = new System.Windows.Forms.Label();
   this.label3 = new System.Windows.Forms.Label();
   this.textBox1 = new System.Windows.Forms.TextBox();
   this.progressBar1 = new System.Windows.Forms.ProgressBar();
   this.button1 = new System.Windows.Forms.Button();
   this.button2 = new System.Windows.Forms.Button();
   this.button3 = new System.Windows.Forms.Button();
   this.button4 = new System.Windows.Forms.Button();
   this.button5 = new System.Windows.Forms.Button();
   this.button6 = new System.Windows.Forms.Button();
   this.button7 = new System.Windows.Forms.Button();
   this.button8 = new System.Windows.Forms.Button();
   this.button9 = new System.Windows.Forms.Button();
   this.listView1 = new System.Windows.Forms.ListView();
   this.driveListBox1 = new Microsoft.VisualBasic.Compatibility.VB6.DriveListBox();
   this.textBox2 = new System.Windows.Forms.TextBox();
   this.SuspendLayout();
   //
   // label1
   //
   this.label1.Location = new System.Drawing.Point(24, 24);
   this.label1.Name = "label1";
   this.label1.Size = new System.Drawing.Size(64, 23);
   this.label1.TabIndex = 0;
   this.label1.Text = "挂失管理";
   //
   // label2
   //
   this.label2.Location = new System.Drawing.Point(112, 24);
   this.label2.Name = "label2";
   this.label2.Size = new System.Drawing.Size(64, 23);
   this.label2.TabIndex = 1;
   this.label2.Text = "总挂失数";
   //
   // label3
   //
   this.label3.Location = new System.Drawing.Point(112, 352);
   this.label3.Name = "label3";
   this.label3.Size = new System.Drawing.Size(32, 23);
   this.label3.TabIndex = 2;
   this.label3.Text = "卡号";
   //
   // textBox1
   //
   this.textBox1.Location = new System.Drawing.Point(184, 24);
   this.textBox1.Name = "textBox1";
   this.textBox1.TabIndex = 3;
   this.textBox1.Text = "0";
   //
   // progressBar1
   //
   this.progressBar1.Location = new System.Drawing.Point(488, 24);
   this.progressBar1.Maximum = 10000;
   this.progressBar1.Name = "progressBar1";
   this.progressBar1.Size = new System.Drawing.Size(136, 23);
   this.progressBar1.TabIndex = 4;
   //
   // button1
   //
   this.button1.Location = new System.Drawing.Point(16, 72);
   this.button1.Name = "button1";
   this.button1.Size = new System.Drawing.Size(80, 32);
   this.button1.TabIndex = 5;
   this.button1.Text = "增加挂失";
   this.button1.Click += new System.EventHandler(this.button1_Click);
   //
   // button2
   //
   this.button2.Location = new System.Drawing.Point(16, 120);
   this.button2.Name = "button2";
   this.button2.Size = new System.Drawing.Size(80, 32);
   this.button2.TabIndex = 6;
   this.button2.Text = "清 空";
   this.button2.Click += new System.EventHandler(this.button2_Click);
   //
   // button3
   //
   this.button3.Location = new System.Drawing.Point(568, 72);
   this.button3.Name = "button3";
   this.button3.Size = new System.Drawing.Size(144, 48);
   this.button3.TabIndex = 7;
   this.button3.Text = "覆盖式发送左边列表中所有挂失卡号至设备";
   this.button3.Click += new System.EventHandler(this.button3_Click);
   //
   // button4
   //
   this.button4.Location = new System.Drawing.Point(568, 144);
   this.button4.Name = "button4";
   this.button4.Size = new System.Drawing.Size(144, 48);
   this.button4.TabIndex = 8;
   this.button4.Text = "<<从设备中读取所有挂失信息";
   this.button4.Click += new System.EventHandler(this.button4_Click);
   //
   // button5
   //
   this.button5.Location = new System.Drawing.Point(568, 224);
   this.button5.Name = "button5";
   this.button5.Size = new System.Drawing.Size(48, 32);
   this.button5.TabIndex = 9;
   this.button5.Text = "刷新";
   this.button5.Click += new System.EventHandler(this.button5_Click);
   //
   // button6
   //
   this.button6.Location = new System.Drawing.Point(568, 280);
   this.button6.Name = "button6";
   this.button6.Size = new System.Drawing.Size(144, 48);
   this.button6.TabIndex = 10;
   this.button6.Text = "写所有挂失信息至U盘或磁盘";
   this.button6.Click += new System.EventHandler(this.button6_Click);
   //
   // button7
   //
   this.button7.Location = new System.Drawing.Point(224, 352);
   this.button7.Name = "button7";
   this.button7.Size = new System.Drawing.Size(136, 48);
   this.button7.TabIndex = 11;
   this.button7.Text = "追加式从设备取消单个卡号挂失";
   this.button7.Click += new System.EventHandler(this.button7_Click);
   //
   // button8
   //
   this.button8.Location = new System.Drawing.Point(392, 352);
   this.button8.Name = "button8";
   this.button8.Size = new System.Drawing.Size(144, 48);
   this.button8.TabIndex = 12;
   this.button8.Text = "追加式挂失单个卡号至设备";
   this.button8.Click += new System.EventHandler(this.button8_Click);
   //
   // button9
   //
   this.button9.Location = new System.Drawing.Point(568, 352);
   this.button9.Name = "button9";
   this.button9.Size = new System.Drawing.Size(144, 48);
   this.button9.TabIndex = 13;
   this.button9.Text = "从设备中查询卡号是否已被挂失";
   this.button9.Click += new System.EventHandler(this.button9_Click);
   //
   // listView1
   //
   this.listView1.Location = new System.Drawing.Point(112, 72);
   this.listView1.Name = "listView1";
   this.listView1.Size = new System.Drawing.Size(440, 256);
   this.listView1.TabIndex = 14;
   this.listView1.View = System.Windows.Forms.View.List;
   //
   // driveListBox1
   //
   this.driveListBox1.Location = new System.Drawing.Point(624, 224);
   this.driveListBox1.Name = "driveListBox1";
   this.driveListBox1.Size = new System.Drawing.Size(88, 22);
   this.driveListBox1.TabIndex = 15;
   //
   // textBox2
   //
   this.textBox2.Location = new System.Drawing.Point(152, 352);
   this.textBox2.Name = "textBox2";
   this.textBox2.Size = new System.Drawing.Size(56, 21);
   this.textBox2.TabIndex = 16;
   this.textBox2.Text = "12";
   //
   // Form3
   //
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.ClientSize = new System.Drawing.Size(752, 422);
   this.Controls.Add(this.textBox2);
   this.Controls.Add(this.driveListBox1);
   this.Controls.Add(this.listView1);
   this.Controls.Add(this.button9);
   this.Controls.Add(this.button8);
   this.Controls.Add(this.button7);
   this.Controls.Add(this.button6);
   this.Controls.Add(this.button5);
   this.Controls.Add(this.button4);
   this.Controls.Add(this.button3);
   this.Controls.Add(this.button2);
   this.Controls.Add(this.button1);
   this.Controls.Add(this.progressBar1);
   this.Controls.Add(this.textBox1);
   this.Controls.Add(this.label3);
   this.Controls.Add(this.label2);
   this.Controls.Add(this.label1);
   this.Name = "Form3";
   this.Text = "Form3";
   this.ResumeLayout(false);

  }
  #endregion

 

  

  private void button1_Click(object sender, System.EventArgs e)
  {
   Form5 f5=new Form5();
   
   f5.ShowDialog();

   String  str;

   str = f5.Value;                                 //InputBox("请输入卡号,必须为小于65535的数字", 输入卡号);
   this.listView1.Items.Add(str);
  }

  private void button2_Click(object sender, System.EventArgs e)
  {
   
   this.listView1.Clear ();
  }

  private void button3_Click(object sender, System.EventArgs e)
  {
   int i;
   Form1 f3 ;
   f3 = (Form1)this.Owner;
   f3.Refresh();
      
   if( f3.axPOS011.DevComPortOpen == 1)
   {
    f3.axPOS011.DevLossClearFromBuf();          // 先清空缓冲
        
    for (i = 0;i<listView1.Items.Count ;i++)
    {
     
     f3.axPOS011.CardCustomNumberStr = listView1.Items[i].Text;
     f3.axPOS011.DevLossAddToBuf();           //加入挂失信息缓冲
    }

    f3.axPOS011.DevNumber = Convert.ToInt32(f3.textBox16.Text);
    this.progressBar1.Maximum = f3.axPOS011.DevLossFrames;
    this.progressBar1.Value = 0;
      
            
    for( i = 0 ;i<=f3.axPOS011.DevLossFrames - 1;i++)
    {
     f3.axPOS011.DevLossFramePoint = i;
     f3.axPOS011.DevLossFrameWrite();
     if( f3.axPOS011.OperatingResults != 0)
          
     {break;}
     else
     {
      this.progressBar1.Value = i + 1;
            
     }

    }
            
    if (f3.axPOS011.OperatingResults == 0 )

    {
     MessageBox.Show ( "下载挂失信息成功!");
    }
    else
    {
     MessageBox.Show(Convert.ToString (f3.axPOS011.OperatingResults));
    }
   }
   else
   {
    MessageBox.Show( "端口未打开!");

   }
  }


  private void button4_Click(object sender, System.EventArgs e)
  {
   Form1 f3 ;
   f3 = (Form1)this.Owner;
   f3.Refresh();
   int i;
   if (f3.axPOS011.DevComPortOpen == 1 )
   {
    f3.axPOS011.DevNumber = Convert.ToInt32(f3.textBox16.Text );
    this.progressBar1.Maximum=f3.axPOS011.DevLossFrames;
    this.progressBar1.Value =0;      
           
    for (i = 0 ;i<f3.axPOS011.DevLossFrames ;i++)
    {
     f3.axPOS011.DevLossFramePoint = i;
     f3.axPOS011.DevLossFrameRead();
     if (f3.axPOS011.OperatingResults != 0 )
     {
      break;
     }
     else
     {
      this.progressBar1.Value=i+1;
     }
    }
           
    if (f3.axPOS011.OperatingResults == 0)
    {
     if (f3.axPOS011.DevLossBufSize > 0)
     {
      for (i = 0;i<f3.axPOS011.DevLossBufSize ;i++)                     
      {
       f3.axPOS011.DevLossBufPoint = i;                          
       listView1.Items.Add( f3.axPOS011.CardCustomNumberStr);
                       
      }      
      MessageBox.Show ( "提取挂失信息成功!");
     }
    }
                           
    else
    {
     MessageBox.Show( Convert.ToString (f3.axPOS011.OperatingResults));

    }
    
     }
   else
   {
    MessageBox.Show( "端口未打开!");
   }
   
  }

  private void button5_Click(object sender, System.EventArgs e)
  {
   this.driveListBox1.Refresh();
  }

  private void button6_Click(object sender, System.EventArgs e)
  {
   Form1 f3 ;
   f3 = (Form1)this.Owner;
   f3.Refresh();
      int i;

   f3.axPOS011.DevLossClearFromBuf();      //先清空缓冲
        
   for (i = 0;i<listView1.Items.Count ;i++)
   {
    
    f3.axPOS011.CardCustomNumberStr = listView1.Items[i].Text;
    f3.axPOS011.DevLossAddToBuf();           //加入挂失信息缓冲
   }
        
   f3.axPOS011.DevDriverStr =this.driveListBox1.Drive;
        
   f3.axPOS011.DevLossWriteAllToDisk();
        
        
   if (f3.axPOS011.OperatingResults == 0 )
   {
    MessageBox.Show ( "写覆盖式挂失信息到U盘或磁盘成功!");
   }
   else
   {
    MessageBox.Show(Convert.ToString ( f3.axPOS011.OperatingResults));
   }
  

 

  }

  private void button9_Click(object sender, System.EventArgs e)
  {

   Form1 f3 ;
   f3 = (Form1)this.Owner;
   f3.Refresh();

   if( f3.axPOS011.DevComPortOpen == 1)
   {
    f3.axPOS011.DevNumber = Convert.ToInt32(f3.textBox16.Text );
    f3.axPOS011.CardCustomNumberStr = textBox2.Text ;        //自编卡号
    f3.axPOS011.DevLossBitRead();

    if( f3.axPOS011.OperatingResults == 0 )
    {
     MessageBox.Show ( "该卡号已被挂失!");
    }
            
    else if (f3.axPOS011.OperatingResults == 113 )
    {
     MessageBox.Show ( "该卡号可使用!");
    }
    else
    {
     MessageBox.Show ( "设备通讯不通!");
    }
   }
   else
   {
    MessageBox.Show  ("端口未打开!");
   }
  
  }

  private void button8_Click(object sender, System.EventArgs e)
  {

   Form1 f3 ;
   f3 = (Form1)this.Owner;
   f3.Refresh();
  
   if (f3.axPOS011.DevComPortOpen == 1 )
   {
    f3.axPOS011.DevNumber = Convert.ToInt32(f3.textBox16.Text );
    f3.axPOS011.CardCustomNumberStr = textBox1.Text ;          //自编卡号
    f3.axPOS011.DevLossBitWrite();
           
           
    if (f3.axPOS011.OperatingResults == 0 )
    {
     MessageBox.Show ( "挂失单张卡号成功!");
    }
    
           
    else
    {
     MessageBox.Show("设备通讯不通!");
    }
   } 
   else
    {
     MessageBox.Show( "端口未打开!");
    }

 

 

  }

  private void button7_Click(object sender, System.EventArgs e)
  {

   Form1 f3 ;
   f3 = (Form1)this.Owner;
   f3.Refresh();
  
   if (f3.axPOS011.DevComPortOpen == 1)
    {
     f3.axPOS011.DevNumber = Convert.ToInt32(f3.textBox16.Text );  //指定设备号
     f3.axPOS011.CardCustomNumberStr = textBox2.Text  ;            //自编卡号
     f3.axPOS011.DevLossBitClear();                                //在设备中清空该卡号的挂失信息

     if( f3.axPOS011.OperatingResults == 0 )                      
      {
       MessageBox.Show ("取消单张卡号成功!");
      
      }
     else
      {
       MessageBox.Show( "设备通讯不通!");
      }
    }
     else
    {
     MessageBox.Show ("端口未打开!");
    }
     

 

 

  }
 }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值