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();
        }
      private void InsuranceButton(object sender)
      {
          if (InsuranceDate == null || InsuranceDate == null || YearsOwner == null || Period == null || YearsCar == null)
          {
              MessageBox.Show("всички полета са задължителни");
              return;
          }

          INSURANCE i = new INSURANCE();

          i.DATE_EXPIRE   = insuranceDate;
          i.ENGINE_LITERS = engine;
          i.OWNERAGE      = yearsOwner;
          i.PERIOD        = period;
          i.PRICE         = finalPrice;
          i.YEAROFCAR     = yearsCar;
          INSURANCE_INFO info = new INSURANCE_INFO();

          if (SelectedCar == null)
          {
              MessageBox.Show("Моля изберете автомобил!");
              return;
          }
          info.CAR       = SelectedCar;
          info.INSURANCE = i;
          ctx.INSURANCE_INFO.Add(info);
          ctx.SaveChanges();
          MessageBox.Show("Гражданската отговорност е създадена!");
      }
示例#3
0
        private void InsuranceCarButton(object sender)
        {
            if (insurancePrice == null || insuranceDate == null)
            {
                MessageBox.Show("всички полета са задължителни");
                return;
            }

            COMPREHENSIVE_COVER c = new COMPREHENSIVE_COVER();

            c.FINAL_PRICE = finalPrice;
            c.PRICE_CAR   = insurancePrice;
            c.DATE_EXPIRE = insuranceDate;

            INFO_COMPREHENSIVE_COVER i = new INFO_COMPREHENSIVE_COVER();

            i.CAR = SelectedCar;

            if (SelectedCar == null)
            {
                MessageBox.Show("Моля изберете автомобил!");
                return;
            }
            i.COMPREHENSIVE_COVER = c;


            ctx.INFO_COMPREHENSIVE_COVER.Add(i);
            ctx.SaveChanges();
            MessageBox.Show("Каското е създадено!");
        }
示例#4
0
        public void FillUser2s()
        {
            USER u = new USER();

            u.USER1    = "12345678";
            u.PASSWORD = "******";

            ctx.USERS.Add(u);
            ctx.SaveChanges();
            // ctx.Database.ExecuteSqlCommand("INSERT INTO OWNERS(ID,EGN,NAME,ADDRESS) values(5,'5','a','b')");
            // ctx.SaveChanges();
        }
        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();
        }
示例#6
0
        private void AddCarButton(object sender)
        {
            Console.WriteLine(Mark);
            Console.WriteLine(model);
            Console.WriteLine(Registration);
            Console.WriteLine(Date); Console.WriteLine(engine);
            if (date == null || engine == 0 || mark == null || registration == null || model == null)
            {
                MessageBox.Show("всички полета са задължителни");
                return;
            }


            CAR c = new CAR();

            c.DATA          = date;
            c.ENGINE_LITERS = engine;
            c.MARK          = mark;
            c.REGISTRATION  = registration;
            c.MODEL         = model;
            bool flag = false;
            var  q    = (from a in ctx.OWNERS
                         select a).ToList();
            ObservableCollection <OWNER> owners = new ObservableCollection <OWNER>(q);

            foreach (OWNER o in owners)
            {
                if (o.NAME == NavigaterWindow.user.OWNER.NAME)
                {
                    o.CARS.Add(c);
                    ctx.Entry(o).State = System.Data.Entity.EntityState.Modified;
                    ctx.SaveChanges();
                    flag = true;
                    MessageBox.Show("adding car finished");
                }
            }
            if (!flag)
            {
                MessageBox.Show("Error adding car");
            }
        }