示例#1
0
        public bool SaveModel(string ID = "")
        {
            string table = ((Main)GetWindowByName("Main")).GetCurrentList();


            if (ID == "" && DetailMovie != null && DetailMovie.id.ToUpper() == id.ToUpper())
            {
                InsertMovie(table);
                return(true);
            }


            id = ID;
            if (DetailMovie != null)
            {
                if (DetailMovie.id.ToUpper() != id.ToUpper())
                {
                    //修改了原来的识别码
                    if (string.IsNullOrEmpty(table))
                    {
                        if (DataBase.SelectMovieByID(ID) != null)
                        {
                            return(false);
                        }
                        DataBase.DeleteByField("movie", "id", DetailMovie.id);
                        DetailMovie.id = id;
                        DataBase.InsertFullMovie(DetailMovie);
                    }
                    else
                    {
                        //修改了清单中的识别码
                        using (MySqlite mySqlite = new MySqlite("mylist"))
                        {
                            if (mySqlite.SelectMovieBySql($"select * from {table} where id='{ID}'") != null)
                            {
                                return(false);
                            }

                            mySqlite.DeleteByField(table, "id", DetailMovie.id);
                            DetailMovie.id = id;
                            mySqlite.InsertFullMovie(DetailMovie, table);
                        }
                    }
                }
                else
                {
                    InsertMovie(table);
                }

                return(true);
            }
            return(false);
        }