public static CardDelete ( long id, |
||
id | long | |
ygopath | ||
리턴 | void |
//撤销 public void Undo() { if (undoSQL.Count == 0) { return; } DataBase.Command(dataform.GetOpenFile(), undoSQL[undoSQL.Count - 1]); undoSQL.RemoveAt(undoSQL.Count - 1); if (undoModified[undoModified.Count - 1].modifiled) { FileModified lastmodify = undoModified[undoModified.Count - 1]; YGOUtil.CardRename(lastmodify.oldid, lastmodify.newid, dataform.GetPath(), lastmodify.delold); } undoModified.RemoveAt(undoModified.Count - 1); if (undoDeleted[undoDeleted.Count - 1].deleted) { FileDeleted lastdelete = undoDeleted[undoDeleted.Count - 1]; foreach (long id in lastdelete.ids) { YGOUtil.CardDelete(id, dataform.GetPath(), YGOUtil.DeleteOption.RESTORE); } } undoDeleted.RemoveAt(undoDeleted.Count - 1); if (undoCopied[undoCopied.Count - 1].copied) { DBcopied lastcopied = undoCopied[undoCopied.Count - 1]; DataBase.DeleteDB(dataform.GetOpenFile(), lastcopied.NewCards); DataBase.CopyDB(dataform.GetOpenFile(), !lastcopied.replace, lastcopied.OldCards); } undoCopied.RemoveAt(undoCopied.Count - 1); dataform.Search(true); }
//删除 public bool DelCards(bool deletefiles) { if (!dataform.CheckOpen()) { return(false); } Card[] cards = dataform.GetCardList(true); if (cards == null || cards.Length == 0) { return(false); } string undo = ""; if (!MyMsg.Question(LMSG.IfDeleteCard)) { return(false); } List <string> sql = new List <string>(); FileDeleted delete = new FileDeleted(); foreach (Card c in cards) { sql.Add(DataBase.GetDeleteSQL(c));//删除 undo += DataBase.GetInsertSQL(c, true); //删除资源 if (deletefiles) { YGOUtil.CardDelete(c.id, dataform.GetPath(), YGOUtil.DeleteOption.BACKUP); delete.deleted = true; delete.ids.Add(c.id); } } if (DataBase.Command(dataform.GetOpenFile(), sql.ToArray()) >= (sql.Count * 2)) { MyMsg.Show(LMSG.DeleteSucceed); dataform.Search(true); undoSQL.Add(undo); undoDeleted.Add(delete); undoModified.Add(new FileModified()); undoCopied.Add(new DBcopied()); return(true); } else { MyMsg.Error(LMSG.DeleteFail); dataform.Search(true); } return(false); }
public void Undo() { DataBase.Command(dataform.GetOpenFile(), _undoSQL); if (this.modifiled) { if (this.delold) { YGOUtil.CardRename(this.oldid, this.newid, dataform.GetPath()); } else { YGOUtil.CardDelete(this.newid, dataform.GetPath()); } } }
public void Undo() { _ = DataBase.Command(dataform.GetOpenFile(), undoSQL); if (modifiled) { if (delold) { YGOUtil.CardRename(oldid, newid, dataform.GetPath()); } else { YGOUtil.CardDelete(newid, dataform.GetPath()); } } }
public bool Excute(params object[] args) { if (!this.dataform.CheckOpen()) { return(false); } bool deletefiles = (bool)args[0]; Card[] cards = this.dataform.GetCardList(true); if (cards == null || cards.Length == 0) { return(false); } string undo = ""; if (!MyMsg.Question(LMSG.IfDeleteCard)) { return(false); } List <string> sql = new List <string>(); foreach (Card c in cards) { sql.Add(DataBase.GetDeleteSQL(c)); //删除 undo += DataBase.GetInsertSQL(c, true); //删除资源 if (deletefiles) { YGOUtil.CardDelete(c.id, this.dataform.GetPath()); } } if (DataBase.Command(this.dataform.GetOpenFile(), sql.ToArray()) >= (sql.Count * 2)) { MyMsg.Show(LMSG.DeleteSucceed); this.dataform.Search(true); this.undoSQL = undo; return(true); } else { MyMsg.Error(LMSG.DeleteFail); this.dataform.Search(true); } return(false); }
public bool Execute(params object[] args) { if (!dataform.CheckOpen()) { return(false); } bool deletefiles = (bool)args[0]; Card[] cards = dataform.GetCardList(true); if (cards == null || cards.Length == 0) { return(false); } string undo = ""; if (!MyMsg.Question(LMSG.IfDeleteCard)) { return(false); } List <string> sql = new(); foreach (Card c in cards) { sql.Add(DataBase.GetDeleteSQL(c));//删除 undo += (dataform.GetOpenFile().EndsWith(".db", StringComparison.OrdinalIgnoreCase) || dataform.GetOpenFile().EndsWith(".bytes", StringComparison.OrdinalIgnoreCase)) ? DataBase.OmegaGetInsertSQL(c, true) : DataBase.GetInsertSQL(c, true); //删除资源 if (deletefiles) { YGOUtil.CardDelete(c.id, dataform.GetPath()); } } if (DataBase.Command(dataform.GetOpenFile(), sql.ToArray()) >= (sql.Count * 2)) { MyMsg.Show(LMSG.DeleteSucceed); dataform.Search(true); undoSQL = undo; return(true); } else { MyMsg.Error(LMSG.DeleteFail); dataform.Search(true); } return(false); }