private void adicionaBanco() { DTOAcrescimos dto = new DTOAcrescimos(); DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLAcrescimos bll = new BLLAcrescimos(cx); //Preenche dados dto.Conta_acrescimo = ""; dto.Obs_acrescimo = ""; dto.Tipo_acrescimo = ""; dto.Valor_acrescimo = 0; dto.Data_acrescimo = dpData.Value; dto.Valor_acrescimo = Convert.ToDouble(txtValor.Text); dto.Id_usuario = idUsuario; dto.Id_unidade = idUnidade; if (txtObs.Text != "") { dto.Obs_acrescimo = txtObs.Text.Trim(); } if (cbConta.SelectedValue.ToString() == "-1") { dto.Tipo_acrescimo = "p"; } else if (cbConta.SelectedValue.ToString() == "-2") { dto.Tipo_acrescimo = "r"; } else { dto.Tipo_acrescimo = "c"; dto.Valor_acrescimo *= -1; dto.Conta_acrescimo = cbConta.Text.ToString().Substring(0, 10); } dto.Descricao_acrescimo = cbConta.Text; bll.Incluir(dto); txtValor.Clear(); txtObs.Clear(); cbConta.Text = ""; dpData.Value = DateTime.Now; MessageBox.Show("Valor incluído com sucesso!"); CarregaDGVs(); }
private void CarregaDGVs() { DateTime Data = new DateTime(AnoAtual, mesAtual, 1); DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLConsultaCMV bll = new BLLConsultaCMV(cx); DataTable table = bll.ListarCustoReceitaPaxAcrescimos(idUnidade, Data); dgvCusto.DataSource = table; dgvCusto.Columns[0].Width = 70; dgvCusto.Columns[0].HeaderText = "DATA"; dgvCusto.Columns[1].Width = 70; dgvCusto.Columns[1].HeaderText = "CUSTO"; dgvCusto.Columns[2].Width = 70; dgvCusto.Columns[2].HeaderText = "+CUSTO"; dgvCusto.Columns[3].Width = 70; dgvCusto.Columns[3].HeaderText = "RECEITA_B"; dgvCusto.Columns[4].Width = 70; dgvCusto.Columns[4].HeaderText = "RECEITA_L"; dgvCusto.Columns[5].Width = 70; dgvCusto.Columns[5].HeaderText = "+RECEITA"; dgvCusto.Columns[6].Width = 50; dgvCusto.Columns[6].HeaderText = "PAX"; dgvCusto.Columns[7].Width = 50; dgvCusto.Columns[7].HeaderText = "+PAX"; //carrega dgvAcrescimos dgvAcrescimos.Rows.Clear(); BLLAcrescimos blla = new BLLAcrescimos(cx); DataTable acrescimos = blla.LocalizarAcrescimos(idUnidade, Data); string data; String[] S; for (int i = 0; i < acrescimos.Rows.Count; i++) { data = Convert.ToDateTime(acrescimos.Rows[i][1]).ToShortDateString(); S = new string[] { acrescimos.Rows[i][0].ToString(), data, acrescimos.Rows[i][2].ToString(), acrescimos.Rows[i][3].ToString(), acrescimos.Rows[i][4].ToString(), acrescimos.Rows[i][5].ToString() }; dgvAcrescimos.Rows.Add(S); } }
private void ExcluiAcrescimo(int id, int linha) { DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLAcrescimos bll = new BLLAcrescimos(cx); if (dgvAcrescimos.Rows[linha].Cells[3].Value.ToString().Substring(1, 1) == ".") { txtValor.Text = (Convert.ToDouble(dgvAcrescimos.Rows[linha].Cells[2].Value) * -1).ToString("#,0.00"); } else { txtValor.Text = (Convert.ToDouble(dgvAcrescimos.Rows[linha].Cells[2].Value)).ToString("#,0.00"); } dpData.Value = Convert.ToDateTime(dgvAcrescimos.Rows[linha].Cells[1].Value); cbConta.Text = dgvAcrescimos.Rows[linha].Cells[3].Value.ToString(); txtObs.Text = dgvAcrescimos.Rows[linha].Cells[4].Value.ToString(); bll.Excluir(id); CarregaDGVs(); }