Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        public void DeleteCosplan(int nummer)
        {
            Cosplans cosplans = new Cosplans
            {
                Where = "Nummer = " + nummer
            };

            cosplans.Read();
            if (!cosplans.EoF)
            {
                cosplans.Delete();
            }
        }
Beispiel #3
0
        public Cosplans GetCosplans(int?franchise_nr = null)
        {
            Cosplans cosplans = new Cosplans();

            if (franchise_nr == null || franchise_nr == 0)
            {
                cosplans.Where = "Nummer is not null";
            }
            else
            {
                cosplans.Where = "Franchise_Nr = " + franchise_nr;
            }
            cosplans.OrderBy = this.CosplansOrderBy.ToString().Replace("_", " ");
            cosplans.Read();

            return(cosplans);
        }
Beispiel #4
0
        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);
            }
        }