コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!Page.IsPostBack)
            {
                CargaTipoPersona();

                if (!(Request.QueryString["Cod"] == null))
                {
                    eCliente.ID_Cliente = Request.QueryString["Cod"].ToString();
                    DataTable dtCliente = new DataTable();
                    dtCliente = objCliente.ListarCliente(eCliente);
                    DataRow dr = dtCliente.Rows[0];

                    tbCodigo.Text         = dr["ID"].ToString();
                    Session["IDContacto"] = dr["IDContacto"].ToString();
                    Session["IDVehiculo"] = dr["IDVehiculo"].ToString();
                    tbContacto.Text       = dr["NombreContacto"].ToString();
                    tbVehiculo.Text       = dr["NombreVehiculo"].ToString();
                    ddlTipo.SelectedValue = dr["Tipo"].ToString();
                    tbNombre.Text         = dr["Nombre"].ToString();
                    tbRazonSocial.Text    = dr["RazonSocial"].ToString();
                    tbDocumento.Text      = dr["Documento"].ToString();
                    tbDireccion.Text      = dr["Direccion"].ToString();
                    tbDistrito.Text       = dr["Distrito"].ToString();
                    tbTelefono.Text       = dr["Telefono"].ToString();
                    tbEmail.Text          = dr["Email"].ToString();
                    tbPaginaWeb.Text      = dr["PaginaWeb"].ToString();

                    btnDetalleVehiculo.Enabled = true;
                    btnDetalleContacto.Enabled = true;
                }

                if (Session["Cliente_IDCliente"].ToString() != "")
                {
                    eCliente.ID_Cliente = Session["Cliente_IDCliente"].ToString();
                    DataTable dtCliente = new DataTable();
                    dtCliente = objCliente.ListarCliente(eCliente);
                    DataRow dr = dtCliente.Rows[0];

                    tbCodigo.Text         = dr["ID"].ToString();
                    Session["IDContacto"] = dr["IDContacto"].ToString();
                    Session["IDVehiculo"] = dr["IDVehiculo"].ToString();
                    tbContacto.Text       = dr["NombreContacto"].ToString();
                    tbVehiculo.Text       = dr["NombreVehiculo"].ToString();
                    ddlTipo.SelectedValue = dr["Tipo"].ToString();
                    tbNombre.Text         = dr["Nombre"].ToString();
                    tbRazonSocial.Text    = dr["RazonSocial"].ToString();
                    tbDocumento.Text      = dr["Documento"].ToString();
                    tbDireccion.Text      = dr["Direccion"].ToString();
                    tbDistrito.Text       = dr["Distrito"].ToString();
                    tbTelefono.Text       = dr["Telefono"].ToString();
                    tbEmail.Text          = dr["Email"].ToString();
                    tbPaginaWeb.Text      = dr["PaginaWeb"].ToString();

                    btnDetalleVehiculo.Enabled = true;
                    btnDetalleContacto.Enabled = true;
                }

                if (Session["Cliente_IDContacto"].ToString() != "0")
                {
                    eContacto.ID_Contacto = Session["Cliente_IDContacto"].ToString();
                    DataTable dtContacto = new DataTable();
                    dtContacto = objContacto.ListarContacto(eContacto);
                    DataRow dr = dtContacto.Rows[0];

                    eCliente.ID_Contacto = dr["ID"].ToString();
                    tbContacto.Text      = dr["Nombre"].ToString();
                }

                if (Session["Cliente_IDVehiculo"].ToString() != "0")
                {
                    eVehiculo.ID_Vehiculo = Session["Cliente_IDVehiculo"].ToString();
                    DataTable dtVehiculo = new DataTable();
                    dtVehiculo = objVehiculo.ListarVehiculo(eVehiculo);
                    DataRow dr = dtVehiculo.Rows[0];

                    eCliente.ID_Vehiculo = dr["ID"].ToString();
                    tbVehiculo.Text      = dr["Placa"].ToString();
                }

                if (tbContacto.Text != "" && tbVehiculo.Text != "")
                {
                    ddlTipo.Enabled       = true;
                    tbNombre.Enabled      = true;
                    tbRazonSocial.Enabled = true;
                    tbDocumento.Enabled   = true;
                    tbDireccion.Enabled   = true;
                    tbDistrito.Enabled    = true;
                    tbTelefono.Enabled    = true;
                    tbEmail.Enabled       = true;
                    tbPaginaWeb.Enabled   = true;
                }
            }
        }
        catch (Exception ex)
        {
            throw new Exception("Error de carga de datos", ex);
        }
    }