private void CarregaGrid(string pQuery) { ViewState["VW_ATLETA"] = PessoaModelo.CarregaDadosPessoaAtleta(pQuery); gvAtleta.DataSource = ViewState["VW_ATLETA"]; gvAtleta.DataBind(); }
public bool Inserir(PessoaModelo pessoa) { using (var entities = databaseEntities.GetDB_LaborSafetyEntities()) { using (var transaction = entities.Database.BeginTransaction()) { try { entities.PESSOA.Add(new PESSOA() { Ativo = true, CodPessoa = pessoa.CodPessoa, CPF = pessoa.CPF, Email = pessoa.Email, Empresa = pessoa.Empresa, Matricula = pessoa.Matricula, Nome = pessoa.Nome, Telefone = pessoa.Telefone }); entities.SaveChanges(); transaction.Commit(); } catch (Exception exception) { transaction.Rollback(); throw exception; } } } return(true); }
private void ShowSelected(CargaDevoluçãoModelo modelo) { dgvProdutos.Rows.Clear(); txtID.Text = modelo.Id.ToString(); txtIdVendedor.Text = modelo.VendedorID.ToString(); VendedorModelo vendedor = SqliteAcessoDados.LoadQuery <VendedorModelo>("select * from Vendedor where Vendedor.ID == " + modelo.VendedorID.ToString())[0]; PessoaModelo pessoa = SqliteAcessoDados.LoadQuery <PessoaModelo>("select * from Pessoa where Pessoa.ID == " + vendedor.PessoaId.ToString())[0]; List <VendedorPraçaModelo> vendedorPraçaList = SqliteAcessoDados.LoadQuery <VendedorPraçaModelo>("select * from VendedorPraça where VendedorPraça.VendedorID == " + modelo.VendedorID.ToString()); foreach (VendedorPraçaModelo vendedorPraça in vendedorPraçaList) { PraçaModelo praça = SqliteAcessoDados.LoadQuery <PraçaModelo>("select * from Praça where Praça.ID == " + vendedorPraça.PraçaId.ToString()).First(); cbbPraça.Items.Add(praça.Id + " - " + praça.Nome); if (praça.Id == modelo.PraçaID) { cbbPraça.SelectedIndex = cbbPraça.Items.Count - 1; } } txtNomeVendedor.Text = pessoa.Nome; txtPlaca.Text = vendedor.Placa; cbbDevolução.SelectedIndex = modelo.Devolução ? 0 : 1; txtData.Text = modelo.Data.ToShortDateString(); ProdutosCargaDevoluçãoList = SqliteAcessoDados.LoadQuery <ProdutosCargaDevoluçãoModelo>("select * from ProdutosCargaDevolução where ProdutosCargaDevolução.CargaDevoluçãoID == " + modelo.Id.ToString()); foreach (ProdutosCargaDevoluçãoModelo item in ProdutosCargaDevoluçãoList) { BuscaProdutoFK(item.ProdutoID, out string produtoNome); dgvProdutos.Rows.Add(item.ProdutoID, produtoNome, item.Quantidade); } }
private void ShowSelected(PedidoModelo modelo) { txtID.Text = modelo.Id.ToString(); txtIdPessoa.Text = modelo.PessoaID.ToString(); PessoaModelo pessoa = SqliteAcessoDados.LoadQuery <PessoaModelo>("select * from Pessoa where Pessoa.ID == " + modelo.PessoaID.ToString())[0]; txtNomePessoa.Text = pessoa.Nome; txtRG.Text = pessoa.RG; txtCPF.Text = pessoa.CPF; txtDataNascimento.Text = pessoa.Nascimento.ToShortDateString(); txtTelefone.Text = pessoa.Telefone; txtPontoReferencia.Text = pessoa.PontoReferencia.ToString(); txtEndereco.Text = pessoa.Endereco; txtNumero.Text = pessoa.Numero.ToString(); txtBairro.Text = pessoa.Bairro; txtCidade.Text = pessoa.Cidade; txtEstado.Text = pessoa.Estado; cbAtivo.Checked = pessoa.Ativo; ItensList = SqliteAcessoDados.LoadQuery <ItemModelo>("select * from Item where Item.PedidoID == " + modelo.Id.ToString()); RefreshItensList(); txtDataEmissão.Text = modelo.DataEmissão.ToShortDateString(); txtDataRetorno.Text = modelo.DataRetorno.ToShortDateString(); txtIdVendedor.Text = modelo.VendedorID.ToString(); VendedorModelo vendedor = SqliteAcessoDados.LoadQuery <VendedorModelo>("select * from Vendedor where Vendedor.ID == " + modelo.VendedorID.ToString())[0]; pessoa = SqliteAcessoDados.LoadQuery <PessoaModelo>("select * from Pessoa where Pessoa.ID == " + vendedor.PessoaId.ToString())[0]; List <VendedorPraçaModelo> vendedorPraçaList = SqliteAcessoDados.LoadQuery <VendedorPraçaModelo>("select * from VendedorPraça where VendedorPraça.VendedorID == " + modelo.VendedorID.ToString()); txtNomeVendedor.Text = pessoa.Nome; txtTelefoneVendedor.Text = pessoa.Telefone; foreach (VendedorPraçaModelo vendedorPraça in vendedorPraçaList) { PraçaModelo praça = SqliteAcessoDados.LoadQuery <PraçaModelo>("select * from Praça where Praça.ID == " + vendedorPraça.PraçaId.ToString()).First(); cbbPraça.Items.Add(praça.Id + " - " + praça.Nome); if (praça.Id == modelo.PraçaID) { cbbPraça.SelectedIndex = cbbPraça.Items.Count - 1; } } txtTotalItens.Text = modelo.TotalItens.ToString(); txtTotalPeças.Text = modelo.TotalUnidades.ToString(); txtComissão.Text = modelo.Comissão.ToString(); txtValorPago.Text = modelo.ValorPago.ToString(); txtValorPago_Leave(null, null); Finalizado = modelo.Finalizado; //txtComissãoValor.Text = "add logica"; }
public int inserir(PessoaModelo pessoa) { using (var connection = new SqlConnection(dbConnection.GetConn())) { return(connection.QuerySingle <int>($"DECLARE @id int;" + $"Insert into Pessoas (nome, usuario) Values ('{pessoa.nome}', '{pessoa.usuario}')" + $"SET @id = SCOPE_IDENTITY();" + $"select @id")); } }
public PessoaModelo ListarPorCpf(string cpf) { PessoaModelo pessoaModelo = new PessoaModelo(); AutoMapper.Mapper.Map(this.pessoaPersistencia.ListarPorCpf(cpf), pessoaModelo); if (cpf == null || cpf == "") { throw new KeyNotFoundException("Pessoa não encontrada."); } return(pessoaModelo); }
public PessoaModelo ListarPorCodigo(long codigo) { PessoaModelo pessoaModelo = new PessoaModelo(); AutoMapper.Mapper.Map(this.pessoaPersistencia.ListarPorCodigo(codigo), pessoaModelo); if (codigo == 0) { throw new KeyNotFoundException("Pessoa não encontrada."); } return(pessoaModelo); }
private void CarregaDadosAtleta(decimal pCodigo) { DataTable lTabela = PessoaModelo.CarregaDadosPessoaAtleta(pCodigo); if (lTabela.Rows.Count > 0) { ImgFoto.ImageUrl = "../administracao/foto.aspx?p=" + pCodigo + ""; hfCodigoPessoa.Value = lTabela.Rows[0]["CODIGO"].ToString(); hfCodigoAtleta.Value = lTabela.Rows[0]["CODIGO_ATLETA"].ToString(); txtNome.Text = lTabela.Rows[0]["NOME"].ToString(); txtNascimento.Text = lTabela.Rows[0]["NASCIMENTO"].ToString(); txtProfissao.Text = lTabela.Rows[0]["PROFISSAO"].ToString(); txtEmail.Text = lTabela.Rows[0]["EMAIL"].ToString(); txtTelefone.Text = lTabela.Rows[0]["TELEFONE"].ToString(); ddlEscolaridade.SelectedValue = lTabela.Rows[0]["ESCOLARIDADE"].ToString(); txtCpf.Text = lTabela.Rows[0]["CPF"].ToString(); txtRg.Text = lTabela.Rows[0]["RG"].ToString(); TxtCelular.Text = lTabela.Rows[0]["CELULAR"].ToString(); txtPlanoSaude.Text = lTabela.Rows[0]["PLANOSAUDE"].ToString(); txtContato.Text = lTabela.Rows[0]["CONTATO"].ToString(); if (hfCodigoAtleta.Value != "") { DataTable lTabelaAtleta = AtletaModelo.CarregaDadosAtleta(decimal.Parse(hfCodigoAtleta.Value)); if (lTabelaAtleta.Rows.Count > 0) { ddlAtletaStatus.SelectedValue = lTabelaAtleta.Rows[0]["ATLETASTATUS"].ToString(); ddlPosicao.SelectedValue = lTabelaAtleta.Rows[0]["POSICAO"].ToString(); NumeracaoIncluir.Visible = false; NumeracaoVisualizar.Visible = true; txtNumeracao.Text = lTabelaAtleta.Rows[0]["NUMERO"].ToString() + "|" + lTabelaAtleta.Rows[0]["CONTADOR"].ToString(); hfNumeracao.Value = lTabelaAtleta.Rows[0]["NUMERO"].ToString(); hfContador.Value = lTabelaAtleta.Rows[0]["CONTADOR"].ToString(); txtAltura.Text = lTabelaAtleta.Rows[0]["ALTURA"].ToString(); txtPeso.Text = lTabelaAtleta.Rows[0]["PESO"].ToString(); txtTamUniforme.Text = lTabelaAtleta.Rows[0]["TAMANHOUNIFORME"].ToString(); } ViewState["VW_ATLETAANEXO"] = AtletaAnexoModelo.AtletaAnexoLista(); gvArquivos.DataSource = ViewState["VW_ATLETAANEXO"]; gvArquivos.DataBind(); } divConsulta.Visible = false; divCadastro.Visible = true; } }
public PessoaModelo inserir(PessoaModelo pessoa) { var result = _pessoaRepositorio.inserir(pessoa); if (result > 0) { return(pessoa); } else { return(default(PessoaModelo)); } }
protected void Page_Load(object sender, System.EventArgs e) { PessoaEntidade.codigo = decimal.Parse(Request.QueryString[0].ToString()); DataTable lFoto = PessoaModelo.Foto(); foreach (DataRow ors in lFoto.Rows) { myfoto = (byte[])ors[0]; } Response.BinaryWrite(myfoto); }
public IHttpActionResult InserirPessoa([FromBody] PessoaModelo pessoas) { try { this.aprNegocio.InserirPessoa(pessoas); return(Ok(GeradorResponse.GenerateSuccessResponse((int)HttpStatusCode.OK, $"Inserção de pessoas ocorrida com sucesso"))); } catch (Exception exception) { throw new Exception(GeradorResponse.GenerateErrorResponseString((int)HttpStatusCode.BadRequest, "Erro ao inserir pessoas", exception), exception); } }
private void Update() { string pRetorno = ""; try { PessoaEntidade.codigo = decimal.Parse(hfCodigoPessoa.Value); PessoaEntidade.codigo_tipopessoa = decimal.Parse("2"); PessoaEntidade.nome = txtNome.Text.ToUpper(); PessoaEntidade.nacimento = DateTime.Parse(txtNascimento.Text); if (fuImagem.FileName != "") { PessoaEntidade.foto = fuImagem.FileBytes; } else { PessoaEntidade.codigo = decimal.Parse(hfCodigoPessoa.Value); DataTable lFoto = PessoaModelo.Foto(); foreach (DataRow ors in lFoto.Rows) { PessoaEntidade.foto = (byte[])ors[0]; } } PessoaEntidade.email = txtEmail.Text; PessoaEntidade.cpf = txtCpf.Text; PessoaEntidade.rg = txtRg.Text; PessoaEntidade.profissao = txtProfissao.Text.ToUpper(); PessoaEntidade.escolaridade = ddlEscolaridade.SelectedItem.Text; PessoaEntidade.planosaude = txtPlanoSaude.Text.ToUpper(); PessoaEntidade.contato = txtContato.Text.ToUpper(); PessoaEntidade.telefone = txtTelefone.Text; PessoaEntidade.celular = TxtCelular.Text; pRetorno = PessoaModelo.Update(); if (pRetorno == "") { exibirMensagem("Ok", "Cadastro atualizado com sucesso", "ok"); divConsulta.Visible = true; divCadastro.Visible = false; CarregaGrid(); } } catch (Exception err) { exibirMensagem("Erro", err.Message.ToString(), "erro"); } }
public PessoaModelo MapeamentoPessoa(PESSOA pessoa) { PessoaModelo pessoaModelo = new PessoaModelo() { CodPessoa = pessoa.CodPessoa, Matricula = pessoa.Matricula, Nome = pessoa.Nome, CPF = pessoa.CPF, Telefone = pessoa.Telefone, Email = pessoa.Email, Empresa = pessoa.Empresa, Ativo = pessoa.Ativo }; return(pessoaModelo); }
private Table CreateTableContentTotalVendas(PedidoModelo pedido, Table t) { t.InsertRow(); PessoaModelo clientePessoa = SqliteAcessoDados.LoadQuery <PessoaModelo>("select * from Pessoa where Pessoa.ID == " + pedido.PessoaID).First(); PraçaModelo praça = SqliteAcessoDados.LoadQuery <PraçaModelo>("select * from Praça where Praça.ID == " + pedido.PraçaID.ToString()).First(); t.Rows.Last().Cells[0].Paragraphs.First().Append(pedido.Id.ToString()).FontSize(10d); t.Rows.Last().Cells[1].Paragraphs.First().Append(clientePessoa.Id.ToString()).FontSize(10d); t.Rows.Last().Cells[2].Paragraphs.First().Append(clientePessoa.Nome).FontSize(10d); t.Rows.Last().Cells[3].Paragraphs.First().Append(praça.Nome).FontSize(10d); t.Rows.Last().Cells[4].Paragraphs.First().Append(pedido.DataEmissão.ToShortDateString()).FontSize(10d); t.Rows.Last().Cells[5].Paragraphs.First().Append(string.Format("{0:C}", pedido.ValorTotal)).FontSize(10d); t.Rows.Last().Cells[6].Paragraphs.First().Append(string.Format("{0:C}", pedido.ValorPago)).FontSize(10d); return(t); }
private void ShowSelected(PessoaModelo modelo) { txtID.Text = modelo.Id.ToString(); txtIdPraça.Text = modelo.PraçaID != -1 ? modelo.PraçaID.ToString() : ""; txtNomePraça.Text = modelo.PraçaID != -1 ? SqliteAcessoDados.LoadQuery <PraçaModelo>("select Nome from Praça where Praça.ID == " + modelo.PraçaID.ToString()).First().Nome : ""; txtName.Text = modelo.Nome; txtRG.Text = modelo.RG; txtCPF.Text = modelo.CPF; txtDataNascimento.Text = modelo.Nascimento.ToShortDateString(); txtTelefone.Text = modelo.Telefone; txtPontoReferencia.Text = modelo.PontoReferencia.ToString(); txtEndereco.Text = modelo.Endereco; txtNumero.Text = modelo.Numero.ToString(); txtBairro.Text = modelo.Bairro; txtCidade.Text = modelo.Cidade; txtEstado.Text = modelo.Estado; cbAtivo.Checked = modelo.Ativo; //? true : false; cbCliente.Checked = modelo.Cliente; }
private void CreateHeaderTotalVendas(PedidoModelo pedido, DocX document) { VendedorModelo vendedor = SqliteAcessoDados.LoadQuery <VendedorModelo>("select * from Vendedor where Vendedor.ID == " + pedido.VendedorID.ToString()).First(); PessoaModelo vendedorPessoa = SqliteAcessoDados.LoadQuery <PessoaModelo>("select * from Pessoa where Pessoa.ID == " + vendedor.PessoaId).First(); document.InsertParagraph(); document.InsertParagraph("VENDEDOR: ") .Bold() .FontSize(10d) .Append(vendedorPessoa.Nome + " ") .FontSize(10d) .Append("TELEFONE: ") .Bold() .FontSize(10d) .Append(vendedorPessoa.Telefone) .FontSize(10d) .Alignment = Alignment.left; document.InsertParagraph(); }
private void Include() { decimal pRetorno = 0; try { if (ValidaDados() == "") { PessoaEntidade.codigo_tipopessoa = decimal.Parse("2"); PessoaEntidade.nome = txtNome.Text.ToUpper(); PessoaEntidade.nacimento = DateTime.Parse(txtNascimento.Text); PessoaEntidade.foto = fuImagem.FileBytes; PessoaEntidade.email = txtEmail.Text; PessoaEntidade.cpf = txtCpf.Text; PessoaEntidade.rg = txtRg.Text; PessoaEntidade.profissao = txtProfissao.Text.ToUpper(); PessoaEntidade.escolaridade = ddlEscolaridade.SelectedItem.Text; PessoaEntidade.planosaude = txtPlanoSaude.Text.ToUpper(); PessoaEntidade.contato = txtContato.Text.ToUpper(); PessoaEntidade.telefone = txtTelefone.Text; PessoaEntidade.celular = TxtCelular.Text; pRetorno = PessoaModelo.Include(); if (pRetorno != 0) { LimparCampos(); exibirMensagem("Ok", "Cadastro efetuado com sucesso", "ok"); } } else { exibirMensagem("Aviso", ValidaDados(), "alerta"); } } catch (Exception err) { exibirMensagem("Erro", err.Message.ToString(), "erro"); } }
public void Editar(PessoaModelo pessoaModelo) { using (DB_LaborSafetyEntities entities = new DB_LaborSafetyEntities()) { PESSOA pessoaExistente = entities.PESSOA.Where(p => p.CodPessoa == pessoaModelo.CodPessoa && p.Ativo).FirstOrDefault(); if (pessoaExistente == null) { throw new KeyNotFoundException(); } pessoaExistente.CodPessoa = pessoaModelo.CodPessoa; pessoaExistente.Matricula = pessoaModelo.Matricula; pessoaExistente.Nome = pessoaModelo.Nome; pessoaExistente.CPF = pessoaModelo.CPF; pessoaExistente.Telefone = pessoaModelo.Telefone; pessoaExistente.Email = pessoaModelo.Email; pessoaExistente.Empresa = pessoaModelo.Empresa; entities.SaveChanges(); } }
private void btAdd_Click(object sender, EventArgs e) { isEditing = false; PessoaModelo p = new PessoaModelo(); AtivarCampos(); btAlterar.Enabled = false; btExcluir.Enabled = false; btPesquisar.Enabled = false; btAnterior.Enabled = false; btAdd.Enabled = false; btUltimo.Enabled = false; btPrimeiro.Enabled = false; btProximo.Enabled = false; LimparCampos(); int ID = SqliteAcessoDados.GetLastID("Pessoa"); txtID.Text = (ID + 1).ToString(); cbAtivo.Checked = true; }
static void Main(string[] args) { var conexao = Conexao.ObterConexao(); // Tratativa de erro: try // -> "tente:"; se der certo, execute isto: { conexao.Open(); // -> Abre a conexão Console.WriteLine("Conexão estabelecida com sucesso!"); PessoaModelo pessoaQueQueroInserir = new PessoaModelo(0, "Maria", "11111111119"); // Pode ser instanciado qualquer id neste caso Inserir inserir = new Inserir(); inserir.Insere(conexao, pessoaQueQueroInserir); PessoaModelo pessoaQueQueroAtualizar = new PessoaModelo(7, "Wellington", "11111111122"); Atualizar atualizar = new Atualizar(); atualizar.Atualiza(conexao, pessoaQueQueroAtualizar); Excluir excluir = new Excluir(); excluir.Exclui(conexao, 8); Consultar consulta = new Consultar(); Console.Write(consulta.ObterTodos(conexao)); } catch (Exception erro) // -> se não der certo, faça isto: { Console.WriteLine($"Erro ao obter conexão: {erro.Message}"); } finally { conexao.Close(); // -> Fecha a conexão } Console.WriteLine() }
private void Include() { decimal pRetorno = 0; try { PessoaEntidade.codigo_tipopessoa = decimal.Parse("2"); PessoaEntidade.nome = txtNome.Text.ToUpper(); PessoaEntidade.nacimento = DateTime.Parse(txtNascimento.Text); PessoaEntidade.foto = fuImagem.FileBytes; PessoaEntidade.email = txtEmail.Text; PessoaEntidade.cpf = txtCpf.Text; PessoaEntidade.rg = txtRg.Text; PessoaEntidade.profissao = txtProfissao.Text.ToUpper(); PessoaEntidade.escolaridade = ddlEscolaridade.SelectedItem.Text; PessoaEntidade.planosaude = txtPlanoSaude.Text.ToUpper(); PessoaEntidade.contato = txtContato.Text.ToUpper(); PessoaEntidade.telefone = txtTelefone.Text; PessoaEntidade.celular = TxtCelular.Text; pRetorno = PessoaModelo.Include(); if (pRetorno != 0) { if (cbDadosAtleta.Checked) { AtletaEntidade.codigo_pessoa = pRetorno; AtletaEntidade.codigo_posicao = decimal.Parse(ddlPosicao.SelectedValue); AtletaEntidade.codigo_atletastatus = decimal.Parse(ddlAtletaStatus.SelectedValue); AtletaEntidade.altura = txtAltura.Text; AtletaEntidade.peso = txtPeso.Text; AtletaEntidade.apelido = txtApelido.Text; AtletaEntidade.numeracao = int.Parse(ddlNumeracao.SelectedValue); UpdateNumeracaoMais(ddlNumeracao.SelectedItem.Text, decimal.Parse(ddlNumeracao.SelectedItem.Text)); AtletaEntidade.tamanhouniforme = txtTamUniforme.Text; pRetorno = AtletaModelo.Include(); DataTable lTabela = (DataTable)ViewState["ANEXAARQUIVO"]; byte[] arquivo = new byte[0]; if (lTabela != null) { for (int i = 0; i < lTabela.Rows.Count; i++) { arquivo = (byte[])lTabela.Rows[i]["ARQUIVO"]; IncludeAnexo(pRetorno, lTabela.Rows[i]["DESCRICAO"].ToString(), lTabela.Rows[i]["TIPOARQUIVO"].ToString().ToUpper(), arquivo); } ExcluiAnexo(""); } } Log("PAG: ATLETA, INCLUSÃO DE REGISTRO: " + pRetorno + ", USUARIO: " + Session["SE_USUARIO"].ToString() + ""); LimparCampos(); exibirMensagem("Ok", "Cadastro efetuado com sucesso", "ok"); } else { exibirMensagem("Erro", Conexao.excecao.Replace("@", "").Replace("'", ""), "erro"); } } catch (Exception err) { exibirMensagem("Erro", err.Message.ToString(), "erro"); } }
private void btDepositos_Click(object sender, EventArgs e) { if (txtIdVendedor.Text != "") { if (cbbPraça.SelectedItem != null) { if (txtDataFinal.Text != "" && txtDataInicial.Text != "") { DateTime dataInicial = DateTime.Parse(txtDataInicial.Text); DateTime dataFinal = DateTime.Parse(txtDataFinal.Text); string query = "select * from Deposito where Deposito.VendedorID == " + txtIdVendedor.Text + " and date(Deposito.Data) BETWEEN date('" + dataInicial.Year + "-" + dataInicial.Month.ToString("00") + "-" + dataInicial.Day.ToString("00") + "') and date('" + dataFinal.Year + "-" + dataFinal.Month.ToString("00") + "-" + dataFinal.Day.ToString("00") + "') order by Deposito.Data"; depositoList = SqliteAcessoDados.LoadQuery <DepositoModelo>(query); } else { depositoList = SqliteAcessoDados.LoadQuery <DepositoModelo>("select * from Deposito where Deposito.VendedorID == " + txtIdVendedor.Text + " order by Deposito.Data"); } if (depositoList.Count > 0) { string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Relatorios"; VendedorModelo vendedor = SqliteAcessoDados.LoadQuery <VendedorModelo>("select * from Vendedor where Vendedor.ID == " + txtIdVendedor.Text).First(); PessoaModelo vendedorPessoa = SqliteAcessoDados.LoadQuery <PessoaModelo>("select * from Pessoa where Pessoa.ID == " + vendedor.PessoaId.ToString()).First(); string fileName = "Depositos - Vendedor - " + vendedorPessoa.Nome + " - Praça - " + cbbPraça.SelectedItem.ToString() + " - "; if (txtDataFinal.Text != "" && txtDataInicial.Text != "") { if (txtDataFinal.Text == txtDataInicial.Text) { fileName += DateTime.Parse(txtDataFinal.Text).Day.ToString() + "_" + DateTime.Parse(txtDataFinal.Text).Month.ToString() + "_" + DateTime.Parse(txtDataFinal.Text).Year.ToString(); } else { fileName += "De - " + DateTime.Parse(txtDataFinal.Text).Day.ToString() + "_" + DateTime.Parse(txtDataFinal.Text).Month.ToString() + "_" + DateTime.Parse(txtDataFinal.Text).Year.ToString() + " - Até - " + DateTime.Parse(txtDataInicial.Text).Day.ToString() + "_" + DateTime.Parse(txtDataInicial.Text).Month.ToString() + "_" + DateTime.Parse(txtDataInicial.Text).Year.ToString(); } } else { fileName += "Todas as Datas"; } fileName += ".docx"; System.IO.Directory.CreateDirectory(docPath); docPath = System.IO.Path.Combine(docPath, fileName); using (var document = DocX.Create(docPath)) { document.InsertParagraph("SABOR MINEIRO - RELATÓRIO").FontSize(11d).Bold().Alignment = Alignment.center; document.InsertParagraph("TOTAL DE VENDAS").FontSize(10d).Bold().Alignment = Alignment.center; document.InsertParagraph(); document.InsertParagraph("PROMOTOR: ").FontSize(10d).Bold() .Append(txtNomeVendedor.Text).FontSize(10d) .Alignment = Alignment.left; document.InsertParagraph("PRAÇA: ").FontSize(10d).Bold() .Append(cbbPraça.SelectedItem.ToString()).FontSize(10d) .Alignment = Alignment.left; document.InsertParagraph(); Table t = document.AddTable(1, 6); t.AutoFit = AutoFit.Contents; t.Design = TableDesign.LightGridAccent3; t.Rows[0].Cells[0].Paragraphs.First().Append("DEPOSTIO").Bold().FontSize(10d).Alignment = Alignment.center; t.Rows[0].Cells[1].Paragraphs.First().Append("DATA").Bold().FontSize(10d).Alignment = Alignment.center; t.Rows[0].Cells[2].Paragraphs.First().Append("DIA SEMANA").Bold().FontSize(10d).Alignment = Alignment.center; t.Rows[0].Cells[3].Paragraphs.First().Append("VALOR PAGO").Bold().FontSize(10d).Alignment = Alignment.center; t.Rows[0].Cells[4].Paragraphs.First().Append("PEPINO").Bold().FontSize(10d).Alignment = Alignment.center; t.Rows[0].Cells[5].Paragraphs.First().Append("TOTAL").Bold().FontSize(10d).Alignment = Alignment.center; decimal totalPeriodo = 0; decimal totalPepinoPeriodo = 0; decimal totalGeralPeriodo = 0; foreach (DepositoModelo deposito in depositoList) { t.InsertRow(); t.Rows.Last().Cells[0].Paragraphs.First().Append(deposito.Id.ToString()).FontSize(10d).Alignment = Alignment.left; t.Rows.Last().Cells[1].Paragraphs.First().Append(deposito.Data.ToShortDateString()).FontSize(10d).Alignment = Alignment.left; t.Rows.Last().Cells[2].Paragraphs.First().Append(DateTimeFormatInfo.CurrentInfo.GetDayName(deposito.Data.DayOfWeek)).FontSize(10d).Alignment = Alignment.left; t.Rows.Last().Cells[3].Paragraphs.First().Append(string.Format("{0:C}", deposito.Valor)).FontSize(10d).Alignment = Alignment.left; t.Rows.Last().Cells[4].Paragraphs.First().Append(string.Format("{0:C}", deposito.ValorPepino)).FontSize(10d).Alignment = Alignment.left; t.Rows.Last().Cells[5].Paragraphs.First().Append(string.Format("{0:C}", deposito.Valor + deposito.ValorPepino)).FontSize(10d).Alignment = Alignment.left; totalPeriodo += deposito.Valor; totalPepinoPeriodo += deposito.ValorPepino; totalGeralPeriodo += deposito.Valor + deposito.ValorPepino; } t.InsertRow(); t.Rows.Last().Cells[0].Paragraphs.First().Append("TOTAL PERIODO").Bold().FontSize(10d).Alignment = Alignment.right; t.Rows.Last().MergeCells(0, 2); t.Rows.Last().Cells[1].Paragraphs.First().Append(string.Format("{0:C}", totalPeriodo)).FontSize(10d).Alignment = Alignment.left; t.Rows.Last().Cells[2].Paragraphs.First().Append(string.Format("{0:C}", totalPepinoPeriodo)).FontSize(10d).Alignment = Alignment.left; t.Rows.Last().Cells[3].Paragraphs.First().Append(string.Format("{0:C}", totalGeralPeriodo)).FontSize(10d).Alignment = Alignment.left; document.InsertTable(t); try { document.Save(); DialogResult result = MessageBox.Show("Relatorio gerado na pasta Meus Documentos -> Relatorios(" + docPath + ")", "Atenção!", MessageBoxButtons.OK); } catch { DialogResult result = MessageBox.Show("Arquivo aberto em outro aplicativo, favor fecha-lo antes de continuar", "Atenção!", MessageBoxButtons.OK); } } /*docForPrint.MarginLeft = 36; * docForPrint.MarginRight = 36; * docForPrint.MarginTop = 36; * docForPrint.MarginBottom = 36; * * foreach (DataGridViewRow row in dgvListaImpressão.Rows) * { * string docTempPath = GerarArquivoImpressão(row); * * if (docTempPath != "") * { * docForPrint.InsertDocument(DocX.Load(docTempPath), false); * } * }*/ //DialogResult result = MessageBox.Show("Relatorio gerado na pasta Meus Documentos -> Relatorios(" + docPath + ")", "Atenção!", MessageBoxButtons.OK); } else { DialogResult result = MessageBox.Show("Nenhum Deposito registrado para esse Vendedor na Praça selecionada", "Atenção!", MessageBoxButtons.OK); } } else { DialogResult result = MessageBox.Show("Selecione uma Praça primeiro", "Atenção!", MessageBoxButtons.OK); } } else { DialogResult result = MessageBox.Show("Selecione um Vendedor primeiro", "Atenção!", MessageBoxButtons.OK); } }
private void Update() { string pRetorno = ""; decimal pRetornoInc = 0; try { PessoaEntidade.codigo = decimal.Parse(hfCodigoPessoa.Value); PessoaEntidade.codigo_tipopessoa = decimal.Parse("2"); PessoaEntidade.nome = txtNome.Text.ToUpper(); PessoaEntidade.nacimento = DateTime.Parse(txtNascimento.Text); if (fuImagem.FileName != "") { PessoaEntidade.foto = fuImagem.FileBytes; } else { PessoaEntidade.codigo = decimal.Parse(hfCodigoPessoa.Value); DataTable lFoto = PessoaModelo.Foto(); foreach (DataRow ors in lFoto.Rows) { PessoaEntidade.foto = (byte[])ors[0]; } } PessoaEntidade.email = txtEmail.Text; PessoaEntidade.cpf = txtCpf.Text; PessoaEntidade.rg = txtRg.Text; PessoaEntidade.profissao = txtProfissao.Text.ToUpper(); PessoaEntidade.escolaridade = ddlEscolaridade.SelectedItem.Text; PessoaEntidade.planosaude = txtPlanoSaude.Text.ToUpper(); PessoaEntidade.contato = txtContato.Text.ToUpper(); PessoaEntidade.telefone = txtTelefone.Text; PessoaEntidade.celular = TxtCelular.Text; pRetorno = PessoaModelo.Update(); if (pRetorno == "") { if (hfCodigoAtleta.Value != "") { AtletaEntidade.codigo = decimal.Parse(hfCodigoAtleta.Value); AtletaEntidade.codigo_posicao = decimal.Parse(ddlPosicao.SelectedValue); AtletaEntidade.codigo_atletastatus = decimal.Parse(ddlAtletaStatus.SelectedValue); AtletaEntidade.altura = txtAltura.Text; AtletaEntidade.peso = txtPeso.Text; AtletaEntidade.apelido = txtApelido.Text; if ((ddlNumeracao.SelectedValue == hfNumeracao.Value) && (int.Parse(hfContador.Value) < 1)) { AtletaEntidade.numeracao = int.Parse(hfNumeracao.Value); } else { AtletaEntidade.numeracao = int.Parse(ddlNumeracao.SelectedValue); UpdateNumeracaoMenos(int.Parse(hfContador.Value), decimal.Parse(hfNumeracao.Value)); UpdateNumeracaoMais(ddlNumeracao.SelectedItem.Text, decimal.Parse(ddlNumeracao.SelectedValue)); } AtletaEntidade.tamanhouniforme = txtTamUniforme.Text; pRetorno = AtletaModelo.Update(); } else { AtletaEntidade.codigo_pessoa = decimal.Parse(hfCodigoPessoa.Value); AtletaEntidade.codigo_posicao = decimal.Parse(ddlPosicao.SelectedValue); AtletaEntidade.codigo_atletastatus = decimal.Parse(ddlAtletaStatus.SelectedValue); AtletaEntidade.altura = txtAltura.Text; AtletaEntidade.peso = txtPeso.Text; AtletaEntidade.apelido = txtApelido.Text; AtletaEntidade.numeracao = int.Parse(ddlNumeracao.SelectedValue); UpdateNumeracaoMais(ddlNumeracao.SelectedItem.Text, decimal.Parse(ddlNumeracao.SelectedValue)); AtletaEntidade.tamanhouniforme = txtTamUniforme.Text; pRetornoInc = AtletaModelo.Include(); } } if (hfCodigoAnexo.Value != "") { AtletaAnexoEntidade.codigo = decimal.Parse(hfCodigoAnexo.Value); AtletaAnexoEntidade.descricao = txtDescricaoArquivos.Text.ToUpper(); pRetorno = AtletaAnexoModelo.Update(); txtDescricaoArquivos.Text = ""; } else { DataTable lTabela = (DataTable)ViewState["ANEXAARQUIVO"]; byte[] arquivo = new byte[0]; if (lTabela != null) { for (int i = 0; i < lTabela.Rows.Count; i++) { arquivo = (byte[])lTabela.Rows[i]["ARQUIVO"]; IncludeAnexo(decimal.Parse(hfCodigoAtleta.Value), lTabela.Rows[i]["DESCRICAO"].ToString(), lTabela.Rows[i]["TIPOARQUIVO"].ToString().ToUpper(), arquivo); } ExcluiAnexo(""); } txtDescricaoArquivos.Text = ""; gvArquivoAdd.DataSource = null; gvArquivoAdd.DataBind(); } Log("PAG: ATLETA, ATUALIZAÇÃO DE REGISTRO: " + hfCodigoPessoa.Value + ", USUARIO: " + Session["SE_USUARIO"].ToString() + ""); exibirMensagem("Ok", "Cadastro atualizado com sucesso", "ok"); divConsulta.Visible = false; divCadastro.Visible = true; ViewState["VW_ATLETAANEXO"] = AtletaAnexoModelo.AtletaAnexoLista(); gvArquivos.DataSource = ViewState["VW_ATLETAANEXO"]; gvArquivos.DataBind(); } catch (Exception err) { exibirMensagem("Erro", err.Message.ToString(), "erro"); } }
public bool Inserir(PessoaModelo pessoa) { return(this.pessoaPersistencia.Inserir(pessoa)); }
public void Editar(PessoaModelo pessoa) { this.pessoaPersistencia.Editar(pessoa); }
private void btCargaDevolução_Click(object sender, EventArgs e) { if (txtIdVendedor.Text != "") { if (cbbPraça.SelectedItem != null) { if (txtDataFinal.Text != "" && txtDataInicial.Text != "") { DateTime dataInicial = DateTime.Parse(txtDataInicial.Text); DateTime dataFinal = DateTime.Parse(txtDataFinal.Text); string query = "select * from CargaDevolução where CargaDevolução.VendedorID == " + txtIdVendedor.Text + " and date(CargaDevolução.Data) BETWEEN date('" + dataInicial.Year + "-" + dataInicial.Month.ToString("00") + "-" + dataInicial.Day.ToString("00") + "') and date('" + dataFinal.Year + "-" + dataFinal.Month.ToString("00") + "-" + dataFinal.Day.ToString("00") + "') order by CargaDevolução.Data"; cargaDevoluçãoList = SqliteAcessoDados.LoadQuery <CargaDevoluçãoModelo>(query); } else { cargaDevoluçãoList = SqliteAcessoDados.LoadQuery <CargaDevoluçãoModelo>("select * from CargaDevolução where CargaDevolução.VendedorID == " + txtIdVendedor.Text + " order by CargaDevolução.Data"); } if (cargaDevoluçãoList.Count > 0) { string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Relatorios"; VendedorModelo vendedor = SqliteAcessoDados.LoadQuery <VendedorModelo>("select * from Vendedor where Vendedor.ID == " + txtIdVendedor.Text).First(); PessoaModelo vendedorPessoa = SqliteAcessoDados.LoadQuery <PessoaModelo>("select * from Pessoa where Pessoa.ID == " + vendedor.PessoaId.ToString()).First(); string fileName = "Cargas e Devoluções - Vendedor - " + vendedorPessoa.Nome + " - Praça - " + cbbPraça.SelectedItem.ToString() + " - "; if (txtDataFinal.Text != "" && txtDataInicial.Text != "") { if (txtDataFinal.Text == txtDataInicial.Text) { fileName += DateTime.Parse(txtDataFinal.Text).Day.ToString() + "_" + DateTime.Parse(txtDataFinal.Text).Month.ToString() + "_" + DateTime.Parse(txtDataFinal.Text).Year.ToString(); } else { fileName += "De - " + DateTime.Parse(txtDataFinal.Text).Day.ToString() + "_" + DateTime.Parse(txtDataFinal.Text).Month.ToString() + "_" + DateTime.Parse(txtDataFinal.Text).Year.ToString() + " - Até - " + DateTime.Parse(txtDataInicial.Text).Day.ToString() + "_" + DateTime.Parse(txtDataInicial.Text).Month.ToString() + "_" + DateTime.Parse(txtDataInicial.Text).Year.ToString(); } } else { fileName += "Todas as Datas"; } fileName += ".docx"; System.IO.Directory.CreateDirectory(docPath); docPath = System.IO.Path.Combine(docPath, fileName); using (var document = DocX.Create(docPath)) { document.InsertParagraph("SABOR MINEIRO - RELATÓRIO").FontSize(11d).Bold().Alignment = Alignment.center; document.InsertParagraph("TOTAL DE VENDAS").FontSize(10d).Bold().Alignment = Alignment.center; document.InsertParagraph(); document.InsertParagraph("PROMOTOR: ").FontSize(10d).Bold() .Append(txtNomeVendedor.Text).FontSize(10d) .Alignment = Alignment.left; document.InsertParagraph("PRAÇA: ").FontSize(10d).Bold() .Append(cbbPraça.SelectedItem.ToString()).FontSize(10d) .Alignment = Alignment.left; document.InsertParagraph("PLACA VEICULO: ").FontSize(10d).Bold() .Append(vendedor.Placa).FontSize(10d) .Alignment = Alignment.left; document.InsertParagraph(); document.InsertParagraph("RELATÓRIO GERAL").FontSize(10d).Bold().Alignment = Alignment.center; document.InsertParagraph(); Table t = document.AddTable(1, 4); t.AutoFit = AutoFit.Contents; t.Design = TableDesign.LightGridAccent3; t.Rows[0].Cells[0].Paragraphs.First().Append("DATA").Bold().FontSize(10d).Alignment = Alignment.center; t.Rows[0].Cells[1].Paragraphs.First().Append("PRODUTO").Bold().FontSize(10d).Alignment = Alignment.center; t.Rows[0].Cells[2].Paragraphs.First().Append("CARGA/DEVOLUÇÃO").Bold().FontSize(10d).Alignment = Alignment.center; t.Rows[0].Cells[3].Paragraphs.First().Append("QUANTIDADE").Bold().FontSize(10d).Alignment = Alignment.center; List <ProdutosCargaDevoluçãoModelo> produtosCargaDevoluçãoList = new List <ProdutosCargaDevoluçãoModelo>(); foreach (CargaDevoluçãoModelo cargaDevolução in cargaDevoluçãoList) { produtosCargaDevoluçãoList = SqliteAcessoDados.LoadQuery <ProdutosCargaDevoluçãoModelo>("select * from ProdutosCargaDevolução where ProdutosCargaDevolução.CargaDevoluçãoID == " + cargaDevolução.Id); foreach (ProdutosCargaDevoluçãoModelo produtosCargaDevolução in produtosCargaDevoluçãoList) { t.InsertRow(); string descrição = SqliteAcessoDados.LoadQuery <ProdutoModelo>("select Descrição from Produto where Produto.ID == " + produtosCargaDevolução.ProdutoID).First().Descrição; t.Rows.Last().Cells[0].Paragraphs.First().Append(cargaDevolução.Data.ToShortDateString()).FontSize(10d).Alignment = Alignment.left; t.Rows.Last().Cells[1].Paragraphs.First().Append(descrição).FontSize(10d).Alignment = Alignment.left; t.Rows.Last().Cells[2].Paragraphs.First().Append(cargaDevolução.Devolução ? "Devolução" : "Carga").FontSize(10d).Alignment = Alignment.left; t.Rows.Last().Cells[3].Paragraphs.First().Append(cargaDevolução.Devolução ? produtosCargaDevolução.Quantidade.ToString() : (produtosCargaDevolução.Quantidade * -1).ToString()).FontSize(10d).Alignment = Alignment.left; } } document.InsertTable(t); document.InsertParagraph(); document.InsertParagraph("RELATÓRIO POR PRODUTO").FontSize(10d).Bold().Alignment = Alignment.center; List <ProdutoModelo> produtoList = SqliteAcessoDados.GetPesquisarTodos <ProdutoModelo>(); foreach (ProdutoModelo produto in produtoList) { document.InsertParagraph(); document.InsertParagraph("PRODUTO: ") .FontSize(10d) .Bold() .Append(produto.Descrição) .Alignment = Alignment.left; document.InsertParagraph(); t = document.AddTable(1, 3); t.Rows[0].Cells[0].Paragraphs.First().Append("DATA").Bold().FontSize(10d).Alignment = Alignment.center; t.Rows[0].Cells[1].Paragraphs.First().Append("CARGA/DEVOLUÇÃO").Bold().FontSize(10d).Alignment = Alignment.center; t.Rows[0].Cells[2].Paragraphs.First().Append("QUANTIDADE").Bold().FontSize(10d).Alignment = Alignment.center; int quantidade = 0; foreach (CargaDevoluçãoModelo cargaDevolução in cargaDevoluçãoList) { produtosCargaDevoluçãoList = SqliteAcessoDados.LoadQuery <ProdutosCargaDevoluçãoModelo>("select * from ProdutosCargaDevolução where ProdutosCargaDevolução.CargaDevoluçãoID == " + cargaDevolução.Id + " and ProdutosCargaDevolução.ProdutoID == " + produto.Id); foreach (ProdutosCargaDevoluçãoModelo produtosCargaDevolução in produtosCargaDevoluçãoList) { t.InsertRow(); string descrição = SqliteAcessoDados.LoadQuery <ProdutoModelo>("select Descrição from Produto where Produto.ID == " + produtosCargaDevolução.ProdutoID).First().Descrição; t.Rows.Last().Cells[0].Paragraphs.First().Append(cargaDevolução.Data.ToShortDateString()).FontSize(10d).Alignment = Alignment.left; t.Rows.Last().Cells[1].Paragraphs.First().Append(cargaDevolução.Devolução ? "Devolução" : "Carga").FontSize(10d).Alignment = Alignment.left; t.Rows.Last().Cells[2].Paragraphs.First().Append(cargaDevolução.Devolução ? produtosCargaDevolução.Quantidade.ToString() : (produtosCargaDevolução.Quantidade * -1).ToString()).FontSize(10d).Alignment = Alignment.left; quantidade += cargaDevolução.Devolução ? produtosCargaDevolução.Quantidade : (produtosCargaDevolução.Quantidade * -1); } } t.InsertRow(); t.Rows.Last().Cells[1].Paragraphs.First().Append("TOTAL PERIODO").Bold().FontSize(10d).Alignment = Alignment.left; t.Rows.Last().Cells[2].Paragraphs.First().Append(quantidade.ToString()).FontSize(10d).Alignment = Alignment.left; document.InsertTable(t); } try { document.Save(); DialogResult result = MessageBox.Show("Relatorio gerado na pasta Meus Documentos -> Relatorios(" + docPath + ")", "Atenção!", MessageBoxButtons.OK); } catch { DialogResult result = MessageBox.Show("Arquivo aberto em outro aplicativo, favor fecha-lo antes de continuar", "Atenção!", MessageBoxButtons.OK); } } } else { DialogResult result = MessageBox.Show("Nenhum registro encontrado nas datas selecionadas para este vendedor e esta praça", "Atenção!", MessageBoxButtons.OK); } } else { DialogResult result = MessageBox.Show("Selecione uma Praça primeiro", "Atenção!", MessageBoxButtons.OK); } } else { DialogResult result = MessageBox.Show("Selecione um Vendedor primeiro", "Atenção!", MessageBoxButtons.OK); } }
public IActionResult Post([FromBody] PessoaModelo pessoa) { return(CreatedAtRoute("", pessoaNegocio.inserir(pessoa))); }
private void GerarRelatorioTotalVendas(List <PedidoModelo> pedidos) { string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Relatorios"; string fileName = ""; bool unico = true; if (txtIdVendedor.Text != "") { VendedorModelo vendedor = SqliteAcessoDados.LoadQuery <VendedorModelo>("select * from Vendedor where Vendedor.ID == " + pedidos[0].VendedorID.ToString()).First(); PessoaModelo vendedorPessoa = SqliteAcessoDados.LoadQuery <PessoaModelo>("select * from Pessoa where Pessoa.ID == " + vendedor.PessoaId.ToString()).First(); fileName = "Vendedor - " + vendedorPessoa.Nome + " - "; unico = true; } else { fileName = "Geral - "; unico = false; } if (txtDataFinal.Text != "" && txtDataInicial.Text != "") { if (txtDataFinal.Text == txtDataInicial.Text) { fileName += DateTime.Parse(txtDataFinal.Text).Day.ToString() + "_" + DateTime.Parse(txtDataFinal.Text).Month.ToString() + "_" + DateTime.Parse(txtDataFinal.Text).Year.ToString(); } else { fileName += "De - " + DateTime.Parse(txtDataFinal.Text).Day.ToString() + "_" + DateTime.Parse(txtDataFinal.Text).Month.ToString() + "_" + DateTime.Parse(txtDataFinal.Text).Year.ToString() + " - Até - " + DateTime.Parse(txtDataInicial.Text).Day.ToString() + "_" + DateTime.Parse(txtDataInicial.Text).Month.ToString() + "_" + DateTime.Parse(txtDataInicial.Text).Year.ToString(); } } else { fileName += "Todas as Datas"; } fileName += ".docx"; System.IO.Directory.CreateDirectory(docPath); docPath = System.IO.Path.Combine(docPath, fileName); if (unico) { using (var document = DocX.Create(docPath)) { document.InsertParagraph("SABOR MINEIRO - RELATÓRIO").FontSize(11d).Bold().Alignment = Alignment.center; document.InsertParagraph("TOTAL DE VENDAS").FontSize(10d).Bold().Alignment = Alignment.center; CreateHeaderTotalVendas(pedidosList.First(), document); Table t = document.AddTable(1, 7); CreateTableTotalVendas(document, t); t = CreateTableContentTotalVendas(pedidosList.First(), t); t = CreateTableLastRowTotalVendas(t); document.InsertTable(t); try { document.Save(); DialogResult result = MessageBox.Show("Relatorio gerado na pasta Meus Documentos -> Relatorios(" + docPath + ")", "Atenção!", MessageBoxButtons.OK); } catch { DialogResult result = MessageBox.Show("Arquivo aberto em outro aplicativo, favor fecha-lo antes de continuar", "Atenção!", MessageBoxButtons.OK); } } } else { using (var document = DocX.Create(docPath)) { document.InsertParagraph("SABOR MINEIRO - RELATÓRIO").FontSize(11d).Bold().Alignment = Alignment.center; document.InsertParagraph("TOTAL DE VENDAS").FontSize(10d).Bold().Alignment = Alignment.center; int vendedorID = -1; Table t = document.AddTable(1, 7); for (int i = 0; i < pedidosList.Count; i++) { if (vendedorID != pedidosList[i].VendedorID) { CreateHeaderTotalVendas(pedidosList[i], document); t = CreateTableTotalVendas(document, t); } t = CreateTableContentTotalVendas(pedidosList[i], t); vendedorID = pedidosList[i].VendedorID; if (i == pedidosList.Count - 1) { t = CreateTableLastRowTotalVendas(t); document.InsertTable(t); } else if (vendedorID != pedidosList[i + 1].VendedorID) { t = CreateTableLastRowTotalVendas(t); document.InsertTable(t); } } try { document.Save(); DialogResult result = MessageBox.Show("Relatorio gerado na pasta Meus Documentos -> Relatorios(" + docPath + ")", "Atenção!", MessageBoxButtons.OK); } catch { DialogResult result = MessageBox.Show("Arquivo aberto em outro aplicativo, favor fecha-lo antes de continuar", "Atenção!", MessageBoxButtons.OK); } } } }
private string GerarArquivoImpressão(DataGridViewRow row) { string id = row.Cells["txtCodigo"].Value.ToString(); string nome = row.Cells["txtNome"].Value.ToString(); string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Impressões\\" + cbbPraça.SelectedItem.ToString(); string fileName = "Pedido - " + id + " - " + nome + ".docx"; System.IO.Directory.CreateDirectory(docPath); docPath = System.IO.Path.Combine(docPath, fileName); PessoaModelo pessoa = SqliteAcessoDados.LoadQuery <PessoaModelo>("select * from Pessoa where Pessoa.ID == " + id).First(); using (var document = DocX.Create(docPath)) { for (int i = 0; i < 2; i++) { document.MarginLeft = 36; // 1cm = 28.3464567pt document.MarginRight = 36; document.MarginTop = 36; document.MarginBottom = 36; document.InsertParagraph("S&S BISCOITOS DI MINAS") .FontSize(11d) .Bold() .Alignment = Alignment.center; document.InsertParagraph("PEDIDO Nº:") .FontSize(10d) .Bold() .Append(" ____") .FontSize(10d) .Alignment = Alignment.right; document.InsertParagraph("NOME: ") .Bold() .FontSize(10d) .Append(pessoa.Nome + " ") //"________________________________________________________________") // adicionar logicas \/ .FontSize(10d) .Append("DATA DE NASCIMENTO: ") .Bold() .FontSize(10d) .Append(pessoa.Nascimento.ToShortDateString()) //"___ / ___ / ___") .FontSize(10d) .Alignment = Alignment.left; document.InsertParagraph("RG: ") .Bold() .FontSize(10d) .Append(pessoa.RG + " ") //"_______________________________ ") .FontSize(10d) .Append("CPF: ") .Bold() .FontSize(10d) .Append(pessoa.CPF + " ") //"______________________________") .FontSize(10d) .Append("TELEFONE: ") .Bold() .FontSize(10d) .Append(pessoa.Telefone) //"(___)_____________________") .FontSize(10d) .Alignment = Alignment.left; document.InsertParagraph("PONTO DE REFERÊNCIA: ") .Bold() .FontSize(10d) .Append(pessoa.PontoReferencia + " ") //"______________________________________________________________________________________________") .FontSize(10d) .Alignment = Alignment.left; document.InsertParagraph("ENDEREÇO: ") .Bold() .FontSize(10d) .Append(pessoa.Endereco + " " + pessoa.Numero + " ") //"_____________________________________________________________________________________________") .FontSize(10d) .Alignment = Alignment.left; document.InsertParagraph("BAIRRO: ") .Bold() .FontSize(10d) .Append(pessoa.Bairro + " ") //"____________________________________________________________") .FontSize(10d) .Append("CIDADE: ") .Bold() .FontSize(10d) .Append(pessoa.Cidade + " - " + pessoa.Estado + " ") //"______________________________") .FontSize(10d) .Alignment = Alignment.left; document.InsertParagraph("VENDEDOR: ") .Bold() .FontSize(10d) .Append(txtNomeVendedor.Text + " ") //"__ __________") .FontSize(10d) .Append("TELEFONE: ") .Bold() .FontSize(10d) .Append(txtTelefoneVendedor.Text + " ") //"(___)_____________________") .FontSize(10d) .Append("PRAÇA: ") .Bold() .FontSize(10d) .Append(cbbPraça.Text + " ") //"__ - ___________") .FontSize(10d) .Alignment = Alignment.left; Table t = document.AddTable(11, 7); t.Design = TableDesign.LightGridAccent3; t.Alignment = Alignment.center; t.AutoFit = AutoFit.Contents; t.Rows[0].Cells[0].Paragraphs.First().Append("PRODUTO").FontSize(10d).Alignment = Alignment.center; t.Rows[0].Cells[1].Paragraphs.First().Append("ENTREGUE").FontSize(10d).Alignment = Alignment.center; t.Rows[0].MergeCells(1, 2); t.Rows[0].Cells[2].Paragraphs.First().Append("D").FontSize(10d).Alignment = Alignment.center; t.Rows[0].Cells[3].Paragraphs.First().Append("V").FontSize(10d).Alignment = Alignment.center; t.Rows[0].Cells[4].Paragraphs.First().Append("VALOR UNIT").FontSize(10d).Alignment = Alignment.center; t.Rows[0].Cells[5].Paragraphs.First().Append(" TOTAL").FontSize(10d).Alignment = Alignment.center; t.Rows[1].Cells[0].Paragraphs.First().Append("CONE").FontSize(10d); t.Rows[2].Cells[0].Paragraphs.First().Append("BISCOITO").FontSize(10d); t.Rows[3].Cells[0].Paragraphs.First().Append("DOCE DE LEITE / COCADA CREMOSA").FontSize(10d); t.Rows[4].Cells[0].Paragraphs.First().Append("MEL").FontSize(10d); t.Rows[5].Cells[0].Paragraphs.First().Append("PAÇOCA / PÉ DE MOÇA").FontSize(10d); t.Rows[6].Cells[0].Paragraphs.First().Append("TRUFA").FontSize(10d); t.Rows[7].Cells[0].Paragraphs.First().Append("PICADINHO").FontSize(10d); t.Rows[8].Cells[0].Paragraphs.First().Append("QUEIJO").FontSize(10d); /*foreach (Row tableRow in t.Rows) * { * for (int i = 0; i < tableRow.Cells.Count; i++) * { * switch (i) * { * case 0: * tableRow.Cells[i].Width = 5.89 * 28.3464567; * break; * case 1: * tableRow.Cells[i].Width = 2.59 * 28.3464567; * break; * case 2: * tableRow.Cells[i].Width = 2.59 * 28.3464567; * break; * case 3: * tableRow.Cells[i].Width = 1.18 * 28.3464567; * break; * case 4: * tableRow.Cells[i].Width = 1.18 * 28.3464567; * break; * case 5: * tableRow.Cells[i].Width = 2.12 * 28.3464567; * break; * case 6: * tableRow.Cells[i].Width = 6.6 * 28.3464567; * break; * default: * break; * } * } * } * * t.SetColumnWidth(0, ); * t.SetColumnWidth(1, ); * t.SetColumnWidth(2, 2.59 * 28.3464567); * t.SetColumnWidth(3, ); * t.SetColumnWidth(4, 1.18 * 28.3464567); * t.SetColumnWidth(5, ); * t.SetColumnWidth(6, );*/ t.Rows[9].Height = 61.228346472; t.Rows[10].Height = 61.228346472; t.Rows[9].MergeCells(0, 5); t.Rows[10].MergeCells(0, 5); t.MergeCellsInColumn(0, 9, 10); t.Rows[9].Cells[0].InsertParagraph("TOTAL DE PEÇAS: ______________________ N° DE ITENS _").FontSize(10d) .InsertParagraphAfterSelf("OBS > ATÉ R$ 89,99 (20 %) COMISSÃO / ATÉ R$ 169,99 (25 %) COMISSÃO /").FontSize(10d) .InsertParagraphAfterSelf("ATÉ R$ 600,00 (30 %) COMISSÃO / ACIMA DE R$ 600,00 (35 %) COMISSÃO / ACIMA DE R$ 990,00 (40 %) COMISSÃO").FontSize(10d) .InsertParagraphAfterSelf(" * NÃO TRABALHAMOS COM DEPÓSITOS EM CONTA BANCÁRIA, NEM CHEQUES").Bold().FontSize(10d) .InsertParagraphAfterSelf(" * NÃO TRABALHAMOS COM BRINDES").Bold().FontSize(10d) .InsertParagraphAfterSelf("DATA DE RETORNO DIA ______ / ______ / ______").FontSize(10d) .InsertParagraphAfterSelf(" _________________________________").FontSize(10d) .InsertParagraphAfterSelf(" ASSINATURA").FontSize(10d); document.InsertTable(t); if (i == 0) { document.InsertParagraph(); } } document.InsertParagraph("EMPRESA FILIADA AO SPC / PAGUE EM DIA E MANTENHA SEU NOME LIMPO").Bold().FontSize(10d); document.InsertSectionPageBreak(); try { document.Save(); return(docPath); } catch { DialogResult result = MessageBox.Show("Arquivo aberto em outro aplicativo, favor fecha-lo antes de continuar", "Atenção!", MessageBoxButtons.OK); return(""); } } }