Beispiel #1
0
 public static CardModel GetCurrentCard(string cardId)
 {
     var card = new CardModel();
     cnn = SqlConnectionData.getConnection();
     try
     {
         string query = "Select * From Cards Where " +
                        "Cards.ID=" + cardId;
         //var command = new SqlCommand(query, cnn);
         var adapter = new SqlDataAdapter(query, cnn);
         var da = new DataTable();
         adapter.Fill(da);
         if (da.Rows.Count > 0)
         {
             card.ID = da.Rows[0]["ID"].ToString();
             card.pin = da.Rows[0]["Pin"].ToString();
             card.status = da.Rows[0]["Status"].ToString();
             card.AccID = da.Rows[0]["AccID"].ToString();
             card.CreateDate = da.Rows[0]["CreateDate"].ToString();
             card.ExpiredDate = da.Rows[0]["ExpiredDate"].ToString();
         }
     }
     catch (Exception e)
     {
         return null;
     }
     finally
     {
         SqlConnectionData.CloseConnection();
     }
     return card;
 }
        public static CardModel ValidateCard(string ID)
        {
            CardModel cardModel=null;
            try{
            
            cardModel= new CardModel();
            cnn = SqlConnectionData.getConnection();
            string queryCommand = "Select * from Cards where Cards.ID=" + ID;
            SqlDataAdapter adapter = new SqlDataAdapter(queryCommand, cnn);
            DataTable da = new DataTable();
            adapter.Fill(da);
            if (da.Rows.Count > 0)
            {
                cardModel.ID = da.Rows[0]["ID"].ToString();
                cardModel.pin = da.Rows[0]["pin"].ToString();
                cardModel.status = da.Rows[0]["Status"].ToString();
                cardModel.AccID = da.Rows[0]["AccID"].ToString();
                cardModel.CreateDate = da.Rows[0]["CreateDate"].ToString();
                cardModel.ExpiredDate = da.Rows[0]["ExpiredDate"].ToString();
            }
            }catch
            {
                cnn.Close();
            }
            finally
            {
                cnn.Close();
            }

            return cardModel;
        }
Beispiel #3
0
 public static int Authentication(CardModel card, string pass, int count)
 {
     if (card.pin != pass)
     {
         if (count < 3)
         {
             return 2;
         }
         else
         {
             AuthenticateUserbll.UpdateStatus(card.ID);
             return 1;
         }
     }
     return 0;
 }
Beispiel #4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="money"></param>
 /// <returns>
 /// 0: Can Withdraw and navigate to WaitForMoneyView.
 /// 1: Can not withdraw and navigate to Thankyou.
 /// </returns>
 public static int Withdraw(float money, CardModel Card, AccountModel Acc)
 {
     if (CanWithdraw(money, Acc.Balance, Acc.OverDraft))
     {
         UpdateAllData(Card.ID, money);
         return 0;
     }
     return 1;
 }
Beispiel #5
0
 public static void UpdateCurrentCard(string cardID)
 {
     Card = CardDAO.GetCurrentCard(cardID);
 }