private void btnEditar_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = Conecta.abrirConexao();
         SqlCommand    cmd = con.CreateCommand();
         cmd.CommandText = "AtualizarFornecedor";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@id", this.txtId.Text);
         cmd.Parameters.AddWithValue("@nome", this.txtNome.Text);
         cmd.Parameters.AddWithValue("@cnpj", this.txtCnpj.Text);
         cmd.Parameters.AddWithValue("@endereco", this.txtEndereco.Text);
         cmd.Parameters.AddWithValue("@fone", this.txtTelefone.Text);
         cmd.Parameters.AddWithValue("@email", this.txtEmail.Text);
         cmd.Parameters.Add("@data", SqlDbType.Date, 31).Value = dtpData.Text;
         Conecta.abrirConexao();
         cmd.ExecuteNonQuery();
         CarregaDgvFornecedor();
         MessageBox.Show("Fornecedor atualizado com sucesso!", "Atualiza", MessageBoxButtons.OK);
         Conecta.fecharConexao();
         txtId.Text       = "";
         txtNome.Text     = "";
         txtCnpj.Text     = "";
         txtEndereco.Text = "";
         txtTelefone.Text = "";
         txtEmail.Text    = "";
         dtpData.Text     = "";
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
 }
示例#2
0
        private void btnLogar_Click(object sender, EventArgs e)
        {
            SqlConnection con = Conecta.abrirConexao();
            string        usu = "select usuario,senha from login where usuario=@login and senha=@senha";
            SqlCommand    cmd = new SqlCommand(usu, con);

            cmd.Parameters.AddWithValue("@login", SqlDbType.NChar).Value = txtLogin.Text.Trim();
            txtSenha.Text = s.Base64Encode(txtSenha.Text);
            string criptografada = txtSenha.Text;

            cmd.Parameters.AddWithValue("@senha", SqlDbType.NChar).Value = criptografada;
            Conecta.abrirConexao();
            cmd.CommandType = CommandType.Text;
            SqlDataReader usuario = cmd.ExecuteReader();

            if (usuario.HasRows)
            {
                this.Hide();
                FrmInicial ini = new FrmInicial();
                ini.Show();
                usuario.Close();
                Conecta.fecharConexao();
            }
            else
            {
                MessageBox.Show("Login ou senha incorretos! Tente novamente!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtLogin.Text = "";
                txtSenha.Text = "";
                usuario.Close();
                Conecta.fecharConexao();
            }
        }
 private void btnBusca_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = Conecta.abrirConexao();
         SqlCommand    cmd = con.CreateCommand();
         cmd.CommandText = "LocalizarFornecedor";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@id", this.txtId.Text);
         cmd.Parameters.AddWithValue("@nome", this.txtNome.Text);
         cmd.Parameters.AddWithValue("@cnpj", this.txtCnpj.Text);
         Conecta.abrirConexao();
         SqlDataReader rd = cmd.ExecuteReader();
         if (rd.Read())
         {
             txtId.Text       = rd["Id"].ToString();
             txtNome.Text     = rd["nome"].ToString();
             txtCnpj.Text     = rd["cnpj"].ToString();
             txtEndereco.Text = rd["endereco"].ToString();
             txtTelefone.Text = rd["telefone"].ToString();
             txtEmail.Text    = rd["email"].ToString();
             dtpData.Text     = rd["data_cadastro"].ToString();
             Conecta.fecharConexao();
         }
         else
         {
             MessageBox.Show("Este fornecedor não foi encontrado em nossa base de dados !", "Sem registro!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             Conecta.fecharConexao();
         }
     }
     finally
     {
     }
 }
 private void btnCadastro_Click(object sender, EventArgs e)
 {
     //codigo para inserir o login no banco
     try
     {
         SqlConnection con = Conecta.abrirConexao();
         SqlCommand    cmd = con.CreateCommand();
         cmd.CommandText = "InserirLogin";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@cpf", txtCpf.Text);
         cmd.Parameters.AddWithValue("@usuario", txtNome.Text);
         //codificando txtsenha.
         txtSenha.Text = b.Base64Encode(txtSenha.Text);
         //nova variavel para atribuo o txtSenha nela.
         string criptografada = txtSenha.Text;
         //o parametro gravar a senha decodificada já no banco.
         cmd.Parameters.AddWithValue("@senha", criptografada);
         Conecta.abrirConexao();
         cmd.ExecuteNonQuery();
         CarregaDgvlogin();
         MessageBox.Show("Registro inserido com sucesso!", "Cadastro", MessageBoxButtons.OK);
         Conecta.fecharConexao();
         txtId.Text    = "";
         txtCpf.Text   = "";
         txtNome.Text  = "";
         txtSenha.Text = "";
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
 }
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = Conecta.abrirConexao();
         SqlCommand    cmd = con.CreateCommand();
         cmd.CommandText = "ExcluirFornecedor";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@Id", this.txtId.Text);
         Conecta.abrirConexao();
         cmd.ExecuteNonQuery();
         CarregaDgvFornecedor();
         MessageBox.Show("Fornecedor apagado com sucesso!", "Excluir", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         Conecta.fecharConexao();
         txtId.Text       = "";
         txtNome.Text     = "";
         txtCnpj.Text     = "";
         txtEndereco.Text = "";
         txtTelefone.Text = "";
         txtEmail.Text    = "";
         dtpData.Text     = "";
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
 }
 private void btnExcluirItem_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = Conecta.abrirConexao();
         SqlCommand    cmd = con.CreateCommand();
         cmd.CommandText = "ExcluirItemBalanca";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@Id", this.txtId.Text);
         Conecta.abrirConexao();
         cmd.ExecuteNonQuery();
         CarregaDgvCaixaVenda();
         MessageBox.Show("Produto apagado com sucesso!", "Excluir", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         Conecta.fecharConexao();
         txtId.Text         = "";
         txtCodigo.Text     = "";
         txtTipo.Text       = "";
         txtNome.Text       = "";
         txtCorte.Text      = "";
         txtQuantidade.Text = "";
         txtUsuario.Text    = "";
         txtValor.Text      = "";
         txtValorTotal.Text = "";
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
 }
 private void btnEditar_Click(object sender, EventArgs e)
 {
     //codigo para atualizar os dados do login
     try
     {
         SqlConnection con = Conecta.abrirConexao();
         SqlCommand    cmd = con.CreateCommand();
         cmd.CommandText = "AtualizarLogin";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@Id", this.txtId.Text);
         cmd.Parameters.AddWithValue("@cpf", this.txtCpf.Text);
         cmd.Parameters.AddWithValue("@usuario", this.txtNome.Text);
         cmd.Parameters.AddWithValue("@senha", this.txtSenha.Text);
         Conecta.abrirConexao();
         cmd.ExecuteNonQuery();
         CarregaDgvlogin();
         MessageBox.Show("Registro atualizado com sucesso!", "Atualizar Registro", MessageBoxButtons.OK, MessageBoxIcon.Information);
         Conecta.fecharConexao();
         txtId.Text    = "";
         txtCpf.Text   = "";
         txtNome.Text  = "";
         txtSenha.Text = "";
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
 }
示例#8
0
 private void btnEditar_Click_1(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = Conecta.abrirConexao();
         SqlCommand    cmd = con.CreateCommand();
         cmd.CommandText = "AtualizarUsuario";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@Id", this.txtId.Text);
         cmd.Parameters.AddWithValue("@nome", this.txtNome.Text);
         cmd.Parameters.AddWithValue("@cpf", this.txtCpf.Text);
         cmd.Parameters.AddWithValue("@fone", this.txtFone.Text);
         cmd.Parameters.AddWithValue("@email", this.txtEmail.Text);
         cmd.Parameters.AddWithValue("@funcao", this.txtFuncao.Text);
         Conecta.abrirConexao();
         cmd.ExecuteNonQuery();
         CarregaDgvUsuario();
         MessageBox.Show("Registro atualizado com sucesso!", "Atualizar Registro", MessageBoxButtons.OK, MessageBoxIcon.Information);
         Conecta.fecharConexao();
         txtId.Text     = "";
         txtNome.Text   = "";
         txtCpf.Text    = "";
         txtFone.Text   = "";
         txtEmail.Text  = "";
         txtFuncao.Text = "";
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
 }
 private void btnInseri_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = Conecta.abrirConexao();
         SqlCommand    cmd = con.CreateCommand();
         cmd.CommandText = "IserirCliente";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@nome", txtNome.Text);
         cmd.Parameters.AddWithValue("@cpf", txtCpf.Text);
         cmd.Parameters.AddWithValue("@endereco", txtEndereco.Text);
         cmd.Parameters.AddWithValue("@telefone", txtTelefone.Text);
         cmd.Parameters.AddWithValue("@email", txtEmail.Text);
         cmd.Parameters.Add("@data_nascimento", SqlDbType.Date, 31).Value = dateTimePicker1.Text;
         Conecta.abrirConexao();
         cmd.ExecuteNonQuery();
         CarregaDgvCliente();
         MessageBox.Show("Cliente cadastrado com sucesso!", "Cadastro", MessageBoxButtons.OK);
         Conecta.fecharConexao();
         txtId.Text           = "";
         txtNome.Text         = "";
         txtCpf.Text          = "";
         txtEndereco.Text     = "";
         txtTelefone.Text     = "";
         txtEmail.Text        = "";
         dateTimePicker1.Text = "";
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
 }
 private void bntLocalizar_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = Conecta.abrirConexao();
         SqlCommand    cmd = con.CreateCommand();
         cmd.CommandText = "Localizarpedido";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@id", this.txtId.Text);
         cmd.Parameters.AddWithValue("@codigo", this.cbxCodigo.Text);
         Conecta.abrirConexao();
         SqlDataReader rd = cmd.ExecuteReader();
         if (rd.Read())
         {
             txtId.Text         = rd["Id"].ToString();
             cbxCodigo.Text     = rd["codigo"].ToString();
             cbxTipo.Text       = rd["tipo"].ToString();
             txtNome.Text       = rd["nome"].ToString();
             cbxCorte.Text      = rd["corte"].ToString();
             txtQuantidade.Text = rd["quantidade"].ToString();
             txtValor.Text      = rd["valor"].ToString();
             txtUsuario.Text    = rd["usuario"].ToString();
             txtValorTotal.Text = rd["valortotal"].ToString();
             Conecta.fecharConexao();
         }
         else
         {
             MessageBox.Show("Este registro não foi encontrado!", "Sem registro!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             Conecta.fecharConexao();
         }
     }
     finally
     {
     }
 }
 private void btnBusca_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = Conecta.abrirConexao();
         SqlCommand    cmd = con.CreateCommand();
         cmd.CommandText = "LocalizarProduto";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@codigo", this.txtCodigo.Text);
         Conecta.abrirConexao();
         SqlDataReader rd = cmd.ExecuteReader();
         if (rd.Read())
         {
             txtId.Text     = rd["Id"].ToString();
             txtCodigo.Text = rd["codigo"].ToString();
             cbxTipo.Text   = rd["tipo"].ToString();
             txtNome.Text   = rd["nome"].ToString();
             txtMarca.Text  = rd["marca"].ToString();
             Conecta.fecharConexao();
         }
         else
         {
             MessageBox.Show("Este registro não foi encontrado!", "Sem registro!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             Conecta.fecharConexao();
         }
     }
     finally
     {
     }
 }
