Files
XPS/project/XPS_deploy/Source/mod_elencoComm.ascx.cs
T
samuele a953cbf7fd Update x logging/zipping/cancellazione
git-svn-id: https://keyhammer.ath.cx/svn/XPS/trunk@83 43c8e981-f90d-406c-a89a-24a2c4268d51
2008-11-13 16:06:13 +00:00

585 lines
20 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_elencoComm : 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();
}
#endregion
#region gestione eventi
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);
_idxGridView = "CodDDT";
mf_clienti.eh_selValore += new EventHandler(mf_clienti_eh_selValore);
mf_tipoFiltro.eh_selValore += new EventHandler(mf_tipoFiltro_eh_selValore);
}
/// <summary>
/// nascondo i pannelli accessori x sicurezza...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void mf_tipoFiltro_eh_selValore(object sender, EventArgs e)
{
pnlCambiaStato.Visible = false;
pnlLogStati.Visible = false;
pnlNew.Visible = false;
pnlSetDueDate.Visible = false;
}
/// <summary>
/// sistemo permessi utente e in cascata sistemo visualizzaizone filtri e controlli
/// </summary>
protected override void SetUpByUserRight()
{
base.SetUpByUserRight();
if (!Page.IsPostBack)
{
// imposto la pag corrente nel controllo di filtraggio...
lblPag.Text = _paginaCorrente;
mf_clienti.ods = odsFiltroClienti;
mf_tipoFiltro.ods = odsTipoFiltro;
fixControlliDaModoCorrente();
}
}
/// <summary>
/// imposta i controlli secondo il modo corrente...
/// </summary>
private void fixControlliDaModoCorrente()
{
// mostro nutton new SOLO se in stato magazzino/direzione...
if (currMode == modoXPS_Equa.magazzino || currMode == modoXPS_Equa.direzione)
{
btnShowNew.Visible = true;
}
else
{
btnShowNew.Visible = false;
}
}
void mf_clienti_eh_selValore(object sender, EventArgs e)
{
// controllo se filtro attivo...
if (mf_clienti.valore != "*")
{
ods.FilterExpression = string.Format("( Cliente LIKE '%{0}%' OR DDT LIKE '%{0}%' OR Descrizione LIKE '%{0}%' ) AND CodCliente = '{0}'", mf_clienti.valore);
}
else
{
ods.FilterExpression = " Cliente LIKE '%{0}%' OR DDT LIKE '%{0}%' OR Descrizione LIKE '%{0}%' ";
}
grView.DataBind();
}
protected override void traduciObj()
{
base.traduciObj();
btnShowNew.Text = traduci("btnShowNew");
btnNewComm.Text = traduci("btnNewComm");
lblCli.Text = traduci("lblCli");
lblNumDDT.Text = traduci("lblNumDDT");
lblDataDDT.Text = traduci("lblDataDDT");
lblDescr.Text = traduci("lblDescr");
lblCicloEqua.Text = traduci("lblCicloEqua");
lblDataPrev.Text = traduci("updateAllObjChild");
txtDueDate.Text = DateTime.Now.AddDays(memLayer.ML.confReadint("defDayLeadTime")).ToString("dd/MM/yyyy");
btnCancel.Text = traduci("btnCancel");
btnOk.Text = traduci("btnOk");
btnCancelStati.Text = traduci("btnCancel");
btnOkStati.Text = traduci("btnOk");
lblImpostaStato.Text = traduci("lblImpostaStato");
cbeOkDueDate.ConfirmText = traduci("confermaOkDueDate");
cbeOkStati.ConfirmText = traduci("confermaOkCambioStati");
}
/// <summary>
/// mostra/nasconde pannello nuovo
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnShowNew_Click(object sender, EventArgs e)
{
scambiaVisibPnlNew();
}
/// <summary>
/// scambio visibilità pnl
/// </summary>
private void scambiaVisibPnlNew()
{
// in base alla visibilità indico il testo corretto e seleziono o meno il filtro...
if (!pnlNew.Visible)
{
btnShowNew.Text = traduci("btnHideNew");
mf_cliNew.ods = odsFiltroClienti;
}
else
{
btnShowNew.Text = traduci("btnShowNew");
}
pnlNew.Visible = !pnlNew.Visible;
}
/// <summary>
/// creazione di un nuovo set...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNewComm_Click(object sender, EventArgs e)
{
DS_applicazioneTableAdapters.v_commesseTableAdapter taComm = new DS_applicazioneTableAdapters.v_commesseTableAdapter();
DS_applicazioneTableAdapters.sp_rec4DayTableAdapter taR4D = new DS_applicazioneTableAdapters.sp_rec4DayTableAdapter();
// calcolo la prima posizione libera della giornata...
int nextIdx = 1;
try
{
nextIdx = 1 + Convert.ToInt32(taR4D.sp_rec4Day(string.Format("{0:yyMMdd}", DateTime.Now, nextIdx)));
}
catch
{ }
// creazione di un nuovo set...
taComm.sp_creaSetObj(string.Format("{0:yyMMdd}{1:00}", DateTime.Now, nextIdx), "EQUA", mf_cliNew.valore, txtDDT.Text, Convert.ToDateTime(txtDataDDT.Text), ddlCiclo.SelectedValue, user_std.UtSn.utente, txtDescr.Text);
// nascondo tutto...
txtDDT.Text = "";
txtDataDDT.Text = "";
txtDescr.Text = "";
scambiaVisibPnlNew();
// aggiorno pannello...
grView.DataBind();
}
/// <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>
/// salvo in session che il prox comando è clonare...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void imgAccetta_Click(object sender, ImageClickEventArgs e)
{
SteamWare.memLayer.ML.setSessionVal("nextObjCommand", "accettaObj");
}
/// <summary>
/// salvo in session che il prox comando è registrare come fatturato...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void imgFattura_Click(object sender, ImageClickEventArgs e)
{
SteamWare.memLayer.ML.setSessionVal("nextObjCommand", "fatturaObj");
}
/// <summary>
/// in caso di aggiornamento verifico se sia salvato un comando accetta...
/// </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 idxObj = 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 (up/down level, clona o update normale
switch (_comando)
{
case "accettaObj":
// aggiorno lo stato dell'oggetto e dei child, x aggiornare prendo tutto quanto INIZIA come l'idx principale (meno il campo "D" quindi del DDT...)
XPS.obj.taObj.UpdStatoTree("02", user_std.UtSn.utente, DateTime.Now, idxObj.Replace("D", "%"));
grView.EditIndex = -1;
grView.DataBind();
// blocco update!
e.Cancel = true;
break;
case "fatturaObj":
// aggiorno lo stato dell'oggetto e dei child, x aggiornare prendo tutto quanto INIZIA come l'idx principale (meno il campo "D" quindi del DDT...)
XPS.obj.taObj.UpdStatoTree("07", user_std.UtSn.utente, DateTime.Now, idxObj.Replace("D", "%"));
grView.EditIndex = -1;
grView.DataBind();
// blocco update!
e.Cancel = true;
break;
default:
// annullo poi update...
e.Cancel = true;
break;
}
}
/// <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;
if (currMode != modoXPS_Equa.magazzino) answ = false;
return answ;
}
/// <summary>
/// restituisce se sia visibile il controllo di fatturazione...
/// </summary>
/// <param name="codStato"></param>
/// <returns></returns>
public bool isFatturaVisible(object codStato)
{
bool answ = true;
if (codStato.ToString().IndexOf("06") < 0) answ = false;
if (currMode != modoXPS_Equa.segreteria) answ = false;
return answ;
}
/// <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 (currMode != modoXPS_Equa.produzione) answ = false;
return answ;
}
/// <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 isSetStatoVisible(object codStato)
{
bool answ = true;
// controllo se sono su visualizzazione produzione...
if (currMode != modoXPS_Equa.direzione) answ = false;
return answ;
}
/// <summary>
/// definisce se sia visibile il semaforo di stato spedizione
/// </summary>
/// <param name="codStato"></param>
/// <returns></returns>
public bool isSemaforoVisibile(object minCodStato, object maxCodStato)
{
bool answ = false;
if ((Convert.ToInt32(maxCodStato) > 4) && (Convert.ToInt32(minCodStato) < 6)) answ = true; // se il max è superiore a 4 qualcosa è spedibile... o spedito, ergo mostro semaforo...
return answ;
}
/// <summary>
/// restituisce path all'immagine corretta x il semaforo di "spedibilità" dato lo stato:
/// ROSSO: niente pronto
/// VERDE: tutto spedito
/// GIALLO: qualcosa di pronto (o anche spedito) e qualcosa no...
/// </summary>
/// <param name="minCodStato"></param>
/// <param name="maxCodStato"></param>
/// <returns></returns>
public string immagineDaStato(object minCodStato, object maxCodStato)
{
string answ = imgPath(SteamWare.tipoImg.semaforoGiallo, SteamWare.dimImg.medium, tipoFileImg.gif);
int codMin = Convert.ToInt32(minCodStato);
int codMax = Convert.ToInt32(maxCodStato);
// in base ai 2 valori relativi decido semafori...
if (codMax < 5) answ = imgPath(SteamWare.tipoImg.semaforoRosso, SteamWare.dimImg.medium, tipoFileImg.gif);
if (codMin > 4) answ = imgPath(SteamWare.tipoImg.semaforoVerde, SteamWare.dimImg.medium, tipoFileImg.gif);
return answ;
}
/// <summary>
/// restituisce tooltip spiegazione stato
/// </summary>
/// <param name="minCodStato"></param>
/// <param name="maxCodStato"></param>
/// <returns></returns>
public string toolTipDaStato(object minCodStato, object maxCodStato)
{
string answ = traduci("commParzProntaSpedire");
int codMin = Convert.ToInt32(minCodStato);
int codMax = Convert.ToInt32(maxCodStato);
// in base ai 2 valori relativi decido semafori...
if (codMax < 5) answ = traduci("commNonProntaSpedire");
if (codMin > 4) answ = traduci("commProntaSpedire");
return answ;
}
/// <summary>
/// determina se l'utente possa cancellare, x ora sempre si...
/// </summary>
/// <returns></returns>
public bool userCanDel(object codStato)
{
return isAccettVisible(codStato);
}
protected override void OnUnload(EventArgs e)
{
base.OnUnload(e);
mf_clienti.eh_selValore -= new EventHandler(mf_clienti_eh_selValore);
}
/// <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;
}
}
/// <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>
/// 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 imgSchedulaTutto_Click(object sender, ImageClickEventArgs e)
{
SteamWare.memLayer.ML.setSessionVal("nextObjCommand", "schedulaTutto");
}
/// <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 imgSetStato_Click(object sender, ImageClickEventArgs e)
{
SteamWare.memLayer.ML.setSessionVal("nextObjCommand", "cambiaStato");
}
/// <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 "schedulaTutto": // non è vero select ma un edit della data/ora di consegna...
pnlSetDueDate.Visible = true;
pnlCambiaStato.Visible = false;
pnlLogStati.Visible = false;
break;
case "cambiaStato": // non è vero select ma un edit dello stato...
pnlCambiaStato.Visible = true;
pnlSetDueDate.Visible = false;
pnlLogStati.Visible = false;
break;
case "mostraLog": // non è vero select ma un show del log di cambio stato
pnlLogStati.Visible = true;
pnlSetDueDate.Visible = false;
pnlCambiaStato.Visible = false;
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));
string codObjCommon = grView.SelectedValue.ToString().Replace("D", "%");
// salvo le date...
XPS.obj.taObj.updateDueDateULP(dueDate, user_std.UtSn.utente, DateTime.Now, codObjCommon);
// aggiorno stato...
XPS.obj.taObj.UpdStatoTree("03", user_std.UtSn.utente, DateTime.Now, codObjCommon);
hidePanelDueDate();
}
protected void btnCancel_Click(object sender, EventArgs e)
{
hidePanelDueDate();
}
protected void btnOkStati_Click(object sender, EventArgs e)
{
string codObjCommon = grView.SelectedValue.ToString().Replace("D", "%");
// aggiorno stato...
XPS.obj.taObj.UpdStatoTree(ddlStato2Set.SelectedValue, user_std.UtSn.utente, DateTime.Now, codObjCommon);
hidePanelStati();
}
protected void btnCancelStati_Click(object sender, EventArgs e)
{
hidePanelStati();
}
/// <summary>
/// nasconde il pannello della modifica stato DDT
/// </summary>
private void hidePanelDueDate()
{
// nascondo i vari controlli...
pnlSetDueDate.Visible = false;
resetSelezione();
}
/// <summary>
/// nasconde il pannello della modifica stato DDT
/// </summary>
private void hidePanelStati()
{
// nascondo i vari controlli...
pnlCambiaStato.Visible = false;
resetSelezione();
}
#endregion
}