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());
            }
        }