日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

POS机C井例子代码(2)

發(fā)布時間:2023/12/19 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 POS机C井例子代码(2) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

詳細代碼

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


namespace POS機C井例子代碼
{
?/// <summary>
?/// Form2 的摘要說明。
?/// </summary>
?public class Form2 : System.Windows.Forms.Form
?{
? 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.Label label1;
? private System.Windows.Forms.Label label2;
? private System.Windows.Forms.Label label3;
? private System.Windows.Forms.TextBox textBox1;
? private System.Windows.Forms.TextBox textBox2;
? private System.Windows.Forms.TextBox textBox3;
? private System.Windows.Forms.Button button6;
? private System.Windows.Forms.Label label4;
? private System.Windows.Forms.Button button7;
? private System.Windows.Forms.Label label5;
? private System.Windows.Forms.ListView listView1;
? private Microsoft.VisualBasic.Compatibility.VB6.DriveListBox driveListBox1;
? private System.Windows.Forms.ProgressBar progressBar2;
? private System.Windows.Forms.ColumnHeader columnHeader1;
? private System.Windows.Forms.ColumnHeader columnHeader2;
? private System.Windows.Forms.ColumnHeader columnHeader3;
? private System.Windows.Forms.ColumnHeader columnHeader4;
? private System.Windows.Forms.ColumnHeader columnHeader5;
? private System.Windows.Forms.ColumnHeader columnHeader6;
? /// <summary>
? /// 必需的設計器變量。
? /// </summary>
? private System.ComponentModel.Container components = null;

//? bool iscontinue ;???? //定義全局變量,繼續(xù)功能
??

? public Form2()
? {
?? //
?? // Windows 窗體設計器支持所必需的
?? //
?? InitializeComponent();

?? //
?? // TODO: 在 InitializeComponent 調用后添加任何構造函數(shù)代碼
?? //
? }

? /// <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.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.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.textBox2 = new System.Windows.Forms.TextBox();
?? this.textBox3 = new System.Windows.Forms.TextBox();
?? this.button6 = new System.Windows.Forms.Button();
?? this.label4 = new System.Windows.Forms.Label();
?? this.button7 = new System.Windows.Forms.Button();
?? this.label5 = new System.Windows.Forms.Label();
?? this.progressBar2 = new System.Windows.Forms.ProgressBar();
?? this.listView1 = new System.Windows.Forms.ListView();
?? this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
?? this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
?? this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
?? this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
?? this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
?? this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
?? this.driveListBox1 = new Microsoft.VisualBasic.Compatibility.VB6.DriveListBox();
?? this.SuspendLayout();
?? //
?? // button1
?? //
?? this.button1.Location = new System.Drawing.Point(16, 16);
?? this.button1.Name = "button1";
?? this.button1.Size = new System.Drawing.Size(80, 32);
?? this.button1.TabIndex = 0;
?? this.button1.Text = "采集記錄";
?? this.button1.Click += new System.EventHandler(this.button1_Click);
?? //
?? // button2
?? //
?? this.button2.Location = new System.Drawing.Point(16, 104);
?? this.button2.Name = "button2";
?? this.button2.Size = new System.Drawing.Size(80, 32);
?? this.button2.TabIndex = 1;
?? this.button2.Text = "刪除記錄";
?? //
?? // button3
?? //
?? this.button3.Location = new System.Drawing.Point(120, 104);
?? this.button3.Name = "button3";
?? this.button3.Size = new System.Drawing.Size(88, 32);
?? this.button3.TabIndex = 2;
?? this.button3.Text = "清空列表";
?? this.button3.Click += new System.EventHandler(this.button3_Click);
?? //
?? // button4
?? //
?? this.button4.Location = new System.Drawing.Point(664, 56);
?? this.button4.Name = "button4";
?? this.button4.Size = new System.Drawing.Size(88, 32);
?? this.button4.TabIndex = 3;
?? this.button4.Text = "暫停";
?? this.button4.Click += new System.EventHandler(this.button4_Click);
?? //
?? // button5
?? //
?? this.button5.Location = new System.Drawing.Point(352, 104);
?? this.button5.Name = "button5";
?? this.button5.Size = new System.Drawing.Size(80, 32);
?? this.button5.TabIndex = 4;
?? this.button5.Text = "刷 新";
?? //
?? // label1
?? //
?? this.label1.Location = new System.Drawing.Point(112, 24);
?? this.label1.Name = "label1";
?? this.label1.Size = new System.Drawing.Size(80, 23);
?? this.label1.TabIndex = 5;
?? this.label1.Text = "記錄總數(shù)";
?? //
?? // label2
?? //
?? this.label2.Location = new System.Drawing.Point(112, 64);
?? this.label2.Name = "label2";
?? this.label2.Size = new System.Drawing.Size(88, 23);
?? this.label2.TabIndex = 6;
?? this.label2.Text = "未上傳總金額";
?? //
?? // label3
?? //
?? this.label3.Location = new System.Drawing.Point(272, 24);
?? this.label3.Name = "label3";
?? this.label3.Size = new System.Drawing.Size(72, 23);
?? this.label3.TabIndex = 7;
?? this.label3.Text = "總上傳幀數(shù)";
?? //
?? // textBox1
?? //
?? this.textBox1.Location = new System.Drawing.Point(168, 24);
?? this.textBox1.Name = "textBox1";
?? this.textBox1.Size = new System.Drawing.Size(80, 21);
?? this.textBox1.TabIndex = 8;
?? this.textBox1.Text = "";
?? //
?? // textBox2
?? //
?? this.textBox2.Location = new System.Drawing.Point(192, 64);
?? this.textBox2.Name = "textBox2";
?? this.textBox2.Size = new System.Drawing.Size(88, 21);
?? this.textBox2.TabIndex = 9;
?? this.textBox2.Text = "";
?? //
?? // textBox3
?? //
?? this.textBox3.Location = new System.Drawing.Point(336, 24);
?? this.textBox3.Name = "textBox3";
?? this.textBox3.Size = new System.Drawing.Size(64, 21);
?? this.textBox3.TabIndex = 10;
?? this.textBox3.Text = "";
?? //
?? // button6
?? //
?? this.button6.Location = new System.Drawing.Point(536, 104);
?? this.button6.Name = "button6";
?? this.button6.Size = new System.Drawing.Size(96, 40);
?? this.button6.TabIndex = 11;
?? this.button6.Text = "從U盤提取記錄";
?? this.button6.Click += new System.EventHandler(this.button6_Click);
?? //
?? // label4
?? //
?? this.label4.Location = new System.Drawing.Point(280, 64);
?? this.label4.Name = "label4";
?? this.label4.Size = new System.Drawing.Size(48, 23);
?? this.label4.TabIndex = 12;
?? this.label4.Text = "分錢";
?? //
?? // button7
?? //
?? this.button7.Location = new System.Drawing.Point(664, 104);
?? this.button7.Name = "button7";
?? this.button7.Size = new System.Drawing.Size(88, 40);
?? this.button7.TabIndex = 14;
?? this.button7.Text = "生成刪除記錄許可文件";
?? this.button7.Click += new System.EventHandler(this.button7_Click);
?? //
?? // label5
?? //
?? this.label5.Location = new System.Drawing.Point(568, 32);
?? this.label5.Name = "label5";
?? this.label5.Size = new System.Drawing.Size(136, 23);
?? this.label5.TabIndex = 16;
?? this.label5.Text = "已采集";
?? //
?? // progressBar2
?? //
?? this.progressBar2.Location = new System.Drawing.Point(432, 24);
?? this.progressBar2.Maximum = 10000;
?? this.progressBar2.Name = "progressBar2";
?? this.progressBar2.Size = new System.Drawing.Size(120, 24);
?? this.progressBar2.TabIndex = 17;
?? //
?? // listView1
?? //
?? this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
????????????????????? this.columnHeader1,
????????????????????? this.columnHeader2,
????????????????????? this.columnHeader3,
????????????????????? this.columnHeader4,
????????????????????? this.columnHeader5,
????????????????????? this.columnHeader6});
?? this.listView1.GridLines = true;
?? this.listView1.Location = new System.Drawing.Point(16, 160);
?? this.listView1.Name = "listView1";
?? this.listView1.Size = new System.Drawing.Size(736, 296);
?? this.listView1.TabIndex = 18;
?? this.listView1.View = System.Windows.Forms.View.Details;
?? //
?? // columnHeader1
?? //
?? this.columnHeader1.Text = "卡號";
?? //
?? // columnHeader2
?? //
?? this.columnHeader2.Text = "充值次數(shù)";
?? //
?? // columnHeader3
?? //
?? this.columnHeader3.Text = "余額";
?? //
?? // columnHeader4
?? //
?? this.columnHeader4.Text = "消費額";
?? //
?? // columnHeader5
?? //
?? this.columnHeader5.Text = "消費時間";
?? this.columnHeader5.Width = 111;
?? //
?? // columnHeader6
?? //
?? this.columnHeader6.Text = "餐次";
?? this.columnHeader6.Width = 67;
?? //
?? // driveListBox1
?? //
?? this.driveListBox1.Location = new System.Drawing.Point(440, 104);
?? this.driveListBox1.Name = "driveListBox1";
?? this.driveListBox1.Size = new System.Drawing.Size(88, 22);
?? this.driveListBox1.TabIndex = 19;
?? //
?? // Form2
?? //
?? this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
?? this.ClientSize = new System.Drawing.Size(840, 478);
?? this.Controls.Add(this.driveListBox1);
?? this.Controls.Add(this.listView1);
?? this.Controls.Add(this.progressBar2);
?? this.Controls.Add(this.label5);
?? this.Controls.Add(this.button7);
?? this.Controls.Add(this.label4);
?? this.Controls.Add(this.button6);
?? this.Controls.Add(this.textBox3);
?? this.Controls.Add(this.textBox2);
?? this.Controls.Add(this.textBox1);
?? this.Controls.Add(this.label3);
?? this.Controls.Add(this.label2);
?? this.Controls.Add(this.label1);
?? 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.Name = "Form2";
?? this.Text = "Form2";
?? this.Load += new System.EventHandler(this.Form2_Load);
?? this.ResumeLayout(false);

