Ejemplo n.º 1
0
        private void PesquisarEntrada()
        {
            StringBuilder sSql = new StringBuilder();
            try
            {
                if (txtPesquisa.Text == "")
                {
                    KryptonMessageBox.Show(lblCampoValor.Text + " está Vazio");
                }
                else if (cbxCampoPesquisa.SelectedIndex == -1)
                {
                    KryptonMessageBox.Show("Campo de Pesquisa está vazio");
                }
                else if (cbxOperador.SelectedIndex == -1)
                {
                    KryptonMessageBox.Show("Campo Operador esta Vazio");
                }
                else
                {
                    sSql.Append("select ");
                    sSql.Append("movensai.cd_doc nNF, ");
                    sSql.Append("movensai.cd_mov Lancamento, ");
                    sSql.Append("movensai.cd_chave_nfe CHAVE, ");
                    sSql.Append("clifor.nm_clifor  nm_clifornor, ");
                    sSql.Append("clifor.cd_ufnor cUF, ");
                    sSql.Append("movensai.dt_emi AAMM, ");
                    sSql.Append("clifor.cd_cgc CNPJ, ");
                    sSql.Append("movensai.cd_serienf serie ");
                    sSql.Append("from movensai  inner join clifor on movensai.cd_clifor = clifor.cd_clifor ");
                    sSql.Append("where movensai.cd_empresa = '");
                    sSql.Append(_sEmp);
                    sSql.Append("' ");
                    sSql.Append("and ");
                    sSql.Append(_campoPesquisa);
                    switch (cbxOperador.SelectedIndex)
                    {
                        case 0:
                            {
                                sSql.Append(" = ");
                                sSql.Append("'");
                                sSql.Append(txtPesquisa.Text.Trim());
                                break;
                            }
                        case 1:
                            {
                                sSql.Append(" > ");
                                sSql.Append("'");
                                sSql.Append(txtPesquisa.Text.Trim());
                                break;
                            }
                        case 2:
                            {
                                sSql.Append(" >= ");
                                sSql.Append("'");
                                sSql.Append(txtPesquisa.Text.Trim());
                                break;
                            }
                        case 3:
                            {
                                sSql.Append(" < ");
                                sSql.Append("'");
                                sSql.Append(txtPesquisa.Text.Trim());
                                break;
                            }
                        case 4:
                            {
                                sSql.Append(" <= ");
                                sSql.Append("'");
                                sSql.Append(txtPesquisa.Text.Trim());
                                break;
                            }
                        case 5:
                            {
                                sSql.Append(" like ");
                                sSql.Append("'%");
                                sSql.Append(txtPesquisa.Text.Trim());
                                sSql.Append("%");
                                break;
                            }
                    }

                    sSql.Append("' ");
                    if (cbxModelo.SelectedIndex == 0)
                    {
                        sSql.Append("and  ");
                        sSql.Append("movensai.cd_chave_nfe is not null ");
                    }

                    FbCommand cmd = new FbCommand(sSql.ToString(), cx.get_Conexao());
                    cx.Open_Conexao();
                    cmd.ExecuteNonQuery();

                    FbDataReader dr = cmd.ExecuteReader();
                    List<belCampoPesquisa> lCampoPesquisa = new List<belCampoPesquisa>();

                    while (dr.Read())
                    {
                        belCampoPesquisa objCampo = new belCampoPesquisa();
                        objCampo.ChaveAcesso = dr["CHAVE"].ToString();
                        objCampo.NumeroNF = dr["nNF"].ToString();
                        objCampo.SeqNF = dr["Lancamento"].ToString();
                        objCampo.sCli_For = dr["nm_clifornor"].ToString();
                        objCampo.cUF = dr["cUF"].ToString();
                        objCampo.AAMM = dr["AAMM"].ToString();
                        objCampo.CNPJ = dr["CNPJ"].ToString();
                        objCampo.serie = dr["serie"].ToString();
                        lCampoPesquisa.Add(objCampo);

                    }
                    dgvPesquisa.DataSource = lCampoPesquisa;
                }
            }
            catch (Exception ex)
            {

                KryptonMessageBox.Show(ex.Message); ;
            }
            finally
            {
                cx.Close_Conexao();
            }
        }
Ejemplo n.º 2
0
        private void dgvPesquisa_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {

            if (e.RowIndex > -1)
            {
                objbelCampoPesquisa = new belCampoPesquisa();
                objbelCampoPesquisa = objbelCampoPesquisa.RetornaCampoSelecionado((dgvPesquisa.DataSource as List<belCampoPesquisa>), dgvPesquisa[1, e.RowIndex].Value.ToString());
                this.Close();
            }

        }
Ejemplo n.º 3
0
        private void btnPesquisarNF_Click(object sender, EventArgs e)
        {
            frmPesquisaNfe frm = new frmPesquisaNfe(_sEmp);
            frm.ShowDialog();
            objbelCampoPesquisa = frm.objbelCampoPesquisa;

            if (objbelCampoPesquisa != null)
            {
                if (objbelCampoPesquisa.ChaveAcesso != "")
                {
                    txtChaveAcesso.Text = objbelCampoPesquisa.ChaveAcesso;
                    tabControl1.SelectedTab = tabPageRefNfe;
                }
                else
                {
                    txtnNFref.Text = objbelCampoPesquisa.NumeroNF;
                    txtClifor.Text = objbelCampoPesquisa.sCli_For;
                    txtCNPJ.Text = objbelCampoPesquisa.CNPJ;
                    txtcUF.Text = objbelCampoPesquisa.cUF;
                    txtserieRef.Text = objbelCampoPesquisa.serie;
                    txtAAMM.Text = Convert.ToDateTime(objbelCampoPesquisa.AAMM).ToString("dd/MM/yyyy");
                    tabControl1.SelectedTab = tabPageRefNotaA1;
                }
                objbelCampoPesquisa = new belCampoPesquisa();
            }

        }