/// <summary> /// 交易记录显示--不限 /// </summary> private void ShowAccount(string time1, string time2) { DataTable dt = null; string tradeType = null; TradeService tradeServie = new TradeService(); string cardid = ThirdData.cardInfo.Cardid; income[0] = 0; income[1] = 0; income[2] = 0; if (ThirdData.tradeType == 0) dt = tradeServie.ViewTransaction(cardid, time1, time2); else if(ThirdData.tradeType == 1) { tradeType = "存款"; dt = tradeServie.ViewTransaction(cardid, time1, time2, tradeType); } else if (ThirdData.tradeType == 2) { tradeType = "取款"; dt = tradeServie.ViewTransaction(cardid, time1, time2, tradeType); } foreach (DataRow dr in dt.Rows) { if (dr["tradeType"].ToString() == "存款") income[0] += Convert.ToDouble(dr["number"]); else if(dr["tradeType"].ToString() == "取款") income[1] += Convert.ToDouble(dr["number"]); } income[2] = income[0] - income[1]; dataGridView.AutoGenerateColumns = false; dataGridView.DataSource = dt; this.cardid.DataPropertyName = "cardid"; this.tradeTime.DataPropertyName = "tradeTime"; this.tradeType.DataPropertyName = "tradeType"; this.tradeMoney.DataPropertyName = "number"; this.about.DataPropertyName = "about"; }
/// <summary> /// 存款 取款功能 /// </summary> private void Change() { int temp = 0; //用来判断是否更新余额 CardInfo cardInfo = ThirdData.cardInfo; TradeService tradeService = new TradeService(); if(tradeMoney.Text == "") { MessageBox.Show("请输入交易金额"); tradeMoney.Focus(); } double money = Convert.ToDouble(tradeMoney.Text); if (addMoney.Checked == true && outMoney.Checked == false) { //存钱 if (money <= 0) { MessageBox.Show("存款金额不正确..."); about.Focus(); } else { //card表更新余额 cardInfo.Balance = money; string str = about.Text; int num = tradeService.depositMoney(cardInfo, str); if (num == 0) MessageBox.Show("存款失败.."); else if (num == 2) MessageBox.Show("添加交易记录失败..."); else { MessageBox.Show("存款成功..."); ThirdData.cardInfo = cardInfo; temp = 1; } } } else if (addMoney.Checked == false && outMoney.Checked == true) { //取钱 if (money > ThirdData.cardInfo.Balance) { MessageBox.Show("金额不足..."); tradeMoney.Text = ""; tradeMoney.Focus(); } else { //card表更新余额 cardInfo.Balance = money; string str = about.Text; int num = tradeService.outMoney(cardInfo, str); if (num == 0) MessageBox.Show("取款失败.."); else if (num == 2) MessageBox.Show("添加交易记录失败..."); else { MessageBox.Show("取款成功..."); ThirdData.cardInfo = cardInfo; temp = 1; } } } else { MessageBox.Show("请选择交易类型"); } if (temp == 1) { cardInfo = tradeService.ViewBalance(cardInfo); if (cardInfo == null) MessageBox.Show("更新余额失败..."); else { ShowCard(ThirdData.cardInfo); //将更新后的余额显示出来 addMoney.Checked = true; tradeMoney.Text = ""; about.Text = ""; tradeMoney.Focus(); } } }