Exemple #1
0

        
        private void BtGerarPatch_Click(object sender, EventArgs e)
        {
            Crystal.SetDatabaseLogon("cad_pro_SEFAZ", "suanota_sefaz01");


            if (maskedTextBox1.Text == String.Empty)
            {
                MessageBox.Show("Favor digitar o número da remessa! " + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            DataBaseConection str = new DataBaseConection();
            //cria a conexão com o banco de dados
            SqlConnection con = str.BuscarConexao();


            SqlDataAdapter sda = new SqlDataAdapter("select nmvalorindice from tb_valor_indice a join tb_documento b on a.iddocumento = b.iddocumento join tb_caixa c on c.idcaixa = b.idcaixa where dscaixa  = '" + maskedTextBox1.Text + "'  and a.idindice = 4 ", con);

            DataSet Ds = new DataSet();

            sda.Fill(Ds, "tb_valor_indice");

            Crystal.SetDataSource(Ds);
            CrvGerarPatch.ReportSource = Crystal;
            con.Close();
        }
Exemple #3
0
        private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string strSql = "Select idcaixa,dscaixa from tb_caixa a join   tb_projeto  b on b.idprojeto = a.idprojeto  where b.idprojeto = '" + comboBox4.SelectedValue + "' and a.idstatus = 1";



                DataBaseConection str = new DataBaseConection();
                //cria a conexão com o banco de dados
                SqlConnection con = str.BuscarConexao();
                //cria o objeto command para executar a instruçao sql
                SqlCommand cmd = new SqlCommand(strSql, con);

                //abre a conexao
                con.Open();
                DataTable dt = new DataTable();
                dt.Load(cmd.ExecuteReader());
                con.Close();
                comboBox5.DataSource         = dt;
                comboBox5.DisplayMember      = "dscaixa";
                comboBox5.ValueMember        = "idcaixa";
                comboBox5.AutoCompleteMode   = AutoCompleteMode.Suggest;
                comboBox5.AutoCompleteSource = AutoCompleteSource.ListItems;
            }
            catch (Exception ex)
            {
            }
        }
Exemple #4
0
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                // string strSql = "select idpallet,nmpallet from tb_pallet a join tb_projeto b on a.idprojeto = b.idprojeto where idstatus = 1 and a.idprojeto = 1";
                string strSql = "select * from tb_tipo_documento a join tb_tipo_processo b on a.idtipoprocesso = b.idtipoprocesso where a.idtipoprocesso = '" + comboBox2.SelectedValue + "'";



                DataBaseConection str = new DataBaseConection();
                //cria a conexão com o banco de dados
                SqlConnection con = str.BuscarConexao();
                //cria o objeto command para executar a instruçao sql
                SqlCommand cmd = new SqlCommand(strSql, con);

                //abre a conexao
                con.Open();
                DataTable dt = new DataTable();
                dt.Load(cmd.ExecuteReader());
                con.Close();
                comboBox3.DataSource         = dt;
                comboBox3.DisplayMember      = "nmtipodocumento";
                comboBox3.ValueMember        = "idtipodocumento";
                comboBox3.AutoCompleteMode   = AutoCompleteMode.Suggest;
                comboBox3.AutoCompleteSource = AutoCompleteSource.ListItems;
            }
            catch (Exception ex)
            {
            }
        }
        private void FrmCadastroRemessa_Load(object sender, EventArgs e)
        {
            // string strSql = "select idpallet,nmpallet from tb_pallet a join tb_projeto b on a.idprojeto = b.idprojeto where idstatus = 1 and a.idprojeto = 1";
            string strSql = "select top 1 dscaixa from tb_caixa order by idcaixa desc";



            DataBaseConection str = new DataBaseConection();
            //cria a conexão com o banco de dados
            SqlConnection con = str.BuscarConexao();

            SqlCommand cmd = new SqlCommand(strSql, con);

            //cria o objeto command para executar a instruçao sql


            //abre a conexao
            con.Open();
            //define o tipo do comando
            cmd.CommandType    = CommandType.Text;
            cmd.CommandTimeout = 120;

            SqlDataReader dr1 = null;

            dr1 = cmd.ExecuteReader();

            if (dr1.Read())
            {
                label5.Text = dr1["dscaixa"].ToString();
            }
        }