? }
? #endregion


? bool iscontinue1 ;

? private void button4_Click(object sender, System.EventArgs e)
? {
?? iscontinue1 =false;
? }

?

? private void button1_Click(object sender, System.EventArgs e)//采集記錄
? {
?
?? Form1 f1 ;
?? f1 = (Form1)this.Owner;
?? f1.Refresh();

?? ListViewItem? list1;
?? int i;

?? if (f1.axPOS011.DevComPortOpen == 1)

?? {
??
???? f1.axPOS011.DevNumber = Convert.ToInt32(f1.textBox16.Text);
???? f1.axPOS011.DevRecTotalRead();
?????????????????? if(f1.axPOS011.OperatingResults == 0)
????? {
???????????????? textBox2.Text = Convert.ToString(f1.axPOS011.DevRecAmountTotal);??????? // 累計金額數(shù)
?????????????????
??????? textBox1.Text =Convert.ToString( f1.axPOS011.DevRecTotal) ;???????????? // 總記錄數(shù)
??????? textBox3.Text =Convert.ToString( f1.axPOS011.DevRecFrames ) ;?????????? //記錄總幀數(shù)p
???????????????????????????????? //以下代碼開始采集記錄
??????? if? (f1.axPOS011.DevRecFrames > 0)
??????? {
???????? iscontinue1=true;
????????
???????? this.progressBar2.Maximum =f1.axPOS011.DevRecFrames;
???????? for(i=0;i<=f1.axPOS011.DevRecFrames -1 ;i++)
???????? {
????????? f1.axPOS011.DevRecFramePoint =i ;?????? //設定當前需要采集的幀指針
????????? f1.axPOS011.DevRecFrameRead()?? ;???????? //執(zhí)行采集通訊
????????? if(f1.axPOS011.OperatingResults != 0)??????? //表示通訊錯誤,采集中斷
??????????? {
???????????? MessageBox.Show ( "通訊錯誤,退出,錯誤代碼為" + Convert.ToString(f1.axPOS011.OperatingResults));
??????????? }
????????? if (iscontinue1==false)
??????????? {
???????????? break ;

??????????? }
????????? //以下可以做進度條算法

????????? this.progressBar2.Value = i + 1;
????????? label5.Text = "已采集" + Convert.ToString(i + 1);
????????
???????? }
???????? if? (this.progressBar2.Value == f1.axPOS011.DevRecFrames)
????????? {
???????????? if (f1.axPOS011.OperatingResults == 0)
???????????? {
????????????? //采集全部成功
????????????? if (f1.axPOS011.DevRecTotal > 0)
????????????? {
?????????????? //下面為提取數(shù)據(jù)
??????????????
???????????????????????????????
?????????????? for (i = 0; i<=f1.axPOS011.DevRecTotal - 1;i++)
?????????????? {
??????????????? f1.axPOS011.DevRecPoint = i???? ;???? //設定當前記錄指針,用于提取記錄數(shù)據(jù),
??????????????? //執(zhí)行完本語句后,以下數(shù)據(jù)才有效

???????????????????????????????????? list1 = new ListViewItem(f1.axPOS011.DevRecCustomNumberStr);//卡號
??????
??????????????? list1.SubItems.Add(Convert.ToString(f1.axPOS011.DevRecRechargeTimes)) ;?????? //充值次數(shù)
????????????????????????????????????
??????????????? list1.SubItems.Add(Convert.ToString (f1.axPOS011.DevRecCardMoney));??????? //余額
????????????????????????????????????
??????????????? list1.SubItems.Add(Convert.ToString(f1.axPOS011.DevRecConsumption) )? ;??????? //當次消費額
??????????????? list1.SubItems.Add(? Convert.ToString(f1.axPOS011.DevRecTimeYear) + "-" + Convert.ToString(f1.axPOS011.DevRecTimeMonth) + "-" + Convert.ToString(f1.axPOS011.DevRecTimeDay) + " " + Convert.ToString(f1.axPOS011.DevRecTimeHour) + ":" + Convert.ToString(f1.axPOS011.DevRecTimeMinute) + ":" + Convert.ToString(f1.axPOS011.DevRecTimeSecond));
??????????????? list1.SubItems.Add (Convert.ToString(f1.axPOS011.DevRecMealType));
??????????????? listView1.Items.Add(list1);?
?????????????????????????????????????????????????????????????????????????
?????????????? }
????????????????????? }
????????????

?????????????????? }

??????????????? }


???????? }

??????? }
???? else
???? {
????? MessageBox.Show("設備通訊不通!");

???? }

???? }


?? else
?? {
??? MessageBox.Show("端口未打開!");

?? }
????????????????
?????????????????????????
?????????????????????????
??????????
?????????????????????
????????????


?
????????
? }

