Exemple #1
0
        private void Eliminar()
        {
            using (var db = new AcopioDb())
            {
                var fincaBusiness = new FincaBusiness(db);

                fincaBusiness.Delete(finca.FincaId);

                db.SaveChanges();
            }

            this.Nuevo();
        }
Exemple #2
0
        private void FincaView_Load(object sender, EventArgs e)
        {
            using (var db = new AcopioDb())
            {
                db.Database.CreateIfNotExists();
            }

            ComarcaToList();

            ProductorToList();

            this.formIsLoaded = true;
        }
Exemple #3
0
        private void Editar(Finca finca)
        {
            if (Validar(finca))
            {
                using (var db = new AcopioDb())
                {
                    var fincaBusiness = new FincaBusiness(db);

                    fincaBusiness.Edit(finca);

                    db.SaveChanges();
                }
            }
        }
Exemple #4
0
        private void ProductorToList()
        {
            using (var db = new AcopioDb())
            {
                var productorBusiness = new ProductorBusiness(db);

                productorComboBox.DataSource = (from p in productorBusiness.ToList() select new { p.ProductorId, ProductorNombre = $"{ p.ProductorNombres } { p.ProductorApellidos }" }).ToList();

                productorComboBox.ValueMember = "ProductorId";

                productorComboBox.DisplayMember = "ProductorNombre";

                productorComboBox.SelectedIndex = -1;
            }
        }
Exemple #5
0
        private void ComarcaToList()
        {
            using (var db = new AcopioDb())
            {
                var comarcaBusiness = new ComarcaBusiness(db);

                comarcaComboBox.DataSource = comarcaBusiness.ToList();

                comarcaComboBox.ValueMember = "ComarcaId";

                comarcaComboBox.DisplayMember = "ComarcaNombre";

                comarcaComboBox.SelectedIndex = -1;
            }
        }
        private void FincaToList(string filtro = "")
        {
            using (var db = new AcopioDb())
            {
                var fincaBusiness = new FincaBusiness(db);

                fincasDataGridView.DataSource = fincaBusiness
                                                .GetList(filtro)
                                                .Select(c => new {
                    c.FincaId,
                    c.FincaNombre,
                    c.Comarca.ComarcaNombre,
                    c.Productor.ProductorCedula,
                    ProductorNombre = c.Productor.ProductorNombres + " " + c.Productor.ProductorApellidos
                })
                                                .ToList();
            }
        }