public void addNewOwner()
        {
            ctx = new AutoDBEntities();
            int id = findIdOfOwner();

            if (id != 0)
            {
                return;
            }
            a = new OWNER();
            if (Egn.Length != 10)
            {
                MessageBox.Show("EGN ERROR!"); return;
            }
            a.NAME = Name1;

            a.EGN = Egn;
            if (Adress.Length > 20 && Adress.Length != 0)
            {
                MessageBox.Show("ADRESS ERROR!"); return;
            }
            a.ADDRESS = Adress;
            idd       = generateID();
            //  a.ID = idd;
            ctx.OWNERS.Add(a);

            ctx.SaveChanges();
            ctx.Dispose();
        }
Esempio n. 2
0
 public void RegistButton(object sender)
 {
     if (ww != null)
     {
         ww.Close();
         ww = null;
     }
     Application.Current.Windows[0].Close();
     rr = new Registration();
     rr.Show();
     ctx.Dispose();
 }
        public void FillUsers()
        {
            var q = (from a in ctx.USERS
                     select a).ToList();

            this.Users = new ObservableCollection <USER>(q);
            foreach (object o in Users)
            {
                Console.WriteLine(o);
            }
            ctx.Dispose();
        }
        public void addNewUser()
        {
            ctx = new AutoDBEntities();
            USER u = new USER();

            //   u.Id = generateID();
            u.USER1    = User;
            u.PASSWORD = Password;
            u.OWNER    = a;
            //   u.OWNERS_ID = idd;
            Console.WriteLine(u.USER1 + " " + u.PASSWORD + " " + u.OWNERS_ID);
            ctx.USERS.Add(u);
            ctx.SaveChanges();
            ctx.Dispose();
        }