private void RequisicaoForm_Load(object sender, EventArgs e) { txtIDSetor.Enabled = false; txtNomeProduto.Enabled = false; txtIDProduto.Enabled = false; txtQuantidadeProduto.Enabled = false; txtData.Enabled = false; gpbPesquisa.Visible = false; CAMADAS.BLL.Setor bllSetor = new CAMADAS.BLL.Setor(); cbSetor.DisplayMember = "nome"; cbSetor.ValueMember = "id"; cbSetor.DataSource = bllSetor.Select(); CAMADAS.BLL.Almoxarifado bllAlmoxarifado = new CAMADAS.BLL.Almoxarifado(); dgvProdutos.DataSource = ""; dgvProdutos.DataSource = bllAlmoxarifado.Select(); CAMADAS.BLL.Requisicao bllRequisicao = new CAMADAS.BLL.Requisicao(); dgvRequisicoes.DataSource = ""; dgvRequisicoes.DataSource = bllRequisicao.Select(); habilitaControles(false); }
private void btnRemover_Click(object sender, EventArgs e) { CAMADAS.BLL.Almoxarifado bllAlmo = new CAMADAS.BLL.Almoxarifado(); string msg = "Não há dados selecionado para remover"; string titBox = "Erro"; if (lblID.Text != "") { msg = "Deseja Remover o Item: " + txtItem.Text; DialogResult resposta = MessageBox.Show(msg, titBox, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (resposta == DialogResult.Yes) { int id = Convert.ToInt32(lblID.Text); bllAlmo.Delete(id); } } else { MessageBox.Show(msg, titBox, MessageBoxButtons.OK, MessageBoxIcon.Warning); } limpaControles(); dgvItens.DataSource = bllAlmo.Select(); }
private void AlmoxarifadoForm_Load(object sender, EventArgs e) { CAMADAS.BLL.Fornecedor bllFornecedor = new CAMADAS.BLL.Fornecedor(); cbFornecedor.DisplayMember = "nome"; cbFornecedor.ValueMember = "id"; cbFornecedor.DataSource = bllFornecedor.Select(); CAMADAS.BLL.Almoxarifado bllAlmo = new CAMADAS.BLL.Almoxarifado(); dgvItens.DataSource = ""; dgvItens.DataSource = bllAlmo.Select(); habilitaControles(false); }
private void btnFiltrar_Click(object sender, EventArgs e) { string mensagem = ""; string tituloMensagem = ""; if (txtFiltrar.Text != "") { try { if (cbPesquisa.SelectedItem.ToString() == "Itens") { if (rdbID.Checked) { int idPesquisado = Convert.ToInt32(txtFiltrar.Text); dgvProdutos.DataSource = new CAMADAS.BLL.Almoxarifado().SelectByID(idPesquisado); } else { string nomePesquisado = txtFiltrar.Text; dgvProdutos.DataSource = new CAMADAS.BLL.Almoxarifado().SelectByNome(nomePesquisado); } } else { if (rdbID.Checked) { int idPesquisado = Convert.ToInt32(txtFiltrar.Text); dgvRequisicoes.DataSource = new CAMADAS.BLL.Requisicao().SelectByID(idPesquisado); } else { string nomePesquisado = txtFiltrar.Text; List <CAMADAS.MODEL.Almoxarifado> lstAlmoxarifado = new CAMADAS.BLL.Almoxarifado().SelectByNome(nomePesquisado); dgvRequisicoes.DataSource = new CAMADAS.BLL.Requisicao().SelectByNome(lstAlmoxarifado); } } } catch { mensagem = "O item pesquisado não existe."; tituloMensagem = "Erro"; MessageBox.Show(mensagem, tituloMensagem, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { mensagem = "O campo texto não pode estar vazio."; tituloMensagem = "Erro"; MessageBox.Show(mensagem, tituloMensagem, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void dgvRequisicoes_DoubleClick(object sender, EventArgs e) { lblID.Text = dgvRequisicoes.SelectedRows[0].Cells["idRC"].Value.ToString(); txtIDSetor.Text = dgvRequisicoes.SelectedRows[0].Cells["setorID"].Value.ToString(); cbSetor.SelectedValue = Convert.ToInt32(dgvRequisicoes.SelectedRows[0].Cells["setorID"].Value.ToString()); txtIDProduto.Text = dgvRequisicoes.SelectedRows[0].Cells["produtoID"].Value.ToString(); txtNomeProduto.Text = dgvRequisicoes.SelectedRows[0].Cells["produto"].Value.ToString(); txtQuantidadeRequisitada.Text = dgvRequisicoes.SelectedRows[0].Cells["quantidadeRC"].Value.ToString(); txtData.Text = dgvRequisicoes.SelectedRows[0].Cells["data"].Value.ToString(); //Recuperar a quantidade do estoque CAMADAS.BLL.Almoxarifado bllAlmo = new CAMADAS.BLL.Almoxarifado(); List <CAMADAS.MODEL.Almoxarifado> lstAlmo = bllAlmo.SelectByID(Convert.ToInt32(txtIDProduto.Text)); txtQuantidadeProduto.Text = lstAlmo[0].quantidade.ToString(); }
private void btnRemover_Click(object sender, EventArgs e) { CAMADAS.BLL.Requisicao bllRequisicao = new CAMADAS.BLL.Requisicao(); string mensagem = "Não há dados selecionado para remover"; string tituloMensagem = "Remover"; if (lblID.Text != "") { mensagem = "Deseja remover a Requisição: " + lblID.Text + "?"; DialogResult resposta = MessageBox.Show(mensagem, tituloMensagem, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (resposta == DialogResult.Yes) { CAMADAS.BLL.Almoxarifado bllAlmo = new CAMADAS.BLL.Almoxarifado(); CAMADAS.MODEL.Almoxarifado almoxarifado = new CAMADAS.MODEL.Almoxarifado(); almoxarifado.id = Convert.ToInt32(txtIDProduto.Text); almoxarifado = bllAlmo.SelectByID(almoxarifado.id)[0]; int quantidadeEstoque = almoxarifado.quantidade; int quantidadeRequisitada = Convert.ToInt32(txtQuantidadeRequisitada.Text); almoxarifado.quantidade = quantidadeEstoque + quantidadeRequisitada; CAMADAS.BLL.Almoxarifado bllAtualizaEstoqueItem = new CAMADAS.BLL.Almoxarifado(); bllAtualizaEstoqueItem.Update(almoxarifado); int idRemocao = Convert.ToInt32(lblID.Text); bllRequisicao.Delete(idRemocao); } } else { MessageBox.Show(mensagem, tituloMensagem, MessageBoxButtons.OK, MessageBoxIcon.Warning); //MessageBox.Show(mensagem, tituloMensagem, MessageBoxButtons.OK, MessageBoxIcon.Warning); } limpaControles(); dgvProdutos.DataSource = new CAMADAS.BLL.Almoxarifado().Select(); dgvRequisicoes.DataSource = bllRequisicao.Select(); }
private void btnGravar_Click(object sender, EventArgs e) { CAMADAS.BLL.Almoxarifado bllAlmo = new CAMADAS.BLL.Almoxarifado(); string msg = ""; string titMsg = ""; if (lblID.Text == "-1") { msg = "Deseja Inserir novo Item?"; titMsg = "Inserir"; } else { msg = "Deseja Alterar o Item?"; titMsg = "Atualizar"; } DialogResult resposta = MessageBox.Show(msg, titMsg, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (resposta == DialogResult.Yes) { CAMADAS.MODEL.Almoxarifado almoxarifado = new CAMADAS.MODEL.Almoxarifado(); almoxarifado.id = Convert.ToInt32(lblID.Text); almoxarifado.fornecedorID = Convert.ToInt32(txtFornecedor.Text); almoxarifado.nome = txtItem.Text; almoxarifado.quantidade = Convert.ToInt32(txtQuantidade.Text); if (lblID.Text == "-1") { bllAlmo.Insert(almoxarifado); } else { bllAlmo.Update(almoxarifado); } } limpaControles(); habilitaControles(false); dgvItens.DataSource = bllAlmo.Select(); }
private void btnGravar_Click(object sender, EventArgs e) { int quantidadeRequisitada = Convert.ToInt32(txtQuantidadeRequisitada.Text); int quantidadeEstoque = Convert.ToInt32(txtQuantidadeProduto.Text); Console.WriteLine("Estoque:" + quantidadeEstoque); Console.WriteLine("RC:" + quantidadeRequisitada); string mensagem = ""; string tituloMensagem = ""; if (quantidadeRequisitada <= quantidadeEstoque) { CAMADAS.BLL.Requisicao bllRequisicao = new CAMADAS.BLL.Requisicao(); if (lblID.Text == "-1") { mensagem = "Deseja criar uma nova requisição?"; tituloMensagem = "Criar Requisição"; } else { mensagem = "Deseja alterar a requisição?"; tituloMensagem = "Atualizar"; } DialogResult resposta = MessageBox.Show(mensagem, tituloMensagem, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (resposta == DialogResult.Yes) { CAMADAS.MODEL.Requisicao requisicao = new CAMADAS.MODEL.Requisicao(); requisicao.id = Convert.ToInt32(lblID.Text); requisicao.setorID = Convert.ToInt32(txtIDSetor.Text); requisicao.produtoID = Convert.ToInt32(txtIDProduto.Text); requisicao.quantidade = Convert.ToInt32(txtQuantidadeRequisitada.Text); CAMADAS.MODEL.Almoxarifado almoxarifado = new CAMADAS.MODEL.Almoxarifado(); almoxarifado.id = Convert.ToInt32(txtIDProduto.Text); almoxarifado.quantidade = quantidadeEstoque - quantidadeRequisitada; CAMADAS.BLL.Almoxarifado bllAtualizaEstoqueItem = new CAMADAS.BLL.Almoxarifado(); bllAtualizaEstoqueItem.Update(almoxarifado); if (lblID.Text == "-1") { requisicao.data = DateTime.Now; bllRequisicao.Insert(requisicao); } else { bllRequisicao.Update(requisicao); } } limpaControles(); habilitaControles(false); dgvProdutos.DataSource = new CAMADAS.BLL.Almoxarifado().Select(); dgvRequisicoes.DataSource = bllRequisicao.Select(); } else { mensagem = "A quantidade requisitada excede o estoque!"; tituloMensagem = "Erro"; MessageBox.Show(mensagem, tituloMensagem, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void gerarReqAlmoxarifado() { CAMADAS.BLL.Almoxarifado bllAlmo = new CAMADAS.BLL.Almoxarifado(); List <CAMADAS.MODEL.Almoxarifado> lstAlmoxarifado = new List <CAMADAS.MODEL.Almoxarifado>(); lstAlmoxarifado = bllAlmo.Select(); string pasta = Funcao.diretorioPasta(); string arquivo = pasta + @"\RelatorioAlmoxarifado.html"; StreamWriter sw = new StreamWriter(arquivo); using (sw) { sw.WriteLine("<html lang='pt-br'>"); sw.WriteLine("<head>"); sw.WriteLine("<meta charset='UTF - 8'>"); sw.WriteLine("<meta name='viewport' content='width = device - width, initial - scale = 1.0'>"); sw.WriteLine("<link rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css' integrity='sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk' crossorigin='anonymous'>"); sw.WriteLine("<title>Relatorio Almoxarifado</title>"); sw.WriteLine("</head>"); sw.WriteLine("<body>"); sw.WriteLine("<br><hr border='5px' />"); sw.WriteLine("<h1> Relatório do Almoxarifado </h1>"); sw.WriteLine("<hr border='5px' /><br>"); sw.WriteLine("<table class='table'>"); sw.WriteLine("<thead class='thead-dark'>"); sw.WriteLine("<tr align='center'>"); sw.WriteLine("<th>ID</th>"); sw.WriteLine("<th>FORNECEDOR</th>"); sw.WriteLine("<th>PRODUTO</th>"); sw.WriteLine("<th>QUANTIDADE</th>"); sw.WriteLine("</thead class='thead-dark'>"); sw.WriteLine("</tr>"); int cont = 0; foreach (CAMADAS.MODEL.Almoxarifado almoxarifado in lstAlmoxarifado) { sw.WriteLine("<tr align='center'>"); sw.WriteLine("<th scope='row'>" + almoxarifado.id + "</th>"); sw.WriteLine("<td>" + almoxarifado.fornecedor + "</td>"); sw.WriteLine("<td>" + almoxarifado.nome + "</td>"); sw.WriteLine("<td>" + almoxarifado.quantidade + "</td>"); sw.WriteLine("</tr>"); cont++; } sw.WriteLine("</table>"); sw.WriteLine("<h5> Quantidade de Itens no Almoxarifado: " + cont + "</h5>"); sw.WriteLine(""); sw.WriteLine("</body>"); sw.WriteLine("</html>"); } System.Diagnostics.Process.Start(arquivo); }