Пример #1
0
 private void formRanchos_Load(object sender, EventArgs e)
 {
     dgvInfoRanchos.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
     dgvInfoRanchos.Size      = new Size(this.Width - 40, this.Height - 200);
     dgvInfoRanchos.Location  = new Point(20, 150);
     btnReporteExcel.Location = new Point(this.Width - 140, this.Size.Height - 40);
     btnAdminRanchos.Location = new Point(this.Width - 170, 50);
     label1.Location          = new Point(this.Width - 220, 95);
     btnActualizar.Location   = new Point(20, this.Size.Height - 40);
     listaRanchos             = Rancho.GetRanchos();
     ActualizarTabla();
 }
Пример #2
0
        private void Consultar()
        {
            var rancho = Rancho.Select(txtCodigoRancho.Text);

            if (rancho.Codigo != null)
            {
                btnGuardar.Text = "Actualizar";
                editar          = true;
                ControlesEditables();
                txtHectareas.Text     = rancho.Hectareas.ToString();
                txtTipoVarietal.Text  = rancho.TipoVarietal.ToString();
                txtTablaVarietal.Text = rancho.TablaVarietal.ToString();
                cbSupervisor.Text     = rancho.IdSupervisor;
            }
            else
            {
                ControlesEditables();
            }
        }
Пример #3
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (editar)
            {
                var existente = new Rancho
                {
                    Codigo        = txtCodigoRancho.Text,
                    Hectareas     = float.Parse(txtHectareas.Text),
                    TipoVarietal  = int.Parse(txtTipoVarietal.Text),
                    TablaVarietal = int.Parse(txtTablaVarietal.Text),
                    IdSupervisor  = cbSupervisor.Text
                };

                if (existente.Update())
                {
                    MessageBox.Show("Insertado");
                    Limpiar();
                }
                else
                {
                    MessageBox.Show("Ocurrio un error");
                }
            }
            else
            {
                if (string.IsNullOrEmpty(txtCodigoRancho.Text))
                {
                    MessageBox.Show("Ingresa el codigo de rancho");
                    txtCodigoRancho.Focus();
                }
                else
                if (string.IsNullOrEmpty(txtHectareas.Text))
                {
                    MessageBox.Show("Ingresa las hectareas");
                    txtHectareas.Focus();
                }
                else
                if (string.IsNullOrEmpty(txtTablaVarietal.Text))
                {
                    MessageBox.Show("Ingresa tabla varietal");
                    txtTablaVarietal.Focus();
                }
                else
                if (string.IsNullOrEmpty(txtTipoVarietal.Text))
                {
                    MessageBox.Show("Ingresa tipo varietal");
                    txtTipoVarietal.Focus();
                }
                else
                if (cbSupervisor.SelectedIndex.Equals(-1))
                {
                    MessageBox.Show("Selecciona un supervisor");
                    cbSupervisor.Focus();
                }
                else
                {
                    var nuevo = new Rancho
                    {
                        Codigo        = txtCodigoRancho.Text,
                        Hectareas     = float.Parse(txtHectareas.Text),
                        TipoVarietal  = int.Parse(txtTipoVarietal.Text),
                        TablaVarietal = int.Parse(txtTablaVarietal.Text),
                        IdSupervisor  = cbSupervisor.Text
                    };

                    if (nuevo.Insert())
                    {
                        MessageBox.Show("Insertado");
                        Limpiar();
                    }
                    else
                    {
                        MessageBox.Show("Ocurrio un error");
                    }
                }
            }
        }
Пример #4
0
 private void btnActualizar_Click(object sender, EventArgs e)
 {
     listaRanchos = Rancho.GetRanchos();
     ActualizarTabla();
 }