コード例 #1
0
        private void Col_DtEmissaoFechamento_Validating(object sender, CancelEventArgs e)
        {
            var controle = ((DataGridViewTextBoxEditingControl)sender);

            // ValidateUtils é uma classe estática utilizada para validação
            if (!string.IsNullOrEmpty(controle.Text) && !ValidateUtils.isDate(controle.Text))
            {
                controle.Clear();
                e.Cancel = true;
                MessageBox.Show("Data inválida.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
 private void txtDtNascimento_Validating(object sender, CancelEventArgs e)
 {
     if (!string.IsNullOrEmpty(((MaskedTextBox)sender).Text))
     {
         ((MaskedTextBox)sender).TextMaskFormat = MaskFormat.IncludePromptAndLiterals;
         if (!ValidateUtils.isDate(((MaskedTextBox)sender).Text))
         {
             MessageBox.Show("Data inválida.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
             ((MaskedTextBox)sender).Text = string.Empty;
             e.Cancel = true;
         }
         ((MaskedTextBox)sender).TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
     }
 }
コード例 #3
0
        protected override void executeCellValidatingChild(object sender, DataGridViewCellValidatingEventArgs e)
        {
            base.executeCellValidatingChild(sender, e);

            if (e.ColumnIndex == COL_ID && !string.IsNullOrEmpty((string)e.FormattedValue))
            {
                //
            }

            if (e.ColumnIndex == COL_PEDIDO && !string.IsNullOrEmpty((string)e.FormattedValue))
            {
                //Executa filtro.
            }

            if (e.ColumnIndex == COL_CLIENTE && !string.IsNullOrEmpty((string)e.FormattedValue))
            {
                //Executa filtro.
            }

            if (e.ColumnIndex == COL_CONDPAG && !string.IsNullOrEmpty((string)e.FormattedValue))
            {
                //Executa filtro.
            }

            if (e.ColumnIndex == COL_DTEMISSAO && !string.IsNullOrEmpty((string)e.FormattedValue))
            {
                if ((string.IsNullOrEmpty((string)e.FormattedValue)) || ((string)e.FormattedValue == "__/__/____"))
                {
                    dgvFiltro[e.ColumnIndex, e.RowIndex].Value = "";
                    return;
                }

                if (!ValidateUtils.isDate((string)e.FormattedValue))
                {
                    e.Cancel = true;
                    dgvFiltro[e.ColumnIndex, e.RowIndex].Value = "";
                    MessageBox.Show("Data inválida.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    //Executa filtro.
                }
            }

            if (e.ColumnIndex == COL_STATUS && !string.IsNullOrEmpty((string)e.FormattedValue))
            {
                //Executa filtro.
            }
        }
コード例 #4
0
 private void Ctrls_Validating(object sender, CancelEventArgs e)
 {
     if (sender is MaskedTextBox)
     {
         if ((((MaskedTextBox)sender).Name == txtDtEmissao.Name) ||
             (((MaskedTextBox)sender).Name == txtDtFechamento.Name) ||
             (((MaskedTextBox)sender).Name == txtDtPrevEntrega.Name))
         {
             if (!string.IsNullOrEmpty(((MaskedTextBox)sender).Text))
             {
                 ((MaskedTextBox)sender).TextMaskFormat = MaskFormat.IncludePromptAndLiterals;
                 if (!ValidateUtils.isDate(((MaskedTextBox)sender).Text))
                 {
                     MessageBox.Show("Data inválida.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                     ((MaskedTextBox)sender).Text = string.Empty;
                     e.Cancel = true;
                 }
                 ((MaskedTextBox)sender).TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
             }
         }
     }
 }
コード例 #5
0
        protected override void executeCellValidatingChild(object sender, DataGridViewCellValidatingEventArgs e)
        {
            base.executeCellValidatingChild(sender, e);

            if (e.ColumnIndex == col_Id && !string.IsNullOrEmpty((string)e.FormattedValue))
            {
                //
            }

            if (e.ColumnIndex == col_nome && !string.IsNullOrEmpty((string)e.FormattedValue))
            {
                //Executa filtro.
            }

            if (e.ColumnIndex == col_descricao && !string.IsNullOrEmpty((string)e.FormattedValue))
            {
                //Executa filtro.
            }

            if (((e.ColumnIndex == col_inclusao) || (e.ColumnIndex == col_alteracao)) && !string.IsNullOrEmpty((string)e.FormattedValue))
            {
                if ((string.IsNullOrEmpty((string)e.FormattedValue)) || ((string)e.FormattedValue == "__/__/____"))
                {
                    dgvFiltro[e.ColumnIndex, e.RowIndex].Value = "";
                    return;
                }

                if (!ValidateUtils.isDate((string)e.FormattedValue))
                {
                    e.Cancel = true;
                    dgvFiltro[e.ColumnIndex, e.RowIndex].Value = "";
                    MessageBox.Show("Data inválida.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    //Executa filtro.
                }
            }
        }
コード例 #6
0
        protected override void imprimirRegistro(object sender, EventArgs e)
        {
            base.imprimirRegistro(sender, e);

            frmRelListPedido_Otica frm = new frmRelListPedido_Otica();

            if (!string.IsNullOrEmpty(txtCodPedidoDe.Text))
            {
                frm.pedidoDe = Convert.ToInt64(txtIdPedidoDe.Text);
            }

            if (!string.IsNullOrEmpty(txtCodPedidoAte.Text))
            {
                frm.pedidoAte = Convert.ToInt64(txtIdPedidoAte.Text);
            }

            if (!string.IsNullOrEmpty(txtCodClienteDe.Text))
            {
                frm.clienteDe = Convert.ToInt64(txtIdClienteDe.Text);
            }

            if (!string.IsNullOrEmpty(txtCodClienteAte.Text))
            {
                frm.clienteAte = Convert.ToInt64(txtIdClienteAte.Text);
            }
            txtDtEmissaoDe.TextMaskFormat = MaskFormat.IncludePromptAndLiterals;
            if (ValidateUtils.isDate(txtDtEmissaoDe.Text))
            {
                frm.data_emissaoDe = Convert.ToDateTime(txtDtEmissaoDe.Text);
            }
            txtDtEmissaoDe.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;

            txtDtEmissaoAte.TextMaskFormat = MaskFormat.IncludePromptAndLiterals;
            if (ValidateUtils.isDate(txtDtEmissaoAte.Text))
            {
                frm.data_emissaoAte = Convert.ToDateTime(txtDtEmissaoAte.Text);
            }
            txtDtEmissaoAte.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;

            if (ValidateUtils.isDate(txtDtFechamentoDe.Text))
            {
                frm.data_fechamentoDe = Convert.ToDateTime(txtDtFechamentoDe.Text);
            }

            if (ValidateUtils.isDate(txtDtFechamentoAte.Text))
            {
                frm.data_fechamentoAte = Convert.ToDateTime(txtDtFechamentoAte.Text);
            }

            if (!string.IsNullOrEmpty(txtIdTransportadoraDe.Text))
            {
                frm.transportadoraDe = Convert.ToInt64(txtIdTransportadoraDe.Text);
            }

            if (!string.IsNullOrEmpty(txtIdTransportadoraAte.Text))
            {
                frm.transportadoraAte = Convert.ToInt64(txtIdTransportadoraAte.Text);
            }

            if (!string.IsNullOrEmpty(txtCodVendedorDe.Text))
            {
                frm.vendedorDe = Convert.ToInt64(txtNomeVendedorDe.Text);
            }

            if (!string.IsNullOrEmpty(txtCodVendedorAte.Text))
            {
                frm.vendedorAte = Convert.ToInt64(txtNomeVendedorAte.Text);
            }

            if (cbCaixaDe.SelectedValue != null)
            {
                frm.caixaDe = (int)cbCaixaDe.SelectedValue;
            }

            if (cbCaixaAte.SelectedValue != null)
            {
                frm.caixaAte = (int)cbCaixaAte.SelectedValue;
            }

            frm.nrpedclienteDe = null;
            if (!string.IsNullOrEmpty(txtNrPedClienteDe.Text))
            {
                frm.nrpedclienteDe = txtNrPedClienteDe.Text;
            }

            frm.nrpedclienteAte = null;
            if (!string.IsNullOrEmpty(txtNrPedClienteAte.Text))
            {
                frm.nrpedclienteAte = txtNrPedClienteAte.Text;
            }

            if (cbStatusDe.SelectedValue != null)
            {
                frm.statusDe = (int)cbStatusDe.SelectedValue;
            }

            if (cbStatusAte.SelectedValue != null)
            {
                frm.statusAte = (int)cbStatusAte.SelectedValue;
            }

            frm.ExibeDialogo();
        }
コード例 #7
0
        protected override void imprimirRegistro(object sender, EventArgs e)
        {
            base.imprimirRegistro(sender, e);

            frmRelListPedido_Otica frm = new frmRelListPedido_Otica();

            if (!string.IsNullOrEmpty(txtCodPedidoDe.Text))
            {
                frm.pedidoDe = Convert.ToInt64(txtCodPedidoDe.Text);
            }

            if (!string.IsNullOrEmpty(txtCodPedidoAte.Text))
            {
                frm.pedidoAte = Convert.ToInt64(txtCodPedidoAte.Text);
            }

            if (!string.IsNullOrEmpty(txtCodClienteDe.Text))
            {
                frm.clienteDe = Convert.ToInt64(txtIdClienteDe.Text);
            }

            if (!string.IsNullOrEmpty(txtCodClienteAte.Text))
            {
                frm.clienteAte = Convert.ToInt64(txtIdClienteAte.Text);
            }

            if (ValidateUtils.isDate(txtDtEmissaoDe.Text))
            {
                frm.data_emissaoDe = Convert.ToDateTime(txtDtEmissaoDe.Text);
            }

            if (ValidateUtils.isDate(txtDtEmissaoAte.Text))
            {
                frm.data_emissaoAte = Convert.ToDateTime(txtDtEmissaoAte.Text);
            }

            if (ValidateUtils.isDate(txtDtFechamentoDe.Text))
            {
                frm.data_fechamentoDe = Convert.ToDateTime(txtDtFechamentoDe.Text);
            }

            if (ValidateUtils.isDate(txtDtFechamentoAte.Text))
            {
                frm.data_fechamentoAte = Convert.ToDateTime(txtDtFechamentoAte.Text);
            }

            if (!string.IsNullOrEmpty(txtIdTransportadoraDe.Text))
            {
                frm.transportadoraDe = Convert.ToInt64(txtIdTransportadoraDe.Text);
            }

            if (!string.IsNullOrEmpty(txtIdTransportadoraAte.Text))
            {
                frm.transportadoraAte = Convert.ToInt64(txtIdTransportadoraAte.Text);
            }

            if (!string.IsNullOrEmpty(txtCodVendedorDe.Text))
            {
                frm.vendedorDe = Convert.ToInt64(txtNomeVendedorDe.Text);
            }

            if (!string.IsNullOrEmpty(txtCodVendedorAte.Text))
            {
                frm.vendedorAte = Convert.ToInt64(txtNomeVendedorAte.Text);
            }

            if (cbCaixaDe.SelectedValue != null)
            {
                frm.caixaDe = (int)cbCaixaDe.SelectedValue;
            }

            if (cbCaixaAte.SelectedValue != null)
            {
                frm.caixaAte = (int)cbCaixaAte.SelectedValue;
            }

            frm.nrpedclienteDe = null;
            if (!string.IsNullOrEmpty(txtNrPedClienteDe.Text))
            {
                frm.nrpedclienteDe = txtNrPedClienteDe.Text;
            }

            frm.nrpedclienteAte = null;
            if (!string.IsNullOrEmpty(txtNrPedClienteAte.Text))
            {
                frm.nrpedclienteAte = txtNrPedClienteAte.Text;
            }

            if (cbStatusDe.SelectedValue != null)
            {
                frm.statusDe = (int)cbStatusDe.SelectedValue;
            }

            if (cbStatusAte.SelectedValue != null)
            {
                frm.statusAte = (int)cbStatusAte.SelectedValue;
            }

            if (stUsuario.UsuarioLogado.Id_empresa != null)
            {
                frm.empresa = stUsuario.UsuarioLogado.Id_empresa;
            }

            if (stUsuario.UsuarioLogado.Id_filial != null)
            {
                frm.filial = stUsuario.UsuarioLogado.Id_filial;
            }
            else
            {
                if (gbFilial.Visible)
                {
                    if (cbFilial.SelectedValue != null)
                    {
                        frm.filial = Convert.ToInt64(cbFilial.SelectedValue);
                    }
                }
            }

            frm.ExibeDialogo();
        }
コード例 #8
0
        protected override void executeCellEndEditChild(object sender, DataGridViewCellEventArgs e)
        {
            base.executeCellEndEditChild(sender, e);

            int      id = 0;
            string   nome = string.Empty, usuario_inclusao = string.Empty, usuario_alteracao = string.Empty, descricao = string.Empty;
            DateTime?inclusao = null, alteracao = null;

            if (!string.IsNullOrEmpty((string)dgvFiltro[col_Id, e.RowIndex].Value.ToString()))
            {
                id = Convert.ToInt32(dgvFiltro[col_Id, e.RowIndex].Value);
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[col_nome, e.RowIndex].Value))
            {
                nome = dgvFiltro[col_nome, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[col_descricao, e.RowIndex].Value))
            {
                descricao = dgvFiltro[col_descricao, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[col_inclusao, e.RowIndex].Value))
            {
                inclusao = Convert.ToDateTime(dgvFiltro[col_inclusao, e.RowIndex].Value);
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[col_alteracao, e.RowIndex].Value))
            {
                alteracao = Convert.ToDateTime(dgvFiltro[col_alteracao, e.RowIndex].Value);
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[col_usuario_inclusao, e.RowIndex].Value))
            {
                usuario_inclusao = dgvFiltro[col_usuario_inclusao, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[col_usuario_alteracao, e.RowIndex].Value))
            {
                usuario_alteracao = dgvFiltro[col_usuario_alteracao, e.RowIndex].Value.ToString();
            }


            Expression <Func <Perfil, bool> > predicate = p => true;


            if (id > 0)
            {
                predicate = predicate = p => p.Id == id;
            }

            if (!string.IsNullOrEmpty(nome))
            {
                predicate = predicate.And(p => p.nome.Contains(nome));
            }

            if (!string.IsNullOrEmpty(descricao))
            {
                predicate = predicate.And(p => p.descricao.Contains(descricao));
            }

            if (!string.IsNullOrEmpty(usuario_inclusao))
            {
                predicate = predicate.And(p => p.usuario_inclusao.Contains(usuario_inclusao));
            }

            if (!string.IsNullOrEmpty(usuario_alteracao))
            {
                predicate = predicate.And(p => p.usuario_alteracao.Contains(usuario_alteracao));
            }

            if ((inclusao != null) & (ValidateUtils.isDate(inclusao.ToString())))
            {
                predicate = predicate.And(p => DbFunctions.TruncateTime(p.inclusao) == DbFunctions.TruncateTime(inclusao));
            }

            if ((alteracao != null) & (ValidateUtils.isDate(alteracao.ToString())))
            {
                predicate = predicate.And(p => DbFunctions.TruncateTime(p.alteracao) == DbFunctions.TruncateTime(alteracao));
            }

            List <Perfil> PerfilList = PerfilBLL.getPerfil(predicate.Expand(), t => t.Id.ToString(), false, deslocamento, tamanhoPagina, out totalReg);

            dgvDados.DataSource = PerfilList;
        }
コード例 #9
0
        private Expression <Func <Pedido_Otica, bool> > executeFilter(object sender, DataGridViewCellEventArgs e)
        {
            int      codigo  = 0;
            string   cliente = string.Empty;
            string   condPag = string.Empty;
            DateTime?DtEmiss = null;
            DateTime?DtFecha = null;
            int?     status  = null;

            if (dgvFiltro[COL_PEDIDO, e.RowIndex].Value != null)
            {
                if (!string.IsNullOrEmpty(dgvFiltro[COL_PEDIDO, e.RowIndex].Value.ToString()))
                {
                    codigo = Convert.ToInt32(dgvFiltro[COL_PEDIDO, e.RowIndex].Value);
                }
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_CLIENTE, e.RowIndex].Value))
            {
                cliente = dgvFiltro[COL_CLIENTE, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_CONDPAG, e.RowIndex].Value))
            {
                condPag = dgvFiltro[COL_CONDPAG, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value))
            {
                if (dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value.ToString() != "__/__/____")
                {
                    if (ValidateUtils.isDate((string)dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value.ToString()))
                    {
                        DtEmiss = Convert.ToDateTime(dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value);
                    }
                }
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_DTFECHAMENTO, e.RowIndex].Value))
            {
                if (dgvFiltro[COL_DTFECHAMENTO, e.RowIndex].Value.ToString() != "__/__/____")
                {
                    if (ValidateUtils.isDate((string)dgvFiltro[COL_DTFECHAMENTO, e.RowIndex].Value.ToString()))
                    {
                        DtFecha = Convert.ToDateTime(dgvFiltro[COL_DTFECHAMENTO, e.RowIndex].Value);
                    }
                }
            }

            if (dgvFiltro[COL_STATUS, e.RowIndex].Value != null)
            {
                status = (int)((DataGridViewComboBoxCell)dgvFiltro[COL_STATUS, e.RowIndex]).Value;
            }

            //var predicate = PredicateBuilder.True<Pedido_Otica>();


            Expression <Func <Pedido_Otica, bool> > predicate = p => true;


            if (codigo > 0)
            {
                predicate = predicate = p => p.codigo == codigo;
            }

            if (!string.IsNullOrEmpty(cliente))
            {
                predicate = predicate.And(p => p.cliente.nome_fantasia.ToLower().Contains(cliente.ToLower()));
            }

            if (!string.IsNullOrEmpty(condPag))
            {
                predicate = predicate.And(p => p.parcela.descricao.Contains(condPag));
            }

            if ((DtEmiss != null) & (ValidateUtils.isDate(DtEmiss.ToString())))
            {
                predicate = predicate.And(p => DbFunctions.TruncateTime(p.data_emissao) == DbFunctions.TruncateTime(DtEmiss));
            }

            if ((DtFecha != null) & (ValidateUtils.isDate(DtFecha.ToString())))
            {
                predicate = predicate.And(p => DbFunctions.TruncateTime(p.data_fechamento) == DbFunctions.TruncateTime(DtFecha));
            }

            if ((status != null) && (status != 9))
            {
                predicate = predicate.And(p => p.status == status);
            }

            return(predicate);
        }
