269 lines
9.1 KiB
C#
269 lines
9.1 KiB
C#
using MapoDb;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Data;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace MoonProAdmin.WebUserControls
|
|
{
|
|
public partial class mod_anagArticoli : System.Web.UI.UserControl
|
|
{
|
|
|
|
#region area da NON modificare
|
|
|
|
#region area protected
|
|
|
|
protected string _idxGridView;
|
|
|
|
/// <summary>
|
|
/// reset della selezione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnReset_Click(object sender, EventArgs e)
|
|
{
|
|
resetSelezione();
|
|
}
|
|
/// <summary>
|
|
/// gestione cambio selezione valore
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
// salvo in session il valore selezionato...
|
|
SteamWare.memLayer.ML.setSessionVal(string.Format("{0}_sel", _idxGridView), grView.SelectedValue, false);
|
|
// sollevo evento nuovo valore...
|
|
if (eh_selValore != null)
|
|
{
|
|
eh_selValore(this, new EventArgs());
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// traduce gli header delle colonne
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
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 = "";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// recupera i dati di un nuovo record contenuti nel footer di un gridView;
|
|
/// questi devono esses opportunamente nominati (es: txt{0}, dl{0}, ...)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void recuperaFooter(object sender, ObjectDataSourceMethodEventArgs e)
|
|
{
|
|
//recupero la riga footer...
|
|
DataColumnCollection colonne = colonneObj();
|
|
string nomeCol;
|
|
string tipoColonna = "";
|
|
foreach (DataColumn colonna in colonne)
|
|
{
|
|
nomeCol = colonna.ColumnName;
|
|
// cerco un textbox o quello che sia...
|
|
if (grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol)) != null)
|
|
{
|
|
tipoColonna = "textBox";
|
|
}
|
|
else if (grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol)) != null)
|
|
{
|
|
tipoColonna = "dropDownList";
|
|
}
|
|
else if (grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol)) != null)
|
|
{
|
|
tipoColonna = "checkBox";
|
|
}
|
|
else if (grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol)) != null)
|
|
{
|
|
tipoColonna = "selAjax";
|
|
}
|
|
// in base al tipo salvo negli inputparameters dell'ODS
|
|
switch (tipoColonna)
|
|
{
|
|
case "textBox":
|
|
e.InputParameters[nomeCol] = ((TextBox)grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol))).Text;
|
|
break;
|
|
case "dropDownList":
|
|
e.InputParameters[nomeCol] = ((DropDownList)grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol))).SelectedValue;
|
|
break;
|
|
case "checkBox":
|
|
e.InputParameters[nomeCol] = ((CheckBox)grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol))).Checked;
|
|
break;
|
|
//case "selAjax":
|
|
// e.InputParameters[nomeCol] = ((mod_selettore_ajax)grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol))).valore;
|
|
// break;
|
|
default:
|
|
break;
|
|
}
|
|
tipoColonna = "";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// svuoto da cache post update
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ods_Updated(object sender, ObjectDataSourceStatusEventArgs e)
|
|
{
|
|
// evento come nuovo...
|
|
if (eh_nuovoValore != null)
|
|
{
|
|
eh_nuovoValore(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region are public
|
|
|
|
/// <summary>
|
|
/// effettua traduzione del lemma
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(string lemma)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma);
|
|
}
|
|
/// <summary>
|
|
/// effettua traduzione in inglese del lemma
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduciEn(string lemma)
|
|
{
|
|
return user_std.UtSn.TraduciEn(lemma);
|
|
}
|
|
/// <summary>
|
|
/// resetta la selezione dei valori in caso di modifiche su altri controlli
|
|
/// </summary>
|
|
public void resetSelezione()
|
|
{
|
|
SteamWare.memLayer.ML.emptySessionVal(string.Format("{0}_sel", _idxGridView));
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
lblWarning.Visible = false;
|
|
if (eh_resetSelezione != null)
|
|
{
|
|
eh_resetSelezione(this, new EventArgs());
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region gestione eventi
|
|
|
|
public event EventHandler eh_resetSelezione;
|
|
public event EventHandler eh_nuovoValore;
|
|
public event EventHandler eh_selValore;
|
|
|
|
#endregion
|
|
|
|
#region area da modificare
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
}
|
|
|
|
/// inizializzazione valori di default
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
protected override void OnInit(EventArgs e)
|
|
{
|
|
base.OnInit(e);
|
|
_idxGridView = "IdxMacchina";
|
|
}
|
|
/// <summary>
|
|
/// nuovo valore creato...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void mod_newOdl1_eh_nuovoValore(object sender, EventArgs e)
|
|
{
|
|
// aggiorno!
|
|
resetSelezione();
|
|
}
|
|
|
|
/// <summary>
|
|
/// elenco colonne del datagrid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected DataColumnCollection colonneObj()
|
|
{
|
|
MapoDb.DS_ProdTempi.DatiMacchineDataTable tabella = new MapoDb.DS_ProdTempi.DatiMacchineDataTable();
|
|
DataColumnCollection colonne = tabella.Columns;
|
|
return colonne;
|
|
}
|
|
public bool delEnabled(object _idx)
|
|
{
|
|
bool answ = false;
|
|
string codArticolo = _idx.ToString();
|
|
// controllo non sia stato mai prodotto sennò non posso cancellare...
|
|
try
|
|
{
|
|
bool? usato = false;
|
|
MapoDb.DataLayer.obj.taAnagArt.checkUsed(codArticolo, ref usato);
|
|
answ = !(bool)usato;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// definisce scrivibilità/editabilità del controllo
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool isWritable()
|
|
{
|
|
return true;
|
|
}
|
|
/// <summary>
|
|
/// crea un nuovo record e ricarica...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
string tempCode = string.Format("_{0:yyyyMMdd-HHmmss}", DateTime.Now);
|
|
string tempName = string.Format("Nuovo articolo creato {0:dd/MM/yyyy HH:mm:ss}", DateTime.Now);
|
|
DataLayer.obj.taAnagArt.Insert(tempCode, tempName,"", "");
|
|
// reset!
|
|
resetSelezione();
|
|
}
|
|
|
|
#endregion
|
|
|
|
protected void ods_Updating(object sender, ObjectDataSourceMethodEventArgs e)
|
|
{
|
|
// verifico eventuali nulli --> ""
|
|
if (e.InputParameters["DescArticolo"] == null) e.InputParameters["DescArticolo"] = "";
|
|
if (e.InputParameters["CurrRev"] == null) e.InputParameters["CurrRev"] = "";
|
|
}
|
|
}
|
|
} |