private void Excluir(int dia) { DialogResult d = MessageBox.Show($"Deseja realmente os dados do dia {dia} de {cbMes.Text}?", "Aviso", MessageBoxButtons.YesNo); if (d.ToString() == "Yes") { DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); DTODados ven = new DTODados(); BLLDados bllven = new BLLDados(cx); DateTime data = new DateTime(Convert.ToInt32(txtAno.Value), Convert.ToInt32(mesSelecionado), dia); bllven.Excluir(data, Convert.ToInt32(cbUnidade.SelectedValue)); bllven.ExcluirPaxDia(data, Convert.ToInt32(cbUnidade.SelectedValue)); AtualizaDados(); } }
private void RecarregadgvLista() { dgvLista.Rows.Clear(); DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLDados bll = new BLLDados(cx); DataTable tabela = bll.LocalizarCodigosAcadastrar(); String[] V; if (tabela.Rows.Count > 0) { for (int i = 0; tabela.Rows.Count > i; i++) { if (tabela.Rows[i][3].ToString() == "0") { V = new string[] { tabela.Rows[i][0].ToString(), tabela.Rows[i][1].ToString() }; this.dgvLista.Rows.Add(V); } } } }
private void AddDB() { DateTime DataI = new DateTime(Convert.ToDateTime(dgvExcel.Rows[1].Cells[1].Value).Year, Convert.ToDateTime(dgvExcel.Rows[1].Cells[1].Value).Month, 1); DateTime DataF = DataI.AddDays(-(DataI.Day - 1)).AddMonths(1).AddDays(-1); #region Venda if (tipo == "venda") { DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); DTODados ven = new DTODados(); BLLDados bllven = new BLLDados(cx); bllven.Excluir(Convert.ToDateTime(dgvExcel.Rows[1].Cells[0].Value), Convert.ToInt32(cbUnidade.SelectedValue)); for (int i = 0; i < dgvExcel.RowCount; i++) { ven.DataVenda = Convert.ToDateTime(dgvExcel.Rows[i].Cells[0].Value); ven.GrupoVenda = Convert.ToInt32(dgvExcel.Rows[i].Cells[2].Value); ven.CanceladosVenda = Convert.ToDouble(dgvExcel.Rows[i].Cells[6].Value); ven.CortesiasVenda = Convert.ToDouble(dgvExcel.Rows[i].Cells[7].Value); ven.PromocoesVenda = Convert.ToDouble(dgvExcel.Rows[i].Cells[8].Value); ven.QuantVenda = Convert.ToDouble(dgvExcel.Rows[i].Cells[9].Value); ven.QuantTotalVenda = Convert.ToDouble(dgvExcel.Rows[i].Cells[10].Value); ven.ValorVenda = Convert.ToDouble(dgvExcel.Rows[i].Cells[18].Value); ven.ValorTotalVenda = Convert.ToDouble(dgvExcel.Rows[i].Cells[19].Value); ven.IdUsuario = Convert.ToInt32(idUsuario); ven.IdUnidade = Convert.ToInt32(cbUnidade.SelectedValue); bllven.Incluir(ven); } this.LimparTela(); } #endregion #region Pax else if (tipo == "pax") { DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); DTODados pax = new DTODados(); BLLDados bllven = new BLLDados(cx); bllven.ExcluirPax(DataI, DataF, Convert.ToInt32(cbUnidade.SelectedValue)); for (int i = 0; i < dgvExcel.RowCount; i++) { if (dgvExcel.Rows[i].Cells[27].Value.ToString() == "FALSO") { pax.DataPax = Convert.ToDateTime(dgvExcel.Rows[i].Cells[0].Value); pax.TurnoPax = Convert.ToInt32(dgvExcel.Rows[i].Cells[1].Value); pax.Pax = Convert.ToDouble(dgvExcel.Rows[i].Cells[6].Value); pax.IdUsuario = Convert.ToInt32(idUsuario); pax.IdUnidade = Convert.ToInt32(cbUnidade.SelectedValue); pax.DiaTurno = (((int)pax.DataPax.DayOfWeek) + 1).ToString() + "." + pax.TurnoPax; bllven.IncluirPax(pax); } } this.LimparTela(); } #endregion #region Custo else if (tipo == "custo") { /* * * DateTime dataatual = Convert.ToDateTime(dgvExcel.Rows[1].Cells[1].Value); * * DateTime Diai = new DateTime(dataatual.Year, dataatual.Month, 1); * * DateTime Diaf = Diai.AddDays(-(Diai.Day - 1)).AddMonths(1).AddDays(-1); * */ DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); DTODados cus = new DTODados(); BLLDados bllven = new BLLDados(cx); BLLExcessoesCusto bllexc = new BLLExcessoesCusto(cx); //bllven.ExcluirCusto(Diai, Diaf, Convert.ToInt32(cbUnidade.SelectedValue)); string tipo, op; double custo, acresc; for (int i = 0; i < dgvExcel.RowCount; i++) { tipo = dgvExcel.Rows[i].Cells[4].Value.ToString(); op = dgvExcel.Rows[i].Cells[7].Value.ToString(); if (dgvExcel.Rows[i].Cells[7].Value.ToString() != "" && Convert.ToInt32(dgvExcel.Rows[i].Cells[0].Value.ToString()) == Convert.ToInt32(cbUnidade.Text)) { //tipo == "CONSUMO - CMV DIVERSOS - A&B" || op == "110.2R" || op == "140.3A" || op == "110.2S" || op == "110.2E" || op == "110.2Y" || op == "110.2U" || op == "210.2B" cus.DataCusto = Convert.ToDateTime(dgvExcel.Rows[i].Cells[1].Value); cus.TipoMovCusto = dgvExcel.Rows[i].Cells[4].Value.ToString(); cus.TipoOperacaoCusto = dgvExcel.Rows[i].Cells[7].Value.ToString(); cus.DescricaoCusto = dgvExcel.Rows[i].Cells[18].Value.ToString(); cus.CodItemCusto = dgvExcel.Rows[i].Cells[2].Value.ToString(); cus.ContaGerencialCusto = dgvExcel.Rows[i].Cells[8].Value.ToString(); cus.MovimentoCusto = Convert.ToInt32(dgvExcel.Rows[i].Cells[11].Value); cus.QuantMovCusto = Convert.ToDouble(dgvExcel.Rows[i].Cells[5].Value.ToString()); try { custo = Convert.ToDouble(dgvExcel.Rows[i].Cells[6].Value); } catch { custo = 0; } try { acresc = Convert.ToDouble(dgvExcel.Rows[17].Cells[6].Value); } catch { acresc = 0; } cus.ValorUnitarioCusto = Math.Round(((custo + acresc) / cus.QuantMovCusto), 4); cus.TipoDocCusto = dgvExcel.Rows[i].Cells[9].Value.ToString(); cus.DocumentoCusto = dgvExcel.Rows[i].Cells[10].Value.ToString(); if (cus.TipoOperacaoCusto == "800.01" || (cus.TipoOperacaoCusto == "800.02" && cus.TipoOperacaoCusto == "9.5.02.106") || cus.TipoOperacaoCusto == "110.2R" || cus.TipoOperacaoCusto == "140.3A" || cus.TipoOperacaoCusto == "110.2S" || cus.TipoOperacaoCusto == "110.2E" || cus.TipoOperacaoCusto == "110.2Y" || cus.TipoOperacaoCusto == "110.2U" || cus.TipoOperacaoCusto == "210.2B" || cus.TipoOperacaoCusto == "191.0" || cus.TipoOperacaoCusto == "800.90" || cus.TipoOperacaoCusto == "800.95") { cus.Grupo = "01"; } else if (cus.TipoOperacaoCusto == "800.06") { cus.Grupo = "06"; } else if (cus.TipoOperacaoCusto == "800.05") { cus.Grupo = "05"; } else if (cus.TipoOperacaoCusto == "800.10") { cus.Grupo = "10"; } else if (cus.TipoOperacaoCusto == "800.02") { cus.Grupo = "02"; } else { cus.Grupo = ""; } if (cus.ContaGerencialCusto == "9.5.02.107") { if (cus.CodItemCusto == "01.12.0008") { cus.ValorUnitarioCusto *= 0.096; } else if (cus.CodItemCusto == "01.12.0017") { cus.ValorUnitarioCusto *= 0.62; } } cus.IdUsuario = Convert.ToInt32(idUsuario); cus.IdUnidade = Convert.ToInt32(cbUnidade.SelectedValue); cus.QuantMovCusto *= -1; if (cus.TipoOperacaoCusto == "191.0" || cus.TipoOperacaoCusto == "800.95") { cus.QuantMovCusto *= -1; } else { } bllven.IncluirCusto(cus); } } this.LimparTela(); } #endregion else { MessageBox.Show("Esta tabela não atende ao pré-requisitos para ser adicionada ao banco de dados."); this.LimparTela(); } }
private void AtualizaChart() { graficoVendaPax.Series[0].Points.Clear(); graficoVendaPax.Series[1].Points.Clear(); graficoVendaReceita.Series[0].Points.Clear(); graficoVendaReceita.Series[1].Points.Clear(); #region Pax DateTime Diai = new DateTime(Convert.ToInt32(txtAno.Value), Convert.ToInt32(mesSelecionado), 1); DateTime Diaf = Diai.AddDays(-(Diai.Day - 1)).AddMonths(1).AddDays(-1); DALConexao cxpax = new DALConexao(DadosDaConexao.StringDaConexao); BLLDados bllpax = new BLLDados(cxpax); DataTable tabela = bllpax.LocalizarPaxDiario(Diai, Diaf, Convert.ToInt32(cbUnidade.SelectedValue)); double paxtotal = 0; double paxanterior = 0; double paxatual = 0; double media; for (int i = 0; i < Diaf.Day; i++) { try { paxatual = Convert.ToDouble(tabela.Rows[i][1]); } catch { paxatual = 0; } media = (paxatual + paxanterior) / 2; graficoVendaPax.Series["Dias"].Points.AddXY((i + 1).ToString(), paxatual); graficoVendaPax.Series["Linha"].Points.AddXY((i + 1).ToString(), media); try { paxanterior = Convert.ToDouble(tabela.Rows[i][1]); } catch { paxanterior = 0; } paxtotal += paxatual; } lbTituloPax.Text = $"PAX total de {cbMes.Text}: {paxtotal.ToString("0")}"; #endregion #region Receita try { DALConexao cxven = new DALConexao(DadosDaConexao.StringDaConexao); BLLDados bllven = new BLLDados(cxven); DataTable tabelav = bllven.LocalizarVenda(Diai, Diaf, Convert.ToInt32(cbUnidade.SelectedValue.ToString())); double vendatotal = 0; double vendaanterior = 0; double vendaatual = 0; media = 0; lbTituloReceita.Text = "RECEITA"; for (int i = 0; i < Diaf.Day; i++) { vendaatual = 0; try { vendaatual = Convert.ToDouble(tabelav.Rows[i][1]); } catch { } media = (vendaatual + vendaanterior) / 2; graficoVendaReceita.Series["Dias"].Points.AddXY((i + 1).ToString(), vendaatual); graficoVendaReceita.Series["Linha"].Points.AddXY((i + 1).ToString(), media); try { vendaanterior = Convert.ToDouble(tabelav.Rows[i][1]); } catch { vendaanterior = 0; } vendatotal += vendaatual; } lbTituloReceita.Text += $" total de {cbMes.Text}: R$ {vendatotal.ToString("0,0.00")}"; } catch { } #endregion this.graficoVendaPax.MouseMove += new System.Windows.Forms.MouseEventHandler(this.graficoVendaPax_MouseMove); }
private void AtualizaDados() { DateTime dataatual = dataSelecionada; DateTime Diai = new DateTime(dataatual.Year, dataatual.Month, 1); DateTime Diaf = Diai.AddDays(-(Diai.Day - 1)).AddMonths(1).AddDays(-1); DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); #region Atualiza Valores de venda //Preenche os dados (R$) DateTime dataBusca = new DateTime(Convert.ToInt32(txtAno.Value), Convert.ToInt32(mesSelecionado), 1); BLLDados bll = new BLLDados(cx); DataTable tabelaVenda = bll.LocalizarVenda(Diai, Diaf, Convert.ToInt32(cbUnidade.SelectedValue)); int i = 0; string valoratual; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor01.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor02.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor03.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor04.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor05.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor06.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor07.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor08.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor09.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor10.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor11.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor12.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor13.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor14.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor15.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor16.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor17.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor18.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor19.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor20.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor21.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor22.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor23.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor24.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor25.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor26.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor27.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor28.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor29.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor30.Text = valoratual; i++; try { valoratual = "R$ " + Convert.ToDouble(tabelaVenda.Rows[i][1]).ToString("#,0.00"); } catch { valoratual = ""; } lbValor31.Text = valoratual; i++; #endregion #region Atualiza Valores de Pax DataTable tabelapax = bll.LocalizarPaxDiario(Diai, Diaf, Convert.ToInt32(cbUnidade.SelectedValue)); i = 0; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax01.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax02.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax03.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax04.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax05.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax06.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax07.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax08.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax09.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax10.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax11.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax12.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax13.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax14.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax15.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax16.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax17.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax18.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax19.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax20.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax21.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax22.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax23.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax24.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax25.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax26.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax27.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax28.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax29.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax30.Text = valoratual; i++; try { valoratual = Convert.ToDouble(tabelapax.Rows[i][1]).ToString("0"); } catch { valoratual = ""; } lbPax31.Text = valoratual; #endregion }