예제 #1
0
        //edytcja skryptu Account
        public string EditScript(Script sc)
        {
            SQL sql = new SQL();
            sql.Connect();

            Script script = sql.ReturnScriptByID(sc.ID);
            script.Content = sc.Content;
            if (script.CheckDate())//jesli true to daty sie zgadzaja
            {
                script.Version += 1;
                //instrukcja dla nadania wersji i unikalnej nazwy
                script.CreateUniqueName();

                while(sql.CheckUniqueName(script.UniqueName))
                {
                    script.Version += 1;
                    script.CreateUniqueName();
                }

                script.DateOfCreate = DateTime.Now;
            }
            else
            {
                script.Version = 0;
                script.CreateUniqueName();
                while (sql.CheckUniqueName(script.UniqueName))
                {
                    script.Version += 1;
                    script.CreateUniqueName();
                }
                script.DateOfCreate = DateTime.Now;
            }
            if (sql.EditScript(script))
            {
                sql.Close();
                return "Edytowano pomyślnie: " + script.UniqueName;
            }
            else
            {
                sql.Close();
                return "Nie udało się.";
            }
        }