Exemple #1
0
 /// <summary>
 /// 查看银行卡号密码是否正确
 /// </summary>
 /// <param name="cardid"></param>
 /// <param name="pwd"></param>
 /// <returns></returns>
 public int CheckIdPwd(CardInfo cardInfo)
 {
     string sql = "select count(*) from card where cardid = @cardid and password = @password";
     SqlParameter[] value = new SqlParameter[]{
         new SqlParameter("@cardid", cardInfo.Cardid),
         new SqlParameter("@password", cardInfo.Password)
     };
     int num = DBHelper.ExecuteScalar(sql, value);
     if (num == 0)
         return 0;
     return 1;
 }
Exemple #2
0
 /// <summary>
 /// 修改卡信息
 /// </summary>
 /// <param name="cardid"></param>
 /// <param name="pwd"></param>
 public int ModifyCard(CardInfo cardInfo)
 {
     string sql = null;
     SqlParameter[] value = null;
     sql = "update card set password = @pwd,bankName=@bankName where cardid = @cardid";
     value = new SqlParameter[]{
             new SqlParameter("@pwd", cardInfo.Password),
             new SqlParameter("@bankName", cardInfo.BankName),
             new SqlParameter("@cardid", cardInfo.Cardid)
         };
     int num = DBHelper.ExecuteCommand(sql, value);
     return num;
 }
Exemple #3
0
 /// <summary>
 /// 添加一张卡
 /// </summary>
 /// <param name="cardid"></param>
 /// <param name="pwd"></param>
 /// <param name="bankName"></param>
 /// <param name="UserId"></param>
 public int addCard(CardInfo cardInfo)
 {
     string time = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now);
     string sql = "insert into card(cardid, bankName, balance, addDate, password, userId)values(@cardid, @bankName, 0, @addDate, @pwd, @userId)";
     SqlParameter[] value = new SqlParameter[]{
         new SqlParameter("@cardid", cardInfo.Cardid),
         new SqlParameter("@bankName", cardInfo.BankName),
         new SqlParameter("@addDate", time),
         new SqlParameter("@pwd", cardInfo.Password),
         new SqlParameter("@userId", cardInfo.UserId)
     };
     int num = DBHelper.ExecuteCommand(sql, value);
     return num;
 }
Exemple #4
0
        /// <summary>
        /// 查看余额
        /// </summary>
        /// <param name="cardid"></param>
        /// <param name="pwd"></param>
        public CardInfo ViewBalance(CardInfo cardInfo)
        {
            CardInfo returnCardInfo = null;
            string sql = "select * from card where cardid = @cardid";
            SqlParameter[] value = new SqlParameter[]{
                new SqlParameter("@cardid", cardInfo.Cardid)
            };
            DataTable table = DBHelper.GetDataTable(sql, value);

            if (table.Rows.Count > 0)
            {
                DataRow dr = table.Rows[0];
                cardInfo.Balance = Convert.ToDouble(dr["balance"]);
                returnCardInfo = cardInfo;
            }
            return returnCardInfo;
        }
Exemple #5
0
 /// <summary>
 /// 取款
 /// </summary>
 /// <param name="cardid"></param>
 /// <param name="balance"></param>
 public int outMoney(CardInfo cardInfo, string about)
 {
     int returnNum = 0;
     string sql = string.Format("update card set balance = balance-@balance where cardid = @cardid");
     SqlParameter[] values = new SqlParameter[]{
         new SqlParameter("@balance", cardInfo.Balance),
         new SqlParameter("@cardid", cardInfo.Cardid)
     };
     int num = DBHelper.ExecuteCommand(sql, values);
     if (num == 1)
     {
         string tradeType = "取款";
         int typeId = 0;
         int temp = addTradeInfo(cardInfo.Cardid, cardInfo.Balance, tradeType, about, typeId);
         if (temp == 1)
             returnNum = 1;
         else if (temp == 0)
             returnNum = 2;
     }
     return returnNum;
 }
