コード例 #1
0
 public Deposito()
 {
     this.BackgroundImage       = Properties.Resources.Libros;
     this.BackgroundImageLayout = ImageLayout.Stretch;
     this.SetStyle(
         ControlStyles.AllPaintingInWmPaint |
         ControlStyles.DoubleBuffer,
         true);
     InitializeComponent();
     //FormGrid();
     Form1_Load();
     Form2_Load();
     Form3_Load();
     aux = new UserData
     {
         Nombre       = "",
         Autor        = "",
         ISBN         = "",
         Edicion      = "",
         AñoImpresion = "",
         Modelo       = "",
         Idioma       = ""
     };
     auxSearcher = new ProductSearchModel
     {
     };
     auxColeccion    = new ProductLibroLogic();
     libros          = auxColeccion.GetLibros(auxSearcher);
     CollectionTotal = libros;
     InitializeListView();
 }
コード例 #2
0
 public RetiroDeLibro()
 {
     this.BackgroundImage       = Properties.Resources.Libros;
     this.BackgroundImageLayout = ImageLayout.Stretch;
     this.SetStyle(
         ControlStyles.AllPaintingInWmPaint |
         ControlStyles.DoubleBuffer,
         true);
     InitializeComponent();
     Form2_Load();
     Form1_Load();
     FormGrid();
     auxSearcher = new ProductSearchModel
     {
     };
     aux = new UserDataMin
     {
         Nombre      = "",
         PrecioPeso  = 0,
         PrecioDolar = 0,
         Cantidad    = 0,
     };
     aux2 = new UserDataMin
     {
         Nombre      = "",
         PrecioPeso  = 0,
         PrecioDolar = 0,
         Cantidad    = 0,
     };
     coleccion = new List <UserDataMin>();
 }
コード例 #3
0
        /* private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
         * {
         *   selected = this.comboBox1.GetItemText(this.comboBox1.SelectedItem);
         *
         *   if (comboBox1.SelectedIndex > -1)
         *   {
         *       listView1.Clear();
         *       FormGrid();
         *       CargarDeposito(selected);
         *
         *   }
         * }
         *
         *    public string Nombre { get; set; }
         *   public string Autor { get; set; }
         *   public int? PriceFrom { get; set; }
         *   public int? PriceTo { get; set; }
         *   public int? Cantidad { get; set; }
         *   public int? CantidadFrom { get; set; }
         *   public int? PrecioPeso { get; set; }
         *   public int? PrecioDolar { get; set; }
         *   public string ISBN { get; set; }
         *   public string Edicion { get; set; }
         *   public string AñoImpresion { get; set; }
         *   public string Modelo { get; set; }
         *   public string Idioma { get; set; }
         */

        private void button2_Click(object sender, EventArgs e)
        {
            auxSearcher = new ProductSearchModel
            {
                Nombre       = textBox8.Text,
                Autor        = textBox9.Text,
                ISBN         = textBox10.Text,
                Edicion      = textBox11.Text,
                AñoImpresion = textBox7.Text,
                Idioma       = textBox12.Text,
            };

            if (numericUpDown3.Value > 0)
            {
                auxSearcher.CantidadFrom = Convert.ToInt32(numericUpDown3.Value);
            }
            if (comboBox6.SelectedItem != null)
            {
                auxSearcher.Modelo = comboBox6.SelectedItem.ToString();
            }
            if (!String.IsNullOrEmpty(textBox14.Text))
            {
                auxSearcher.PriceFrom = Convert.ToInt32(textBox14.Text);
            }
            if (!String.IsNullOrEmpty(textBox13.Text))
            {
                auxSearcher.PriceTo = Convert.ToInt32(textBox13.Text);
            }


            /*listView1.Clear();
             * FormGrid();*/
            auxColeccion = new ProductLibroLogic();
            libros       = auxColeccion.GetLibros(auxSearcher);
            InitializeListView();
        }
