using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using SteamWare; public partial class mod_elFamMacch : ApplicationUserControl { public event EventHandler eh_selezioneValore; 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(); // i primi valori ("0") di default sono "ND"... li inserisco come standard... DS_applicazioneTableAdapters.AnagFamMacchineTableAdapter taFamMacc = new DS_applicazioneTableAdapters.AnagFamMacchineTableAdapter(); taFamMacc.Insert("-- [NUOVA] n.d. --"); grView.DataBind(); } protected void grView_SelectedIndexChanged(object sender, EventArgs e) { if (eh_selezioneValore != null) { eh_selezioneValore(this, new EventArgs()); } } /// /// restituisce il valore selezionato... se non selezionato restituisce -1 /// public int idxFamMacc_sel { get { int answ = -1; if (grView.SelectedIndex != -1) { answ = Convert.ToInt32(grView.SelectedValue); } return answ; } } protected void ods_Updated(object sender, ObjectDataSourceStatusEventArgs e) { grView.SelectedIndex = -1; grView.DataBind(); } /// /// determina se sia cancellabile /// /// /// public bool isDeletable(object idx) { bool answ=false; if (TA_app.obj.taMacc2Fam.getByFam(Convert.ToInt32(idx)).Rows.Count == 0) { answ = true; } return answ; } /// /// esegue update /// public void doUpdate() { grView.DataBind(); } }