public bool Consultar() { // Creo un dataset DsEmpresaTerceros ds = new DsEmpresaTerceros(); // creo un parametro para pasarle al store procedure SqlParameter pEmpresaTercerosID = new SqlParameter("@EmpresaTercerosID", this.EmpresaTercerosID); // lleno el dataset con lo que devuelve el store Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "EmpresaTercerosONE", pEmpresaTercerosID); // obtengo el primer registro (y el unico) DsEmpresaTerceros.DatosRow dr = (DsEmpresaTerceros.DatosRow)ds.Datos.Rows[0]; // si el dataset tiene datos... if (ds.Datos.Rows.Count > 0) { //this.UnidadNegocio.UnidadNegocioID = dr.IsUnidadNegocioIDNull() ? 0 : dr.UnidadNegocioID; this.RazonSocial = dr.RazonSocial; this.Email = dr.IsEmailNull() ? null : dr.Email; this.CondicionIvaID = (SisPack.CondicionIva)dr.CondicionIvaID; //this.TipoDocumento = (SisPack.TipoDocumento) dr.TipoDocumentoID; this.NroCUIT = dr.NroCUIT; //this.IngresosBrutosNro = dr.IsIngresosBrutosNroNull() ? null : dr.IngresosBrutosNro; //this.FechaAlta = dr.FechaAlta; this.ODomicilioLegal.DomicilioID = dr.IsDomicilioLegalNull() ? 0 : dr.DomicilioLegal; if (this.ODomicilioLegal.DomicilioID != 0) { this.TieneDomicilioLegal = true; ((Domicilio)this.ODomicilioLegal).Consultar(); } this.ODomicilioReal.DomicilioID = dr.IsDomicilioRealNull() ? 0 : dr.DomicilioReal; if (this.ODomicilioReal.DomicilioID != 0) { this.TieneDomicilioReal = true; ((Domicilio)this.ODomicilioReal).Consultar(); } this.Seguro = dr.IsSeguroNull() ? 0 : dr.Seguro; } else { throw new Exception("No se encuentra ningun registro para el id solicitado."); } return(true); }
private void Buscar() { int total = 0; try { IEmpresaTerceros empresa = EmpresaTercerosFactory.GetEmpresaTerceros(); int agenciaRef = this.agenciaReferencia == "" ? 0 : Convert.ToInt32(this.agenciaReferencia); DsEmpresaTerceros ds = empresa.GetEmpresaTerceros(agenciaRef); string filtro = "RazonSocial LIKE '" + this.razonSocial + "%'"; DsEmpresaTerceros.DatosRow[] drLista = (DsEmpresaTerceros.DatosRow[])ds.Datos.Select(filtro); total = drLista.Length; if (total > 0) { if (total == 1) { DsEmpresaTerceros.DatosRow dr = drLista[0]; this.txtEmpresaTercerosID.Text = dr.EmpresaTercerosID.ToString(); this.txtRazonSocial.Text = dr.RazonSocial; this.txtErrorMsg.Text = ""; this.txtOpen.Text = ""; } else { this.txtRazonSocial.Text = this.razonSocial; this.txtAgenciaReferencia.Text = this.agenciaReferencia; this.txtOpen.Text = "S"; } } else { this.txtEmpresaTercerosID.Text = ""; this.txtErrorMsg.Text = "No se encontraron datos."; this.txtOpen.Text = ""; } } catch (Exception ex) { this.txtErrorMsg.Text = "Error al consultar datos de empresa de terceros: " + ex.Message; } }
private void dtgEmpresas_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { if (e.CommandName == "Select") { int indice = e.Item.DataSetIndex; BindGrid(); DsEmpresaTerceros.DatosRow[] drLista = (DsEmpresaTerceros.DatosRow[]) this.dtgEmpresas.DataSource; if (drLista == null) { return; } if (drLista.Length == 0) { return; } DsEmpresaTerceros.DatosRow dr = drLista[indice]; if (dr == null) { return; } int empresaTercerosID = dr.EmpresaTercerosID; string razonSocial = dr.RazonSocial; StringBuilder scriptString = new StringBuilder(); scriptString.Append("<script language='javascript'>\n"); scriptString.Append("window.dialogArguments.EmpresaTercerosID = '" + empresaTercerosID.ToString() + "';\n"); scriptString.Append("window.dialogArguments.RazonSocial = '" + razonSocial + "';\n"); scriptString.Append("window.returnValue = true;\n"); scriptString.Append("window.close();\n"); scriptString.Append("</script>"); Page.RegisterClientScriptBlock("scriptModalEmpresaTerceros", scriptString.ToString()); } }