Ejemplo n.º 1
0
            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);
            }
Ejemplo n.º 2
0
            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);
            }
Ejemplo n.º 3
0
        //添加
        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);
        }
Ejemplo n.º 4
0
            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);
            }