? private void button3_Click(object sender, System.EventArgs e)
? {
?? listView1.Items.Clear();
? }

? private void button6_Click(object sender, System.EventArgs e)//從U盤提取記錄
? {
?? ListViewItem? list1;
?? int i;

?? Form1 f1 ;
?? f1 = (Form1)this.Owner;
?? f1.Refresh();

?? f1.axPOS011.DevDriverStr = driveListBox1.Drive;???????????????????? //U盤
?? f1.axPOS011.DevNumber = Convert.ToInt32(f1.textBox16.Text)? ;?????? //機號

??

?? f1.axPOS011.DevRecReadFromDisk();

?? if (f1.axPOS011.OperatingResults == 0 )
?? {
??? textBox1.Text = Convert.ToString (f1.axPOS011.DevRecTotal);????????? //總記錄數(shù)

??? textBox2.Text = Convert.ToString(f1.axPOS011.DevRecAmountTotal) ;??? //累計金額數(shù)

??? for (i = 0;i< f1.axPOS011.DevRecTotal;i++)
???????? {
????
?????? f1.axPOS011.DevRecPoint = i ;??????????????????????????? //設定當前記錄指針,用于提取記錄數(shù)據(jù),
?????? //執(zhí)行完本語句后,以下數(shù)據(jù)才有效

?????? list1 = new ListViewItem(f1.axPOS011.DevRecCustomNumberStr);????????????????? //卡號
???????
?????? list1.SubItems.Add(Convert.ToString(f1.axPOS011.DevRecRechargeTimes)) ;?????? //充值次數(shù)
???????????????????
?????? list1.SubItems.Add(Convert.ToString (f1.axPOS011.DevRecCardMoney));?????????? //余額
???????????????????
?????? list1.SubItems.Add(Convert.ToString(f1.axPOS011.DevRecConsumption) )? ;?????? //當次消費額
?????? list1.SubItems.Add(? Convert.ToString(f1.axPOS011.DevRecTimeYear) + "-" + Convert.ToString(f1.axPOS011.DevRecTimeMonth) + "-" + Convert.ToString(f1.axPOS011.DevRecTimeDay) + " " + Convert.ToString(f1.axPOS011.DevRecTimeHour) + ":" + Convert.ToString(f1.axPOS011.DevRecTimeMinute) + ":" + Convert.ToString(f1.axPOS011.DevRecTimeSecond));
?????? list1.SubItems.Add (Convert.ToString(f1.axPOS011.DevRecMealType));
?????? listView1.Items.Add(list1);?
????
?????????
?
????????? }
??? MessageBox.Show ( "從U盤提取記錄成功!");
?? }
?? else if (f1.axPOS011.OperatingResults == 40)
??? {
???? MessageBox.Show("該機號對應的記錄文件不存在");

??? }
?? else if (f1.axPOS011.OperatingResults == 45)
??? {
???? MessageBox.Show("文件不是該機號設備生成的文件!" );
??? }
?? else
??? {
???? MessageBox.Show( Convert.ToString (f1.axPOS011.OperatingResults));
??? }
??
? }