示例#12
0
 private void btnPesquisa_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = Conecta.abrirConexao();
         SqlCommand    cmd = con.CreateCommand();
         cmd.CommandText = "LocalizarLogin";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@cpf", this.txtCpf.Text);
         Conecta.abrirConexao();
         SqlDataReader rd = cmd.ExecuteReader();
         if (rd.Read())
         {
             txtId.Text   = rd["Id"].ToString();
             txtCpf.Text  = rd["cpf"].ToString();
             txtNome.Text = rd["usuario"].ToString();
             //txtSenha.Text = rd["senha"].ToString();
             Conecta.fecharConexao();
             rd.Close();
         }
         else
         {
             MessageBox.Show("Nenhum registro encontrado!", "Sem registro!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             Conecta.fecharConexao();
         }
     }
     finally
     {
     }
 }
 private void btnEditar_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = Conecta.abrirConexao();
         SqlCommand    cmd = con.CreateCommand();
         cmd.CommandText = "AtualizarProduto";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@id", this.txtId.Text);
         cmd.Parameters.AddWithValue("@codigo", this.txtCodigo.Text);
         cmd.Parameters.AddWithValue("@tipo", this.cbxTipo.Text);
         cmd.Parameters.AddWithValue("@Nome", this.txtNome.Text);
         cmd.Parameters.AddWithValue("@marca", this.txtMarca.Text);
         Conecta.abrirConexao();
         cmd.ExecuteNonQuery();
         CarregaDgvProduto();
         MessageBox.Show("Produto atualizado com sucesso!", "Atualiza", MessageBoxButtons.OK);
         Conecta.fecharConexao();
         txtId.Text     = "";
         txtCodigo.Text = "";
         cbxTipo.Text   = "";
         txtNome.Text   = "";
         txtMarca.Text  = "";
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
 }
        private void btnFinalizarPedido_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection con = Conecta.abrirConexao();
                SqlCommand    cmd = con.CreateCommand();
                cmd.CommandText = "InserirItemVendaBalanca1";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@codigo", cbxCodigo.Text);
                cmd.Parameters.AddWithValue("@tipo", cbxTipo.Text);
                cmd.Parameters.AddWithValue("@Nome", txtNome.Text);
                cmd.Parameters.AddWithValue("@corte", cbxCorte.Text);
                cmd.Parameters.Add("@quantidade", SqlDbType.Int).Value = (txtQuantidade.Text);
                cmd.Parameters.Add("@valor", SqlDbType.Int).Value      = Convert.ToDecimal(txtValor.Text);
                cmd.Parameters.AddWithValue("@usuario", txtUsuario.Text);
                cmd.Parameters.Add("@valortotal", SqlDbType.Int).Value      = Convert.ToDecimal(txtQuantidade.Text) * Convert.ToDecimal(txtValor.Text);
                cmd.Parameters.Add("@datapedido", SqlDbType.DateTime).Value = DateTime.Now;
                Conecta.abrirConexao();
                cmd.ExecuteNonQuery();
                Conecta.fecharConexao();
                SqlCommand cmdo = con.CreateCommand();
                cmdo.CommandText = "Excluirpedido";
                cmdo.CommandType = CommandType.StoredProcedure;
                cmdo.Parameters.AddWithValue("@Id", this.txtId.Text);
                Conecta.abrirConexao();
                cmdo.ExecuteNonQuery();
                CarregaDgvPedidoDelivery();
                MessageBox.Show("Pedido finalizada com sucesso. Vai para finalizar venda", "Pedido", MessageBoxButtons.OK, MessageBoxIcon.Information);

                /* if (comand == DialogResult.Yes)
                 * {
                 *   FrmComandoPedido compe = new FrmComandoPedido();
                 *   compe.codigo = cbxCodigo.Text;
                 *   compe.Show();
                 *   this.Close();
                 * }*/
                Conecta.fecharConexao();
                txtId.Text         = "";
                cbxCodigo.Text     = "";
                cbxTipo.Text       = "";
                txtNome.Text       = "";
                cbxCorte.Text      = "";
                txtQuantidade.Text = "";
                txtValor.Text      = "";
                txtValorTotal.Text = "";
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
            }
        }
        public void CarregaDgvCliente()
        {
            SqlConnection con   = Conecta.abrirConexao();
            String        query = "select * from Cliente";
            SqlCommand    cmd   = new SqlCommand(query, con);

            Conecta.abrirConexao();
            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da   = new SqlDataAdapter(cmd);
            DataTable      clie = new DataTable();

            da.Fill(clie);
            dgvCliente.DataSource = clie;
            Conecta.fecharConexao();
        }
        public void CarregaDgvFornecedor()
        {
            SqlConnection con   = Conecta.abrirConexao();
            String        query = "select * from Fornecedor";
            SqlCommand    cmd   = new SqlCommand(query, con);

            Conecta.abrirConexao();
            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da    = new SqlDataAdapter(cmd);
            DataTable      forne = new DataTable();

            da.Fill(forne);
            dgvFornecedor.DataSource = forne;
            Conecta.fecharConexao();
        }
        public void CarregaDgvProduto()
        {
            SqlConnection con   = Conecta.abrirConexao();
            String        query = "select * from produto";
            SqlCommand    cmd   = new SqlCommand(query, con);

            Conecta.abrirConexao();
            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da      = new SqlDataAdapter(cmd);
            DataTable      produto = new DataTable();

            da.Fill(produto);
            DgvProduto.DataSource = produto;
            Conecta.fecharConexao();
        }
