private void Button_moCard_Click(object sender, EventArgs e) { string sql1, sql2; int id; ListView.SelectedIndexCollection c = listView_Cards.SelectedIndices; if (c.Count > 0) { if (int.TryParse(listView_Cards.Items[c[0]].SubItems[0].Text, out id)) { sql1 = CDB.GetUpdataSQL(CDB.cards[id]); SQL.Append(sql1); sql2 = CDB.GetUpdataSQL(GetCard()); //MessageBox.Show(sql[0]+"\n"+sql[1]); if (CDB.Command(CDBfile, sql2) < 2) { MessageBox.Show("修改失败!\n如果修改密码,请先添加再删除。", "错误"); } else { ReadData(); } } } }
private void Button_cancelCard_Click(object sender, EventArgs e) { if (SQL.Length > 0) { CDB.Command(CDBfile, SQL.ToString()); ReadData(); SQL.Remove(0, SQL.Length); } }
private void Button_addCard_Click(object sender, EventArgs e) { CardData data = GetCard(); string sql = CDB.GetInsertSQL(data); if (CDB.Command(CDBfile, sql) < 2) { MessageBox.Show("添加失败!\n卡片已经存在!", "错误"); } else { SQL.Append("delete from datas where id="); SQL.Append(data.code.ToString()); SQL.Append(";delete from texts where id="); SQL.Append(data.code.ToString()); SQL.Append(";"); ReadData(); } }
private void Button_delCard_Click(object sender, EventArgs e) { int Pid = 0; StringBuilder dsql = new StringBuilder(); ListView.SelectedIndexCollection c = listView_Cards.SelectedIndices; if (c.Count > 0) { for (int i = 0; i < c.Count; i++) { if (int.TryParse(listView_Cards.Items[c[i]].SubItems[0].Text, out Pid)) { dsql.Append("delete from datas where id="); dsql.Append(Pid.ToString()); dsql.Append(";delete from texts where id="); dsql.Append(Pid.ToString()); dsql.Append(";"); SQL.Append(CDB.GetInsertSQL(CDB.cards[Pid])); } } CDB.Command(CDBfile, dsql.ToString()); dsql = null; ReadData(); } }