Exemplo n.º 1
0
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Label6.Text = "";
            Label8.Text = "";
            DropDownList2.Items.Clear();
            DAL.DALPagamento        SelectPagamento = new DAL.DALPagamento();
            List <Modelo.Pagamento> pagamentos      = SelectPagamento.SelectPagamento(int.Parse(DropDownList1.SelectedValue));
            int contador = 0;

            foreach (Modelo.Pagamento pagamento in pagamentos)
            {
                if (contador == 0)
                {
                    DropDownList2.Items.Add(new ListItem(pagamento.mesReferencia.ToString() + "/" + pagamento.anoReferencia.ToString(), pagamento.mesReferencia.ToString() + "/" + pagamento.anoReferencia.ToString()));
                }
                else
                {
                    if (DropDownList2.Items.Contains(DropDownList2.Items.FindByText(pagamento.mesReferencia.ToString() + "/" + pagamento.anoReferencia.ToString())))
                    {
                        DropDownList2.Items.Add(new ListItem(pagamento.mesReferencia.ToString() + "/" + pagamento.anoReferencia.ToString(), pagamento.mesReferencia.ToString() + "/" + pagamento.anoReferencia.ToString()));
                        DropDownList2.Items.RemoveAt(DropDownList2.Items.Count - 1);
                    }
                    else
                    {
                        DropDownList2.Items.Add(new ListItem(pagamento.mesReferencia.ToString() + "/" + pagamento.anoReferencia.ToString(), pagamento.mesReferencia.ToString() + "/" + pagamento.anoReferencia.ToString()));
                    }
                }
                contador = contador + 1;
            }
            DAL.DALFuncionario        SelectFuncionario = new DAL.DALFuncionario();
            List <Modelo.Funcionario> funcionarios1     = SelectFuncionario.Select(int.Parse(DropDownList1.SelectedValue));

            Label4.Text = funcionarios1[0].salario.ToString();
        }
Exemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         DAL.DALFuncionario        SelectFuncionario = new DAL.DALFuncionario();
         List <Modelo.Funcionario> funcionarios      = SelectFuncionario.SelectAll();
         if (funcionarios.Count >= 1)
         {
             foreach (Modelo.Funcionario funcionario in funcionarios)
             {
                 DropDownList1.Items.Add(new ListItem(funcionario.nome, funcionario.idFuncionario.ToString()));
             }
             DAL.DALPagamento        SelectPagamento = new DAL.DALPagamento();
             List <Modelo.Pagamento> pagamentos      = SelectPagamento.SelectPagamento(int.Parse(DropDownList1.SelectedValue));
             int contador = 0;
             foreach (Modelo.Pagamento pagamento in pagamentos)
             {
                 if (contador == 0)
                 {
                     DropDownList2.Items.Add(new ListItem(pagamento.mesReferencia.ToString() + "/" + pagamento.anoReferencia.ToString(), pagamento.mesReferencia.ToString() + "/" + pagamento.anoReferencia.ToString()));
                 }
                 else
                 {
                     if (DropDownList2.Items.Contains(DropDownList2.Items.FindByText(pagamento.mesReferencia.ToString() + "/" + pagamento.anoReferencia.ToString())))
                     {
                         DropDownList2.Items.Add(new ListItem(pagamento.mesReferencia.ToString() + "/" + pagamento.anoReferencia.ToString(), pagamento.mesReferencia.ToString() + "/" + pagamento.anoReferencia.ToString()));
                         DropDownList2.Items.RemoveAt(DropDownList2.Items.Count - 1);
                     }
                     else
                     {
                         DropDownList2.Items.Add(new ListItem(pagamento.mesReferencia.ToString() + "/" + pagamento.anoReferencia.ToString(), pagamento.mesReferencia.ToString() + "/" + pagamento.anoReferencia.ToString()));
                     }
                 }
                 contador = contador + 1;
             }
             List <Modelo.Funcionario> funcionarios1 = SelectFuncionario.Select(int.Parse(DropDownList1.SelectedValue));
             Label4.Text = funcionarios1[0].salario.ToString();
         }
     }
 }