コード例 #4
0
        public List <UserData> GetLibros(ProductSearchModel searchModel)
        {
            Global Global     = new Global();
            var    result     = new List <UserData>();
            var    aux2       = new UserData();
            var    client     = new MongoClient(Global.Path_DataBase);
            var    database   = client.GetDatabase("app_libro");
            var    collection = database.GetCollection <BsonDocument>("Stock");
            var    builder    = Builders <BsonDocument> .Filter;
            var    filter     = builder.Empty;

            if (searchModel != null)
            {
                if (!string.IsNullOrEmpty(searchModel.Nombre))
                {
                    filter = filter & (builder.Eq("Nombre", searchModel.Nombre));
                }
                if (!string.IsNullOrEmpty(searchModel.Autor))
                {
                    filter = filter & (builder.Eq("Autor", searchModel.Autor));
                }
                if (searchModel.PriceFrom.HasValue)
                {
                    filter = filter & (builder.Gt("PrecioPeso", searchModel.PriceFrom - 1));
                }
                if (searchModel.PriceTo.HasValue)
                {
                    filter = filter & (builder.Lt("PrecioPeso", searchModel.PriceTo));
                }
                if (searchModel.Cantidad.HasValue)
                {
                    filter = filter & (builder.Eq("Cantidad", searchModel.Cantidad));
                }
                if (searchModel.CantidadFrom.HasValue)
                {
                    filter = filter & (builder.Gt("Cantidad", searchModel.CantidadFrom - 1));
                }
                if (searchModel.PrecioPeso.HasValue)
                {
                    filter = filter & (builder.Eq("PrecioPeso", searchModel.PrecioPeso));
                }
                if (searchModel.PrecioDolar.HasValue)
                {
                    filter = filter & (builder.Eq("PrecioDolar", searchModel.PrecioDolar));
                }
                if (!string.IsNullOrEmpty(searchModel.ISBN))
                {
                    filter = filter & (builder.Eq("ISBN", searchModel.ISBN));
                }
                if (!string.IsNullOrEmpty(searchModel.Edicion))
                {
                    filter = filter & (builder.Eq("Edicion", searchModel.Edicion));
                }
                if (!string.IsNullOrEmpty(searchModel.AñoImpresion))
                {
                    filter = filter & (builder.Eq("AñoImpresion", searchModel.AñoImpresion));
                }
                if (!string.IsNullOrEmpty(searchModel.Modelo))
                {
                    filter = filter & (builder.Eq("Modelo", searchModel.Modelo));
                }
                if (!string.IsNullOrEmpty(searchModel.Idioma))
                {
                    filter = filter & (builder.Eq("Idioma", searchModel.Idioma));
                }
            }
            var result2 = collection.Find(filter).ToList();

            /*if(result2 == null)
             * {
             *  MessageBox.Show("hola");
             * }*/
            foreach (var doc in result2)
            {
                /*BsonClassMap.RegisterClassMap<UserData>(cm => {
                 *  cm.MapIdField("Nombre");
                 *  cm.MapField("Autor");
                 *  cm.MapIdField("Cantidad");
                 *  cm.MapField("PrecioPeso");
                 *  cm.MapIdField("PrecioDolar");
                 *  cm.MapField("ISBN");
                 *  cm.MapField("Edicion");
                 *  cm.MapField("AñoImpresion");
                 *  cm.MapField("Modelo");
                 *  cm.MapField("Idioma");
                 * });*/
                //aux2 = BsonSerializer.Deserialize<UserData>(doc);

                /*aux2 = new UserData()
                 * {
                 *  Nombre = doc["Nombre"].AsString,
                 *  Autor = doc["Autor"].AsString,
                 *  Cantidad = doc["Cantidad"].AsInt32,
                 *  PrecioPeso = doc["PrecioPeso"].AsInt32,
                 *  PrecioDolar = doc["PrecioDolar"].AsInt32,
                 *  ISBN = doc["ISBN"].AsString,
                 *  Edicion = doc["Edicion"].AsString,
                 *  AñoImpresion = doc["AñoImpresion"].AsString,
                 *  Modelo = doc["Modelo"].AsString,
                 *  Idioma = doc["Idioma"].AsString
                 * };*/

                aux2 = new UserData
                {
                    Nombre       = doc.GetValue("Nombre", null).AsString,
                    Autor        = doc.GetValue("Autor", null).AsString,
                    Cantidad     = (doc.GetValue("Cantidad", 0).AsInt32),
                    PrecioPeso   = doc.GetValue("PrecioPeso", 0).AsInt32,
                    PrecioDolar  = doc.GetValue("PrecioDolar", 0).AsInt32,
                    ISBN         = doc.GetValue("ISBN", "N/A").AsString,
                    Edicion      = doc.GetValue("Edicion", "N/A").AsString,
                    AñoImpresion = doc.GetValue("AñoImpresion", "N/A").AsString,
                    Modelo       = doc.GetValue("Modelo", "N/A").AsString,
                    Idioma       = doc.GetValue("Idioma", "N/A").AsString,
                };
                result.Add(aux2);
            }
            return(result);
        }