1

Estou precisando comparar um valor de um dos campos de um DataTable, para realizar uma condição if, mas não sei como fazer. segue abaixo:

 public partial class imp_orcamento : DevExpress.XtraReports.UI.XtraReport
{
    Datatable_orcamento dat_orc = new Datatable_orcamento();

    DataTable ret_orc = new DataTable();

    public imp_orcamento(int id_orc)
    {
        InitializeComponent();

        met_dic_cli(id_orc);
    }

    private void met_dic_cli(int id_orcamento)
    {
        ret_orc = dat_orc.rpt_orcamento(id_orcamento);

        xrLabel1.DataBindings.Add(new XRBinding("Text", ret_orc, "id_orc"));
        xrLabel2.DataBindings.Add(new XRBinding("Text", ret_orc, "data"));
        xrLabel3.DataBindings.Add(new XRBinding("Text", ret_orc, "nome_fantasia"));
        xrLabel6.DataBindings.Add(new XRBinding("Text", ret_orc, "n_doc"));
        xrLabel10.DataBindings.Add(new XRBinding("Text", ret_orc, "tipo_doc"));
        xrLabel12.DataBindings.Add(new XRBinding("Text", ret_orc, "statos"));
        xrLabel13.DataBindings.Add(new XRBinding("Text", ret_orc, "tipo"));
        xrLabel8.DataBindings.Add(new XRBinding("Text", ret_orc, "contato"));
        xrLabel9.DataBindings.Add(new XRBinding("Text", ret_orc, "departamento"));
        xrLabel4.DataBindings.Add(new XRBinding("Text", ret_orc, "vendedor"));
        xrLabel5.DataBindings.Add(new XRBinding("Text", ret_orc, "perfil"));
        xrLabel7.DataBindings.Add(new XRBinding("Text", ret_orc, "tel"));
        xrLabel14.DataBindings.Add(new XRBinding("Text", ret_orc, "val_prop"));
        xrLabel15.DataBindings.Add(new XRBinding("Text", ret_orc, "tp_frete"));
        xrLabel16.DataBindings.Add(new XRBinding("Text", ret_orc, "obs"));
        xrLabel17.DataBindings.Add(new XRBinding("Text", ret_orc, "condicao"));
        xrLabel18.DataBindings.Add(new XRBinding("Text", ret_orc, "modo"));
        if (ret_orc.Columns.Equals("cli_final") != true)
        {
            xrCheckBox1.Checked = true;
        }
    }
1

2 Respostas 2

1

Outra forma seria convert o DataTable ret_orc para um AsEnumerable.

 /// Convert to AsEnumerable
   var qrIn = from row in ret_orc .AsEnumerable()
    select new 
    {
        xrCheckBox1.Checked = dtr["cli_final"].ToString() != "0",
    }
1

Galera, consegui fazer, utilizando DataTableReader Estou fazendo assim:

DataTableReader dtr = ret_orc.CreateDataReader();

        if (dtr.HasRows)
        {
            while(dtr.Read())
            {
                string a = dtr["cli_final"].ToString();

                if (a != "0")
                {
                    xrCheckBox1.Checked = true;
                }
            }
        }
3
  • 1
    Thomas, se você tive duvida quanto a isso seria melhor abrir outra pergunta. 8/08/2016 às 11:47
  • 1
    Ou editar a pergunta colocando esse código e mudá-la perguntando se está correto. Enquanto não há respostas, é possível modificar a pergunta (depois só pode se não invalidar as respostas existentes.
    – Maniero
    8/08/2016 às 12:30
  • Ok. Como ja existem respostas, vou deixar como está. editando a minha resposta.. obrigado. 8/08/2016 às 13:14

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .