segunda-feira, 14 de maio de 2012

Tela de cadastro de clientes com list box

Olá Pessoal

Neste artigo mostrarei como fazer uma tela(protótipo) para cadastramento de clientes e seleção de assuntos de interesse do cliente. É apenas uma demonstração do nosso curso de C# onde demonstramos a manipulação de ListBox em um WebForm.
Acompanhe o código abaixo e veja como ficou.


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <style type="text/css">
        .style2
        {
            width: 96px;
            height: 34px;
        }
        .style3
        {
            height: 34px;
        }
        .style4
        {
            width: 123px;
        }
        .style5
        {
            width: 157px;
            text-align: center;
        }
        .style6
        {
            text-align: center;
        }
        .style7
        {
            text-align: left;
        }
    </style>
</head>
<form id="form1" runat="server">
<table align="center">
    <tr>
        <td class="style6" colspan="2">
            Cadastro de Clientes</td>
    </tr>
    <tr>
        <td class="style6">
            &nbsp;</td>
        <td>
            &nbsp;</td>
    </tr>
    <tr>
        <td class="style7">
            <asp:Label ID="Label1" runat="server" Text="Nome"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="nome" runat="server" Columns="50" Font-Size="Medium"
                Height="28px" MaxLength="50" Width="431px"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td class="style7">
            <asp:Label ID="Label2" runat="server" Text="Endereço"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="endereco" runat="server" Columns="50" Font-Size="Medium"
                Height="28px" MaxLength="50" Width="431px"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td class="style7">
            <asp:Label ID="Label3" runat="server" Text="Telefone"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="telefone" runat="server" Columns="14" Font-Size="Medium"
                MaxLength="14"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td class="style7">
            <asp:Label ID="Label4" runat="server" Text="Bairro"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="Bairro" runat="server" Columns="30" Font-Size="Medium"
                Height="22px" MaxLength="30" Width="261px"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td class="style7">
            <asp:Label ID="Label5" runat="server" Text="Cidade"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="cidade" runat="server" Columns="30" Font-Size="Medium"
                Height="22px" MaxLength="30" Width="261px"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td class="style7">
            <asp:Label ID="Label6" runat="server" Text="Estado"></asp:Label>
        </td>
        <td>
            <asp:DropDownList ID="estado" runat="server">
                <asp:ListItem Value="AC">Acre</asp:ListItem>
                <asp:ListItem Value="AL">Alagoas</asp:ListItem>
                <asp:ListItem Value="AP">Amapá</asp:ListItem>
                <asp:ListItem Value="AM">Amazonas</asp:ListItem>
                <asp:ListItem Value="BA">Bahia</asp:ListItem>
                <asp:ListItem Value="CE">Ceará</asp:ListItem>
                <asp:ListItem Value="DF">Distrito Federal</asp:ListItem>
                <asp:ListItem Value="ES">Espirito Santo</asp:ListItem>
                <asp:ListItem Selected="True" Value="GO">Goiás</asp:ListItem>
                <asp:ListItem Value="MA">Maranhão</asp:ListItem>
                <asp:ListItem Value="MT">Mato Grosso </asp:ListItem>
                <asp:ListItem Value="MS">Mato Groso do Sul</asp:ListItem>
                <asp:ListItem Value="MG">Minas Gerais</asp:ListItem>
                <asp:ListItem Value="PA">Pará</asp:ListItem>
                <asp:ListItem Value="PB">Paraíba</asp:ListItem>
                <asp:ListItem Value="PR">Paraná</asp:ListItem>
                <asp:ListItem Value="PE">Pernambuco</asp:ListItem>
                <asp:ListItem Value="PI">Piauí</asp:ListItem>
                <asp:ListItem Value="RJ">Rio de Janeiro</asp:ListItem>
                <asp:ListItem Value="RN">Rio Grande do Norte</asp:ListItem>
                <asp:ListItem Value="RS">Rio Grande do Sul</asp:ListItem>
                <asp:ListItem Value="RO">Rondônia</asp:ListItem>
                <asp:ListItem Value="RR">Roraíma</asp:ListItem>
                <asp:ListItem Value="SP">São Paulo</asp:ListItem>
                <asp:ListItem Value="SC">Santa Catarina</asp:ListItem>
                <asp:ListItem Value="SE">Sergipe </asp:ListItem>
                <asp:ListItem Value="TO">Tocantins</asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>
    <tr>
        <td class="style7">
            <asp:Label ID="Label7" runat="server" Text="CPF"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="cpf" runat="server" Columns="14" MaxLength="14"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td class="style6">
            &nbsp;</td>
        <td>
            <table style="width:100%;">
                <tr>
                    <td class="style4" style="text-align: center">
                        <asp:Label ID="Label9" runat="server" Text="Assuntos"></asp:Label>
                    </td>
                    <td class="style5">
                        <asp:Label ID="Label11" runat="server" Width="20px"></asp:Label>
                    </td>
                    <td style="text-align: center">
                        <asp:Label ID="Label10" runat="server" Text="Prediletos"/>
                    </td>
                </tr>
                <tr>
                    <td class="style4" rowspan="4">
                       <asp:ListBox id="assuntos" runat="server" Height="116px" Width="121px">
                            <asp:ListItem Value="inf">Informatica</asp:ListItem>
                            <asp:ListItem Value="Aut">Automóvel</asp:ListItem>
                            <asp:ListItem Value="Cul">Cultura</asp:ListItem>
                            <asp:ListItem Value="Cui">Culinaria</asp:ListItem>
                            <asp:ListItem Value="Tre">Treinamento</asp:ListItem>
                            <asp:ListItem Value="Fin">Finanças</asp:ListItem>
                            <asp:ListItem Value="Rel">Religião </asp:ListItem>
                            <asp:ListItem Value="Pol">Política</asp:ListItem>
                        </asp:ListBox>
                    </td>
                    <td class="style5">
                        <asp:Button ID="tudoL" runat="server" Text="&lt;&lt;" onclick="tudoL_Click"
                            ToolTip="Limpar todos os assuntos prediletos e voltar para assuntos" />
                    </td>
                    <td rowspan="4">
                        <asp:ListBox ID="prediletos" runat="server" Height="119px" Width="132px"
                            SelectionMode="Multiple">
                        </asp:ListBox>
                    </td>
                </tr>
                <tr>
                    <td class="style5">
                        <asp:Button ID="tudoR" runat="server" Text="&gt;&gt;" onclick="tudoR_Click" />
                    </td>
                </tr>
                <tr>
                    <td class="style5">
                        <asp:Button ID="RtoL" runat="server" Text=" &lt; " onclick="RtoL_Click" />
                    </td>
                </tr>
                <tr>
                    <td class="style5">
                        <asp:Button ID="LtoR" runat="server" onclick="LtoR_click" Text=" &gt; " />
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td class="style2">
        </td>
        <td class="style3">
            <asp:Button ID="Button1" runat="server" onclick="limparCampos" Text="Limpar" />
            <asp:Label ID="Label8" runat="server" Height="17px" Width="304px">                                  
            </asp:Label>
            <asp:Button ID="Salvar" runat="server" Text="Salvar" />
        </td>
    </tr>
</table>
&nbsp;&nbsp;&nbsp;
</form>
<script language="C#" runat="server">
 

</script>
</html>

agora no arquivo Default.aspx.cs coloque.







Espero que tenham gostado deste código e desafio você a fazer o restante do código. Abraço a todos.
Jorge Albernaz Martins.'.

Nenhum comentário:

Postar um comentário

Obrigado por contribuir para melhorar este blog, deixe sua mensagem.
Forte Abraço