424 lines
14 KiB
C#
424 lines
14 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Configuration;
|
|
using System.Collections;
|
|
using System.Web;
|
|
using System.Web.Security;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Web.UI.WebControls.WebParts;
|
|
using System.Web.UI.HtmlControls;
|
|
using SteamWare;
|
|
using XPS_data;
|
|
|
|
namespace XPS.WebUserControls
|
|
{
|
|
public partial class mod_dettComm : SteamWare.UserControl
|
|
{
|
|
#region area da NON modificare
|
|
|
|
#region area protected
|
|
|
|
protected string _idxGridView;
|
|
protected bool _showNewBtn = true;
|
|
|
|
/// <summary>
|
|
/// aggiorna controlli datagrid e numero righe in pagina
|
|
/// </summary>
|
|
protected void aggiornaControlliDataGL()
|
|
{
|
|
grView.PageSize = righeDataGridMed;
|
|
}
|
|
/// <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>
|
|
/// reset della selezione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnReset_Click(object sender, EventArgs e)
|
|
{
|
|
resetSelezione();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region gestione eventi
|
|
|
|
public event EventHandler eh_resetSelezione;
|
|
public event EventHandler eh_selValore;
|
|
|
|
#endregion
|
|
|
|
#region public
|
|
|
|
/// <summary>
|
|
/// definisce visibilità btnNew
|
|
/// </summary>
|
|
public bool showNewBtn
|
|
{
|
|
get
|
|
{
|
|
return _showNewBtn;
|
|
}
|
|
set
|
|
{
|
|
_showNewBtn = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// effettua update del modulo
|
|
/// </summary>
|
|
public void doUpdate()
|
|
{
|
|
resetSelezione();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region area codice variabile
|
|
|
|
/// <summary>
|
|
/// elenco colonne del datagrid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected DataColumnCollection colonneObj()
|
|
{
|
|
DS_applicazione.v_commesseDataTable tabella = new DS_applicazione.v_commesseDataTable();
|
|
DataColumnCollection colonne = tabella.Columns;
|
|
return colonne;
|
|
}
|
|
/// <summary>
|
|
/// modo d'uso PRIVATE del controllo tra i vari magazzino/segreteria/produzione/direzione
|
|
/// </summary>
|
|
protected modoXPS_Equa _currMode = modoXPS_Equa.segreteria;
|
|
/// <summary>
|
|
/// inizializzazione valori di default
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
protected override void OnInit(EventArgs e)
|
|
{
|
|
base.OnInit(e);
|
|
traduciObj();
|
|
aggiornaControlliDataGL();
|
|
_idxGridView = "CodRow";
|
|
updateNavBar();
|
|
mod_logStati1.eh_reset += new EventHandler(mod_logStati1_eh_reset);
|
|
}
|
|
/// <summary>
|
|
/// reset visibilità log stati
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void mod_logStati1_eh_reset(object sender, EventArgs e)
|
|
{
|
|
pnlLogStati.Visible = false;
|
|
showDetailPnl(false);
|
|
// resetto grView
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
}
|
|
/// <summary>
|
|
/// Imposta classi css x mostrare o meno panel dettaglio
|
|
/// </summary>
|
|
/// <param name="doShow"></param>
|
|
private void showDetailPnl(bool doShow)
|
|
{
|
|
divMain.Attributes.Remove("class");
|
|
divDet.Attributes.Remove("class");
|
|
if (doShow)
|
|
{
|
|
divMain.Attributes.Add("class", "col-sm-10");
|
|
divDet.Attributes.Add("class", "col-sm-2");
|
|
}
|
|
else
|
|
{
|
|
divMain.Attributes.Add("class", "col-sm-12");
|
|
divDet.Attributes.Add("class", "col-sm-0");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// aggiorno navbar
|
|
/// </summary>
|
|
protected void updateNavBar()
|
|
{
|
|
mod_navPath1.valore = memLayer.ML.QSS("CodDDT");
|
|
mod_navPath1.tooltip = traduci("go2commesse");
|
|
// traduco...
|
|
mod_navPath1.linkText = traduci("ElencoComm");
|
|
mod_navPath1.linkURL = memLayer.ML.StringSessionObj("returnPage");
|
|
}
|
|
|
|
protected void traduciObj()
|
|
{
|
|
lblRowsDDT.Text = traduci("lblRowsDDT");
|
|
}
|
|
|
|
/// <summary>
|
|
/// mostra/nasconde pannello nuovo
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnShowNew_Click(object sender, EventArgs e)
|
|
{
|
|
scambiaVisibPnlNew();
|
|
}
|
|
|
|
private void scambiaVisibPnlNew()
|
|
{
|
|
// in base alla visibilità indico il testo corretto e seleziono o meno il filtro...
|
|
#if false
|
|
if (!pnlNew.Visible)
|
|
{
|
|
btnShowNew.Text = traduci("btnHideNew");
|
|
mf_cliNew.ods = odsFiltroClienti;
|
|
}
|
|
else
|
|
{
|
|
btnShowNew.Text = traduci("btnShowNew");
|
|
}
|
|
pnlNew.Visible = !pnlNew.Visible;
|
|
#endif
|
|
}
|
|
/// <summary>
|
|
/// creazione di un nuovo set...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNewComm_Click(object sender, EventArgs e)
|
|
{
|
|
#if false
|
|
// creazione di un nuovo set...
|
|
DS_applicazioneTableAdapters.v_commesseTableAdapter taComm = new DS_applicazioneTableAdapters.v_commesseTableAdapter();
|
|
taComm.sp_creaSetObj(DateTime.Now.ToString("yyyyMMdd_hhmmss"), "EQUA", mf_cliNew.valore, txtDDT.Text, txtNome.Text, user_std.UtSn.utente, txtDescr.Text);
|
|
// nascondo tutto...
|
|
txtNome.Text = "";
|
|
scambiaVisibPnlNew();
|
|
// aggiorno pannello...
|
|
grView.DataBind();
|
|
#endif
|
|
}
|
|
|
|
/// <summary>
|
|
/// inserisce nuovo valore da footer
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lblIns_click(object sender, EventArgs e)
|
|
{
|
|
// click su inserimento, chiamo il metodo insert dell'ObjectDataSource
|
|
ods.Insert();
|
|
}
|
|
/// <summary>
|
|
/// gestione evento richiesta nuovo valore (mostra footer, ...)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
// reset selezione...
|
|
resetSelezione();
|
|
// mostro il footer oppure la riga dei dettagli x nuovo...
|
|
if (grView.FooterRow != null)
|
|
{
|
|
grView.FooterRow.Visible = true;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// salvo in session che il prox comando è clonare...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbMostraLogStati_Click(object sender, EventArgs e)
|
|
{
|
|
SteamWare.memLayer.ML.setSessionVal("nextObjCommand", "mostraLog");
|
|
}
|
|
|
|
/// <summary>
|
|
/// gestione cambio selezione valore
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
string _comando = "";
|
|
if (SteamWare.memLayer.ML.isInSessionObject("nextObjCommand"))
|
|
{
|
|
_comando = SteamWare.memLayer.ML.StringSessionObj("nextObjCommand");
|
|
SteamWare.memLayer.ML.emptySessionVal("nextObjCommand");
|
|
}
|
|
switch (_comando)
|
|
{
|
|
case "mostraLog": // non è vero select ma un show del log di cambio stato
|
|
pnlLogStati.Visible = true;
|
|
mod_logStati1.idxObj = grView.SelectedValue.ToString();
|
|
showDetailPnl(true);
|
|
break;
|
|
default: // è select...
|
|
// salvo in session il valore selezionato...
|
|
SteamWare.memLayer.ML.setSessionVal(string.Format("{0}_sel", _idxGridView), grView.SelectedValue.ToString(), true);
|
|
// sollevo evento nuovo valore...
|
|
if (eh_selValore != null)
|
|
{
|
|
eh_selValore(this, new EventArgs());
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// salvo in session che il prox comando è clonare...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void imgClonaRow_Click(object sender, ImageClickEventArgs e)
|
|
{
|
|
SteamWare.memLayer.ML.setSessionVal("nextObjCommand", "clonaRow");
|
|
}
|
|
/// <summary>
|
|
/// in caso di aggiornamento verifico se sia salvato un comando clona...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_RowUpdating(object sender, GridViewUpdateEventArgs e)
|
|
{
|
|
// quale comando?
|
|
// carico l'idx dell'oggetto
|
|
string _idxCiclo = e.Keys["Cod"].ToString();
|
|
string _comando = "";
|
|
if (SteamWare.memLayer.ML.isInSessionObject("nextObjCommand"))
|
|
{
|
|
_comando = SteamWare.memLayer.ML.StringSessionObj("nextObjCommand");
|
|
SteamWare.memLayer.ML.emptySessionVal("nextObjCommand");
|
|
}
|
|
// verifico il tipo di richiesta (clona o update normale)
|
|
switch (_comando)
|
|
{
|
|
case "clonaRow":
|
|
XPS_data.DS_applicazioneTableAdapters.v_righeTableAdapter taRiga = new XPS_data.DS_applicazioneTableAdapters.v_righeTableAdapter();
|
|
taRiga.sp_clonaRowObj(_idxCiclo);
|
|
grView.EditIndex = -1;
|
|
grView.DataBind();
|
|
// blocco update!
|
|
e.Cancel = true;
|
|
break;
|
|
default:
|
|
// faccio update!
|
|
break;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// effettua update del modulo
|
|
/// </summary>
|
|
public void doUpdateNoReset()
|
|
{
|
|
grView.DataBind();
|
|
}
|
|
/// <summary>
|
|
/// restituisce se sia visibile il controllo di accettazione...
|
|
/// </summary>
|
|
/// <param name="codStato"></param>
|
|
/// <returns></returns>
|
|
public bool isAccettVisible(object codStato)
|
|
{
|
|
bool answ = true;
|
|
if (codStato.ToString().IndexOf("01") < 0) answ = false;
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// restituisce se rimangano altri valori a pari idxObjMamma - ovvero non sto cancellando l'ultima riga... che è vietato...
|
|
/// </summary>
|
|
/// <param name="codStato"></param>
|
|
/// <returns></returns>
|
|
public bool otherRemains(object IdxObjMamma)
|
|
{
|
|
bool answ = false;
|
|
int sisters = Convert.ToInt32(XPS_data.XPS.obj.taObj.countSisters(IdxObjMamma.ToString()));
|
|
if (sisters > 1) answ = true;
|
|
return answ;
|
|
}/// <summary>
|
|
/// restituisce true se sia l'ultimo oggetto del suo tipo (max posizione x codice mamma...)
|
|
/// </summary>
|
|
/// <param name="codStato"></param>
|
|
/// <returns></returns>
|
|
public bool lastSister(object IdxObjMamma, object posizione)
|
|
{
|
|
bool answ = false;
|
|
string maxPos = XPS_data.XPS.obj.taObj.lastSister(IdxObjMamma.ToString()).ToString();
|
|
if (Convert.ToInt32(maxPos) == Convert.ToInt32(posizione)) answ = true;
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// determina se l'utente possa cancellare
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool userCanDel(object codStato, object IdxObjMamma, object posizione)
|
|
{
|
|
return (isAccettVisible(codStato) && lastSister(IdxObjMamma, posizione));
|
|
//return (isAccettVisible(codStato) && otherRemains(IdxObjMamma) && lastSister(IdxObjMamma, posizione));
|
|
}
|
|
/// <summary>
|
|
/// imposta il modo d'uso del controllo tra i vari magazzino/segreteria/produzione/direzione
|
|
/// </summary>
|
|
public modoXPS_Equa currMode
|
|
{
|
|
get
|
|
{
|
|
return _currMode;
|
|
}
|
|
set
|
|
{
|
|
_currMode = value;
|
|
}
|
|
}
|
|
|
|
protected void ods_Deleted(object sender, ObjectDataSourceStatusEventArgs e)
|
|
{
|
|
resetSelezione();
|
|
}
|
|
/// <summary>
|
|
/// resetta la selezione dei valori in caso di modifiche su altri controlli
|
|
/// </summary>
|
|
public void resetSelezione()
|
|
{
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
pnlLogStati.Visible = false;
|
|
if (eh_resetSelezione != null)
|
|
{
|
|
eh_resetSelezione(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |