예제 #1
0
        private void btnDownLoad_Click(object sender, EventArgs e)
        {
            btnDownLoad.Enabled = false;
            this.Cursor = Cursors.WaitCursor;
            if (cboType.SelectedIndex == 0)
            {
                CardControl card = new CardControl(txtIP.Text);
                List<string> CardList = new List<string>();
                foreach (DataGridViewRow dr in dataGridView1.Rows)
                {
                    try
                    {
                        if (dr.Cells[0].Value != null)
                        {
                            CardList.Add(dr.Cells[0].Value.ToString() + "," + dr.Cells[1].Value.ToString() + "," + dr.Cells[2].Value.ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }                    
                }
                string ErrorMessage = card.AddUserData(CardList);
                if (ErrorMessage == "")
                {
                    MessageBox.Show("全部卡號下載成功");
                }
                else
                {
                    MessageBox.Show(ErrorMessage);
                }

            }
            else
            {
                RAC960CardControl card = new RAC960CardControl(txtIP.Text);
                List<string> CardList = new List<string>();
                foreach (DataGridViewRow dr in dataGridView1.Rows)
                {
                    try
                    {
                        if (dr.Cells[0].Value != null)
                        {
                            CardList.Add(dr.Cells[0].Value.ToString() + "," + dr.Cells[2].Value.ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }  
                }
                string ErrorMessage = card.AddAllUserData(CardList);
                if (ErrorMessage == "")
                {
                    MessageBox.Show("全部卡號下載成功");
                }
                else
                {
                    MessageBox.Show(ErrorMessage);
                }
            }
            this.Cursor = Cursors.Default;
            btnDownLoad.Enabled = true;
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            FrmNewCard f = new FrmNewCard();
            f.StartPosition = FormStartPosition.CenterScreen;
            try
            {
                if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    if (cboType.SelectedIndex == 0)
                    {
                        CardControl card = new CardControl(txtIP.Text);
                        List<string> cardList = new List<string>(1);
                        string weg = f.WEG;
                        if (weg.Length < 10)
                        {
                            int AddLen = 10 - weg.Length;
                            for (int i = 0; i < AddLen; i++)
                            {
                                weg = "0" + weg;
                            }
                        }
                        cardList.Add(f.ABA + "," + weg + "," + f.Message);

                        string ErrorMessge = card.AddUserData(cardList);
                        if (ErrorMessge == "")
                        {
                            MessageBox.Show("下載成功");
                        }
                        else
                        {
                            MessageBox.Show(ErrorMessge);
                        }
                    }
                    else
                    {
                        RAC960CardControl card = new RAC960CardControl(txtIP.Text);
                        if (card.AddUserData(f.ABA, f.Message) == true)
                        {
                            MessageBox.Show("下載成功");
                        }
                        else
                        {
                            MessageBox.Show("下載失敗");
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("輸入資料錯誤");
            }
        }