예제 #1
0
        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);
                }
            }
        }
        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");
            }
        }
예제 #3
0
        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");
            }
        }
예제 #4
0
        public void MostrarEmprestimos()
        {
            CN_EmprestimoExternos objeto = new CN_EmprestimoExternos();

            dataGridView1.DataSource = objeto.MostrarEmprestimos();
        }
        public void ExecutarRenovacao()
        {
            CN_EmprestimoExternos objeto = new CN_EmprestimoExternos();

            dataGridViewLista.DataSource = objeto.ExecutarRenovacao(idEmprestimo);
        }
        //exibe os dados   dos emprestimos do usuario selecionado
        public void MostrarEmprestimoUnico()
        {
            CN_EmprestimoExternos objeto = new CN_EmprestimoExternos();

            dataGridViewLista.DataSource = objeto.MostrarEmprestimoUnicoRenovacao(idExternos);
        }
        //exibir nomes que estao com emprestimos pendentes
        public void ExibirConsultaExternos()
        {
            CN_EmprestimoExternos objeto = new CN_EmprestimoExternos();

            dataGridViewExternos.DataSource = objeto.ConsultarexternosDevolu();
        }