首页 > 代码库 > PDA开发数据由本地上传至DB

PDA开发数据由本地上传至DB

  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