Exemplo n.º 1
0
 private void btnBuscaID_Click(object sender, EventArgs e) //boton buscar por id
 {
     try
     {
         dataGridView1.DataSource = SearchID.Get(Convert.ToInt32(txtIDproduct.Text.Trim()));
     }
     catch (Exception fatallity)
     {
         MessageBox.Show("Error: " + fatallity.Message);
     }
 }
 void GetUserCollection(object parameter)
 {
     if (SearchID.IsEmpty() == false)
     {
         //collectionLogList = new ObservableCollection<CollectionEntry>(userCollectionModel.GetUserCollectionList(SearchID));
         CollectionLogList = userCollectionModel.GetCollectionsLog(start, itemCount, ascending, SearchID, selectedDate, out totalItems);
         NotifyPropertyChanged("Start");
         NotifyPropertyChanged("End");
         NotifyPropertyChanged("TotalItems");
         if (CollectionLogList.IsEmpty() == false)
         {
             this.OnPropertyChanged(new PropertyChangedEventArgs("collectionLogList"));
         }
         else
         {
             MessageBox.Show("User ID is not present");
         }
     }
     else
     {
         MessageBox.Show("Enter User ID to search");
     }
 }
Exemplo n.º 3
0
        private void btnUpdateReg_Click(object sender, EventArgs e) //btn guardar  registro Actualizado
        {
            //guardar una talla
            try
            {
                if (string.IsNullOrWhiteSpace(cmboSize.Text.Trim()))
                {
                }
                else
                {
                    //buscar id de la talla seleccionada
                    int IdSizze = SearchID.SearchIDSize(cmboSize.Text);
                    //buscar id del producto
                    var Idproducto = QueryProducts.EncuentraIdProducts(cmbBuscarProd.Text.Trim());
                    //Insertar la talla y el id del producto en tabla SizeOfProduct
                    InsertaProducto.InsertarTalla(Idproducto, IdSizze);
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: " + error.Message);
            }

            //guardar el registro actualizado

            DateTime thisDay = DateTime.Today;
            var      fecha   = thisDay.ToString();
            //buscar id del producto
            var Idproducto2 = QueryProducts.EncuentraIdProducts(cmbBuscarProd.Text.Trim());
            //lista de datos
            List <string> cadenaUpdate = new List <string>();

            cadenaUpdate.Add(cmbTypeUpdate.Text);                                                        //typyId
            cadenaUpdate.Add(Convert.ToString(QueryColor.EncuentraIdColor(cmbColorUpdate.Text)));        //buscar el id del color y agregarlo a la lista
            cadenaUpdate.Add(Convert.ToString(QueryBrand.EncuentraIdBrand(cmbMarcaUpdate.Text)));        //busca id y agregar a la lista
            cadenaUpdate.Add(Convert.ToString(QueryProvider.EncuentraIdProvider(cmbProveeUpdate.Text))); // busca id y agrega a la lista
            cadenaUpdate.Add(Convert.ToString(QueryCatalog.EncuentraIdCatalog(cmbCatalogoUpdate.Text))); // busca id y agrega a la lista
            cadenaUpdate.Add(txtTitleUpdate.Text);                                                       // Title
            cadenaUpdate.Add(txtNombreUpdate.Text);                                                      // Nombre
            cadenaUpdate.Add(txtDescUpdate.Text);                                                        // Descripcion
            cadenaUpdate.Add(txtObsUpdate.Text);                                                         //observaciones
            cadenaUpdate.Add(txtPriceDisUpdate.Text);                                                    //price distributor
            cadenaUpdate.Add(txtPriceClientUpdate.Text);                                                 //price client
            cadenaUpdate.Add(txtPriceMemberUpdate.Text);                                                 //price Member
            cadenaUpdate.Add(cmbEnableUpdate.Text);                                                      //Enable
            cadenaUpdate.Add(txtKeywordsUpdate.Text);                                                    //keywords
            cadenaUpdate.Add(fecha);                                                                     //fecha y hora
            try
            {
                UpdateProducto.ActualizarProducto(Idproducto2, cadenaUpdate);    //envio de la cadena a la funcion
                MessageBox.Show("Registro Guardado");
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: " + error.Message);
            }
            //guardar imagen
            var context = new DataProductsEntities();

            if (txtImgDesc.Text.Trim().Equals(""))
            {
            }                                           //si esta vacio no pasa nada, no es necesario guardar img, es opcional
            else
            {
                //crear memoria de bytes
                byte[] file     = null;
                Stream myStream = openFileDialog1.OpenFile();
                using (MemoryStream ms = new MemoryStream())
                {
                    myStream.CopyTo(ms);
                    file = ms.ToArray();
                }
                var logic = 0;
                if (cmbEnableUpdate.Text == "YES")
                {
                    logic = 1;
                }
                else
                {
                    logic = 0;
                }
                GuardarImagen.RegistraImagen(Idproducto2, txtImgDesc.Text.Trim(), file, fecha, logic);
                MessageBox.Show("Registro completado con exito");
            }
        }