Exemplo n.º 1
0
Arquivo: Core.cs Projeto: AokiMiku/ACP
        public void SaveCosplan(string name = "", int franchise_nr = 0, int?nummer = null, bool erledigt = false)
        {
            Cosplans cosplans = new Cosplans();

            if (!string.IsNullOrEmpty(name))
            {
                cosplans.Name = name;
            }
            if (franchise_nr > 0)
            {
                cosplans.Franchise_Nr = franchise_nr;
            }

            if (nummer == null)
            {
                cosplans.Erledigt = false;
                cosplans.Save(ApS.Databases.SqlAction.Insert);
            }
            else
            {
                cosplans.Where    = "Nummer = " + nummer;
                cosplans.Erledigt = erledigt;
                cosplans.Save(ApS.Databases.SqlAction.Update);
            }
        }
Exemplo n.º 2
0
Arquivo: Core.cs Projeto: AokiMiku/ACP
        public static void ResetCosplanNummern()
        {
            using (Cosplans cosplans = new Cosplans())
            {
                // read highest number
                cosplans.Where     = "Nummer is not null";
                cosplans.OrderBy   = "Nummer desc";
                cosplans.AnzahlTop = 1;

                cosplans.Read();
                int newNummer = cosplans.Nummer + 1;

                cosplans.OrderBy = "Franchise_Nr asc, Nummer asc";
                cosplans.Read();

                while (!cosplans.EoF)
                {
                    cosplans.Where  = "Nummer = " + cosplans.Nummer;
                    cosplans.Nummer = newNummer++;

                    cosplans.Save(ApS.Databases.SqlAction.Update);

                    cosplans.Skip();
                }
                // now reset all
                cosplans.Where = "Nummer is not null";
                cosplans.Read();
                newNummer = 1;
                while (!cosplans.EoF)
                {
                    cosplans.Where  = "Nummer = " + cosplans.Nummer;
                    cosplans.Nummer = newNummer++;

                    cosplans.Save(ApS.Databases.SqlAction.Update);

                    cosplans.Skip();
                }

                string stmt = "ALTER SEQUENCE GEN_COSPLANS_ID RESTART WITH " + --newNummer + ";";
                cosplans.Execute(stmt);
            }
        }