Exemple #6
0
 /// <summary>
 /// 存款
 /// </summary>
 /// <param name="cardid">银行卡号</param>
 /// <param name="balance">存款金额</param>
 public int depositMoney(CardInfo cardInfo, string about)
 {
     string sql = "update card set balance = balance + @balance where cardid = @cardid";
     SqlParameter[] value = new SqlParameter[]{
         new SqlParameter("@balance", cardInfo.Balance),
         new SqlParameter("@cardid", ThirdData.cardInfo.Cardid)
     };
     int returnNum = 0;
     int num = DBHelper.ExecuteCommand(sql, value);
     if (num == 1)
     {
         string tradeType = "存款";
         int typeId = 0;
         int temp = addTradeInfo(cardInfo.Cardid, cardInfo.Balance, tradeType, about, typeId);
         if (temp == 1)
             returnNum = 1;
         else if (temp == 0)
             returnNum = 2;
     }
     return returnNum;
 }
Exemple #7
0
 /// <summary>
 /// 交易界面展示
 /// </summary>
 /// <param name="cardInfo"></param>
 private void ShowCard(CardInfo cardInfo)
 {
     ThirdData.cardInfo = cardInfo;
     cardid.Text = ThirdData.cardInfo.Cardid;
     password_card.Text = ThirdData.cardInfo.Password;
     bankName.Text = ThirdData.cardInfo.BankName;
     balance.Text = ThirdData.cardInfo.Balance.ToString();
     cardid.Enabled = false;
     password_card.Enabled = false;
     bankName.Enabled = false;
     addMoney.Enabled = true;
     outMoney.Enabled = true;
     tradeMoney.Enabled = true;
     addMoney.Checked = true;
     about.Enabled = true;
     balance.Enabled = false;
     okMain.Enabled = true;
     ModifyCard.Enabled = true;
     tradeManage.Enabled = true;
     addCard.Enabled = true;
 }
Exemple #8
0
 /// <summary>
 /// 查找卡的功能
 /// </summary>
 private void searchCard()
 {
     string id = cardid.Text;
     string pwd = password_card.Text;
     if (id == "" || pwd == "")
     {
         MessageBox.Show("银行卡号或密码不能为空");
         if (id == "")
             cardid.Focus();
         else if (pwd == "")
             password_card.Focus();
     }
     else
     {
         CardOpera cardOpera = new CardOpera();
         CardInfo cardInfo = new CardInfo();
         cardInfo.Cardid = id;
         cardInfo.Password = pwd;
         cardInfo.UserId = ThirdData.user.Id;
         cardInfo = cardOpera.ViewCard(cardInfo);
         if (cardInfo == null)
         {
             MessageBox.Show("银行卡或者密码不正确!!!");
             cardid.Text = "";
             password_card.Text = "";
             cardid.Focus();
         }
         else
         {
             ShowCard(cardInfo);
         }
         okMain.Text = "交易";
         ThirdData.mark = 2;
     }
 }
Exemple #9
0
        /// <summary>
        /// 查看卡信息
        /// </summary>
        /// <param name="cardid"></param>
        /// <param name="pwd"></param>
        public CardInfo ViewCard(CardInfo cardInfo)
        {
            CardInfo returnCardInfo = null;
            string sql = "select * from card where cardid = @cardid and password = @pwd and userId = @userid";
            SqlParameter[] value = new SqlParameter[]{
                new SqlParameter("@cardid", cardInfo.Cardid),
                new SqlParameter("@pwd", cardInfo.Password),
                new SqlParameter("@userid", cardInfo.UserId)
            };
            DataTable table = DBHelper.GetDataTable(sql, value);

            if (table.Rows.Count > 0)
            {
                returnCardInfo = new CardInfo();
                DataRow dr = table.Rows[0];
                returnCardInfo.Cardid = cardInfo.Cardid;
                returnCardInfo.Password = cardInfo.Password;
                returnCardInfo.UserId = Convert.ToInt32(dr["userId"]);
                returnCardInfo.BankName = dr["bankName"].ToString();
                returnCardInfo.AddDate = dr["addDate"].ToString();
                returnCardInfo.Balance = Convert.ToDouble(dr["balance"]);
            }
            return returnCardInfo;
        }