Foxtable(狐表)用户栏目专家坐堂 → [求助]求助于狐爸啊,还是读卡写卡的问题


  共有7349人关注过本帖树形打印复制链接

主题:[求助]求助于狐爸啊,还是读卡写卡的问题

帅哥哟,离线,有人找我吗?
fjt4444
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:118 积分:906 威望:0 精华:0 注册:2013/3/21 12:44:00
[求助]求助于狐爸啊,还是读卡写卡的问题  发帖心情 Post By:2013/4/2 11:22:00 [只看该作者]

真心感谢狐爸帮忙将全局代码搞定,但目前急于测试是否能调用。所以我不得不再贴上一段C#的write和read代码。麻烦狐爸看看,然后帮忙转换一下。万分感谢!
写卡:
 protected void btnxieka_Click(object sender, EventArgs e)
    {
        if (Xieka())
        {
            myLib.PublicModule.Javascript.AlertAndRedirect("写卡成功!", "CardList2.aspx");
        }
        else
        {
            myLib.PublicModule.Javascript.Alert("写入失败!", true);
            return;
        }
    }

    private bool Xieka()
    {
        //写入磁卡的内容(业主ID,业主姓名,卡号,卡号ID)
        string ownerid = this.txtOwnerID.Value;

        string cardnumber = this.txtCardNumber.Text;

        string cardguid = this.ViewStateCardGuid;

        string key = ownerid + "," + cardnumber + "," + cardguid;

        bool b = DUKa.WriteIn(key);

        return b;
    }



读卡:
  private void Button3_Click(object sender, EventArgs e)
        {
            try
            {
                string msg = "";
                bool b = DUKa.ReadCard("", out msg);//D8读卡
                if (b)
                {
                    string[] cardlist = msg.Split(',');//三个参数:业主id,卡号,卡号id

                    DataTable dtable = new DataTable();

                    dtable = bll.GetOwnerInfo(Convert.ToInt32(cardlist[0]));

                    if (dtable != null)
                    {
                        this.txtCardNumber.Text = cardlist[1].ToString();
                        this.txtOwnerName.Text = dtable.Rows[0]["OwnerName"].ToString();
                        this.cardid = Convert.ToInt32(cardlist[2].ToString());
                        this.ownerid = Convert.ToInt32(cardlist[0].ToString());
                    }

                }
                else
                {
                    MessageBox.Show("读卡失败");
                }
            }
            catch {
                MessageBox.Show("读卡失败");
            }
        }

 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2013/4/2 11:42:00 [只看该作者]

Protected Sub btnxieka_Click(sender As Object, e As EventArgs)
 If Xieka() Then
  myLib.PublicModule.Javascript.AlertAndRedirect("写卡成功!", "CardList2.aspx")
 Else
  myLib.PublicModule.Javascript.Alert("写入失败!", True)
  Return
 End If
End Sub


Private Function Xieka() As Boolean
 '写入磁卡的内容(业主ID,业主姓名,卡号,卡号ID)
 Dim ownerid As String = Me.txtOwnerID.Value


 Dim cardnumber As String = Me.txtCardNumber.Text


 Dim cardguid As String = Me.ViewStateCardGuid


 Dim key As String = ownerid & "," & cardnumber & "," & cardguid


 Dim b As Boolean = DUKa.WriteIn(key)


 Return b
End Function

 

 

 

Private Sub Button3_Click(sender As Object, e As EventArgs)
 Try
  Dim msg As String = ""
  Dim b As Boolean = DUKa.ReadCard("", msg)
  'D8读卡
  If b Then
   Dim cardlist As String() = msg.Split(","C)
   '三个参数:业主id,卡号,卡号id

   Dim dtable As New DataTable()


   dtable = bll.GetOwnerInfo(Convert.ToInt32(cardlist(0)))


   If dtable IsNot Nothing Then
    Me.txtCardNumber.Text = cardlist(1).ToString()
    Me.txtOwnerName.Text = dtable.Rows(0)("OwnerName").ToString()
    Me.cardid = Convert.ToInt32(cardlist(2).ToString())
    Me.ownerid = Convert.ToInt32(cardlist(0).ToString())


   End If
  Else
   MessageBox.Show("读卡失败")
  End If
 Catch
  MessageBox.Show("读卡失败")
 End Try
End Sub


 回到顶部
帅哥哟,离线,有人找我吗?
fjt4444
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:118 积分:906 威望:0 精华:0 注册:2013/3/21 12:44:00
谢谢狐爸。  发帖心情 Post By:2013/4/2 11:45:00 [只看该作者]

先谢谢狐爸了!我先试试

 回到顶部