コード例 #10
0
        private void executeFilter(object sender, DataGridViewCellEventArgs e)
        {
            int      codigo      = 0;
            string   os          = string.Empty;
            string   cliente     = string.Empty;
            string   condPag     = string.Empty;
            string   vendedor    = string.Empty;
            string   laboratorio = string.Empty;
            DateTime?DtEmiss     = null;
            decimal? total       = null;
            int?     status      = null;
            string   cancelado   = string.Empty;
            string   usuario     = string.Empty;

            if (dgvFiltro[COL_PEDIDO, e.RowIndex].Value != null)
            {
                if (!string.IsNullOrEmpty(dgvFiltro[COL_PEDIDO, e.RowIndex].Value.ToString()))
                {
                    codigo = Convert.ToInt32(dgvFiltro[COL_PEDIDO, e.RowIndex].Value);
                }
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_OS, e.RowIndex].Value))
            {
                os = dgvFiltro[COL_OS, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_CLIENTE, e.RowIndex].Value))
            {
                cliente = dgvFiltro[COL_CLIENTE, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_CONDPAG, e.RowIndex].Value))
            {
                condPag = dgvFiltro[COL_CONDPAG, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_VENDEDOR, e.RowIndex].Value))
            {
                vendedor = dgvFiltro[COL_VENDEDOR, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_LABORATORIO, e.RowIndex].Value))
            {
                laboratorio = dgvFiltro[COL_LABORATORIO, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value))
            {
                if (dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value.ToString() != "__/__/____")
                {
                    if (ValidateUtils.isDate((string)dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value.ToString()))
                    {
                        DtEmiss = Convert.ToDateTime(dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value);
                    }
                }
            }

            if (dgvFiltro[COL_TOTAL, e.RowIndex].Value != null)
            {
                total = Convert.ToDecimal(dgvFiltro[COL_TOTAL, e.RowIndex].Value);
            }

            if (dgvFiltro[COL_STATUS, e.RowIndex].Value != null)
            {
                status = (int)((DataGridViewComboBoxCell)dgvFiltro[COL_STATUS, e.RowIndex]).Value;
            }

            if (e.ColumnIndex == COL_CANCELADO)
            {
                DataGridViewCheckBoxCell cell = dgvFiltro.CurrentCell as DataGridViewCheckBoxCell;
                if (cell != null)
                {
                    CheckState value = (CheckState)cell.EditedFormattedValue;
                    switch (value)
                    {
                    case CheckState.Checked:
                        cancelado = "S";
                        break;

                    case CheckState.Unchecked:
                        cancelado = "N";
                        break;

                    default:
                        cancelado = string.Empty;
                        break;
                    }
                }
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_USUARIO, e.RowIndex].Value))
            {
                usuario = dgvFiltro[COL_USUARIO, e.RowIndex].Value.ToString();
            }

            //var predicate = PredicateBuilder.True<Pedido_Otica>();


            Expression <Func <Pedido_Otica, bool> > predicate = p => true;


            if (codigo > 0)
            {
                predicate = predicate = p => p.codigo == codigo;
            }

            if (!string.IsNullOrEmpty(os))
            {
                predicate = predicate.And(p => p.pedido_otica_infoadic.Any(c => c.ordem_servico == os));
            }

            if (!string.IsNullOrEmpty(cliente))
            {
                predicate = predicate.And(p => p.cliente.nome_fantasia.ToLower().Contains(cliente.ToLower()));
            }

            if (!string.IsNullOrEmpty(condPag))
            {
                predicate = predicate.And(p => p.parcela.descricao.Contains(condPag));
            }

            if (!string.IsNullOrEmpty(vendedor))
            {
                predicate = predicate.And(p => p.vendedor.nome.ToLower().Contains(vendedor.ToLower()));
            }

            if (!string.IsNullOrEmpty(laboratorio))
            {
                predicate = predicate.And(p => p.pedido_otica_infoadic.Any(c => c.laboratorio.ToLower().Contains(laboratorio.ToLower())));
            }

            if ((DtEmiss != null) & (ValidateUtils.isDate(DtEmiss.ToString())))
            {
                predicate = predicate.And(p => DbFunctions.TruncateTime(p.data_emissao) == DbFunctions.TruncateTime(DtEmiss));
            }

            if ((total != null))
            {
                predicate = predicate.And(p => p.itempedido_otica.Any(c => c.valor_total == total));
            }

            if ((status != null) && (status != 7))
            {
                predicate = predicate.And(p => p.status == status);
            }

            if (!string.IsNullOrEmpty(cancelado))
            {
                predicate = predicate.And(p => p.cancelado == cancelado);
            }

            if (!string.IsNullOrEmpty(usuario))
            {
                predicate = predicate.And(p => p.transportadora.usuario_inclusao.ToLower().Contains(usuario.ToLower()));
            }

            List <Pedido_Otica> Pedido_OticaList = Pedido_OticaBLL.getPedido_Otica(predicate.Expand(), t => t.Id.ToString(), false, deslocamento, tamanhoPagina, out totalReg);

            dgvDados.DataSource = Pedido_OticaBLL.ToList_Pedido_OticaView(Pedido_OticaList);
        }
