Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Eduardo Martínez V.
Programación .Net 2
Instituto IACC
17-10-2021
Desarrollo
namespace Excepciones
{
public partial class Inmobiliaria : Form
{
if (!string.IsNullOrEmpty(txtCodigo.Text))
{
int largo = txtCodigo.Text.Length;
if (largo == 5)
{
validaLetras(txtCodigo.Text.Substring(0, 2));
validaNumeros(txtCodigo.Text.Substring(2, 3));
}
else
throw new Exception("El codigo debe ser de largo 5, 2 letras
y 3 numeros.");
}
else
throw new Exception("Debe ingresar Codigo");
if (!string.IsNullOrEmpty(txtUbicacion.Text))
{
string ubicacion = txtUbicacion.Text.Trim().ToUpper();
if (!string.IsNullOrEmpty(txtBanos.Text))
{
int banos = Convert.ToInt32(txtBanos.Text);
if (banos < 1 || banos > 3)
throw new Exception("El numero de baños debe estar dentro
del rango 1-2");
}
else
throw new Exception("Debe ingresar numero de dormitorios");
}
catch (FormatException ex)
{
count++;
MessageBox.Show($"ERROR:{ex.Message}", "FormatException");
}
catch (Exception ex)
{
count++;
MessageBox.Show($"ERROR:{ex.Message}", "Exception");
}
finally
{
if (count == 0)
{
MessageBox.Show("Sin Errores");
MostrarResumen();
}
else
MessageBox.Show("Se presentaron errores de validacion");
}
}
if (pos1 == 0)
throw new Exception("El primero no puede ser cero");
}
catch (Exception ex)
{
throw new Exception($"Valida codigo numeros {ex.Message}");
}
if (vocales.Contains(let1) || vocales.Contains(let2))
throw new Exception("No pueden haber vocales");
if (let1 == let2)
throw new Exception("No puede haber 2 consonantes iguales");
try
{
decimal valorUF = decimal.Parse(txtValorUf.Text);
decimal valorDepaUF = decimal.Parse(txtValorDepa.Text);
decimal valorPesos = valorDepaUF * valorUF;
}
catch (Exception ex)
{
}
}
}
Salida
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Excepciones
{
public partial class Info : Form
{
public Info(string resumen)
{
InitializeComponent();
txtResumen.Text = resumen;
}
}
}