POS消费机C#例子代码
詳細(xì)代碼
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data ;
namespace POS機(jī)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>
? /// 必需的設(shè)計器變量。
? /// </summary>
? private System.ComponentModel.Container components = null;
? public Form3()
? {
?? //
?? // Windows 窗體設(shè)計器支持所必需的
?? //
?? InitializeComponent();
?? //
?? // TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼
?? //
? }
? /// <summary>
? /// 清理所有正在使用的資源。
? /// </summary>
? protected override void Dispose( bool disposing )
? {
?? if( disposing )
?? {
??? if(components != null)
??? {
???? components.Dispose();
??? }
?? }
?? base.Dispose( disposing );
? }
? #region Windows 窗體設(shè)計器生成的代碼
? /// <summary>
? /// 設(shè)計器支持所需的方法 - 不要使用代碼編輯器修改
? /// 此方法的內(nèi)容。
? /// </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 = "總掛失數(shù)";
?? //
?? // 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 = "覆蓋式發(fā)送左邊列表中所有掛失卡號至設(shè)備";
?? 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 = "<<從設(shè)備中讀取所有掛失信息";
?? 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 = "追加式從設(shè)備取消單個卡號掛失";
?? 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 = "追加式掛失單個卡號至設(shè)備";
?? 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 = "從設(shè)備中查詢卡號是否已被掛失";
?? 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的數(shù)字", 輸入卡號);
?? 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 ( "設(shè)備通訊不通!");
??? }
?? }
?? 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("設(shè)備通訊不通!");
??? }
?? }
?? 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 );? //指定設(shè)備號
???? f3.axPOS011.CardCustomNumberStr = textBox2.Text? ;??????????? //自編卡號
???? f3.axPOS011.DevLossBitClear();??????????????????????????????? //在設(shè)備中清空該卡號的掛失信息
???? if( f3.axPOS011.OperatingResults == 0 )??????????????????????
????? {
?????? MessageBox.Show ("取消單張卡號成功!");
??????
????? }
???? else
????? {
?????? MessageBox.Show( "設(shè)備通訊不通!");
????? }
??? }
???? else
??? {
???? MessageBox.Show ("端口未打開!");
??? }
????
? }
?}
}
?
轉(zhuǎn)載于:https://blog.51cto.com/reader/597062
總結(jié)
以上是生活随笔為你收集整理的POS消费机C#例子代码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 电脑开不了机怎么办
- 下一篇: row_number() over (p