public Boolean InsertarJustipreciacionAvaluos(ModeloNegocios.SolicitudAvaluosExt objJustipreciacion) { bool ok = false; //llamado a la capa de datos, para insertar la informacion AccesoDatos.JustipreciacionDAL conn = new AccesoDatos.JustipreciacionDAL(); ok = conn.Inserta(objJustipreciacion); return(ok); }
//RCA 21/08/2017 private Boolean InsertarJustipreciacion() { Boolean Ok = true; try { string strSecuencial = null; if (this.txtFolioBPM.Text.Length > 0) { strSecuencial = this.txtFolioBPM.Text.Trim(); } string strGenerico = null; if (this.TextBox1.Text.Length > 0) { strGenerico = this.TextBox1.Text.Trim(); } //me da un numero que es el idsector string strsector = null; if (this.DropDownSector.SelectedItem.Text != "") { strsector = this.DropDownSector.SelectedValue; } //me da un numero que es el id de institucion string strInstitucion = null; if (this.DropDownListInstitucion.SelectedItem.Text != "") { strInstitucion = this.DropDownListInstitucion.SelectedValue; } decimal SupTerDic = 0; if (this.TextBoxSupDic.Text.Length > 0) { SupTerDic = Convert.ToDecimal(this.TextBoxSupDic.Text.Trim()); } string UnidadSupTerDic = null; if (this.DropDownListUniTer.SelectedItem.Text != "") { UnidadSupTerDic = this.DropDownListUniTer.SelectedValue; } decimal SupConsDic = 0; if (this.TextBoxConsDic.Text.Length > 0) { SupConsDic = Convert.ToDecimal(this.TextBoxConsDic.Text.Trim()); } string UnidadSupConsDic = null; if (this.DropDownListUniCons.SelectedItem.Text != "") { UnidadSupConsDic = this.DropDownListUniCons.SelectedValue; } decimal SupRenDic = 0; if (this.TextBoxRenDic.Text.Length > 0) { SupRenDic = Convert.ToDecimal(this.TextBoxRenDic.Text.Trim()); } string UnidadSupRenDic = null; if (this.DropDownListRenDic.SelectedItem.Text != "") { UnidadSupRenDic = this.DropDownListRenDic.SelectedValue; } decimal MontoDic = 0; if (this.TextBoxMOntoDic.Text.Length > 0) { MontoDic = Convert.ToDecimal(this.TextBoxMOntoDic.Text.Trim()); } string UnidadResponsable = null; if (this.TextBoxUnidadrespon.Text.Length > 0) { UnidadResponsable = TextBoxUnidadrespon.Text.Trim(); } string Calle = null; if (this.TextBoxCalle.Text.Length > 0) { Calle = this.TextBoxCalle.Text.Trim(); } string NumExt = null; if (this.TextBoxNumExt.Text.Length > 0) { NumExt = this.TextBoxNumExt.Text.Trim(); } //no es necesario que este lleno este campo string NumInt = null; if (this.TextBoxNumInt.Text.Length > 0) { NumInt = this.TextBoxNumInt.Text.Trim(); } //me da un numero que es su id string Estado = null; if (this.DropDownListEdo.SelectedItem.Text != "") { Estado = this.DropDownListEdo.SelectedValue; } //me da un numero que es su id string Municipio = null; if (this.DropDownListMpo.SelectedItem.Text != "") { Municipio = this.DropDownListMpo.SelectedValue; } string CP = null; if (this.TextBoxCP.Text.Length > 0) { CP = this.TextBoxCP.Text.Trim(); } //colonia string Colonia = null; if (this.DropDownListColonia.SelectedItem.Text == "- Otra colonia -") { if (this.TextBoxOtraColonia.Text.Length > 0) { Colonia = this.TextBoxOtraColonia.Text.Trim(); } } else { Colonia = this.DropDownListColonia.SelectedItem.Text; } string ruta = null; if (FUJustipreciacion.HasFile) { //llamo a un metodo para guardar el archivo ruta = SaveFile(FUJustipreciacion.PostedFile); } int IdUser = ((SSO)Session["Contexto"]).IdUsuario.Value; if (!string.IsNullOrEmpty(ruta)) { ModeloNegocios.SolicitudAvaluosExt objJustipreciacion = new ModeloNegocios.SolicitudAvaluosExt(); //poblar propiedades objJustipreciacion.NoSecuencial = strSecuencial; objJustipreciacion.NoGenerico = strGenerico; objJustipreciacion.SectorId = Convert.ToInt32(strsector); objJustipreciacion.InstitucionId = Convert.ToInt32(strInstitucion); objJustipreciacion.SuperficieTerrenoDictaminado = SupTerDic; objJustipreciacion.UnidadMedidaTerrenoDictaminado = UnidadSupTerDic; objJustipreciacion.SuperficieConstruidaDictaminado = SupConsDic; objJustipreciacion.UnidadMedidaConstruidaDictaminado = UnidadSupConsDic; objJustipreciacion.SuperficieRentableDictaminado = SupRenDic; objJustipreciacion.UnidadMedidaRentableDictaminado = UnidadSupRenDic; objJustipreciacion.MontoDictaminado = MontoDic; objJustipreciacion.UnidadResponsable = UnidadResponsable; objJustipreciacion.FechaDictamen = Convert.ToDateTime(this.TextBoxFechaDictamen.Text.Trim());//convertimos de string a dategtime objJustipreciacion.Calle = Calle; objJustipreciacion.NoExterior = NumExt; objJustipreciacion.NoInterior = NumInt; objJustipreciacion.ColoniaInmueble = Colonia; objJustipreciacion.EstadoId = Convert.ToInt32(Estado); objJustipreciacion.MunicipioId = Convert.ToInt32(Municipio); objJustipreciacion.CP = CP; objJustipreciacion.RutaDocumento = ruta; objJustipreciacion.IdUsuarioRegistro = IdUser; //se inserta la justipreciacion en el sistema bool Correcto = new NegocioJustipreciacionExt().InsertarJustipreciacionAvaluos(objJustipreciacion); if (Correcto == true) { objJustipreciacion = null; Ok = true; } else { Msj = "No fue posible registrar la justipreciacion, por favor vuelva a intentar ó verifique si ya fue captura el secuencial."; this.LabelInfo.Text = "<div class='alert alert-warning'><strong> ¡Precaución! </strong> " + Msj + "</div>"; this.LabelInfoEnviar.Text = this.LabelInfo.Text; MostrarMensajeJavaScript(Msj); this.LabelInfoEnviar.Focus(); objJustipreciacion = null; Ok = false; } }//fin del if para validar si la ruta es diferente de null else { string mensaje = "el tamaño del archivo es mayor de 900kb ."; this.LabelInfo.Text += "<div class='alert alert-warning'><strong> ¡Precaución! </strong> " + mensaje + "</div>"; this.LabelInfoEnviar.Text = this.LabelInfo.Text; return(Ok = false); } } catch (System.Data.SqlClient.SqlException ex) { //TODO: implementar registro de Bitacora de Excepciones Msj = "Ocurrió una excepción al procesar el registro de la información de la justipreciacion, por favor vuelva a intentar ó reporte a Sistemas."; this.LabelInfo.Text = "<div class='alert alert-danger'><strong> Error </strong>" + Msj + "</div>"; this.LabelInfoEnviar.Text = this.LabelInfo.Text; MostrarMensajeJavaScript(Msj); this.LabelInfoEnviar.Focus(); //Registra informacion acerca de una excepcion BitacoraExcepcion BitacoraExcepcionAplictivo = new BitacoraExcepcion { CadenaconexionBD = System.Configuration.ConfigurationManager.ConnectionStrings["cnArrendamientoInmueble"].ConnectionString, Aplicacion = "ContratosArrto", Modulo = MethodInfo.GetCurrentMethod().DeclaringType.ToString() + ".aspx", Funcion = MethodBase.GetCurrentMethod().Name + "()", DescExcepcion = ex.InnerException == null ? ex.Message : ex.InnerException.Message, Usr = ((SSO)Session["Contexto"]).UserName.ToString() }; BitacoraExcepcionAplictivo.RegistrarBitacoraExcepcion(); BitacoraExcepcionAplictivo = null; } catch (Exception ex) { if (ex.InnerException != null) { if (ex.InnerException.Message.Contains("o es posible") || ex.InnerException.Message.Contains("ya fue aplicado")) { Msj = ex.InnerException.Message; this.LabelInfo.Text = "<div class='alert alert-danger'><strong> Error </strong>" + Msj + "</div>"; MostrarMensajeJavaScript(Msj); Ok = false; } } //msj al usuario Msj = "Ocurrió una excepción al procesar el registro de la información de la justipreciacion, por favor vuelva a intentar ó reporte a Sistemas."; this.LabelInfo.Text = "<div class='alert alert-danger'><strong> Error </strong>" + Msj + "</div>"; this.LabelInfoEnviar.Text = this.LabelInfo.Text; MostrarMensajeJavaScript(Msj); this.LabelInfoEnviar.Focus(); //Registra informacion acerca de una excepcion BitacoraExcepcion BitacoraExcepcionAplictivo = new BitacoraExcepcion { CadenaconexionBD = System.Configuration.ConfigurationManager.ConnectionStrings["cnArrendamientoInmueble"].ConnectionString, Aplicacion = "ContratosArrto", Modulo = MethodInfo.GetCurrentMethod().DeclaringType.ToString() + ".aspx", Funcion = MethodBase.GetCurrentMethod().Name + "()", DescExcepcion = ex.InnerException == null ? ex.Message : ex.InnerException.Message, Usr = ((SSO)Session["Contexto"]).UserName.ToString() }; BitacoraExcepcionAplictivo.RegistrarBitacoraExcepcion(); BitacoraExcepcionAplictivo = null; } return(Ok); }