public string InserirEmprestimoExternos(EmprestimoExternos Externos) { try { Conexao.LimparParametros(); Conexao.AdicionarParametros("@IdEmprestimo", Externos.IdEmprestimo); Conexao.AdicionarParametros("@IdOperacao", Externos.IdOperacao); Conexao.AdicionarParametros("@IdSituacao", Externos.IdSituacao); Conexao.AdicionarParametros("@IdExterno", Externos.IdExterno); Conexao.AdicionarParametros("@Id_FuncionarioCadastro", Externos.Id_FuncionarioCadastro); Conexao.AdicionarParametros("@IdLivro", Externos.IdLivro); Conexao.AdicionarParametros("@Dataatual", Externos.DataAtual); Conexao.AdicionarParametros("@DataSaida", Externos.DataSaida); Conexao.AdicionarParametros("@DataEntregou", DateTime.Now); Conexao.AdicionarParametros("@DataProcesso", DateTime.Now); string codigo = Conexao.ExecutarManipulacao(CommandType.StoredProcedure, "USP_EmprestimoAddExternos").ToString(); return(codigo); } catch (SqlException erro) { throw erro; } }
public void AtualizaDataVencimento(EmprestimoExternos externos) { try { Conexao.LimparParametros(); Conexao.AdicionarParametros("@IdEmprestimo", externos.IdEmprestimo); Conexao.ExecutarManipulacao(CommandType.StoredProcedure, "USP_AtualizaCampoVencimentoExterno").ToString(); //erro de objeto é so colocar pra retornar o id } catch (SqlException erro) { throw erro; } }
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")))) { EmprestimoExternos objetoCT = new EmprestimoExternos { IdEmprestimo = Convert.ToInt32(dataGridView1.Rows[i].Cells["IdEmprestimo"].Value),//pega o valor do id emp }; CN_EmprestimoExternos objetoCN = new CN_EmprestimoExternos(); objetoCN.AtualizaDataVencimento(objetoCT); } } }
/* public DataTable ExecutarDevolucao(int IdEmprestimo, int IdLivro,int IdExterno) * {// USP_DevolucaoProfesssor * SqlCommand c = new SqlCommand(); * DataTable Tabela = new DataTable(); * c.Connection = Conexao.AbrirConexao(); * c.Parameters.Add(new SqlParameter("@IdEmprestimo", IdEmprestimo)); * c.Parameters.Add(new SqlParameter("@IdLivro", IdLivro)); * c.Parameters.Add(new SqlParameter("@IdExterno", IdExterno)); * c.CommandText = "USP_DevolucaoExternos"; * c.CommandType = CommandType.StoredProcedure; * * leerDados = c.ExecuteReader(); * Tabela.Load(leerDados); * * leerDados.Close(); * * return Tabela; * }*/ public void Devolucao(EmprestimoExternos externos) { try { Conexao.LimparParametros(); Conexao.AdicionarParametros("@IdEmprestimo", externos.IdEmprestimo); Conexao.AdicionarParametros("@IdExterno", externos.IdExterno); Conexao.AdicionarParametros("@IdLivro", externos.IdLivro); Conexao.ExecutarManipulacao(CommandType.StoredProcedure, "USP_DevolucaoExternos").ToString(); } catch (SqlException erro) { throw erro; } }
private void buttonDevolver_Click(object sender, EventArgs e) { //criar menssagem de confirmação 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) { EmprestimoExternos objetoCT = new EmprestimoExternos { 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 IdExterno = Convert.ToInt32(dataGridViewLista.Rows[i].Cells["IdExternos"].Value), }; CN_EmprestimoExternos objetoCN = new CN_EmprestimoExternos(); objetoCN.Devolucao(objetoCT); } } ExibirConsultaExterno(); MostrarEmprestimoUnico(); checkBox1.Checked = false; MessageBox.Show("Devolução efetuada com sucesso"); } }
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 - 0; i++) { Conexao.LimparParametros(); try { EmprestimoExternos objetoCT = new EmprestimoExternos { IdExterno = 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_EmprestimoExternos objetoCN = new CN_EmprestimoExternos(); retorno = objetoCN.InserirEmprestimoExternos(objetoCT); } catch (Exception ex) { MessageBox.Show("Não foi possivel inserir por: " + ex); } } try { int IdProfessor = Convert.ToInt32(retorno); MessageBox.Show($"Empréstimo efetuado com sucesso"); //atualiza os forms dataGridView1.Rows.Clear(); //dando erro aqui ComboLivro(); ComboExterno(); this.Close(); } catch (FormatException) { //condição para verificar os emprestimos pendentes string message = retorno + " Livro " + dataRowViewLivros.Row.ItemArray[1]; 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"); } }