d2070202c2
Ricompilazione generale git-svn-id: https://keyhammer.ath.cx/svn/XPS/trunk@91 43c8e981-f90d-406c-a89a-24a2c4268d51
444 lines
14 KiB
C#
444 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;
|
|
public partial class mod_ULP : ApplicationUserControl
|
|
{
|
|
#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 override void aggiornaControlliDataGL()
|
|
{
|
|
base.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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// resetta la selezione dei valori in caso di modifiche su altri controlli
|
|
/// </summary>
|
|
public void resetSelezione()
|
|
{
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
if (eh_resetSelezione != null)
|
|
{
|
|
eh_resetSelezione(this, new EventArgs());
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region gestione eventi
|
|
|
|
public event EventHandler eh_resetSelezione;
|
|
public event EventHandler eh_nuovoValore;
|
|
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>
|
|
/// inizializzazione valori di default
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
protected override void OnInit(EventArgs e)
|
|
{
|
|
base.OnInit(e);
|
|
_idxGridView = "CodRow";
|
|
}
|
|
|
|
protected override void bindControlli()
|
|
{
|
|
base.bindControlli();
|
|
}
|
|
|
|
/// <summary>
|
|
/// determino se il pulsante di conferma tutto schedulato sia visibile...
|
|
/// </summary>
|
|
public void setupControlli()
|
|
{
|
|
// calcolo se tutto l'albero cui appartiene la row madre abbia data di schedulazione...
|
|
bool allSched = false;
|
|
try
|
|
{
|
|
// carico codRow mamma...
|
|
string codComune = calcObjCommon();
|
|
DS_applicazioneTableAdapters.sp_contaNonSchedTableAdapter taContaNonSched = new DS_applicazioneTableAdapters.sp_contaNonSchedTableAdapter();
|
|
allSched = (taContaNonSched.GetData(codComune)[0].quanti == 0);
|
|
// controllo se loadAllCdC stato sia 2...
|
|
if (XPS.obj.taObj.getByIdxObj(memLayer.ML.StringSessionObj("CodRow_sel"))[0].CodStato != "02")
|
|
{
|
|
allSched = false;
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
pnlSetAllSched.Visible = allSched;
|
|
}
|
|
|
|
protected override void traduciObj()
|
|
{
|
|
base.traduciObj();
|
|
lblULP.Text = traduci("lblULP");
|
|
lblDataPrev.Text = traduci("updateObjDueDate");
|
|
txtDueDate.Text = DateTime.Now.AddDays(memLayer.ML.confReadint("defDayLeadTime")).ToString("dd/MM/yyyy");
|
|
btnCancel.Text = traduci("btnCancel");
|
|
btnOk.Text = traduci("btnOk");
|
|
btnAllSched.Text = traduci("btnAllSched");
|
|
}
|
|
|
|
|
|
/// <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 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":
|
|
DS_applicazioneTableAdapters.v_ULPTableAdapter taULP = new DS_applicazioneTableAdapters.v_ULPTableAdapter();
|
|
taULP.sp_clonaObj(_idxCiclo);
|
|
grView.EditIndex = -1;
|
|
grView.DataBind();
|
|
// blocco update!
|
|
e.Cancel = true;
|
|
// segnalo update...
|
|
if (eh_nuovoValore != null)
|
|
{
|
|
eh_nuovoValore(this, new EventArgs());
|
|
}
|
|
break;
|
|
default:
|
|
// faccio update!
|
|
break;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// righe aggiornate
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_RowUpdated(object sender, GridViewUpdatedEventArgs e)
|
|
{
|
|
// segnalo update...
|
|
if (eh_nuovoValore != null)
|
|
{
|
|
eh_nuovoValore(this, new EventArgs());
|
|
}
|
|
}
|
|
/// <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 true 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 = 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.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) && otherRemains(IdxObjMamma) && lastSister(IdxObjMamma, posizione));
|
|
}
|
|
/// <summary>
|
|
/// determina se l'utente possa editare o duplicare la riga
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool userCanEdit(object codStato)
|
|
{
|
|
return isAccettVisible(codStato);
|
|
}
|
|
/// <summary>
|
|
/// restituisce se sia visibile il controllo di edit x schedulare in blocco tutto (oggetto, righe, ULP...)
|
|
/// </summary>
|
|
/// <param name="codStato"></param>
|
|
/// <returns></returns>
|
|
public bool isSchedulaVisible(object codStato)
|
|
{
|
|
bool answ = true;
|
|
if (codStato.ToString().IndexOf("02") < 0) answ = false;
|
|
// controllo se sono su visualizzazione produzione...
|
|
if (memLayer.ML.StringSessionObj("returnPage").IndexOf("Prod") < 0) answ = false;
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// salvo in session che il prox comando è inserire scheduling x tutti... x non fare select...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void imgSchedula_Click(object sender, ImageClickEventArgs e)
|
|
{
|
|
SteamWare.memLayer.ML.setSessionVal("nextObjCommand", "schedulaObj");
|
|
}
|
|
/// <summary>
|
|
/// salvo in session che il prox comando è clonare...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void imgMostraLogStati_Click(object sender, ImageClickEventArgs 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 "schedulaObj": // non è vero select ma un show del log di cambio stato
|
|
pnlSetDueDate.Visible = true;
|
|
pnlLogStati.Visible = false;
|
|
break;
|
|
case "mostraLog": // non è vero select ma un show del log di cambio stato
|
|
pnlSetDueDate.Visible = false;
|
|
pnlLogStati.Visible = true;
|
|
mod_logStati1.idxObj = grView.SelectedValue.ToString();
|
|
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;
|
|
}
|
|
}
|
|
|
|
protected void btnOk_Click(object sender, EventArgs e)
|
|
{
|
|
// significa che mi chiedono di impostare la data a tutti i child...
|
|
DateTime dueDate = Convert.ToDateTime(txtDueDate.Text).AddHours(Convert.ToInt32(ddlOra.SelectedValue));
|
|
// salvo le date...
|
|
XPS.obj.taObj.updateDueDateULP(dueDate, user_std.UtSn.utente, DateTime.Now, grView.SelectedValue.ToString());
|
|
hidePanelDueDate();
|
|
}
|
|
|
|
protected void btnCancel_Click(object sender, EventArgs e)
|
|
{
|
|
pnlSetDueDate.Visible = false;
|
|
resetSelezione();
|
|
}
|
|
/// <summary>
|
|
/// incida come tutto schedulato il ddt...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAllSched_Click(object sender, EventArgs e)
|
|
{
|
|
string codObjCommon = calcObjCommon();
|
|
// aggiorno stato...
|
|
XPS.obj.taObj.UpdStatoTree("03", user_std.UtSn.utente, DateTime.Now, codObjCommon);
|
|
hidePanelDueDate();
|
|
}
|
|
/// <summary>
|
|
/// calcola il codice dell'obj mamma...
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private string calcObjCommon()
|
|
{
|
|
int posR = 8; // grView.SelectedValue.ToString().IndexOf("U");
|
|
string codObjCommon = memLayer.ML.StringSessionObj("CodRow_sel").Substring(0, posR) + "%";
|
|
return codObjCommon;
|
|
}
|
|
/// <summary>
|
|
/// nasconde il pannello della data di consegna
|
|
/// </summary>
|
|
private void hidePanelDueDate()
|
|
{
|
|
// nascondo i vari controlli...
|
|
pnlSetDueDate.Visible = false;
|
|
setupControlli();
|
|
resetSelezione();
|
|
if (eh_nuovoValore != null)
|
|
{
|
|
eh_nuovoValore(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
protected void grView_RowDeleted(object sender, GridViewDeletedEventArgs e)
|
|
{
|
|
if (eh_nuovoValore != null)
|
|
{
|
|
eh_nuovoValore(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
} |