📄 retail.cs
字号:
}
else
{
//文件完整时
//if(File.Exists(sNewFile)) File.Delete(sNewFile);
break;
}
}
}
//接收新文件
string result="";
if(status)
{
for(int i=0;i<4;i++)
{
if(i==3)
{
//错误,退出
status=false;
break;
}
//接收新文件:Server->PDA
result=net.DownFile(BC(PDAID(),30));
Thread.Sleep(WaitTime);
if(result.Substring(0,5).CompareTo("Empty")==0)
{
status=false;
net.SendCmd(CB("Error",64)); //反馈错误
break;
}
if(result.Substring(0,5).CompareTo("Error")!=0)
{
//接收成功
//net.SendCmd(result+BC("",38));
net.SendCmd(CB("Suces",64)); //反馈成功
break;
}
else
{
status=false;
net.SendCmd(CB("Error",64)); //反馈错误
break;
}
}
}
//文本导入数据库
if(status)
{
for(int i=0;i<4;i++)
{
if(i==3)
{
//导入不成功,退出
status=false;
break;
}
bool Dciku=false;
//如果不需要更新词库
if(result.Length<21)
{
status=false;
break;
}
if(result.Substring(21,5)=="76514")
Dciku=true;
//导入成功
//Thread.Sleep(5000);
if(sf.TXT2DB(result.Substring(0,21),Dciku))
{
Thread.Sleep(WaitTime);
if(File.Exists(result.Substring(0,21)))
File.Delete(result.Substring(0,21));
break;
}
}
}
if(status)
{
//断开网络
net.Close();
//MessageBOX.Text="下载完成!";
}
else
{
//MessageBOX.Text="";
net.Close();
//MessageBox.Show("网络通讯出现问题,本次通讯取消!");
}
}
catch(SocketException)
{
//MessageBOX.Text="配额不足!请联网重试!";
//MessageBox.Show("配额不足!请联网重试!");
MsgBox(rm.GetString("10005"),MsgTitle,3);
}
//Thread.Sleep(2000);
}
//#######################################################################详查函数#######################################################################
private void GoLookp()
{
if(!IsOnLine())
{
TBox_Memo.Text=" 该商品的特征码是:"+PDATA+","+stempTime;
return;
}
TBox_Memo.Text="";
CENet net=new CENet(ServerIP,ServerPort);
Thread.Sleep(1000);
MsgBox(rm.GetString("10007"),MsgTitle,3);
CEData lo;
lo=new CEData();
Len = new SubStr();
SqlCeConnection conn=lo.conn;
string TEXTPC,SqlText;
try
{
switch (GZQZ)
{
case "0"://贵重物品得到事物交易批次信息;详细查询事物的批次信息
TEXTPC = net.LookP(LOOK);
PathSub s = new PathSub();
string[] PatchArray = s.BusPath(Path);//截取返回的交易批次信息到字符型数组
for(int i=0;i<PatchArray.Length;i++)
{
try
{
SqlText = null;
SqlCeDataReader myReader=null;
SqlText = "SELECT * FROM TAD WHERE TADAA='"+PatchArray[i].ToString()+"'";
SqlCeCommand cmd=new SqlCeCommand(SqlText,conn);
myReader=cmd.ExecuteReader();
myReader.Read();
if (TBox_Memo.Text=="")
{
TBox_Memo.Text="产品可能来自: " + myReader.GetString(2);
}
else
{
TBox_Memo.Text=TBox_Memo.Text + "," + myReader.GetString(2);
}
myReader.Close();
}
catch
{
//MessageBOX.Text=" 查询失败!";
conn.Dispose();
ScanData="";
ScanSize=0;
GZQZ = "";
return;
}
}
TBox_Memo.Text = TBox_Memo.Text + ",打印批次信息:" +TEXTPC;
break;
case "1"://次贵重物品得到事物交易批次信息
PathSub ss = new PathSub();
string[] PatchArrayc = ss.BusPath(Path);//截取返回的交易批次信息到字符型数组
for(int i=0;i<PatchArrayc.Length;i++)
{
try
{
SqlText = null;
SqlCeDataReader myReader=null;
SqlText = "SELECT * FROM TAD WHERE TADAA='"+PatchArrayc[i].ToString()+"'";
SqlCeCommand cmd=new SqlCeCommand(SqlText,conn);
myReader=cmd.ExecuteReader();
myReader.Read();
if (TBox_Memo.Text=="")
{
TBox_Memo.Text="产品可能来自 " + myReader.GetString(2);
}
else
{
TBox_Memo.Text=TBox_Memo.Text + "," + myReader.GetString(2);
}
myReader.Close();
}
catch
{
//MessageBOX.Text=" 查询失败!";
conn.Dispose();
ScanData="";
ScanSize=0;
GZQZ = "";
return;
}
}
break;
case "2":
TBox_Memo.Text = net.LookP(LOOK);
break;
case "3":
//
break;
}
}
catch
{
ScanData="";
ScanSize=0;
GZQZ = "";
net.Close();
conn.Dispose();
//MessageBOX.Text = " 查询失败!";
return;
}
net.Close();
conn.Dispose();
ScanData="";
ScanSize=0;
GZQZ = "";
TBox_Memo.Text+=" 该商品的特征码是:"+PDATA;
//MessageBOX.Text="";
//Thread.Sleep(1000);
}
//################################################################### 详查函数 结束 ##########################################################################################
//########################################################## 终端按钮响应事件(ZJNET ADD 2005.8.25)##################################################################
private void ScanKeys(object o, EventArgs e)
{
g_mi.Update();
//按下PDA左上方的按钮
if(g_mi.KeyPressed((int)GXInput.HardwareKeys.kHardwareKey5))//下载配额
{
}
//按下PDA左下方的按钮
if(g_mi.KeyPressed((int)GXInput.HardwareKeys.kHardwareKey6)) //详查信息
{
}
if(g_mi.KeyPressed((int)GXInput.HardwareKeys.kHardwareKey7))//执行交易过程
{
}
if(g_mi.KeyPressed((int)GXInput.HardwareKeys.kHardwareKey8))//执行扫描过程
{
Clear();
MessageBOX.Text = "";
if(ScanSize<40)
{
ScanData="";
ScanSize=0;
gScanner.TriggerScanner();
Thread.Sleep(2000);
}
if(ScanSize>40)
{
//Singularity();//异常信息的处理
//MessageBOX.Text=" 错误条码!";
ScanData="";
ScanSize=0;
//return;
}
if(ScanSize==40)
{
ScanData="";
ScanSize=0;
gScanner.TriggerScanner();
}
}
}
//########################################################## 终端按钮响应事件 结束 ##################################################################
private void Btn_Scan_Click(object sender, System.EventArgs e)
{
if(!IsScan)
return;
IsScan=false;
try
{
Clear();
MessageBOX.Text = "";
if(ScanSize<40)
{
ScanData="";
ScanSize=0;
gScanner.TriggerScanner();
Thread.Sleep(2000);
}
if(ScanSize>40)
{
//Singularity();//异常信息的处理
//MessageBOX.Text=" 错误条码!";
ScanData="";
ScanSize=0;
//return;
}
if(ScanSize==40)
{
ScanData="";
ScanSize=0;
gScanner.TriggerScanner();
}
}
finally
{
IsScan=true;
}
}
//=======================================图像按钮的构造函数=============================================
public class PictureButton : Control
{
Image backgroundImage, pressedImage;
bool pressed = false;
// Property for the background image to be drawn behind the button text.
public Image BackgroundImage
{
get
{
return this.backgroundImage;
}
set
{
this.backgroundImage = value;
}
}
// Property for the background image to be drawn behind the button text when
// the button is pressed.
/// </summary>
public Image PressedImage
{
get
{
return this.pressedImage;
}
set
{
this.pressedImage = value;
}
}
// When the mouse is pressed, set the "pressed" flag = true and invalidate
// to cause a repaint. The Compact Framework sets the mouse capture automatically.
protected override void OnMouseDown(MouseEventArgs e)
{
this.pressed = true;
this.Invalidate();
base.OnMouseDown (e);
}
// When the mouse is released, reset the "pressed" flag and invalidate to redraw the
// button in the un-pressed state.
protected override void OnMouseUp(MouseEventArgs e)
{
this.pressed = false;
this.Invalidate();
base.OnMouseUp (e);
}
// Override the OnPaint method so we can draw the background image and the text.
protected override void OnPaint(PaintEventArgs e)
{
if(this.pressed && this.pressedImage != null)
e.Graphics.DrawImage(this.pressedImage, 0, 0);
else
e.Graphics.DrawImage(this.backgroundImage, 0, 0);
// Draw the text if there is any.
if(this.Text.Length > 0)
{
SizeF size = e.Graphics.MeasureString(this.Text, this.Font);
// Center the text inside the client area of the PictureButton.
e.Graphics.DrawString(this.Text,
this.Font,
new SolidBrush(this.ForeColor),
(this.ClientSize.Width - size.Width) / 2,
(this.ClientSize.Height - size.Height) / 2);
}
// Draw a border around the outside of the control to look like regular
// PPC buttons.
e.Graphics.DrawRectangle(new Pen(Color.Black), 0, 0,
this.ClientSize.Width - 1, this.ClientSize.Height - 1);
base.OnPaint(e);
}
}
//==========================================构造结束==========================================================
private void t_Tick(object sender, EventArgs e)
{
Noti.RemoveLast();
t.Enabled=false;
}
/// <summary>
/// 检验当前PDA是否处于通讯状态
/// </summary>
/// <returns>true:代表处于通讯中,false:代表处于离线中</returns>
private bool IsOnLine()
{
string sTemp="";
IPAddress[] addressList=null;
try
{
addressList = Dns.GetHostByName(Dns.GetHostName()).AddressList;
}
catch
{
return false;
}
for (int i = 0; i < addressList.Length; i ++)
{
sTemp += addressList[i].ToString();
}
if(sTemp.CompareTo("127.0.0.1")==0)
{
return false;
}
else
{
return true;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -