public void ExecutarDevolucao() { string messagem = "Tem Certeza que deseja Executar essa Devolução ?" + dataGridViewLista.CurrentRow.Cells["Nome_Livro"].Value.ToString();; string captionn = "Alerta"; MessageBoxButtons buttonss = MessageBoxButtons.YesNo; DialogResult resultt; resultt = MessageBox.Show(messagem, captionn, buttonss); if (resultt == System.Windows.Forms.DialogResult.Yes) { EmprestimoAluno objetoCT = new EmprestimoAluno { IdEmprestimo = Convert.ToInt32(dataGridViewLista.CurrentRow.Cells["IdEmprestimo"].Value), //pega o valor do id emp IdLivro = Convert.ToInt32(dataGridViewLista.CurrentRow.Cells["Id_Livro"].Value), //pega o valor do id livro Id_Aluno = Convert.ToInt32(dataGridViewLista.CurrentRow.Cells["IdAluno"].Value), }; CN_EmprestimoAluno objetoCN = new CN_EmprestimoAluno(); objetoCN.Devolucao(objetoCT); ExibirConsultaAluno(); MostrarEmprestimoUnico(); checkBox1.Checked = false; MessageBox.Show("Devolução efetuada com sucesso"); } }
public EmprestimoAlunoConsu(EmprestimoAluno emprestimo, Aluno aluno, Livro livro, string func) { InitializeComponent(); // labelId.Text = aluno.IdEmprestimo.ToString(); labelNome.Text = aluno.Nome; labelLivro.Text = livro.Nome_Livro; labelReno.Text = emprestimo.DataProcesso.ToString("dd/MM/yyyy"); labelDEV.Text = emprestimo.DataSaida.ToString("dd/MM/yyyy"); labelDataEmpre.Text = emprestimo.DataAtual.ToString("dd/MM/yyyy"); textBox2.Text = Convert.ToString(emprestimo.Id_FuncionarioCadastro); textBox1.Text = func; labelidAluno.Text = Convert.ToString(aluno.IdAluno); if ((emprestimo.DataEntregou <= emprestimo.DataSaida) && emprestimo.IdSituacao != 3) { labelEntre.Text = "Não Devolvido"; } else { labelEntre.Text = emprestimo.DataEntregou.ToString("dd/MM/yyyy"); }//criar função apertar lado direito do mause validação pra noa colocar uma data de devolução menor que a tual }
private void buttonDevolver_Click(object sender, EventArgs e) { string messagem = "Tem Certeza que deseja Executar essa Devolução ?" + dataGridViewLista.CurrentRow.Cells["Nome_Livro"].Value.ToString();; string captionn = "Alerta"; MessageBoxButtons buttonss = MessageBoxButtons.YesNo; DialogResult resultt; resultt = MessageBox.Show(messagem, captionn, buttonss); if (resultt == System.Windows.Forms.DialogResult.Yes) { int contagem = dataGridViewLista.Rows.Count; for (int i = 0; i < contagem; i++) { if (Convert.ToBoolean(dataGridViewLista.Rows[i].Cells["Column1"].Value) == true) { EmprestimoAluno objetoCT = new EmprestimoAluno { IdEmprestimo = Convert.ToInt32(dataGridViewLista.Rows[i].Cells["IdEmprestimo"].Value), //pega o valor do id emp IdLivro = Convert.ToInt32(dataGridViewLista.Rows[i].Cells["Id_Livro"].Value), //pega o valor do id livro Id_Aluno = Convert.ToInt32(dataGridViewLista.Rows[i].Cells["IdAluno"].Value), }; CN_EmprestimoAluno objetoCN = new CN_EmprestimoAluno(); objetoCN.Devolucao(objetoCT); } } ExibirConsultaAluno(); MostrarEmprestimoUnico(); checkBox1.Checked = false; MessageBox.Show("Devolução efetuada com sucesso"); } }
private void btnConsultar_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 0) { MessageBox.Show("Nenhum usuario foi selecionado.", "Consultar", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } EmprestimoAluno objetoCT = new EmprestimoAluno(); Aluno aluno = new Aluno(); Livro livro = new Livro(); objetoCT.IdEmprestimo = Convert.ToInt32(dataGridView1.CurrentRow.Cells["IdEmprestimo"].Value.ToString()); aluno.Nome = dataGridView1.CurrentRow.Cells["Nome"].Value.ToString(); livro.Nome_Livro = dataGridView1.CurrentRow.Cells["Nome_livro"].Value.ToString(); objetoCT.IdSituacao = Convert.ToInt32(dataGridView1.CurrentRow.Cells["idSituacao"].Value.ToString()); objetoCT.DataAtual = Convert.ToDateTime(dataGridView1.CurrentRow.Cells["DataAtual"].Value.ToString()); objetoCT.DataEntregou = Convert.ToDateTime(dataGridView1.CurrentRow.Cells["DataEntregou"].Value.ToString()); objetoCT.DataProcesso = Convert.ToDateTime(dataGridView1.CurrentRow.Cells["DataProcesso"].Value.ToString()); objetoCT.DataSaida = Convert.ToDateTime(dataGridView1.CurrentRow.Cells["DataSaida"].Value.ToString()); //objetoCT.Id_FuncionarioCadastro= Convert.ToInt32(dataGridView1.CurrentRow.Cells["Id_FuncionarioCadastro"].Value.ToString()); aluno.IdAluno = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Id_Aluno"].Value.ToString()); string func = dataGridView1.CurrentRow.Cells["NomeF"].Value.ToString(); EmprestimoAlunoConsu frmprofessorConsulta = new EmprestimoAlunoConsu(objetoCT, aluno, livro, func); DialogResult dialog = frmprofessorConsulta.ShowDialog(); }
public string InserirEmprestimoAluno(EmprestimoAluno aluno) { try { Conexao.LimparParametros(); Conexao.AdicionarParametros("@IdEmprestimo", aluno.IdEmprestimo); Conexao.AdicionarParametros("@IdOperacao", aluno.IdOperacao); Conexao.AdicionarParametros("@IdSituacao", aluno.IdSituacao); Conexao.AdicionarParametros("@Idaluno", aluno.Id_Aluno); Conexao.AdicionarParametros("@Id_FuncionarioCadastro", aluno.Id_FuncionarioCadastro); Conexao.AdicionarParametros("@IdLivro", aluno.IdLivro); Conexao.AdicionarParametros("@Dataatual", aluno.DataAtual); Conexao.AdicionarParametros("@DataSaida", aluno.DataSaida); Conexao.AdicionarParametros("@DataEntregou", DateTime.Now); Conexao.AdicionarParametros("@DataProcesso", DateTime.Now); string codigo = Conexao.ExecutarManipulacao(CommandType.StoredProcedure, "USP_EmprestimoAddAluno").ToString(); return(codigo); } catch (SqlException erro) { throw erro; } }
/* public DataTable ExecutarAtt(int IdEmprestimo) * { * SqlCommand c = new SqlCommand(); * DataTable Tabela = new DataTable(); * c.Connection = Conexao.AbrirConexao(); * c.Parameters.Add(new SqlParameter("@IdEmprestimo", IdEmprestimo)); * c.CommandText = "USP_AtualizaCampoVencimento"; * c.CommandType = CommandType.StoredProcedure; * * leerDados = c.ExecuteReader(); * Tabela.Load(leerDados); * * leerDados.Close(); * * return Tabela; * }*/ public void AtualizaDataVencimento(EmprestimoAluno aluno) { try { Conexao.LimparParametros(); Conexao.AdicionarParametros("@IdEmprestimo", aluno.IdEmprestimo); Conexao.ExecutarManipulacao(CommandType.StoredProcedure, "USP_AtualizaCampoVencimento").ToString(); //erro de objeto é so colocar pra retornar o id } catch (SqlException erro) { throw erro; } }
public EmprestimoAlunoColecao Consulta() { EmprestimoAlunoColecao Colecao = new EmprestimoAlunoColecao(); Conexao.LimparParametros(); DataTable dataTablealuno = Conexao.ExecutarConsulta(CommandType.StoredProcedure, "MostrarEmprestimosAlunos"); foreach (DataRow alunoLinha in dataTablealuno.Rows) { Aluno aluno = new Aluno(); EmprestimoAluno emprestimo = new EmprestimoAluno(); Funcionarios funcionarios = new Funcionarios(); //Livro livro = new Livro(); aluno.IdAluno = Convert.ToInt32(alunoLinha["Id_Aluno"]); aluno.Nome = Convert.ToString(alunoLinha["Nome"]); /* aluno.Cpf = Convert.ToString(alunoLinha["Cpf"]); * aluno.Matricula = Convert.ToString(alunoLinha["Matricula"]); * aluno.Telefone = Convert.ToString(alunoLinha["Telefone"]); * aluno.Email = Convert.ToString(alunoLinha["Email"]); * aluno.Id_FuncionarioCadastro = Convert.ToInt32(alunoLinha["Id_FuncionarioCadastro"]); */ funcionarios.Nome = alunoLinha["Nomef"].ToString(); aluno.Funcionarios = funcionarios; emprestimo.IdEmprestimo = Convert.ToInt32(alunoLinha["IdEmprestimo"].ToString()); // livro.Codigo_Livro= Convert.ToInt32(alunoLinha["Codigo_Livro"].ToString()); // livro.Nome_Livro = alunoLinha["Nome_Livro"].ToString(); emprestimo.IdSituacao = Convert.ToInt32(alunoLinha["IdSituacao"].ToString()); emprestimo.DataAtual = Convert.ToDateTime(alunoLinha["DataAtual"].ToString()); emprestimo.DataEntregou = Convert.ToDateTime(alunoLinha["DataProcesso"].ToString()); emprestimo.DataProcesso = Convert.ToDateTime(alunoLinha["DataEntregou"].ToString()); emprestimo.DataSaida = Convert.ToDateTime(alunoLinha["DataSaida"].ToString()); //emprestimo.Livro = livro; emprestimo.Aluno = aluno; Colecao.Add(emprestimo); } return(Colecao); }
/* private void timer1_Tick(object sender, EventArgs e) * { * * for (int i = 0; i < dataGridView1.Rows.Count; i++) * { * if (Convert.ToString( dataGridView1.Rows[i].Cells["Descricao"].Value) == "Em Andamento" && (Convert.ToDateTime(dataGridView1.Rows[i].Cells["Column4"].Value) < Convert.ToDateTime(DateTime.Now.ToString("dd/MM/yyyy")))) * { * * * EmprestimoAluno objetoCT = new EmprestimoAluno * { * IdEmprestimo = Convert.ToInt32(dataGridView1.Rows[i].Cells["IdEmprestimo"].Value),//pega o valor do id emp * * }; * * CN_EmprestimoAluno objetoCN = new CN_EmprestimoAluno(); * objetoCN.AtualizaDataVencimento(objetoCT); * * * } * } * //timer1.Enabled = false; * //MostrarEmprestimos(); * }*/ public void Atualizatudo() { MostrarEmprestimos(); for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (Convert.ToString(dataGridView1.Rows[i].Cells["Descricao"].Value) == "Em Andamento" && (Convert.ToDateTime(dataGridView1.Rows[i].Cells["DataSaida"].Value) < Convert.ToDateTime(DateTime.Now.ToString("dd/MM/yyyy")))) { EmprestimoAluno objetoCT = new EmprestimoAluno { IdEmprestimo = Convert.ToInt32(dataGridView1.Rows[i].Cells["idEmprestimo"].Value),//pega o valor do id emp }; CN_EmprestimoAluno objetoCN = new CN_EmprestimoAluno(); objetoCN.AtualizaDataVencimento(objetoCT); } } }
public void Devolucao(EmprestimoAluno aluno) { try { Conexao.LimparParametros(); Conexao.AdicionarParametros("@IdEmprestimo", aluno.IdEmprestimo); Conexao.AdicionarParametros("@Idaluno", aluno.Id_Aluno); Conexao.AdicionarParametros("@IdLivro", aluno.IdLivro); Conexao.ExecutarManipulacao(CommandType.StoredProcedure, "USP_DevolucaoAluno").ToString(); } catch (SqlException erro) { throw erro; } }
//Cadastrar Registro private void btnEnviar_Click(object sender, EventArgs e) { if (dataGridView1.Rows.Count > 0) { string retorno = null; var dataRowView = this.comboBox1.SelectedItem as DataRowView; //combobox usuario var dataRowViewLivros = this.comboBox2.SelectedItem as DataRowView; //combo box livros string messagem = "Tem Certeza que deseja Executar esse empréstimo?" + dataRowViewLivros.Row.ItemArray[1]; string captionn = "Alerta"; MessageBoxButtons buttonss = MessageBoxButtons.YesNo; DialogResult resultt; resultt = MessageBox.Show(messagem, captionn, buttonss); if (resultt == System.Windows.Forms.DialogResult.Yes) { for (int i = 0; i < dataGridView1.Rows.Count; i++) { Conexao.LimparParametros(); try { EmprestimoAluno objetoCT = new EmprestimoAluno { Id_Aluno = Convert.ToInt32(dataRowView.Row.ItemArray[0]),//pegar id do usuario IdOperacao = 1, IdSituacao = 1, IdEmprestimo = 0, IdLivro = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value.ToString()), Id_FuncionarioCadastro = UserLoginCache.Id_Funcionario, // DataAtual = DateTime.ParseExact(dateTimePicker1.Text, "dd/MM/yyyy", null), DataAtual = Convert.ToDateTime(dateTimePicker1.Text), DataSaida = Convert.ToDateTime(dateTimePicker2.Text), }; CN_EmprestimoAluno objetoCN = new CN_EmprestimoAluno(); retorno = objetoCN.InserirEmprestimoAluno(objetoCT); } catch (Exception) { MessageBox.Show("Codigo ou Usuario Indisponivel. "); } } try { int IdProfessor = Convert.ToInt32(retorno); if (retorno != null) { MessageBox.Show($"Empréstimo efetuado com sucesso"); } //atualiza os forms dataGridView1.Rows.Clear(); ComboAluno(); ComboLivro(); // this.Close(); } catch (FormatException) { //condição para verificar os emprestimos pendentes string message = retorno; string caption = "Alerta"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; result = MessageBox.Show(message, caption, buttons); if (result == System.Windows.Forms.DialogResult.Yes) { new EmprestimosPendentes().ShowDialog(); } //MessageBox.Show(retorno); //throw; } } } else { MessageBox.Show("Selecione no minimo um item para inserir o empréstimo"); } }