コード例 #11
0
        protected override void executeCellEndEditChild(object sender, DataGridViewCellEventArgs e)
        {
            base.executeCellEndEditChild(sender, e);

            int      id         = 0;
            string   fornecedor = string.Empty;
            string   documento  = string.Empty;
            decimal? valor      = null;
            DateTime?vencimento = null;
            DateTime?previsao   = null;
            DateTime?pagamento  = null;
            string   pago       = string.Empty;


            if (dgvFiltro[COL_ID, e.RowIndex].Value != null)
            {
                id = Convert.ToInt32(dgvFiltro[COL_ID, e.RowIndex].Value);
            }

            if (dgvFiltro[COL_FORNECEDOR, e.RowIndex].Value != null)
            {
                fornecedor = dgvFiltro[COL_FORNECEDOR, e.RowIndex].Value.ToString();
            }

            if (dgvFiltro[COL_DOCUMENTO, e.RowIndex].Value != null)
            {
                documento = dgvFiltro[COL_DOCUMENTO, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_VENCIMENTO, e.RowIndex].Value))
            {
                if (dgvFiltro[COL_VENCIMENTO, e.RowIndex].Value.ToString() != "__/__/____")
                {
                    if (ValidateUtils.isDate((string)dgvFiltro[COL_VENCIMENTO, e.RowIndex].Value.ToString()))
                    {
                        vencimento = Convert.ToDateTime(dgvFiltro[COL_VENCIMENTO, e.RowIndex].Value);
                    }
                }
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_PREVISAO, e.RowIndex].Value))
            {
                if (dgvFiltro[COL_PREVISAO, e.RowIndex].Value.ToString() != "__/__/____")
                {
                    if (ValidateUtils.isDate((string)dgvFiltro[COL_PREVISAO, e.RowIndex].Value.ToString()))
                    {
                        previsao = Convert.ToDateTime(dgvFiltro[COL_PREVISAO, e.RowIndex].Value);
                    }
                }
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_PAGAMENTO, e.RowIndex].Value))
            {
                if (dgvFiltro[COL_PAGAMENTO, e.RowIndex].Value.ToString() != "__/__/____")
                {
                    if (ValidateUtils.isDate((string)dgvFiltro[COL_PAGAMENTO, e.RowIndex].Value.ToString()))
                    {
                        pagamento = Convert.ToDateTime(dgvFiltro[COL_PAGAMENTO, e.RowIndex].Value);
                    }
                }
            }

            if (dgvFiltro[COL_VALOR, e.RowIndex].Value != null)
            {
                valor = Convert.ToDecimal(dgvFiltro[COL_VALOR, e.RowIndex].Value);
            }

            if (e.ColumnIndex == COL_PAGO)
            {
                DataGridViewCheckBoxCell cell = dgvFiltro.CurrentCell as DataGridViewCheckBoxCell;
                if (cell != null)
                {
                    CheckState value = (CheckState)cell.EditedFormattedValue;
                    switch (value)
                    {
                    case CheckState.Checked:
                        pago = "S";
                        break;

                    case CheckState.Unchecked:
                        pago = "N";
                        break;

                    default:
                        pago = string.Empty;
                        break;
                    }
                }
            }

            Expression <Func <Contas_Pagar, bool> > predicate = p => true;


            if (id > 0)
            {
                predicate = predicate = p => p.Id == id;
            }

            if (!string.IsNullOrEmpty(fornecedor))
            {
                predicate = predicate.And(p => p.cliente.nome_fantasia.ToLower().Contains(fornecedor.ToLower()));
            }

            if (!string.IsNullOrEmpty(documento))
            {
                predicate = predicate.And(p => p.Documento.Contains(documento));
            }

            if ((vencimento != null) & (ValidateUtils.isDate(vencimento.ToString())))
            {
                predicate = predicate.And(p => DbFunctions.TruncateTime(p.vencimento) == DbFunctions.TruncateTime(vencimento));
            }

            if ((previsao != null) & (ValidateUtils.isDate(previsao.ToString())))
            {
                predicate = predicate.And(p => DbFunctions.TruncateTime(p.previsao) == DbFunctions.TruncateTime(previsao));
            }

            if ((pagamento != null) & (ValidateUtils.isDate(pagamento.ToString())))
            {
                predicate = predicate.And(p => DbFunctions.TruncateTime(p.pagamento) == DbFunctions.TruncateTime(pagamento));
            }

            if ((valor != null))
            {
                predicate = predicate.And(p => p.valor == valor);
            }

            if (!string.IsNullOrEmpty(pago))
            {
                predicate = predicate.And(p => p.pago == pago);
            }

            if (Id_filial != null)
            {
                predicate = predicate.And(p => p.Id_filial == Id_filial);
            }

            List <Contas_Pagar> Contas_PagarList = Contas_PagarBLL.getContas_Pagar(predicate.Expand(), t => t.Id.ToString(), false, deslocamento, tamanhoPagina, out totalReg);

            dgvDados.DataSource = Contas_PagarBLL.ToList_Contas_PagarView(Contas_PagarList);
        }
