public void Listar() { cterreno ter = new cterreno(); if (cmbestado.Text == "TODOS") { ter.ListarLibres(dataGridView1, txtidterreno.Text); } else { ter.ListarLibresReservado(dataGridView1, txtidterreno.Text, cmbestado.Text); // MessageBox.Show(cmbestado.Text); } txtlibre.Text = ter.TerrenosLibres(); txtreservado.Text = ter.TerrenosReservados(); txttotal.Text = ter.TerrenosTotal(); }
private void btnaceptar_Click(object sender, EventArgs e) { cterreno ter = new cterreno(); if (!ter.Duplicado(txtidterreno.Text)) { if (dataGridView1.RowCount > 3) { //guardar terreno ter.Idterreno = txtidterreno.Text; ter.IdUrbanizacion = int.Parse((cmburbanizacion.SelectedValue).ToString()); ter.Idtipo = int.Parse((cmbtipoterreno.SelectedValue).ToString()); ter.MetrosCuadrados = txtmetros.Text; ter.EstadoReserva = "LIBRE"; ter.Precio = txtprecio.Text; ter.Estado = "HABILITADO"; ter.Registrar(); // guardar coordenadas for (int i = 0; i < dataGridView1.RowCount; i++) { ccoordenada cor = new ccoordenada(); cor.CodLote = txtidterreno.Text; cor.Latitud = dataGridView1[1, i].Value.ToString(); cor.Longitud = dataGridView1[2, i].Value.ToString(); cor.Registrar(); } MessageBox.Show("Terreno registrado correctamente"); Limpiar(); ultimoreg = txtidterreno.Text; CargarTerrenos(); DibujarLotes(); } else { MessageBox.Show("Error al guardar. \n Inserte las coordenadas del terreno.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Error al intentar Guardar, ya existe el Terreno.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void txtidterreno_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { //enter key is down if (txtidterreno.TextLength > 2) { if (ter.ExisteTerreno(txtidterreno.Text)) { btnadicionar.Enabled = true; ter = ter.ObtenerRegistro(txtidterreno.Text); if (ter.Estado == "DESHABILITADO") { MessageBox.Show("El terreno se encuentra Deshabilitado."); txtidterreno.SelectAll(); txtidterreno.Focus(); } else { txtmetros.Text = ter.MetrosCuadrados; txtprecio.Text = ter.Precio; txtestado.Text = ter.EstadoReserva; btnadicionar.Focus(); } } else { //dataGridView1.Rows.Clear(); MessageBox.Show("No existe el terreno."); btnadicionar.Enabled = false; txtidterreno.Focus(); txtidterreno.SelectAll(); } } else { //dataGridView1.Rows.Clear(); } } }