protected void btnModSpesa_Click(object sender, EventArgs e) { bool isUpdated = SpeseDAO.UpdateSpesa(new Spese { IdSpesa = Convert.ToInt32(hidSpese.Value), Descrizione = txtSpeseDescr.Text, Prezzo = Convert.ToDecimal(txtSpesePrezzo.Text) }); if (isUpdated) { lblIsSpesaInserita.Text = "Spesa '" + txtSpeseDescr.Text + "' modificata con successo"; lblIsSpesaInserita.ForeColor = Color.Blue; } else { lblIsSpesaInserita.Text = "Errore durante la modifica della spesa '" + txtSpeseDescr.Text + "'"; lblIsSpesaInserita.ForeColor = Color.Red; } ResettaCampi(pnlInsSpese); BindGridSpese(); btnModSpesa.Visible = false; btnInsSpesa.Visible = true; }
protected void PopolaCampiSpesa(int idSpesa, bool isControlEnabled) { EnableDisableFields(pnlInsSpese, isControlEnabled); //Popolo i textbox Spese sp = SpeseDAO.GetDettagliSpesa(idSpesa.ToString()); txtSpeseDescr.Text = sp.Descrizione; txtSpesePrezzo.Text = sp.Prezzo.ToString("N2"); }
public IHttpActionResult GetAll([FromUri] string descrizione) { try { List <Spese> items = SpeseDAO.GetByDescription(descrizione); return(Ok(items)); } catch (Exception ex) { string messaggio = $"Errore durante la GetAll in SpeseController --- {ex}"; log.Error(messaggio); return(BadRequest(messaggio)); } }
protected void grdSpese_RowCommand(object sender, GridViewCommandEventArgs e) { int idSpesa = Convert.ToInt32(e.CommandArgument.ToString()); if (e.CommandName == "VisualSpesa") { lblTitoloInserimento.Text = "Visualizza Spesa"; lblIsSpesaInserita.Text = ""; btnInsSpesa.Visible = btnModSpesa.Visible = false; PopolaCampiSpesa(idSpesa, false); } else if (e.CommandName == "ModSpesa") { lblTitoloInserimento.Text = "Modifica Spesa"; lblIsSpesaInserita.Text = ""; btnModSpesa.Visible = true; btnInsSpesa.Visible = false; hidSpese.Value = idSpesa.ToString(); PopolaCampiSpesa(idSpesa, true); } else if (e.CommandName == "ElimSpesa") { bool isEliminato = SpeseDAO.DeleteSpesa(idSpesa); if (isEliminato) { lblIsSpesaInserita.Text = "Spesa eliminata con successo"; lblIsSpesaInserita.ForeColor = Color.Blue; } else { lblIsSpesaInserita.Text = "Errore durante l'eliminazione della spesa"; lblIsSpesaInserita.ForeColor = Color.Red; } BindGridSpese(); ResettaCampi(pnlInsSpese); btnModSpesa.Visible = false; btnInsSpesa.Visible = true; lblTitoloInserimento.Text = "Inserimento Spese"; } }
protected void btnInsSpesa_Click(object sender, EventArgs e) { if (txtSpeseDescr.Text != "") { if (txtSpesePrezzo.Text != "") { bool isInserito = SpeseDAO.InsertSpesa(new Spese { Descrizione = txtSpeseDescr.Text, Prezzo = Convert.ToDecimal(txtSpesePrezzo.Text) }); if (isInserito) { lblIsSpesaInserita.Text = "Spesa '" + txtSpeseDescr.Text + "' inserita con successo"; lblIsSpesaInserita.ForeColor = Color.Blue; } else { lblIsSpesaInserita.Text = "Errore durante l'inserimento della spesa '" + txtSpeseDescr.Text + "'"; lblIsSpesaInserita.ForeColor = Color.Red; } BindGridSpese(); ResettaCampi(pnlInsSpese); } else { lblIsSpesaInserita.Text = "È necessario inserire un valore nel campo \"Prezzo\""; lblIsSpesaInserita.ForeColor = Color.Red; } } else { lblIsSpesaInserita.Text = "Il campo 'Descrizione' deve essere compilato"; lblIsSpesaInserita.ForeColor = Color.Red; } }
private void BindGridSpese() { grdSpese.DataSource = SpeseDAO.GetByDescription(txtFiltroSpesaDescr.Text); grdSpese.DataBind(); }