private void criarFinanceiro(int idReserva, int idUsuario) { Conexao conexao = new Conexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("sp_Ins_Financeiro", conexao.conexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Dt_FINANCEIRO", Convert.ToDateTime(dtpReserva.Text)); cmd.Parameters.AddWithValue("@ID_HORARIORESERVA", idReserva); cmd.Parameters.AddWithValue("@ID_USUARIO", idUsuario); cmd.Parameters.AddWithValue("@ST_FINANCEIRO", "True"); cmd.Parameters.AddWithValue("@STC_FINANCEIRO", "EM ABERTO"); cmd.Parameters.AddWithValue("@VL_FINANCEIRO", Double.Parse(txtValorCampo.Text.Replace("R$", "")) * vezes); cmd.ExecuteReader(CommandBehavior.SingleRow); conexao.desconectar(); }
//Metodo preencher tela com dados. public void preencheCadastro() { Conexao conexao = new Conexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("sp_Sel_FinanceiroEsp", conexao.conexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ID_HORARIORESERVA", LoginUsuario.getReserva()); cmd.Parameters.AddWithValue("@ST_FINANCEIRO", "True"); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow); if (dr.Read()) { lblCliente.Text = dr[("Nome Cliente")].ToString(); lblValor.Text = "R$ " + dr[("Valor").ToString()]; } conexao.desconectar(); }
private void preencheCadastro() { Conexao conexao = new Conexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("sp_Sel_CampoEsp", conexao.conexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ID_CAMPO", dgvDados.CurrentRow.Cells[0].Value); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow); if (dr.Read()) { txtCodigo.Text = dr[("ID_CAMPO")].ToString(); txtCodigo.Text = txtCodigo.Text.PadLeft(5, '0'); txtDescricao.Text = dr[("DS_CAMPO")].ToString(); txtValor.Text = dr[("VL_CAMPO")].ToString(); } }
private void CmbCampo_SelectedIndexChanged(object sender, System.EventArgs e) { Conexao conexao = new Conexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conexao.conexao; cmd.CommandText = "sp_Sel_Campo"; cmd.Parameters.AddWithValue("@Ds_Campo", cmbCampo.Text); cmd.Parameters.AddWithValue("@ST_CAMPO", "True"); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow); if (dr.Read()) { txtValorCampo.Text = "R$ " + dr[("Valor")].ToString(); } }
private void preencheCadastro() { LimparCh(); Conexao conexao = new Conexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("sp_Sel_HorariosReservaEsp", conexao.conexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ID_HrReserva", dgvDados.CurrentRow.Cells[0].Value); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow); horario = string.Empty; if (dr.Read()) { horario = dr[("Hora Reservada")].ToString(); preencheCbHorarioAdd(horario); } conexao.desconectar(); }
private void btnSalvar_Click(object sender, EventArgs e) { //Formata Visual SidePanel.Height = btnSalvar.Height; SidePanel.Top = btnSalvar.Top; //Verifica se todos os campos estão preenchidos if (txtDescricao.Text == "" || txtValor.Text == "") { //Mensagem para o usuário MessageBox.Show("Informe todos os campos!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Conexao conexao = new Conexao(); conexao.conectar(); if (funcao == "ADICIONAR") { SqlCommand cmd = new SqlCommand("sp_Ins_Campo", conexao.conexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@DS_CAMPO", txtDescricao.Text); cmd.Parameters.AddWithValue("@VL_CAMPO", double.Parse(txtValor.Text)); cmd.Parameters.AddWithValue("@ST_CAMPO", "True"); cmd.ExecuteReader(CommandBehavior.SingleRow); } else { SqlCommand cmd = new SqlCommand("sp_Upd_Campo", conexao.conexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@DS_CAMPO", txtDescricao.Text); cmd.Parameters.AddWithValue("@VL_CAMPO", double.Parse(txtValor.Text)); cmd.Parameters.AddWithValue("@ID_CAMPO", Convert.ToInt32(txtCodigo.Text)); cmd.Parameters.AddWithValue("@ST_CAMPO", "True"); cmd.ExecuteReader(CommandBehavior.SingleRow); } conexao.desconectar(); controleBotao(true); atualizaGridView(); } }
private void preencheCadastro() { Conexao conexao = new Conexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("sp_Sel_UsuarioEsp", conexao.conexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ID_USUARIO", dgvDados.CurrentRow.Cells[0].Value); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow); if (dr.Read()) { txtCodigo.Text = dr[("ID_USUARIO")].ToString(); txtCodigo.Text = txtCodigo.Text.PadLeft(5, '0'); txtNome.Text = dr[("NM_USUARIO")].ToString(); txtSenha.Text = dr[("SH_USUARIO")].ToString(); txtNSenha.Text = dr[("SH_USUARIO")].ToString(); cmdNivel.Text = dr[("NA_USUARIO")].ToString(); } }
private void txtCliente_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { try { Conexao conexao = new Conexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conexao.conexao; cmd.CommandText = "sp_Sel_Cliente"; cmd.Parameters.AddWithValue("@NM_CLIENTE", txtCliente.Text); cmd.Parameters.AddWithValue("@CELULAR_CLIENTE", ""); cmd.Parameters.AddWithValue("@ST_CLIENTE", "True"); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); dgvClientes.DataSource = ds.Tables[0]; dgvClientes.Columns[0].Visible = false; dgvClientes.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvClientes.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable; dgvClientes.Columns[2].Width = 120; dgvClientes.Columns[2].Visible = false; conexao.desconectar(); if (dgvClientes.RowCount != 0) { dgvClientes.Focus(); } else { txtCliente.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void btnSalvar_Click(object sender, EventArgs e) { //Verifica se as senhas novas são iguais. if (txtSenha1.Text != txtSenha2.Text) { MessageBox.Show("Senhas NOVAS estão Diferentes! Tente Novamente ...", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { //Verifica se a senha atual é igual a informada, se 'SIM', Altera a senha. Conexao conexao = new Conexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("sp_Sel_UsuarioSenha", conexao.conexao); cmd.Parameters.AddWithValue("@Nm_Usuario", txtUsuario.Text); cmd.Parameters.AddWithValue("@Sh_Usuario", txtSenha.Text); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { //Altera a senha. Conexao conexaoUpdate = new Conexao(); conexaoUpdate.conectar(); SqlCommand cmdUpdate = new SqlCommand("sp_Upd_UsuarioSenha", conexaoUpdate.conexao); cmdUpdate.Parameters.AddWithValue("@Id_Usuario", LoginUsuario.getUsuarioId()); cmdUpdate.Parameters.AddWithValue("@Sh_Usuario", txtSenha1.Text.ToUpper()); cmdUpdate.CommandType = CommandType.StoredProcedure; cmdUpdate.ExecuteReader(CommandBehavior.SingleRow); conexaoUpdate.desconectar(); MessageBox.Show("Senha Alterada com SUCESSO!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } else { conexao.desconectar(); MessageBox.Show("Senhas ANTIGA é Diferente! Tente Novamente ...", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtSenha.Focus(); } } }
private void preencheCadastroAdd() { LimparCh(); Conexao conexao = new Conexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("sp_Sel_HorariosReservaAdd", conexao.conexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ST_Horario", "True"); cmd.Parameters.AddWithValue("@Dt_reserva", DateTime.Parse(dtpReserva.Text).ToString("yyyy-MM-dd")); cmd.Parameters.AddWithValue("@Id_Campo", int.Parse(cmbCampo.SelectedValue.ToString())); SqlDataReader dr = cmd.ExecuteReader(); horario = string.Empty; while (dr.Read()) { horario = horario + " " + dr[("Hora Reservada")].ToString(); } conexao.desconectar(); preencheCbHorarioAdd(horario); }
//Método para atualizar grid. private void atualizaGridView() { { Conexao conexao = new Conexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("sp_Sel_HorariosReserva", conexao.conexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ST_Horario", "True"); cmd.Parameters.AddWithValue("@Dt_Horario", dtFiltro.Value); cmd.Parameters.AddWithValue("@NM_Cliente", txtFiltro.Text); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); dgvDados.DataSource = ds.Tables[0]; dgvDados.Columns[0].Width = 100; dgvDados.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvDados.Columns[2].Width = 170; dgvDados.Columns[3].Width = 90; dgvDados.Columns[4].Width = 250; conexao.desconectar(); } }
private void permitirAcesso(int usuario) { Conexao conexao = new Conexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("sp_Sel_UsuarioAcesso", conexao.conexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id_Usuario", usuario); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { if (dr["Na_Usuario"].ToString() == "FUNCIONÁRIO") { //Painel Cadastro btnCadastros.Enabled = true; btnCadCampo.Enabled = true; btnCadCliente.Enabled = true; btnCadUsuario.Enabled = false; //Painel Procedimentos btnProcedimentos.Enabled = true; btnReserva.Enabled = true; //Painel Financeiro btnFinanceiro.Enabled = true; btnCaixa.Enabled = true; //Painel Listagem btnListagem.Enabled = false; btnLisCampo.Enabled = false; btnLisCliente.Enabled = false; btnLisUsuario.Enabled = false; //Painel Relatorios btnRelatorios.Enabled = false; btnRelReserva.Enabled = false; btnRelFinanceiro.Enabled = false; } conexao.desconectar(); } }
private void btnExcluir_Click(object sender, EventArgs e) { //Formata Visual SidePanel.Height = btnExcluir.Height; SidePanel.Top = btnExcluir.Top; if (dgvDados.RowCount > 0) { //Mensagem para o usuário DialogResult iResposta; iResposta = MessageBox.Show("Deseja realmente excluir?", "Confirmar!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (iResposta.ToString() == "Yes") { try { Conexao conexao = new Conexao(); conexao.conectar(); SqlCommand cmd = new SqlCommand("sp_Del_Horario", conexao.conexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ID_ID_HrReserva", Convert.ToInt32(dgvDados.CurrentRow.Cells[0].Value)); cmd.Parameters.AddWithValue("@ST_CAIXA", "False"); cmd.ExecuteReader(CommandBehavior.SingleRow); conexao.desconectar(); atualizaGridView(); } catch (Exception ex) { if (ex.Message.Contains("foreign key")) { MessageBox.Show("Informe o Excluir! Verifique o financeiro", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } }
private void btnSalvar_Click(object sender, EventArgs e) { //Formata Visual SidePanel.Height = btnSalvar.Height; SidePanel.Top = btnSalvar.Top; //Verifica se todos os campos estão preenchidos if (ValidaCPF.IsCpf(txtCpf.Text)) { if (txtNome.Text == "" || txtRg.Text == "" || txtCpf.Text == "" || txtTelefone.Text == "" || txtCelular.Text == "" || txtEnd.Text == "" || txtNumero.Text == "" || txtComplemento.Text == "" || txtBairro.Text == "" || txtCep.Text == "" || txtCidade.Text == "" || txtUf.Text == "") { //Mensagem para o usuário MessageBox.Show("Informe todos os campos!", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Conexao conexao = new Conexao(); conexao.conectar(); if (funcao == "ADICIONAR") { SqlCommand cmd = new SqlCommand("sp_Ins_Cliente", conexao.conexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@NM_CLIENTE", txtNome.Text); cmd.Parameters.AddWithValue("@RG_CLIENTE", txtRg.Text); cmd.Parameters.AddWithValue("@CPF_CLIENTE", txtCpf.Text); cmd.Parameters.AddWithValue("@TELEFONE_CLIENTE", txtTelefone.Text); cmd.Parameters.AddWithValue("@CELULAR_CLIENTE", txtCelular.Text); cmd.Parameters.AddWithValue("@ENDERECO_CLIENTE", txtEnd.Text); cmd.Parameters.AddWithValue("@NUMERO_CLIENTE", txtNumero.Text); cmd.Parameters.AddWithValue("@COMPLEMENTO_CLIENTE", txtComplemento.Text); cmd.Parameters.AddWithValue("@BAIRRO_CLIENTE", txtBairro.Text); cmd.Parameters.AddWithValue("@CEP_CLIENTE", txtCep.Text); cmd.Parameters.AddWithValue("@CIDADE_CLIENTE", txtCidade.Text); cmd.Parameters.AddWithValue("@ESTADO_CLIENTE", txtUf.Text); cmd.Parameters.AddWithValue("@OBS_CLIENTE", txtObs.Text); cmd.Parameters.AddWithValue("@ST_CLIENTE", "True"); cmd.ExecuteReader(CommandBehavior.SingleRow); } else { SqlCommand cmd = new SqlCommand("sp_Upd_Cliente", conexao.conexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ID_CLIENTE", Convert.ToInt32(txtCodigo.Text)); cmd.Parameters.AddWithValue("@NM_CLIENTE", txtNome.Text); cmd.Parameters.AddWithValue("@RG_CLIENTE", txtRg.Text); cmd.Parameters.AddWithValue("@CPF_CLIENTE", txtCpf.Text); cmd.Parameters.AddWithValue("@TELEFONE_CLIENTE", txtTelefone.Text); cmd.Parameters.AddWithValue("@CELULAR_CLIENTE", txtCelular.Text); cmd.Parameters.AddWithValue("@ENDERECO_CLIENTE", txtEnd.Text); cmd.Parameters.AddWithValue("@NUMERO_CLIENTE", txtNumero.Text); cmd.Parameters.AddWithValue("@COMPLEMENTO_CLIENTE", txtComplemento.Text); cmd.Parameters.AddWithValue("@BAIRRO_CLIENTE", txtBairro.Text); cmd.Parameters.AddWithValue("@CEP_CLIENTE", txtCep.Text); cmd.Parameters.AddWithValue("@CIDADE_CLIENTE", txtCidade.Text); cmd.Parameters.AddWithValue("@ESTADO_CLIENTE", txtUf.Text); cmd.Parameters.AddWithValue("@OBS_CLIENTE", txtObs.Text); cmd.Parameters.AddWithValue("@ST_CLIENTE", "True"); cmd.ExecuteReader(CommandBehavior.SingleRow); } conexao.desconectar(); controleBotao(true); atualizaGridView(); } } else { MessageBox.Show("CPF Inválido!", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnSalvar_Click(object sender, EventArgs e) { horario = string.Empty; criatextoHorario(); //Formata Visual SidePanel.Height = btnSalvar.Height; SidePanel.Top = btnSalvar.Top; //Verifica se todos os campos estão preenchidos if (cmbCampo.Text == "" || dtpReserva.Text == "" || dgvClientes.Rows.Count == 0 || vezes == 0) { //Mensagem para o usuário MessageBox.Show("Informe todos os campos!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Conexao conexao = new Conexao(); conexao.conectar(); if (funcao == "ADICIONAR") { SqlCommand cmd = new SqlCommand("sp_Ins_HorariosReserva", conexao.conexao); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ID_Cliente", dgvClientes.CurrentRow.Cells[0].Value); cmd.Parameters.AddWithValue("@ID_Campo", cmbCampo.SelectedValue); cmd.Parameters.AddWithValue("@HR_Reservada", horario.Trim()); cmd.Parameters.AddWithValue("@ST_Horario", "True"); cmd.Parameters.AddWithValue("@DT_Reserva", dtpReserva.Value); cmd.Parameters.AddWithValue("@TP_Reservado", 1); cmd.Parameters.AddWithValue("@Vl_Reserva", Double.Parse(txtValorCampo.Text.Replace("R$", "")) * vezes); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SingleRow); if (dr.Read()) { idReserva = int.Parse(dr[("Retorno")].ToString()); criarFinanceiro(idReserva, LoginUsuario.getUsuarioId()); } else { idReserva = 0; } } else { SqlCommand cmd = new SqlCommand("sp_Ins_HorariosReserva", conexao.conexao); cmd.Parameters.AddWithValue("@ID_Cliente", dgvClientes.CurrentRow.Cells[0].Value); cmd.Parameters.AddWithValue("@ID_Campo", cmbCampo.SelectedValue); cmd.Parameters.AddWithValue("@HR_Reservada", " ");//Verificar CheckBox cmd.Parameters.AddWithValue("@ST_Horario", "True"); cmd.Parameters.AddWithValue("@DT_Reserva", dtpReserva.Value); cmd.Parameters.AddWithValue("@TP_Reservado", 1); cmd.Parameters.AddWithValue("@Vl_Reserva", Double.Parse(txtValorCampo.Text.Replace("R$", ""))); cmd.ExecuteReader(CommandBehavior.SingleRow); } conexao.desconectar(); DialogResult iResposta; iResposta = MessageBox.Show("Deseja receber a reserva?", "Confirmar!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (iResposta.ToString() == "Yes") { LoginUsuario.reserva(Convert.ToInt32(idReserva)); frmRecebimento frmRecebimento = new frmRecebimento(); frmRecebimento.ShowDialog(); } iResposta = MessageBox.Show("Deseja imprimir o comprovante?", "Confirmar!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (iResposta.ToString() == "Yes") { Imprimir(); } controleBotao(true); atualizaGridView(); idReserva = 0; } }