Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("CustomerId,CustomerTile,CustomerForenames,CustomerSurnames,CustomerDOB,CustomerAddressStreet,CustomerAddressTown,CustomerAddressSCountry,CustomerAddressPostalCode,CustomerContactPhone,CustomerWorkPhone,CustomerMobibletPhone,ContactEmailAddress")] Custumers custumers)
        {
            if (id != custumers.CustomerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(custumers);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustumersExists(custumers.CustomerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(custumers));
        }
Exemplo n.º 2
0
        public static List <Custumers> Listado()
        {
            List <Custumers> cl = null;
            Custumers        ob;

            SQL = "SELECT * from customers";
            MySqlDataReader rg = Mysqlcon.Query(SQL);

            cl = new List <Custumers>();
            while (rg.Read())
            {
                ob                   = new Custumers();
                ob.Number            = rg.GetInt32("customerNumber");//campo en DB
                ob.Name              = rg.GetString("customerName");
                ob.ConstactFirstName = rg.GetString("contactFirstName");
                ob.ContactLastName   = rg.GetString("contactLastName");
                ob.Phone             = rg.GetString("phone");
                ob.AddressLine1      = rg.GetString("addressLine1");
                ob.City              = rg.GetString("city");
                ob.Country           = rg.GetString("country");
                ob.CreditLimit       = rg.GetDouble("creditLimit");
                cl.Add(ob);
            }
            rg.Close();
            return(cl);
        }//end Listado
        public PageAddEditCustumers(Custumers selectClient)
        {
            InitializeComponent();
            if (selectClient != null)
            {
                _ccurrnetClients = selectClient;
            }

            DataContext = _ccurrnetClients;
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("CustomerId,CustomerTile,CustomerForenames,CustomerSurnames,CustomerDOB,CustomerAddressStreet,CustomerAddressTown,CustomerAddressSCountry,CustomerAddressPostalCode,CustomerContactPhone,CustomerWorkPhone,CustomerMobibletPhone,ContactEmailAddress")] Custumers custumers)
        {
            if (ModelState.IsValid)
            {
                _context.Add(custumers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(custumers));
        }
        private void BtnAddservice_Click(object sender, RoutedEventArgs e)
        {
            if (_ccurrnetServices.Cost <= 0)
            {
                MessageBox.Show("Цена должна быть больше 0");
                return;
            }

            Categoris p = (Categoris)CBoxServices.SelectedItem;

            _ccurrnetServices.IdCategory = p.Id;
            Custumers o = (Custumers)CBoxCustumers.SelectedItem;

            _ccurrnetServices.IdCustumer = p.Id;

            if (_ccurrnetServices.Id == 0)
            {
                WildberriesEntities1.GetContext().Services.Add(_ccurrnetServices);
            }

            try
            {
                WildberriesEntities1.GetContext().SaveChanges();
                MessageBox.Show("Услуга успешно сохранена");
                NavManager.AccountFrame.Navigate(new PageServices(NavManager.BtnServices.Content + ""));
            }
            catch (DbEntityValidationException ex)
            {
                if (ApplicationConfig.IsDev)
                {
                    foreach (var errors in ex.EntityValidationErrors)
                    {
                        foreach (var validationError in errors.ValidationErrors)
                        {
                            MessageBox.Show(validationError.ErrorMessage);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Произошла ошибка", "Внимание", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
        }
Exemplo n.º 6
0
        }//end Listado

        public static Custumers Buscar(int Number)
        {
            Custumers ob = null;

            SQL = $"SELECT * FROM customers WHERE customerNumber = { Number}";
            MySqlDataReader rg = Mysqlcon.Query(SQL);

            if (rg.Read())
            {
                ob        = new Custumers();
                ob.Number = rg.GetInt32("customerNumber");//campo en DB
                ob.Name   = rg.GetString("customerName");
                String date   = rg.GetString("addressLine2");
                String adress = (date != "") ? " " + rg.GetString("addressLine2") : "";
                ob.AddressLine1           = rg.GetString("addressLine1") + " - " + adress;
                ob.Phone                  = rg.GetString("phone");
                ob.SalesRepEmployeeNumber = rg.GetInt32("salesRepEmployeeNumber");
            }
            rg.Close();
            return(ob);
        }//end Buscar
Exemplo n.º 7
0
        public static void Initializate(Examen2Contex context)
        {
            context.Database.EnsureCreated(); // crea bd si no existe

            if (context.Guests.Any())
            {
                // la bd ya tiene datos
            }
            else
            {
                var Guests = new Guests[] {
                    new Guests {
                        GuestTile          = "guest1", GuestAddressPostalCode = "1234", GuestAddressSCountry = "MEX",
                        GuestAddressStreet = "SN luis", GuestAddressTown = "x", GuestContactPhone = "1234567890", GuestForenames = "x", GuestsDOB = "x", GuestSurnames = "x"
                    },
                    new Guests {
                        GuestTile          = "guest2", GuestAddressPostalCode = "4321", GuestAddressSCountry = "US",
                        GuestAddressStreet = "", GuestAddressTown = "d", GuestContactPhone = "0987654321", GuestForenames = "", GuestsDOB = "a", GuestSurnames = "a"
                    },
                    new Guests {
                        GuestTile          = "guest3", GuestAddressPostalCode = "2222", GuestAddressSCountry = "MEX",
                        GuestAddressStreet = "", GuestAddressTown = "q", GuestContactPhone = "0978654322", GuestForenames = "guest", GuestsDOB = "q", GuestSurnames = "a"
                    },
                    new Guests {
                        GuestTile          = "guest4", GuestAddressPostalCode = "1111", GuestAddressSCountry = "US",
                        GuestAddressStreet = "", GuestAddressTown = "q", GuestContactPhone = "1234567899", GuestForenames = "guest", GuestsDOB = "DOB", GuestSurnames = "surnames"
                    }
                };
                // pasar el arreglo a la tabla de FilmGeneres en el modelo
                foreach (Guests g in Guests)
                {
                    context.Guests.Add(g);
                }


                context.SaveChanges();
            }



            if (context.Custumers.Any())
            {
                return; // la bd ya tiene datos
            }

            var Custumers = new Custumers[] {
                new Custumers {
                    CustomerAddressPostalCode = "9999", CustomerAddressSCountry = "MEX", CustomerSurnames = "Armando",
                    ContactEmailAddress       = "*****@*****.**", CustomerContactPhone = "0987654321",
                    CustomerAddressStreet     = "Colon #66", CustomerAddressTown = "x",
                    CustomerDOB       = "ok", CustomerForenames = "Forenames", CustomerMobibletPhone = "1234567890", CustomerTile = "Cliente 1",
                    CustomerWorkPhone = "1234567899"
                },
            };

            foreach (Custumers g in Custumers)
            {
                context.Custumers.Add(g);
            }

            context.SaveChanges();
        }