private void btnUpLoad_Click(object sender, EventArgs e)
{
if (!System.IO.File.Exists(LoadFile))
{
MES.PDA.Core.Service.MessageServices.ShowWarm("请先扫描数据并保存!");
tbDelivery.Focus();
return;
}
else
{
string mes = string.Empty;
int successCount = 0;
using (StreamReader sr = new StreamReader(LoadFile))
{
String line;
while ((line = sr.ReadLine()) != null)
{
string[] ss = line.Split(',');
if (ss.Length > 0)
{
List<string> ls = new List<string>();
ls.Add(ss[0]);
ls.Add(ss[1]);
ls.Add(ss[2]);
string sql = "{?=call apps.cux_pda_load_scan_utl.data_load(" + StrUtil.BuildPara(ls) + ")}";
//MES.PDA.Core.Service.MessageServices.ShowWarm(sql);
//return;
string ret = (string)MES.PDA.Core.Service.DatabaseAccessService.execute(sql, ReturnType.STRING);
if (!ret.StartsWith("0@"))
{
mes += ret + ",数据为delivery_id:" + ss[0].ToString() + ",item_id:" + ss[0].ToString() + ",lot_num:" + ss[2].ToString();
mes += "\r\n";
}
else
{
successCount = successCount + 1;
}
}
}
}
string sql1 = "{?=call apps.cux_pda_load_scan_utl.end_data_load('" + tbDelivery.Text.Trim() + "')}";
//MES.PDA.Core.Service.MessageServices.ShowWarm(sql);
//return;
string ret1 = (string)MES.PDA.Core.Service.DatabaseAccessService.execute(sql1, ReturnType.STRING);
if (!ret1.StartsWith("0@"))
{
mes += "修改交货单下载状态失败!" + ret1;
}
mes = "数据上传成功:" + successCount.ToString() + "条。\r\n" + mes;
MES.PDA.Core.Service.MessageServices.ShowWarm(mes);
System.IO.File.Delete(LoadFile);
System.IO.File.Delete(DownFile);
}
}
PDA开发数据由本地上传至DB
最新推荐文章于 2022-04-27 17:10:19 发布
该段代码展示了如何从PDA设备读取本地文件数据,并逐行处理后调用存储过程上传到数据库。如果文件不存在,则提示用户。上传过程中记录成功和失败的数据,并在完成后清理本地文件。
摘要由CSDN通过智能技术生成