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 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(); } }