挂失
1. dal cardinfo getState
/// <summary>
/// 获取挂失状态。
/// </summary>
/// <param name="CardID">卡号</param>
/// <returns>true为已挂失</returns>
public bool getState(string CardID)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select IsReportLoss from cardinfo ");
strSql.Append(" where cardID='" + CardID + "'");
object r= DbHelperSQL.GetSingle(strSql.ToString());
bool re =false ;
string xxx = r.ToString();
if (r.ToString() =="True") { re = true; }
return re;
}
2. dal cardinfo ChangeState
//更改状态。
public bool ChangeState(string CardID)
{
string sql = "update cardinfo set IsReportLoss=((IsReportLoss+1) % 2) where cardID='" + CardID + "' ";
int n= DbHelperSQL.ExecuteSql(sql);
if (n >= 1)
{
return true;
}
else
{ return false; }
}
3. Bll-cardinfo- getState
public bool getState(string CardID)
{
return dal.getState(CardID);
}
4. Bll-cardinfo- ChangeState
public bool ChangeState(string CardID)
{
return dal.ChangeState(CardID);
}
5. winf-lost
!)增加卡号字段
public string CardID;
2)编写load事件
private void Lost_Load(object sender, EventArgs e)
{
BLL.cardinfo bll = new BLL.cardinfo();
bool IsLost= bll.getState(CardID);
if (IsLost) { button1.Text = "取消挂失"; }
else { button1.Text = "挂失"; }
}
3)编写按钮点击事件
private void button1_Click(object sender, EventArgs e)
{
BLL.cardinfo bll = new BLL.cardinfo();
bool isOK= bll.ChangeState(CardID);
if (isOK)
{
if (button1.Text == "挂失")
{ label1.Text = "挂失操作成功"; button1.Text = "取消挂失"; }
else
{ label1.Text = "取消挂失操作成功"; button1.Text = "挂失"; }
}
else
{
label1.Text = "操作失败";
}
}
6. winf-main-菜单
private void 挂失ToolStripMenuItem_Click(object sender, EventArgs e)
{
Lost lo = new Lost();
lo.CardID = CardID;
lo.ShowDialog();
}