public bool Excute(params object[] args) { if (!dataform.CheckOpen()) { return(false); } Card c = dataform.GetCard(); if (c.id <= 0) //卡片密码不能小于等于0 { MyMsg.Error(LMSG.CodeCanNotIsZero); return(false); } Card[] cards = dataform.GetCardList(false); foreach (Card ckey in cards) //卡片id存在 { if (c.id == ckey.id) { MyMsg.Warning(LMSG.ItIsExists); return(false); } } if (DataBase.Command(dataform.GetOpenFile(), DataBase.GetInsertSQL(c, true)) >= 2) { MyMsg.Show(LMSG.AddSucceed); _undoSQL = DataBase.GetDeleteSQL(c); dataform.Search(true); dataform.SetCard(c); return(true); } MyMsg.Error(LMSG.AddFail); return(false); }
public bool Execute(params object[] args) { if (!dataform.CheckOpen()) { return(false); } Card c = dataform.GetCard(); if (c.id <= 0)//卡片密码不能小于等于0 { MyMsg.Error(LMSG.CodeCanNotIsZero); return(false); } else if (c.id > 268435455) { MyMsg.Error(LMSG.AddFail); return(false); } else if (c.omega[0] > 0) { if (c.ot > 0x7) { MyMsg.Error(LMSG.AddFail); return(false); } else if (c.id > 134217727) { MyMsg.Warning("Strings will fail to show up for this passcode."); } } Card[] cards = dataform.GetCardList(false); foreach (Card ckey in cards)//卡片id存在 { if (c.id == ckey.id) { MyMsg.Warning(LMSG.ItIsExists); return(false); } } if (DataBase.Command(dataform.GetOpenFile(), (dataform.GetOpenFile().EndsWith(".db", StringComparison.OrdinalIgnoreCase) || dataform.GetOpenFile().EndsWith(".bytes", StringComparison.OrdinalIgnoreCase) ? DataBase.OmegaGetInsertSQL(c, true) : DataBase.GetInsertSQL(c, true))) >= 2) { MyMsg.Show(LMSG.AddSucceed); undoSQL = DataBase.GetDeleteSQL(c); dataform.Search(true); dataform.SetCard(c); return(true); } MyMsg.Error(LMSG.AddFail); return(false); }
//添加 public bool AddCard() { if (!dataform.CheckOpen()) { return(false); } Card c = dataform.GetCard(); if (c.id <= 0)//卡片密码不能小于等于0 { MyMsg.Error(LMSG.CodeCanNotIsZero); return(false); } Card[] cards = dataform.GetCardList(false); foreach (Card ckey in cards)//卡片id存在 { if (c.id == ckey.id) { MyMsg.Warning(LMSG.ItIsExists); return(false); } } if (DataBase.Command(dataform.GetOpenFile(), DataBase.GetInsertSQL(c, true)) >= 2) { MyMsg.Show(LMSG.AddSucceed); undoSQL.Add(DataBase.GetDeleteSQL(c)); undoModified.Add(new FileModified()); undoDeleted.Add(new FileDeleted()); undoCopied.Add(new DBcopied()); dataform.Search(true); dataform.SetCard(c); return(true); } MyMsg.Error(LMSG.AddFail); 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); }
public bool Execute(params object[] args) { if (!dataform.CheckOpen()) { return(false); } Card[] cards = (Card[])args[0]; if (cards == null || cards.Length == 0) { return(false); } bool replace = false; Card[] oldcards = DataBase.Read(dataform.GetOpenFile(), true, ""); if (oldcards != null && oldcards.Length != 0) { int i = 0; foreach (Card oc in oldcards) { foreach (Card c in cards) { if (c.id == oc.id) { i += 1; if (i == 1) { replace = MyMsg.Question(LMSG.IfReplaceExistingCard); break; } } } if (i > 0) { break; } } } _ = DataBase.CopyDB(dataform.GetOpenFile(), !replace, cards); copied = true; newCards = cards; this.replace = replace; oldCards = oldcards; return(true); }
public bool Excute(params object[] args) { if (!dataform.CheckOpen()) { return(false); } bool modfiles = (bool)args[0]; Card c = dataform.GetCard(); Card oldCard = dataform.GetOldCard(); if (c.Equals(oldCard)) //没有修改 { MyMsg.Show(LMSG.ItIsNotChanged); return(false); } if (c.id <= 0) { MyMsg.Error(LMSG.CodeCanNotIsZero); return(false); } string sql; if (c.id != oldCard.id) //修改了id { sql = DataBase.GetInsertSQL(c, false); //插入 bool delold = MyMsg.Question(LMSG.IfDeleteCard); if (delold) //是否删除旧卡片 { if (DataBase.Command(dataform.GetOpenFile(), DataBase.GetDeleteSQL(oldCard)) < 2) { //删除失败 MyMsg.Error(LMSG.DeleteFail); delold = false; } else { //删除成功,添加还原sql _undoSQL = DataBase.GetDeleteSQL(c) + DataBase.GetInsertSQL(oldCard, false); } } else { _undoSQL = DataBase.GetDeleteSQL(c); //还原就是删除 } //如果删除旧卡片,则把资源修改名字,否则复制资源 if (modfiles) { if (delold) { YGOUtil.CardRename(c.id, oldCard.id, dataform.GetPath()); } else { YGOUtil.CardCopy(c.id, oldCard.id, dataform.GetPath()); } this.modifiled = true; this.oldid = oldCard.id; this.newid = c.id; this.delold = delold; } } else { //更新数据 sql = DataBase.GetUpdateSQL(c); _undoSQL = DataBase.GetUpdateSQL(oldCard); } if (DataBase.Command(dataform.GetOpenFile(), sql) > 0) { MyMsg.Show(LMSG.ModifySucceed); dataform.Search(true); dataform.SetCard(c); return(true); } else { MyMsg.Error(LMSG.ModifyFail); } return(false); }