zoukankan      html  css  js  c++  java
  • PDA开发数据由DB下载至PDA本地

    public string DownFile = "\下载.txt";//下载路径
            public string LoadFile = "\上传.txt";//上传路径
            public List<string> _readtxt = new List<string>();
            public MainForm()
            {
                InitializeComponent();
                tbDelivery.Focus();
            }
            private void btnDownLoad_Click(object sender, EventArgs e)
            {
                try
                {
                    if (tbDelivery.Text.Trim().Length == 0)
                    {
                        MES.PDA.Core.Service.MessageServices.ShowWarm("请先扫描供货号!");
                        tbDelivery.Focus();
                        return;
                    }
                    else
                    {
                        if (!CheckDelivery())
                        {
                            return;
                        }
                        if (System.IO.File.Exists(DownFile))
                        {
                            StreamReader objReader = new StreamReader(DownFile);
                            string sLine = "";
                            sLine = objReader.ReadLine();
                            if (sLine != string.Empty)
                            {
                                string[] ss = sLine.Split(',');
                                if (ss.Length > 0)
                                {
                                    if (ss[0] != tbDelivery.Text.Trim())
                                    {
                                        MES.PDA.Core.Service.MessageServices.ShowWarm("本机已下载供货号:" + ss[0] + ",请扫描该供货号并上传后,再下载其他供货号!");
                                        objReader.Close();
                                        return;
                                    }
                                    else
                                    {
                                        MES.PDA.Core.Service.MessageServices.ShowWarm("该供货号已下载,请进行扫描并上传!");
                                        objReader.Close();
                                        return;
                                    }
                                }
                            }
                            objReader.Close();
                        }
                        else
                        {
                            FileStream fs = System.IO.File.Create(DownFile);
                            StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.GetEncoding("UTF-8"));
                            string sql = Sql.getDelivery(tbDelivery.Text.Trim());
                            Daisy.Common.McsClient.McsDataReader reader = (Daisy.Common.McsClient.McsDataReader)MES.PDA.Core.Service.DatabaseAccessService.execute(sql, MES.PDA.Core.Service.ReturnType.RESULTSET);
                            if (reader.rowNumber == 0)
                            {
                                MES.PDA.Core.Service.MessageServices.ShowWarm("获取供货号信息失败!");
                                sw.Close();
                                return;
    
                            }
                            else
                            {
                                string sLine = string.Empty;
                                while (reader.Read())
                                {
                                    //MES.PDA.Core.Service.MessageServices.ShowWarm(reader.getString(2));
                                    sLine = reader.getString(0) + "," + reader.getString(1) + "," + reader.getString(2) + "," + reader.getString(3) + "," + reader.getString(4) + "," + reader.getString(5);
                                    //sw.WriteLine(sLine);
                                    sw.WriteLine(sLine);
                                }
                                sw.Flush();
                                sw.Close();
                            }
                            var sqlload = "{?=call apps.cux_pda_load_scan_utl.init_data_download('" + tbDelivery.Text.Trim() + "')}";
    
                            //MES.PDA.Core.Service.MessageServices.ShowWarm(sql);
                            //return;
                            string ret = (string)MES.PDA.Core.Service.DatabaseAccessService.execute(sqlload, ReturnType.STRING);
    
    
                            if (!ret.StartsWith("0@"))
                            {
                                MES.PDA.Core.Service.MessageServices.ShowWarm(ret);
                                return;
                            }
                            else
                            {
                                MES.PDA.Core.Service.MessageServices.ShowWarm("下载成功!");
                                btnScan.Focus();
                            } 
                        }
                    }
                }
                catch (Exception ex)
                {
                    MES.PDA.Core.Service.MessageServices.ShowWarm(ex.ToString());
                }
            }

  • 相关阅读:
    [LeetCode]题解(python):086
    [LeetCode]题解(python):083
    [LeetCode]题解(python):082
    两位图灵奖得主万字长文:新计算机架构,黄金十年爆发!——读后感
    《架构漫谈》阅读笔记三
    以《淘宝网》为例,描绘质量属性的六个常见属性场景
    周学习笔记(01)——大三下
    Anconda、Pycharm下载、安装、配置教程(极其详细)
    《架构漫谈》阅读笔记二
    《架构漫谈》阅读笔记一
  • 原文地址:https://www.cnblogs.com/wanghang/p/6299128.html
Copyright © 2011-2022 走看看