public void update(FinanceiroType type) { MySqlConnection con = new MySqlConnection(Dados.StringConexao); string SQL = "UPDATE financeiro " + "SET id_associacao = @id_associacao, titulo = @titulo, valor = @valor, data = @data, tipo = @tipo " + "WHERE id_financeiro = @id_financeiro"; MySqlCommand cmd = new MySqlCommand(SQL, con); cmd.Parameters.AddWithValue("@id_financeiro", type.IdFinanceiro); cmd.Parameters.AddWithValue("@id_associacao", type.IdAssociacao); cmd.Parameters.AddWithValue("@titulo", type.Titulo); cmd.Parameters.AddWithValue("@valor", type.Valor); cmd.Parameters.AddWithValue("@data", type.Data); cmd.Parameters.AddWithValue("@tipo", type.Tipo); try { con.Open(); cmd.ExecuteNonQuery(); } finally { con.Close(); } }
protected void Page_Load(object sender, EventArgs e) { try { int id = Convert.ToInt32(Request.QueryString["id"]); FinanceiroBLL financBLL = new FinanceiroBLL(); FinanceiroType financ = financBLL.selectRecord(id); if (financ.IdFinanceiro != null && financ.IdFinanceiro > 0 && financ.IdAssociacao == Int32.Parse(Session["AssociacaoID"].ToString())) { financBLL.delete(financ); Session["FlashMsg"] = "Apagado com sucesso"; Session["FlashMsgType"] = "success"; } else { throw new Exception("Id invalido"); } } catch (Exception ex) { Session["FlashMsg"] = "Ocorreu um erro ao apagar"; Session["FlashMsgType"] = "danger"; } Response.Redirect("~/Painel/Financeiro.aspx"); }
public FinanceiroType execReader(MySqlDataReader dr) { FinanceiroType type = new FinanceiroType(); type.IdFinanceiro = Convert.ToInt32(dr["id_financeiro"].ToString()); type.IdAssociacao = Convert.ToInt32(dr["id_associacao"].ToString()); type.Titulo = dr["titulo"].ToString(); type.Valor = dr.GetDouble("valor"); type.Data = dr["data"].ToString(); type.Tipo = dr["tipo"].ToString(); return type; }
public FinanceiroType execReader(MySqlDataReader dr) { FinanceiroType type = new FinanceiroType(); type.IdFinanceiro = Convert.ToInt32(dr["id_financeiro"].ToString()); type.IdAssociacao = Convert.ToInt32(dr["id_associacao"].ToString()); type.Titulo = dr["titulo"].ToString(); type.Valor = dr.GetDouble("valor"); type.Data = dr["data"].ToString(); type.Tipo = dr["tipo"].ToString(); return(type); }
public void delete(FinanceiroType type) { MySqlConnection con = new MySqlConnection(Dados.StringConexao); string SQL = "DELETE FROM financeiro " + "WHERE id_financeiro = @id"; MySqlCommand cmd = new MySqlCommand(SQL, con); cmd.Parameters.AddWithValue("@id", type.IdFinanceiro); try { con.Open(); cmd.ExecuteNonQuery(); } finally { con.Close(); } }
protected void Page_Load(object sender, EventArgs e) { url_list = "~/Painel/Financeiro.aspx"; int id = Convert.ToInt32(Request.QueryString["id"]); financBLL = new FinanceiroBLL(); if (id > 0) { _TitlePage = "Editar"; financ = financBLL.selectRecord(id); if (financ.IdFinanceiro > 0 && Master.SessionAssociacaoId == financ.IdAssociacao) { if (!IsPostBack) { double newValor = financ.Valor; if (financ.Valor < 0) { newValor = financ.Valor * -1; } txtTitulo.Text = financ.Titulo; txtValor.Text = newValor.ToString(); txtData.Text = financ.DataFormatSql; RdoTipo.SelectedValue = financ.Tipo; } } else { Session["FlashMsg"] = "Id invalido"; Session["FlashMsgType"] = "danger"; Response.Redirect(url_list); } } else { _TitlePage = "Adicionar"; financ = new FinanceiroType(); } _TitlePage += " Receita ou Despesa"; this.Title = _TitlePage; this.DataBind(); }
public FinanceiroType selectRecord(int id) { MySqlConnection con = new MySqlConnection(Dados.StringConexao); string SQL = "SELECT * FROM financeiro " + "WHERE id_financeiro = @id"; MySqlCommand cmd = new MySqlCommand(SQL, con); cmd.Parameters.AddWithValue("@id", id); con.Open(); MySqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); FinanceiroType type = new FinanceiroType(); if (dr.Read()) { type = execReader(dr); } return(type); }
public int insert(FinanceiroType obj) { MySqlConnection con = new MySqlConnection(Dados.StringConexao); string SQL = "INSERT INTO financeiro " + "( " + "id_associacao," + "titulo," + "valor," + "data," + "tipo" + ") " + "VALUES" + "( " + "@id_associacao," + "@titulo," + "@valor," + "@data," + "@tipo" + ")"; MySqlCommand cmd = new MySqlCommand(SQL, con); cmd.Parameters.AddWithValue("@id_associacao", obj.IdAssociacao); cmd.Parameters.AddWithValue("@titulo", obj.Titulo); cmd.Parameters.AddWithValue("@valor", obj.Valor); cmd.Parameters.AddWithValue("@data", obj.Data); cmd.Parameters.AddWithValue("@tipo", obj.Tipo); con.Open(); int id = 0; try { cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT MAX(id_financeiro) " + "FROM financeiro"; id = Convert.ToInt32(cmd.ExecuteScalar()); } finally { con.Close(); } return(id); }
public int insert(FinanceiroType obj) { MySqlConnection con = new MySqlConnection(Dados.StringConexao); string SQL = "INSERT INTO financeiro " + "( " + "id_associacao," + "titulo," + "valor," + "data," + "tipo" + ") " + "VALUES" + "( " + "@id_associacao," + "@titulo," + "@valor," + "@data," + "@tipo" + ")"; MySqlCommand cmd = new MySqlCommand(SQL, con); cmd.Parameters.AddWithValue("@id_associacao", obj.IdAssociacao); cmd.Parameters.AddWithValue("@titulo", obj.Titulo); cmd.Parameters.AddWithValue("@valor", obj.Valor); cmd.Parameters.AddWithValue("@data", obj.Data); cmd.Parameters.AddWithValue("@tipo", obj.Tipo); con.Open(); int id = 0; try { cmd.ExecuteNonQuery(); cmd.CommandText = "SELECT MAX(id_financeiro) " + "FROM financeiro"; id = Convert.ToInt32(cmd.ExecuteScalar()); } finally { con.Close(); } return id; }
public void delete(FinanceiroType obj) { DAL.delete(obj); }
public void update(FinanceiroType obj) { DAL.update(obj); }
public int insert(FinanceiroType obj) { return(DAL.insert(obj)); }
public FinanceiroType selectRecord(int id) { MySqlConnection con = new MySqlConnection(Dados.StringConexao); string SQL = "SELECT * FROM financeiro " + "WHERE id_financeiro = @id"; MySqlCommand cmd = new MySqlCommand(SQL, con); cmd.Parameters.AddWithValue("@id", id); con.Open(); MySqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); FinanceiroType type = new FinanceiroType(); if (dr.Read()) { type = execReader(dr); } return type; }
public int insert(FinanceiroType obj) { return DAL.insert(obj); }