示例#1
0
        private void btnUpload_Click(object sender, System.EventArgs e)
        {
            InitComm();

            int nUploadCnt = 0;

            if (m_nCommType == 1)              //網口
            {
                if (0 == CP5200.CP5200_Net_UploadFile(Convert.ToByte(m_cmbCardID.SelectedIndex + 1), GetProgramFileName(), GetProgramFileName()))
                {
                    nUploadCnt++;
                }

                if (0 == CP5200.CP5200_Net_UploadFile(Convert.ToByte(m_cmbCardID.SelectedIndex + 1), GetPlaybillFileName(), GetPlaybillFileName()))
                {
                    nUploadCnt++;
                }

                if (nUploadCnt > 0)
                {
                    CP5200.CP5200_Net_RestartApp(Convert.ToByte(m_cmbCardID.SelectedIndex + 1));
                }
            }
            else             //串口
            {
                if (0 == CP5200.CP5200_RS232_UploadFile(Convert.ToByte(m_cmbCardID.SelectedIndex + 1), GetProgramFileName(), GetProgramFileName()))
                {
                    nUploadCnt++;
                }

                if (0 == CP5200.CP5200_RS232_UploadFile(Convert.ToByte(m_cmbCardID.SelectedIndex + 1), GetPlaybillFileName(), GetPlaybillFileName()))
                {
                    nUploadCnt++;
                }

                if (nUploadCnt > 0)
                {
                    CP5200.CP5200_RS232_RestartApp(Convert.ToByte(m_cmbCardID.SelectedIndex + 1));
                }
            }


            String strName = String.Format("Upload 2 files ,{0:D} successful ,{1:D}  failed!", nUploadCnt, 2 - nUploadCnt);

            MessageBox.Show(strName);
        }