//? private void button8_Click(object sender, System.EventArgs e)
//? {
//?? ListViewItem? list1;
//?? list1 = new ListViewItem("0");???? //卡號
//?? list1.SubItems.Add("1") ;????????? //充值次數(shù)
//?? list1.SubItems.Add("2");?????????? //余額
//?? list1.SubItems.Add("3");?????????? //當次消費額
//?? list1.SubItems.Add("4");
//?? list1.SubItems.Add("5");
//?? listView1.Items.Add(list1);
//? }

? private void Form2_Load(object sender, System.EventArgs e)
? {
?
? }

? private void button7_Click(object sender, System.EventArgs e)
? {
?
?? Form1 f1 ;
?? f1 = (Form1)this.Owner;
?? f1.Refresh();

????? f1.axPOS011.DevDriverStr = driveListBox1.Drive;
?? f1.axPOS011.DevNumber = Convert.ToInt32(f1.textBox16.Text);
?? f1.axPOS011.DevRecClearFileToDisk();
?????
?? if (f1.axPOS011.OperatingResults == 0)
??? {

??????? MessageBox.Show ( "寫記錄刪除許可文件到U盤成功!");
??? }
?? else? if( f1.axPOS011.OperatingResults == 46 )
????? {
?????? MessageBox.Show( "尚未提取文件記錄!");
???? }
?? else
????? {
?????? MessageBox.Show(Convert.ToString (f1.axPOS011.OperatingResults));
????? }
??

? }
?
?}
}

?

轉載于:https://blog.51cto.com/reader/597052

總結

以上是生活随笔為你收集整理的POS机C井例子代码(2)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。