Exemple #7
0
        private void BtnovoUser_Click(object sender, EventArgs e)
        {
            {
                if (textBox3.Text == string.Empty | textBox4.Text == string.Empty | comboBox2.Text == string.Empty)
                {
                    MessageBox.Show("Prencher os campos Usuario, Senha e Confirmar senha!" + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    comboBox2.Focus();
                    return;
                }

                if (textBox4.Text != textBox3.Text)
                {
                    MessageBox.Show("As senhas não conferem! " + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    comboBox2.Focus();
                    return;
                }
                try
                {
                    string strSql = "update tb_usuario "
                                    + "set senha = '" + textBox3.Text + "' "
                                    + "where idusuario = '" + comboBox2.SelectedValue + "'";


                    DataBaseConection str = new DataBaseConection();
                    //cria a conexão com o banco de dados
                    SqlConnection con = str.BuscarConexao();
                    //cria o objeto command para executar a instruçao sql
                    SqlCommand cmd = new SqlCommand(strSql, con);
                    //abre a conexao
                    con.Open();

                    //define o tipo do comando
                    cmd.CommandType    = CommandType.Text;
                    cmd.CommandTimeout = 120;

                    SqlDataReader dr = cmd.ExecuteReader();

                    //limpar campos

                    textBox3.Clear();
                    textBox4.Clear();
                    comboBox2.Focus();

                    //fecha a conexção
                    con.Close();

                    MessageBox.Show("SENHA ALTERADA COM SUCESSO");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("DADOS NÃO ENCONTRADOS " + ex.Message + "\n" + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    Application.Exit();
                }
                finally
                {
                }
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            if (textBox4.Text == String.Empty)
            {
                MessageBox.Show("Favor informar a Remessa! " + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Focus();
                return;
            }

            try
            {
                string strSql = "update tb_caixa set idstatus = 1 where dscaixa = '" + textBox4.Text + "'";



                DataBaseConection str = new DataBaseConection();
                //cria a conexão com o banco de dados
                SqlConnection con = str.BuscarConexao();

                SqlCommand cmd = new SqlCommand(strSql, con);

                con.Open();

                //define o tipo do comando
                cmd.CommandType    = CommandType.Text;
                cmd.CommandTimeout = 120;
                //obtem um datareader

                SqlDataReader dr = cmd.ExecuteReader();


                textBox3.Clear();

                if (dr.RecordsAffected >= 1)
                {
                    con.Close();
                    MessageBox.Show("Remessa Liberada!");
                    textBox4.Clear();
                    textBox4.Focus();
                }
                else
                {
                    con.Close();
                    MessageBox.Show("Remessa Inexistente!");
                    textBox4.Clear();
                    textBox4.Focus();
                }
            }


            catch (Exception ex)
            {
                MessageBox.Show("DADOS NÃO ENCONTRADOS " + ex.Message + "\n" + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                Application.Exit();
            }
        }
Exemple #9
0
        private void telamenu_Load(object sender, EventArgs e)
        {
            textBox2.Text = idusuario.ToString();



            // TODO: This line of code loads data into the 'cad_proDataSet.tb_projeto' table. You can move, or remove it, as needed.
            this.tb_projetoTableAdapter.Fill(this.cad_proDataSet.tb_projeto);

            try

            {
                //string strProvider = "Data Source=10.254.194.53;Initial Catalog=cad_pro_SEFAZ;Persist Security Info=True;User ID=sa;Password=senha@123; Connect Timeout = 120";
                //define a instrução SQL



                string strSql = "select idperfil from tb_usuario where idusuario = '" + textBox2.Text + "' and idperfil = 1 ";



                DataBaseConection str = new DataBaseConection();
                //cria a conexão com o banco de dados
                SqlConnection con = str.BuscarConexao();
                //cria o objeto command para executar a instruçao sql
                SqlCommand cmd = new SqlCommand(strSql, con);

                //abre a conexao
                con.Open();

                //define o tipo do comando
                cmd.CommandType    = CommandType.Text;
                cmd.CommandTimeout = 120;

                SqlDataReader dr = cmd.ExecuteReader();

                if (dr.HasRows)
                {
                    btConfig.Visible = true;
                }
                else
                {
                    BtAtrsenhausuario.Visible = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DADOS NÃO ENCONTRADOS " + ex.Message + "\n" + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                Application.Exit();
            }
        }
Exemple #10
0
        private void button1_Click(object sender, EventArgs e)
        {
            {
                if (maskedTextBox4.Text == String.Empty | maskedTextBox14.Text == String.Empty)
                {
                    MessageBox.Show("Prencer todos os campos! " + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    textBox1.Focus();
                    return;
                }

                try
                {
                    string strSql = "declare @tmp as table (iddocumento int) "
                                    + "insert into @tmp "
                                    + "select a.iddocumento from tb_valor_indice a "
                                    + "join tb_documento b on b.iddocumento = a.iddocumento "
                                    + "where nmvalorindice = '000" + maskedTextBox4.Text + "' and idcaixa =  " + textBox2.Text + " "
                                    + "begin "
                                    + "delete from tb_valor_indice where iddocumento in(select distinct iddocumento from @tmp); "
                                    + "delete from tb_documento where iddocumento in (select distinct iddocumento from @tmp); "
                                    + "end ";



                    DataBaseConection str = new DataBaseConection();
                    //cria a conexão com o banco de dados
                    SqlConnection con = str.BuscarConexao();

                    SqlCommand cmd = new SqlCommand(strSql, con);

                    con.Open();

                    //define o tipo do comando
                    cmd.CommandType    = CommandType.Text;
                    cmd.CommandTimeout = 120;
                    //obtem um datareader

                    SqlDataReader dr = cmd.ExecuteReader();



                    if (dr.RecordsAffected >= 1)
                    {
                        con.Close();
                        MessageBox.Show("Documento Excluido!");
                    }

                    else
                    {
                        con.Close();
                        MessageBox.Show("Documento Inexistente!");
                    }
                }


                catch (Exception ex)
                {
                    MessageBox.Show("DADOS NÃO ENCONTRADOS " + ex.Message + "\n" + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    Application.Exit();
                }
                finally
                {
                    BtUpdate.Visible = false;
                    BtInsert.Visible = true;
                    maskedTextBox14.Clear();
                    maskedTextBox4.Clear();
                    maskedTextBox4.Focus();
                }
            }
        }
Exemple #11
0
        //btupdate
        private void button14_Click(object sender, EventArgs e)
        {
            {
                if (maskedTextBox4.Text == String.Empty | maskedTextBox14.Text == String.Empty)
                {
                    MessageBox.Show("Prencer todos os campos! " + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    textBox1.Focus();
                    return;
                }

                try
                {
                    string strSql = "declare @identitydoc int "
                                    + "insert into tb_documento values (" + comboBox3.SelectedValue + ",getdate()," + textBox2.Text + "," + textBox7.Text + "); select @@identity "
                                    + "set @identitydoc = @@identity "
                                    + "insert into tb_valor_indice values ('000" + maskedTextBox4.Text + "',@identitydoc,1) "
                                    + "insert into tb_valor_indice values ('" + maskedTextBox14.Text + "',@identitydoc,2) "
                                    + "insert into tb_valor_indice values ('*" + maskedTextBox14.Text + "000" + maskedTextBox4.Text + "*',@identitydoc,4) "

                                    + "select indice,nmvalorindice from tb_valor_indice a "
                                    + "join tb_indice b on a.idindice = b.idindice "
                                    + "where iddocumento = @identitydoc";



                    DataBaseConection str = new DataBaseConection();
                    //cria a conexão com o banco de dados
                    SqlConnection con = str.BuscarConexao();

                    SqlCommand cmd = new SqlCommand(strSql, con);

                    //SqlCommand cmd1 = new SqlCommand(novodocumento, con);


                    //con.Open();
                    //cmd1.CommandType = CommandType.Text;
                    //cmd1.CommandTimeout = 120;
                    //SqlDataReader dr1 = cmd1.ExecuteReader();
                    //con.Close();
                    //abre a conexao
                    con.Open();

                    //define o tipo do comando
                    cmd.CommandType    = CommandType.Text;
                    cmd.CommandTimeout = 120;
                    //obtem um datareader

                    SqlDataReader dr = cmd.ExecuteReader();

                    if (dr.HasRows)
                    {
                        con.Close();
                        maskedTextBox4.Clear();
                        maskedTextBox14.Clear();
                        maskedTextBox4.Focus();

                        //string strProvider = "Data Source=10.254.194.53;Initial Catalog=cad_pro_SEFAZ;Persist Security Info=True;User ID=sa;Password=senha@123; Connect Timeout = 120";
                        //define a instrução SQL



                        // string strSql = "select idpallet,nmpallet from tb_pallet a join tb_projeto b on a.idprojeto = b.idprojeto where idstatus = 1 and a.idprojeto = 1";
                        string strSql1 = "select count(iddocumento) as qtddoc from tb_documento where idcaixa = " + textBox2.Text + "";



                        //cria o objeto command para executar a instruçao sql
                        SqlCommand cmd1 = new SqlCommand(strSql1, con);

                        //abre a conexao
                        con.Open();
                        //define o tipo do comando
                        cmd1.CommandType    = CommandType.Text;
                        cmd1.CommandTimeout = 120;

                        SqlDataReader dr1 = null;

                        dr1 = cmd1.ExecuteReader();

                        if (dr1.Read())
                        {
                            label48.Text = dr1["qtddoc"].ToString();
                        }
                    }



                    con.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("DADOS NÃO ENCONTRADOS " + ex.Message + "\n" + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    Application.Exit();
                }
                finally
                {
                    BtUpdate.Visible = false;
                    BtInsert.Visible = true;
                    maskedTextBox14.Clear();
                    maskedTextBox4.Focus();
                }
            }
        }
Exemple #12
0
        private void Indexer_Load(object sender, EventArgs e)
        {
            this.Text = "Indexer Caixa: " + dscaixa;
            //Desabilita o botão Fechar (X)
            IntPtr hMenu         = GetSystemMenu(this.Handle, false);
            int    MenuItemCount = GetMenuItemCount(hMenu);

            RemoveMenu(hMenu, MenuItemCount - 1, MF_BYPOSITION);

            // TODO: This line of code loads data into the 'cad_proDataSet.tb_projeto' table. You can move, or remove it, as needed.
            this.tb_projetoTableAdapter.Fill(this.cad_proDataSet.tb_projeto);
            // TODO: This line of code loads data into the 'cad_proDataSet.tb_pallet' table. You can move, or remove it, as needed.

            // TODO: This line of code loads data into the 'cad_proDataSet.tb_projeto' table. You can move, or remove it, as needed.
            this.tb_projetoTableAdapter.Fill(this.cad_proDataSet.tb_projeto);



            if (idprojeto != "" | idcaixa != "" | idusuario != "")
            {
                textBox1.Text = idprojeto;
                textBox2.Text = idcaixa;
                textBox7.Text = idusuario;
            }
            // if (idcaixa != "")
            // {
            //     textBox1.Text = idcaixa;
            // }

            // {



            // string strSql = "select idpallet,nmpallet from tb_pallet a join tb_projeto b on a.idprojeto = b.idprojeto where idstatus = 1 and a.idprojeto = 1";
            string strSql = "select idtipoprocesso,nmtipoprocesso from tb_tipo_processo where idprojeto = " + textBox1.Text + "";



            DataBaseConection str = new DataBaseConection();
            //cria a conexão com o banco de dados
            SqlConnection con = str.BuscarConexao();
            //cria o objeto command para executar a instruçao sql
            SqlCommand cmd = new SqlCommand(strSql, con);

            //abre a conexao
            con.Open();
            DataTable dt = new DataTable();

            dt.Load(cmd.ExecuteReader());
            con.Close();
            comboBox2.DataSource    = dt;
            comboBox2.DisplayMember = "nmtipoprocesso";
            comboBox2.ValueMember   = "idtipoprocesso";

            // string strSql = "select idpallet,nmpallet from tb_pallet a join tb_projeto b on a.idprojeto = b.idprojeto where idstatus = 1 and a.idprojeto = 1";
            string strSql1 = "select count(iddocumento) as qtddoc from tb_documento where idcaixa = " + textBox2.Text + "";



            //cria a conexão com o banco de dados

            //cria o objeto command para executar a instruçao sql
            SqlCommand cmd1 = new SqlCommand(strSql1, con);

            //abre a conexao
            con.Open();
            //define o tipo do comando
            cmd1.CommandType    = CommandType.Text;
            cmd1.CommandTimeout = 120;


            SqlDataReader dr1 = null;

            dr1 = cmd1.ExecuteReader();


            if (dr1.Read())
            {
                label48.Text = dr1["qtddoc"].ToString();
            }


            con.Close();

            //comboBox2.AutoCompleteMode = AutoCompleteMode.Suggest;
            //comboBox2.AutoCompleteSource = AutoCompleteSource.ListItems;
        }
Exemple #13
0
        private void maskedTextBox4_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                {
                    string strSql = "select CodParticipante from tb_auto_complete_participante where CodRemessa =  '" + maskedTextBox4.Text + "' ";



                    DataBaseConection str = new DataBaseConection();
                    //cria a conexão com o banco de dados
                    SqlConnection con = str.BuscarConexao();
                    //cria o objeto command para executar a instruçao sql

                    SqlCommand cmd = new SqlCommand(strSql, con);

                    //SqlCommand cmd1 = new SqlCommand(novodocumento, con);


                    //con.Open();
                    //cmd1.CommandType = CommandType.Text;
                    //cmd1.CommandTimeout = 120;
                    //SqlDataReader dr1 = cmd1.ExecuteReader();
                    //con.Close();
                    //abre a conexao
                    con.Open();

                    //define o tipo do comando
                    cmd.CommandType    = CommandType.Text;
                    cmd.CommandTimeout = 120;
                    //obtem um datareader

                    SqlDataReader dr = cmd.ExecuteReader();


                    if (dr.HasRows)
                    {
                        con.Close();

                        BtUpdate.Visible = true;
                        BtInsert.Visible = false;
                        {
                            try
                            {
                                string strSql1 = "select CodParticipante from tb_auto_complete_participante where CodRemessa =  '" + maskedTextBox4.Text + "'";



                                //cria o objeto command para executar a instruçao sql

                                SqlCommand cmd1 = new SqlCommand(strSql1, con);

                                //SqlCommand cmd1 = new SqlCommand(novodocumento, con);


                                //con.Open();
                                //cmd1.CommandType = CommandType.Text;
                                //cmd1.CommandTimeout = 120;
                                //SqlDataReader dr1 = cmd1.ExecuteReader();
                                //con.Close();
                                //abre a conexao
                                con.Open();

                                //define o tipo do comando
                                cmd1.CommandType    = CommandType.Text;
                                cmd1.CommandTimeout = 120;
                                //obtem um datareader

                                SqlDataReader dr1 = cmd1.ExecuteReader();



                                if (dr1.HasRows)
                                {
                                    while (dr1.Read())
                                    {
                                        maskedTextBox14.Text = dr1["CodParticipante"].ToString();
                                        this.maskedTextBox14.Focus();
                                    }
                                    if (dr1.HasRows)
                                    {
                                        try
                                        {
                                            con.Close();



                                            string strSql2 = "select nmvalorindice from tb_valor_indice where iddocumento = " + textBox11.Text + "";


                                            System.Data.SqlClient.SqlCommand com = new System.Data.SqlClient.SqlCommand(string.Format("select nmvalorindice from tb_valor_indice where iddocumento = " + textBox11.Text + " ", CommandType.Text), con);

                                            SqlCommand cmd2 = new SqlCommand(strSql2, con);


                                            System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter(cmd2);
                                            cmd2.CommandType    = CommandType.Text;
                                            cmd2.CommandTimeout = 120;
                                            DataTable dt = new DataTable();


                                            con.Open();
                                            da.Fill(dt);
                                            maskedTextBox14.Text = dt.Rows[1]["nmvalorindice"].ToString();


                                            con.Close();
                                        }

                                        catch (Exception ex)
                                        {
                                        }
                                    }
                                }
                            }



                            catch (Exception ex)
                            {
                                MessageBox.Show("DADOS NÃO ENCONTRADOS " + ex.Message + "\n" + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                                Application.Exit();
                            }

                            return;
                        }
                    }

                    else
                    {
                        this.maskedTextBox14.Focus();
                    }
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == String.Empty | textBox2.Text == String.Empty)
            {
                MessageBox.Show("Favor preencha todos os campos! " + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox1.Focus();
                return;
            }
            string strSql = "select * from tb_caixa where dscaixa = '" + textBox1.Text + "'+'/'+right ((CONVERT(VARCHAR(20), GETDATE(), 103)),4)  and idstatus <> 6";



            DataBaseConection str = new DataBaseConection();
            //cria a conexão com o banco de dados
            SqlConnection con = str.BuscarConexao();
            //cria o objeto command para executar a instruçao sql

            SqlCommand cmd = new SqlCommand(strSql, con);

            con.Open();

            //define o tipo do comando
            cmd.CommandType    = CommandType.Text;
            cmd.CommandTimeout = 120;
            //obtem um datareader

            SqlDataReader dr = cmd.ExecuteReader();


            if (dr.HasRows)
            {
                MessageBox.Show("Caixa já cadastrada anteriormente! " + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            else
            {
                {
                    try
                    {
                        string strSql1 = "declare  @numero int ,@dscaixa varchar(18) ,@ano varchar(18) "

                                         + "set @numero = " + textBox1.Text + " "
                                         + "set @dscaixa = 0 "
                                         + "set @ano = right ((CONVERT(VARCHAR(20), GETDATE(), 103)),4) "
                                         + "while  @numero >='" + textBox1.Text + "' and  @numero <='" + textBox2.Text + "' "
                                         + "begin "
                                         + "insert into tb_caixa (dscaixa,idstatus,idprojeto) "
                                         + "values (CONVERT(VARCHAR(20), @numero, 12)+'/'+@ano,1,1) "

                                         + "set @numero =  @numero +1 "

                                         + "end";



                        SqlConnection con1 = str.BuscarConexao();
                        //cria o objeto command para executar a instruçao sql

                        SqlCommand cmd1 = new SqlCommand(strSql1, con1);

                        //SqlCommand cmd1 = new SqlCommand(novodocumento, con);


                        //con.Open();
                        //cmd1.CommandType = CommandType.Text;
                        //cmd1.CommandTimeout = 120;
                        //SqlDataReader dr1 = cmd1.ExecuteReader();
                        //con.Close();
                        //abre a conexao
                        con1.Open();

                        //define o tipo do comando
                        cmd1.CommandType    = CommandType.Text;
                        cmd1.CommandTimeout = 120;
                        //obtem um datareader

                        SqlDataReader dr1 = cmd1.ExecuteReader();

                        textBox1.Focus();
                        textBox1.Clear();
                        textBox2.Clear();

                        if (dr.HasRows)
                        {
                        }
                        con.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("DADOS NÃO ENCONTRADOS " + ex.Message + "\n" + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        Application.Exit();
                    }
                    finally
                    {
                        MessageBox.Show("Caixa cadastrada com sucesso!  \n", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
Exemple #15
0
        private void button1_Click(object sender, EventArgs e)
        {
            dataGridView1.Columns.Clear();
            Boolean consulta = true;

            try
            {
                string strSql = "select remessa,lote,participante,[Status] as [Status da Remessa] from (select nmvalorindice as Lote,a.iddocumento from tb_valor_indice a "
                                + "join tb_documento c on c.iddocumento = a.iddocumento where  a.idindice = 1 ) g "
                                + "inner join (select nmvalorindice as Participante,d.iddocumento,dscaixa as Remessa,nmstatus as Status from tb_valor_indice d "
                                + "join tb_documento e on d.iddocumento = e.iddocumento "
                                + "join tb_caixa j on j.idcaixa = e.idcaixa "
                                + "join tb_status k on k.idstatus = j.idstatus "
                                + "where j.dscaixa = '" + MtRemessa.Text.Replace(" ", "") + "' and d.idindice = 2) h "
                                + "on g.iddocumento = h.iddocumento "
                                + "order by h.iddocumento";


                DataBaseConection str = new DataBaseConection();
                //cria a conexão com o banco de dados
                SqlConnection con = str.BuscarConexao();
                //cria o objeto command para executar a instruçao sql
                SqlCommand cmd = new SqlCommand(strSql, con);
                //abre a conexao
                con.Open();

                //define o tipo do comando
                cmd.CommandType    = CommandType.Text;
                cmd.CommandTimeout = 120;
                //obtem um datareader

                SqlDataReader dr       = cmd.ExecuteReader();
                int           nColunas = dr.FieldCount;
                for (int i = 0; i < nColunas; i++)
                {
                    dataGridView1.Columns.Add(dr.GetName(i).ToString(), dr.GetName(i).ToString());
                    dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                }

                //define um array de strings com nCOlunas
                string[] linhaDados = new string[nColunas];
                //percorre o DataRead



                consulta = false;
                while (dr.Read())
                {
                    //percorre cada uma das colunas
                    for (int a = 0; a < nColunas; a++)
                    {
                        //verifica o tipo de dados da coluna
                        if (dr.GetFieldType(a).ToString() == "System.Int32")
                        {
                            linhaDados[a] = dr.GetInt32(a).ToString();
                        }
                        if (dr.GetFieldType(a).ToString() == "System.String")
                        {
                            linhaDados[a] = dr.GetString(a).ToString();
                        }
                        if (dr.GetFieldType(a).ToString() == "System.DateTime")
                        {
                            linhaDados[a] = dr.GetDateTime(a).ToString();
                        }
                    }

                    if (consulta)
                    {
                        MessageBox.Show("DADOS NÃO ENCONTRADOS");
                    }
                    dataGridView1.Rows.Add(linhaDados);
                }
                //fecha a conexção
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("DADOS NÃO ENCONTRADOS " + ex.Message + "\n" + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                Application.Exit();
            }
            finally
            {
            }
        }
Exemple #16
0
        private void button8_Click(object sender, EventArgs e)
        {
            {
                if (comboBox5.Text == String.Empty)
                {
                    MessageBox.Show("Favor escolha uma remessa! " + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    textBox1.Focus();
                    return;
                }

                try
                {
                    string strSql = "select * from tb_caixa where idcaixa = " + comboBox5.SelectedValue + " and idusuario is null or idusuario =" + idusuario + "";



                    DataBaseConection str = new DataBaseConection();
                    //cria a conexão com o banco de dados
                    SqlConnection con = str.BuscarConexao();

                    SqlCommand cmd = new SqlCommand(strSql, con);

                    //SqlCommand cmd1 = new SqlCommand(novodocumento, con);


                    //con.Open();
                    //cmd1.CommandType = CommandType.Text;
                    //cmd1.CommandTimeout = 120;
                    //SqlDataReader dr1 = cmd1.ExecuteReader();
                    //con.Close();
                    //abre a conexao
                    con.Open();

                    //define o tipo do comando
                    cmd.CommandType    = CommandType.Text;
                    cmd.CommandTimeout = 120;
                    //obtem um datareader

                    SqlDataReader dr = cmd.ExecuteReader();

                    if (dr.HasRows)
                    {
                        try
                        {
                            con.Close();

                            // string strSql = "select idpallet,nmpallet from tb_pallet a join tb_projeto b on a.idprojeto = b.idprojeto where idstatus = 1 and a.idprojeto = 1";
                            string strSql1 = "update tb_caixa set idstatus = 2 where idcaixa = '" + comboBox5.SelectedValue + "'";
                            string strSql2 = "update tb_caixa set idusuario = " + idusuario + " where idcaixa = '" + comboBox5.SelectedValue + "'";



                            //cria a conexão com o banco de dados

                            //cria o objeto command para executar a instruçao sql
                            SqlCommand cmd1 = new SqlCommand(strSql1, con);
                            SqlCommand cmd2 = new SqlCommand(strSql2, con);
                            //abre a conexao
                            con.Open();
                            DataTable dt = new DataTable();
                            dt.Load(cmd1.ExecuteReader());
                            dt.Load(cmd2.ExecuteReader());
                            con.Close();
                        }

                        catch (Exception ex)
                        {
                            MessageBox.Show("FALHA DE ACESSO " + ex.Message + "\n" + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        comboBox5.SelectedItem = -1;
                        Indexer frm = new Indexer();
                        frm.idprojeto = comboBox4.SelectedValue.ToString();
                        frm.idcaixa   = comboBox5.SelectedValue.ToString();
                        frm.dscaixa   = comboBox5.Text;
                        frm.idusuario = textBox2.Text;
                        frm.ShowDialog();
                        groupPallet.Visible = false;

                        Indexer indexer = new CadastroProtocolo.Indexer();
                        indexer.Parent = this.Parent;

                        this.button8.Enabled = true;

                        this.Show();
                        comboBox4.SelectedValue = -1;
                        comboBox5.SelectedValue = -1;
                    }
                    else
                    {
                        MessageBox.Show("A remessa " + comboBox5.Text + " já está em uso! \n Favor escolha outra remessa.");
                    }



                    con.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("DADOS NÃO ENCONTRADOS " + ex.Message + "\n" + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    Application.Exit();
                }
            }
        }
Exemple #17
0
        void Rremessa()
        {
            dataGridView1.Columns.Clear();
            Boolean consulta = true;

            try
            {
                string strSql = "SELECT upper (nmlogin) as Usuario,dscaixa as Caixa,LTRIM(LEFT(CONVERT(VARCHAR(20), min(dtinclusao), 108), 8))[Hora Inicial],LTRIM(LEFT(CONVERT(VARCHAR(20), max(dtinclusao), 108), 8))[Hora Final],LTRIM(LEFT(CONVERT(VARCHAR(20), max(dtinclusao)- min(dtinclusao), 108), 8)) [Tempo Gasto],count(distinct a.iddocumento)Documentos "
                                + "from tb_documento a  "
                                + "join tb_usuario b on a.idusuario = b.idusuario "
                                + "join tb_caixa c on c.idcaixa = a.idcaixa "
                                + "where CONVERT(VARCHAR(20),  dtinclusao, 103) = '" + dateTimePicker2.Text + "' and idprojeto = " + comboBox1.SelectedValue + " and idtipodocumento = " + comboBox2.SelectedValue + " "
                                + "group by NmLogin,dscaixa";


                DataBaseConection str = new DataBaseConection();
                //cria a conexão com o banco de dados
                SqlConnection con = str.BuscarConexao();
                //cria o objeto command para executar a instruçao sql
                SqlCommand cmd = new SqlCommand(strSql, con);
                //abre a conexao
                con.Open();

                //define o tipo do comando
                cmd.CommandType    = CommandType.Text;
                cmd.CommandTimeout = 120;
                //obtem um datareader

                SqlDataReader dr       = cmd.ExecuteReader();
                int           nColunas = dr.FieldCount;
                for (int i = 0; i < nColunas; i++)
                {
                    dataGridView1.Columns.Add(dr.GetName(i).ToString(), dr.GetName(i).ToString());
                    dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                }

                //define um array de strings com nCOlunas
                string[] linhaDados = new string[nColunas];
                //percorre o DataRead



                consulta = false;
                while (dr.Read())
                {
                    //percorre cada uma das colunas
                    for (int a = 0; a < nColunas; a++)
                    {
                        //verifica o tipo de dados da coluna
                        if (dr.GetFieldType(a).ToString() == "System.Int32")
                        {
                            linhaDados[a] = dr.GetInt32(a).ToString();
                        }
                        if (dr.GetFieldType(a).ToString() == "System.String")
                        {
                            linhaDados[a] = dr.GetString(a).ToString();
                        }
                        if (dr.GetFieldType(a).ToString() == "System.DateTime")
                        {
                            linhaDados[a] = dr.GetDateTime(a).ToString();
                        }
                    }

                    if (consulta)
                    {
                        MessageBox.Show("DADOS NÃO ENCONTRADOS");
                    }
                    dataGridView1.Rows.Add(linhaDados);
                }
                //fecha a conexção
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("DADOS NÃO ENCONTRADOS " + ex.Message + "\n" + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                Application.Exit();
            }
            finally
            {
            }
        }
Exemple #18
0
        public void Logar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtUsuario.Text == String.Empty)
                {
                    MessageBox.Show("Favor prencher os campos Usuário e Senha! " + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtUsuario.Focus();
                    return;
                }



                //define a instrução SQL



                string strSql = "select idusuario,nmlogin,senha from tb_usuario where nmlogin = '******' and senha = '" + txtSenha.Text + "' ";


                DataBaseConection str = new DataBaseConection();
                //cria a conexão com o banco de dados
                SqlConnection con = str.BuscarConexao();
                //cria o objeto command para executar a instruçao sql
                SqlCommand cmd = new SqlCommand(strSql, con);

                //abre a conexao
                con.Open();

                //define o tipo do comando
                cmd.CommandType    = CommandType.Text;
                cmd.CommandTimeout = 120;

                cmd.Parameters.Add("@usuario", SqlDbType.VarChar).Value = txtUsuario.Text;
                cmd.Parameters.Add("@senha", SqlDbType.VarChar).Value   = txtSenha.Text;



                SqlDataReader dr = null;

                dr = cmd.ExecuteReader();

                if (dr.Read())
                {
                    this.Hide();

                    telamenu frmp = new telamenu(txtUsuario.Text);

                    frmp.idusuario = dr["idusuario"].ToString();

                    frmp.Show();
                }
                else
                {
                    MessageBox.Show("Usuário ou Senha Incorretos! " + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtUsuario.Clear();
                    txtSenha.Clear();
                    txtUsuario.Focus();
                }

                //fecha a conexção
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("DADOS NÃO ENCONTRADOS " + ex.Message + "\n" + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                Application.Exit();
            }
            finally
            {
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == String.Empty | textBox2.Text == String.Empty | textBox3.Text == String.Empty | textBox4.Text == String.Empty | comboBox1.Text == String.Empty)
            {
                MessageBox.Show("Favor prencher os campos Usuário,Nome e Senha! " + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox2.Focus();
                return;
            }



            if (textBox4.Text != textBox3.Text)
            {
                MessageBox.Show("As senhas não conferem. " + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox3.Clear();
                textBox3.Focus();

                return;
            }



            {
                try
                {
                    string strSql = "insert into tb_usuario  (nmlogin,nome,senha,idperfil) "
                                    + "values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "'," + comboBox1.SelectedValue + ")";



                    DataBaseConection str = new DataBaseConection();
                    //cria a conexão com o banco de dados
                    SqlConnection con = str.BuscarConexao();
                    //cria o objeto command para executar a instruçao sql
                    SqlCommand cmd = new SqlCommand(strSql, con);
                    //abre a conexao
                    con.Open();

                    //define o tipo do comando
                    cmd.CommandType    = CommandType.Text;
                    cmd.CommandTimeout = 120;

                    SqlDataReader dr = cmd.ExecuteReader();

                    //limpar campos
                    textBox1.Clear();
                    textBox2.Clear();
                    textBox3.Clear();
                    textBox4.Clear();

                    textBox2.Focus();

                    //fecha a conexção
                    con.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("DADOS NÃO ENCONTRADOS " + ex.Message + "\n" + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    Application.Exit();
                }
                finally
                {
                    MessageBox.Show("USUARIO CADASTRADO COM SUCESSO");
                }
            }
        }
        private void button1_Click_1(object sender, EventArgs e)
        {
            {
                DialogResult dialogo = MessageBox.Show("Deseja realmente excluir este usuário?" + "\n", "Finalizar Remessa", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                if (dialogo == DialogResult.Yes)
                {
                    if (textBox1.Text == String.Empty)
                    {
                        MessageBox.Show("Favor informar a usuário! " + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        textBox1.Focus();
                        return;
                    }

                    try
                    {
                        string strSql = "delete from tb_usuario where nmlogin = '******' ";



                        DataBaseConection str = new DataBaseConection();
                        //cria a conexão com o banco de dados
                        SqlConnection con = str.BuscarConexao();

                        SqlCommand cmd = new SqlCommand(strSql, con);

                        con.Open();

                        //define o tipo do comando
                        cmd.CommandType    = CommandType.Text;
                        cmd.CommandTimeout = 120;
                        //obtem um datareader

                        SqlDataReader dr = cmd.ExecuteReader();


                        textBox3.Clear();

                        if (dr.RecordsAffected >= 1)
                        {
                            con.Close();
                            MessageBox.Show("Usuário Deletado!");
                            textBox3.Clear();
                            textBox3.Focus();
                        }
                        else
                        {
                            con.Close();
                            MessageBox.Show("Usuário Inexistente!");
                            textBox3.Clear();
                            textBox3.Focus();
                        }
                    }


                    catch (Exception ex)
                    {
                        MessageBox.Show("DADOS NÃO ENCONTRADOS " + ex.Message + "\n" + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        Application.Exit();
                    }
                }
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult dialogo = MessageBox.Show("Deseja realmente excluir esta remessa remessa?" + "\n", "Finalizar Remessa", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

            if (dialogo == DialogResult.Yes)
            {
                if (textBox3.Text == String.Empty)
                {
                    MessageBox.Show("Favor informar a Remessa! " + "\n", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    textBox1.Focus();
                    return;
                }

                try
                {
                    string strSql = "declare @tmp as table (iddocumento int)  "
                                    + "insert into @tmp  "
                                    + "select a.iddocumento from tb_valor_indice a "
                                    + "join tb_documento b on b.iddocumento = a.iddocumento "
                                    + "join tb_caixa c on c.idcaixa = b.idcaixa "
                                    + "where  dscaixa =  '" + textBox3.Text + "' "
                                    + "begin "
                                    + "delete from tb_valor_indice where iddocumento in(select distinct iddocumento from @tmp); "
                                    + "delete from tb_documento where iddocumento in (select distinct iddocumento from @tmp); "
                                    + "delete from tb_caixa where idcaixa in (select distinct idcaixa from @tmp); "
                                    + "end";



                    DataBaseConection str = new DataBaseConection();
                    //cria a conexão com o banco de dados
                    SqlConnection con = str.BuscarConexao();

                    SqlCommand cmd = new SqlCommand(strSql, con);

                    con.Open();

                    //define o tipo do comando
                    cmd.CommandType    = CommandType.Text;
                    cmd.CommandTimeout = 120;
                    //obtem um datareader

                    SqlDataReader dr = cmd.ExecuteReader();


                    textBox3.Clear();

                    if (dr.RecordsAffected >= 1)
                    {
                        con.Close();
                        MessageBox.Show("Remessa Deletada!");
                        textBox3.Clear();
                        textBox3.Focus();
                    }
                    else
                    {
                        con.Close();
                        MessageBox.Show("Remessa Inexistente!");
                        textBox3.Clear();
                        textBox3.Focus();
                    }
                }


                catch (Exception ex)
                {
                    MessageBox.Show("DADOS NÃO ENCONTRADOS " + ex.Message + "\n" + ex.StackTrace, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    Application.Exit();
                }
            }
        }