コード例 #12
0
        private void executeFilter(object sender, DataGridViewCellEventArgs e)
        {
            int      codigo  = 0;
            string   cliente = string.Empty;
            string   condPag = string.Empty;
            DateTime?DtEmiss = null;
            DateTime?DtFecha = null;
            int?     status  = null;

            if (dgvFiltro[COL_PEDIDO, e.RowIndex].Value != null)
            {
                if (!string.IsNullOrEmpty(dgvFiltro[COL_PEDIDO, e.RowIndex].Value.ToString()))
                {
                    codigo = Convert.ToInt32(dgvFiltro[COL_PEDIDO, e.RowIndex].Value);
                }
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_CLIENTE, e.RowIndex].Value))
            {
                cliente = dgvFiltro[COL_CLIENTE, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_CONDPAG, e.RowIndex].Value))
            {
                condPag = dgvFiltro[COL_CONDPAG, e.RowIndex].Value.ToString();
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value))
            {
                if (dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value.ToString() != "__/__/____")
                {
                    if (ValidateUtils.isDate((string)dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value.ToString()))
                    {
                        DtEmiss = Convert.ToDateTime(dgvFiltro[COL_DTEMISSAO, e.RowIndex].Value);
                    }
                }
            }

            if (!string.IsNullOrEmpty((string)dgvFiltro[COL_DTFECHAMENTO, e.RowIndex].Value))
            {
                if (dgvFiltro[COL_DTFECHAMENTO, e.RowIndex].Value.ToString() != "__/__/____")
                {
                    if (ValidateUtils.isDate((string)dgvFiltro[COL_DTFECHAMENTO, e.RowIndex].Value.ToString()))
                    {
                        DtFecha = Convert.ToDateTime(dgvFiltro[COL_DTFECHAMENTO, e.RowIndex].Value);
                    }
                }
            }

            if (dgvFiltro[COL_STATUS, e.RowIndex].Value != null)
            {
                status = (int)((DataGridViewComboBoxCell)dgvFiltro[COL_STATUS, e.RowIndex]).Value;
            }

            //var predicate = PredicateBuilder.True<Pedido_Otica>();


            Expression <Func <Pedido_Otica, bool> > predicate = p => true;


            if (codigo > 0)
            {
                predicate = predicate = p => p.codigo == codigo;
            }

            if (!string.IsNullOrEmpty(cliente))
            {
                predicate = predicate.And(p => p.cliente.nome_fantasia.Contains(cliente));
            }

            if (!string.IsNullOrEmpty(condPag))
            {
                predicate = predicate.And(p => p.parcela.descricao.Contains(condPag));
            }

            if ((DtEmiss != null) & (ValidateUtils.isDate(DtEmiss.ToString())))
            {
                predicate = predicate.And(p => DbFunctions.TruncateTime(p.data_emissao) == DbFunctions.TruncateTime(DtEmiss));
            }

            if ((DtFecha != null) & (ValidateUtils.isDate(DtFecha.ToString())))
            {
                predicate = predicate.And(p => DbFunctions.TruncateTime(p.data_fechamento) == DbFunctions.TruncateTime(DtFecha));
            }

            if ((status != null) && (status != StatusPedidoLimpo))
            {
                predicate = predicate.And(p => p.status == status);
            }

            pedido_OticaBLL = new Pedido_OticaBLL();
            List <Pedido_Otica> Pedido_OticaList = pedido_OticaBLL.getPedido_Otica(predicate.Expand(), t => t.Id.ToString(), false, deslocamento, tamanhoPagina, out totalReg);

            dgvDados.DataSource = pedido_OticaBLL.ToList_Pedido_OticaParcelaView(Pedido_OticaList);
        }