示例#18
0
        //criando o metodo para carregar o gride
        public void CarregaDgvlogin()
        {
            SqlConnection con   = Conecta.abrirConexao();
            String        query = "select * from Login";
            SqlCommand    cmd   = new SqlCommand(query, con);

            Conecta.abrirConexao();
            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da    = new SqlDataAdapter(cmd);
            DataTable      login = new DataTable();

            da.Fill(login);
            DgvLogim.DataSource = login;
            Conecta.fecharConexao();
        }
        public void CarregaCbxTipo()
        {
            String     pro = "SELECT Id, nome FROM produto";
            SqlCommand cmd = new SqlCommand(pro, con);

            Conecta.abrirConexao();
            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da = new SqlDataAdapter(pro, con);
            DataSet        ds = new DataSet();

            da.Fill(ds, "tipo");
            cbxTipo.ValueMember   = "Id";
            cbxTipo.DisplayMember = "tipo";
            cbxTipo.DataSource    = ds.Tables["tipo"];
            Conecta.fecharConexao();
        }
 private void btnFinalizarVenda_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = Conecta.abrirConexao();
         SqlCommand    cmd = con.CreateCommand();
         cmd.CommandText = "VendaFinalizada";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@codigo", txtCodigo.Text);
         cmd.Parameters.AddWithValue("@tipo", txtTipo.Text);
         cmd.Parameters.AddWithValue("@Nome", txtNome.Text);
         cmd.Parameters.AddWithValue("@corte", txtCorte.Text);
         cmd.Parameters.Add("@quantidade", SqlDbType.Float).Value = (txtQuantidade.Text);
         cmd.Parameters.Add("@valor", SqlDbType.Int).Value        = Convert.ToDecimal(txtValor.Text);
         cmd.Parameters.AddWithValue("@usuario", txtUsuario.Text);
         cmd.Parameters.Add("@valortotal", SqlDbType.Int).Value       = Convert.ToDecimal(txtQuantidade.Text) * Convert.ToDecimal(txtValor.Text);
         cmd.Parameters.Add("@datavendido", SqlDbType.DateTime).Value = DateTime.Now;
         Conecta.abrirConexao();
         cmd.ExecuteNonQuery();
         Conecta.fecharConexao();
         SqlCommand cmdo = con.CreateCommand();
         cmdo.CommandText = "ExcluirItemBalanca";
         cmdo.CommandType = CommandType.StoredProcedure;
         cmdo.Parameters.AddWithValue("@Id", this.txtId.Text);
         Conecta.abrirConexao();
         cmdo.ExecuteNonQuery();
         CarregaDgvCaixaVenda();
         MessageBox.Show("Venda finalizada com sucesso!", "Cadastro", MessageBoxButtons.OK);
         Conecta.fecharConexao();
         txtId.Text         = "";
         txtCodigo.Text     = "";
         txtTipo.Text       = "";
         txtNome.Text       = "";
         txtCorte.Text      = "";
         txtQuantidade.Text = "";
         txtValor.Text      = "";
         txtValorTotal.Text = "";
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
 }
 public void CarregaDgvPedidoDelivery()
 {
     try
     {
         SqlConnection con  = Conecta.abrirConexao();
         string        pedi = "select * from PedidoDelivery";
         SqlCommand    cmd  = new SqlCommand(pedi, con);
         Conecta.abrirConexao();
         cmd.CommandType = CommandType.Text;
         SqlDataAdapter da     = new SqlDataAdapter(cmd);
         DataTable      pedido = new DataTable();
         da.Fill(pedido);
         dgvPedidoDelivery.DataSource = pedido;
         Conecta.fecharConexao();
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
 }
 public void CarregaDgvCaixaVenda()
 {
     try
     {
         SqlConnection con  = Conecta.abrirConexao();
         string        pedi = "select * from ItemVendaBalanca";
         SqlCommand    cmd  = new SqlCommand(pedi, con);
         Conecta.abrirConexao();
         cmd.CommandType = CommandType.Text;
         SqlDataAdapter da    = new SqlDataAdapter(cmd);
         DataTable      venda = new DataTable();
         da.Fill(venda);
         dgvCaixaVenda.DataSource = venda;
         Conecta.fecharConexao();
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
 }
 private void btnAtualizar_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = Conecta.abrirConexao();
         SqlCommand    cmd = con.CreateCommand();
         cmd.CommandText = "Atualizarpedido";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@id", this.txtId.Text);
         cmd.Parameters.AddWithValue("@codigo", this.cbxCodigo.Text);
         cmd.Parameters.AddWithValue("@tipo", this.cbxTipo.Text);
         cmd.Parameters.AddWithValue("@Nome", this.txtNome.Text);
         cmd.Parameters.AddWithValue("@corte", this.cbxCorte.Text);
         cmd.Parameters.AddWithValue("@quantidade", this.txtQuantidade.Text);
         cmd.Parameters.AddWithValue("@valor", SqlDbType.Int).Value           = Convert.ToDecimal(this.txtValor.Text);
         cmd.Parameters.AddWithValue("@usuario", SqlDbType.NChar).Value       = this.txtUsuario.Text;
         cmd.Parameters.AddWithValue("@valortotal", SqlDbType.Int).Value      = Convert.ToDecimal(this.txtQuantidade.Text) * Convert.ToDecimal(this.txtValor.Text);
         cmd.Parameters.AddWithValue("@datapedido", SqlDbType.DateTime).Value = DateTime.Now;
         Conecta.abrirConexao();
         cmd.ExecuteNonQuery();
         CarregaDgvPedidoDelivery();
         MessageBox.Show("Produto atualizado com sucesso!", "Atualiza", MessageBoxButtons.OK);
         Conecta.fecharConexao();
         txtId.Text         = "";
         cbxCodigo.Text     = "";
         cbxTipo.Text       = "";
         txtNome.Text       = "";
         cbxCorte.Text      = "";
         txtQuantidade.Text = "";
         txtUsuario.Text    = "";
         txtValor.Text      = "";
         txtValorTotal.Text = "";
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
 }
示例#24
0
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConnection con = Conecta.abrirConexao();
         SqlCommand    cmd = con.CreateCommand();
         cmd.CommandText = "ExcluirLogin";
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@Id", this.txtId.Text);
         Conecta.abrirConexao();
         cmd.ExecuteNonQuery();
         CarregaDgvlogin();
         MessageBox.Show("Registro apagado com sucesso!", "Excluir Registro", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         Conecta.fecharConexao();
         txtId.Text    = "";
         txtCpf.Text   = "";
         txtNome.Text  = "";
         txtSenha.Text = "";
     }
     catch (Exception er)
     {
         MessageBox.Show(er.Message);
     }
 }