using SteamWare; using System; using System.Web.UI.WebControls; public partial class mod_interventoOpMtz : ApplicationUserControl { public event EventHandler eh_resetSelezione; /// /// evento dati associati a controllo /// /// /// protected void grView_DataBound(object sender, EventArgs e) { if (grView.Rows.Count > 0) { LinkButton lb; // aggiorno gli headers foreach (TableCell cella in grView.HeaderRow.Cells) { try { lb = (LinkButton)cella.Controls[0]; lb.Text = traduci(lb.Text); } catch { } } int totRecord = grView.Rows.Count + grView.PageSize * (grView.PageCount - 1); lblNumRec.Text = string.Format("{0} records of ~ {1}", grView.Rows.Count, totRecord); } else { lblNumRec.Text = ""; } } /// /// reset delle selezioni /// /// /// protected void btnReset_Click(object sender, EventArgs e) { resetSelezione(); } /// /// resetta la selezione dei valori in caso di modifiche su altri controlli /// public void resetSelezione() { grView.SelectedIndex = -1; grView.DataBind(); if (eh_resetSelezione != null) { eh_resetSelezione(this, new EventArgs()); } } /// /// seleziono valore in editing... /// /// /// protected void grView_RowEditing(object sender, GridViewEditEventArgs e) { // seleziono la riga corrente... grView.SelectedIndex = e.NewEditIndex; } /// /// gestione evento inserimento nuovo record standard (se ZERO presenti) /// /// /// protected void btnNewFromEmpty_Click(object sender, EventArgs e) { // reset selezione... resetSelezione(); int numIntMtz = memLayer.ML.IntSessionObj("numIntMtz_sel"); string matr = memLayer.ML.confReadString("defaultMatr"); TA_app.obj.taIntOpMtz.Insert(numIntMtz, matr, 0); grView.DataBind(); } /// /// restituisce un booleano se sia abilitato inserimento nuovi valori (solo se NON C'E' GIA' un operatore con amtricola di default...) /// /// public bool canInsertNew() { bool answ = false; int numIntMtz = memLayer.ML.IntSessionObj("numIntMtz_sel"); string matr = memLayer.ML.confReadString("defaultMatr"); try { answ = (TA_app.obj.taIntOpMtz.getByMatrNumIntMtz(numIntMtz, matr).Rows.Count == 0); } catch { } return (answ && isOnEdit); } /// /// restituisce true se il controllo è in modalità editing (e non selezione...) /// public bool isOnEdit { get { return _vistaModulo == tipoVistaMod.editing; } } /// /// traduce matricola in matr + cognome + nome /// /// /// public string traduciMatrOp(object matr) { string answ = ""; try { answ = TA_app.obj.taSelMatrOp.getByValue(matr.ToString())[0].label; } catch { } return answ; } }