84357746b4
fix quotation buttons non subito visibili/aggiornati
574 lines
21 KiB
C#
574 lines
21 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using C2P_Data;
|
|
using SteamWare;
|
|
|
|
namespace C2P.WebUserControls
|
|
{
|
|
public partial class mod_QuoteDet : SteamWare.UserControl
|
|
{
|
|
/// <summary>
|
|
/// stringa UID univoca
|
|
/// </summary>
|
|
public string uid
|
|
{
|
|
get
|
|
{
|
|
return this.UniqueID.Replace("$", "_").Replace("-", "_");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// tipo di quote x la scheda corrente
|
|
/// </summary>
|
|
protected string QuoteType
|
|
{
|
|
get
|
|
{
|
|
return lblQuoteType.Text;
|
|
}
|
|
set
|
|
{
|
|
lblQuoteType.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// codice quote x la scheda corrente
|
|
/// </summary>
|
|
protected string CodQuote
|
|
{
|
|
get
|
|
{
|
|
return lblCodQuote.Text;
|
|
}
|
|
set
|
|
{
|
|
lblCodQuote.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// rev quote x la scheda corrente
|
|
/// </summary>
|
|
protected string QuoteRev
|
|
{
|
|
get
|
|
{
|
|
return lblQuoteRev.Text;
|
|
}
|
|
set
|
|
{
|
|
lblQuoteRev.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// STATO x la scheda corrente
|
|
/// </summary>
|
|
protected string Status
|
|
{
|
|
get
|
|
{
|
|
return lblStatus.Text;
|
|
}
|
|
set
|
|
{
|
|
lblStatus.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// IDX STATO x la scheda corrente (hidden)
|
|
/// </summary>
|
|
protected string IdxQState
|
|
{
|
|
get
|
|
{
|
|
return lblIdxQState.Text;
|
|
}
|
|
set
|
|
{
|
|
lblIdxQState.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// RISULTATO OFFERTA x la scheda corrente (hidden)
|
|
/// </summary>
|
|
protected string OfferResult
|
|
{
|
|
get
|
|
{
|
|
return lblOffRes.Text;
|
|
}
|
|
set
|
|
{
|
|
lblOffRes.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// precedente valore richiesto...
|
|
/// </summary>
|
|
protected string prevReq
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("prevReq_" + uid);
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("prevReq_" + uid, value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// indica se sia attivo in modalità editing qualche modulo
|
|
/// </summary>
|
|
protected bool editActive
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.BoolSessionObj("editActive_" + uid);
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("editActive_" + uid, value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// procedura caricamento apgina...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
// recupero valori della chaive della quote da URL...
|
|
if (!Page.IsPostBack)
|
|
{
|
|
updateBaseData();
|
|
hlRevHist.NavigateUrl = string.Format("~/RevisionHistory?QuoteType={0}&CodQuote={1}", QuoteType, CodQuote);
|
|
hlRevHist.ToolTip = traduci("RevisionHistory");
|
|
hlGetPdf.NavigateUrl = string.Format("~/RepOffers?ticket=0&QuoteType={0}&CodQuote={1}&QuoteRev={2}", QuoteType, CodQuote, QuoteRev);
|
|
hlRevHist.ToolTip = traduci("RevisionHistory");
|
|
prevReq = "";
|
|
editActive = false;
|
|
setModVisibility("Header");
|
|
setBtnVisibility();
|
|
}
|
|
mod_Q_Header1.eh_update += mod_Q_Header1_eh_update;
|
|
mod_Q_Quot1.eh_update += mod_Q_Quot1_eh_update;
|
|
mod_Q_Costs1.eh_update += mod_Q_Costs1_eh_update;
|
|
// fix visibilità costi x user base...
|
|
lbCosts.Visible = userIsSuper;
|
|
}
|
|
/// <summary>
|
|
/// stato scheda attuale
|
|
/// </summary>
|
|
protected int IdxQS
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.IntSessionObj(string.Format("idxQS_{0}", uid));
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal(string.Format("idxQS_{0}", uid), value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// update costo offerto
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void mod_Q_Costs1_eh_update(object sender, EventArgs e)
|
|
{
|
|
updateBaseData();
|
|
setModVisibility("");
|
|
setBtnVisibility();
|
|
}
|
|
/// <summary>
|
|
/// aggiorna info base dell'offerta
|
|
/// </summary>
|
|
private void updateBaseData()
|
|
{
|
|
// leggo da url e salvo (se ci sono...)
|
|
QuoteType = Request.QueryString["QuoteType"];
|
|
CodQuote = Request.QueryString["CodQuote"];
|
|
QuoteRev = Request.QueryString["QuoteRev"];
|
|
// carico stato offerta...
|
|
IdxQS = 0;
|
|
string CodItem = "";
|
|
try
|
|
{
|
|
IdxQS = DtProxy.man.taQFQ.getByKey(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev), "N")[0].IdxQState;
|
|
CodItem = DtProxy.man.taQFQ.getByKey(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev), "N")[0].CodItem;
|
|
OfferResult = DtProxy.man.taQFQ.getByKey(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev), "N")[0].OfferResult;
|
|
}
|
|
catch
|
|
{ }
|
|
IdxQState = IdxQS.ToString();
|
|
Status = traduci(string.Format("IdxQState-{0:D2}", IdxQS));
|
|
setBtnVisibility();
|
|
mod_Q_Quot1.doUpdate();
|
|
//2015.05.26 update altri moduli!
|
|
mod_Q_Costs1.doUpdate();
|
|
mod_Q_ExtrPar1.doUpdate();
|
|
mod_Q_PackPar1.doUpdate();
|
|
// fix articolo x visualizzazione...
|
|
mod_imgPreview.CodItem = CodItem;
|
|
}
|
|
/// <summary>
|
|
/// richiesto update x cambiamento valori header
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void mod_Q_Quot1_eh_update(object sender, EventArgs e)
|
|
{
|
|
updateBaseData();
|
|
setModVisibility("");
|
|
setBtnVisibility();
|
|
}
|
|
/// <summary>
|
|
/// richiesto update x cambiamento valori costs
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void mod_Q_Header1_eh_update(object sender, EventArgs e)
|
|
{
|
|
updateBaseData();
|
|
setModVisibility("");
|
|
setBtnVisibility();
|
|
}
|
|
/// <summary>
|
|
/// premuto uno dei buttons dell'header
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbt_Click(object sender, EventArgs e)
|
|
{
|
|
LinkButton lBtn = ((LinkButton)sender);
|
|
setModVisibility(lBtn.CommandArgument);
|
|
setBtnVisibility();
|
|
}
|
|
/// <summary>
|
|
/// sistemazione della visibilità dei moduli di dettaglio/editing
|
|
/// </summary>
|
|
private void setModVisibility(string req)
|
|
{
|
|
bool okCreate = false;
|
|
bool showEdit = false;
|
|
if (QuoteType == "" || CodQuote == "" || QuoteRev == "")
|
|
// se NON HO dati x una richiesta specifica vado in modalità INSERT..
|
|
{
|
|
// mostro solo controllo header in modalità INSERT
|
|
editActive = true;
|
|
mod_Q_Header1.setInsertMode();
|
|
mod_Q_Costs1.Visible = false;
|
|
mod_Q_ExtrPar1.Visible = false;
|
|
mod_Q_Header1.Visible = true;
|
|
mod_Q_PackPar1.Visible = false;
|
|
lbConvQ2S.Visible = false;
|
|
}
|
|
else
|
|
// altrimenti gestione ordinaria di editing
|
|
{
|
|
lbConvQ2S.Visible = true;
|
|
switch (req)
|
|
{
|
|
case "Costs":
|
|
mod_Q_Costs1.Visible = true;
|
|
mod_Q_ExtrPar1.Visible = false;
|
|
mod_Q_Header1.Visible = false;
|
|
mod_Q_PackPar1.Visible = false;
|
|
break;
|
|
case "ExtrPar":
|
|
mod_Q_Costs1.Visible = false;
|
|
mod_Q_ExtrPar1.Visible = true;
|
|
mod_Q_Header1.Visible = false;
|
|
mod_Q_PackPar1.Visible = false;
|
|
break;
|
|
case "Header":
|
|
// 2015.05.27 sempre editabile ma passo QS x determinare COSA (se stato >2 solo esito...)
|
|
if (prevReq == req) mod_Q_Header1.toggleMode();
|
|
mod_Q_Header1.IdxQS = IdxQS;
|
|
mod_Q_Costs1.Visible = false;
|
|
mod_Q_ExtrPar1.Visible = false;
|
|
mod_Q_Header1.Visible = true;
|
|
mod_Q_PackPar1.Visible = false;
|
|
break;
|
|
case "PackPar":
|
|
mod_Q_Costs1.Visible = false;
|
|
mod_Q_ExtrPar1.Visible = false;
|
|
mod_Q_Header1.Visible = false;
|
|
mod_Q_PackPar1.Visible = true;
|
|
break;
|
|
case "Quote":
|
|
// SOLO se stato <= approvato(2)...
|
|
if (IdxQS < 2)
|
|
{
|
|
// 2015.06.11 sempre attivo il toggle NON faccio check che sia già stato richiesto...
|
|
//if (prevReq == req) mod_Q_Quot1.toggleMode();
|
|
mod_Q_Quot1.toggleMode();
|
|
}
|
|
break;
|
|
default:
|
|
mod_Q_Costs1.Visible = false;
|
|
mod_Q_ExtrPar1.Visible = false;
|
|
mod_Q_Header1.Visible = true;
|
|
mod_Q_PackPar1.Visible = false;
|
|
editActive = false;
|
|
break;
|
|
}
|
|
// verifica se sia attivo editing
|
|
editActive = (mod_Q_Header1.isEditing || mod_Q_Quot1.isEditing);
|
|
prevReq = req;
|
|
// controllo SE sia visibile il pulsante crea offerta (netMargin > 0... DA VERIFICARE)
|
|
DS_Quotes.QuoteFull_QRow riga;
|
|
try
|
|
{
|
|
riga = DtProxy.man.taQFQ.getByKey(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev), "N")[0];
|
|
if (riga.NetMar > 0 || riga.PriceOff > 0)
|
|
{
|
|
okCreate = true;
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
showEdit = true;
|
|
}
|
|
// fix visibilità button creazione offerta
|
|
lbCreateOffer.Visible = okCreate;
|
|
// fix altri button x edit..
|
|
if (!showEdit || editActive)
|
|
{
|
|
lbCosts.CssClass = "btn btn-default disabled";
|
|
lbExtrPar.CssClass = "btn btn-default disabled";
|
|
lbHeader.CssClass = "btn btn-default disabled";
|
|
lbPackPar.CssClass = "btn btn-default disabled";
|
|
lbQuotation.CssClass = "btn btn-default disabled";
|
|
// riabilito controlli in edit...
|
|
if (mod_Q_Header1.isEditing) lbHeader.CssClass = "btn btn-default";
|
|
if (mod_Q_Quot1.isEditing) lbQuotation.CssClass = "btn btn-default";
|
|
}
|
|
else
|
|
{
|
|
lbCosts.CssClass = "btn btn-default";
|
|
lbExtrPar.CssClass = "btn btn-default";
|
|
lbHeader.CssClass = "btn btn-default";
|
|
lbPackPar.CssClass = "btn btn-default";
|
|
lbQuotation.CssClass = "btn btn-default";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// sistema visibilità buttons x cambio stato
|
|
/// </summary>
|
|
private void setBtnVisibility()
|
|
{
|
|
// in base a stato corrente offerta decide cosa mostrare...
|
|
string currState = IdxQState;
|
|
// se è in edit UNO dei panels allora devo evitare editing con buttons finali...
|
|
if (editActive) currState = "-1";
|
|
switch (currState)
|
|
{
|
|
case "0":
|
|
divStato0.Visible = true;
|
|
divStato1.Visible = false;
|
|
divStato2.Visible = false;
|
|
divStato3.Visible = false;
|
|
btnGetPdf.Visible = true;
|
|
break;
|
|
case "1":
|
|
divStato0.Visible = false;
|
|
divStato1.Visible = true;
|
|
divStato2.Visible = false;
|
|
divStato3.Visible = false;
|
|
btnGetPdf.Visible = true;
|
|
break;
|
|
case "2":
|
|
divStato0.Visible = false;
|
|
divStato1.Visible = false;
|
|
divStato2.Visible = true;
|
|
divStato3.Visible = false;
|
|
btnGetPdf.Visible = true;
|
|
break;
|
|
case "3":
|
|
divStato0.Visible = false;
|
|
divStato1.Visible = false;
|
|
divStato2.Visible = false;
|
|
// 2015.02.26 SOLO SE è in result = TBD
|
|
bool condTbd = false;
|
|
try
|
|
{
|
|
condTbd = OfferResult == "TBD"; // hard coded !!!
|
|
}
|
|
catch
|
|
{ }
|
|
// 2015.05.26 SOLO SE è l'ULTIMA revisione...
|
|
bool condIsLast = false;
|
|
try
|
|
{
|
|
condIsLast = DtProxy.man.taCLQ.GetData(QuoteType, Convert.ToInt64(CodQuote))[0].lastRev == Convert.ToInt32(QuoteRev);
|
|
}
|
|
catch
|
|
{ }
|
|
//divStato3.Visible = true;
|
|
divStato3.Visible = condTbd && condIsLast;
|
|
btnGetPdf.Visible = true;
|
|
break;
|
|
default:
|
|
divStato0.Visible = false;
|
|
divStato1.Visible = false;
|
|
divStato2.Visible = false;
|
|
divStato3.Visible = false;
|
|
btnGetPdf.Visible = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// CONVERTE offerta in simulazione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbConvQ2S_Click(object sender, EventArgs e)
|
|
{
|
|
// update da Q ad S del tipo offerta
|
|
DS_Quotes.QuoteListDataTable tab = DtProxy.man.taQL.makeSim(Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev), user_std.UtSn.utente);
|
|
if (tab.Rows.Count > 0)
|
|
{
|
|
// seleziona l'offerta duplicata!
|
|
Response.Redirect(string.Format("Quote?QuoteType={0}&CodQuote={1}&QuoteRev={2}", tab[0].QuoteType, tab[0].CodQuote, tab[0].QuoteRev));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// invia email x workflow
|
|
/// </summary>
|
|
/// <param name="_mailTo"></param>
|
|
/// <param name="_subj2T"></param>
|
|
/// <param name="_obj2T"></param>
|
|
private void sendWFlowEmail(string _mailTo, string _subj2T, string _obj2T)
|
|
{
|
|
if (_mailTo != "")
|
|
{
|
|
string _mailFrom = memLayer.ML.confReadString("_fromEmail");
|
|
string _oggetto = traduci(_subj2T);
|
|
string fullUrl = string.Format("{0}/Quote?QuoteType={1}&CodQuote={2}&QuoteRev={3}", memLayer.ML.confReadString("baseUrl"), QuoteType, CodQuote, QuoteRev);
|
|
string _corpo = string.Format(traduci(_obj2T), fullUrl);
|
|
gestEmail.geAuth.mandaEmail(_mailFrom, _mailTo, _oggetto, _corpo);
|
|
}
|
|
else
|
|
{
|
|
logger.lg.scriviLog("Errore: manca email!", tipoLog.ERROR);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Crea un offerta (SE
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lnkCreateOffer_Click(object sender, EventArgs e)
|
|
{
|
|
// cambio stato offerta da draft!
|
|
DtProxy.man.taQFQ.updateQState(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev), 1, user_std.UtSn.utente);
|
|
// invio email di stato CREATED ad approvatore
|
|
string _mailTo = memLayer.ML.confReadString("wfApprTo");
|
|
sendWFlowEmail(_mailTo, "subjMailCreate", "objMailCreate");
|
|
// aggiorno!
|
|
updateBaseData();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// rifiuta e riporta in draft
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbReject_Click(object sender, EventArgs e)
|
|
{
|
|
// invio email di stato REJECTED da approvatore
|
|
string _mailTo = user_std.UtSn.emailDaUsername(DtProxy.man.taQL.getByKey(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev))[0].UserMod);
|
|
sendWFlowEmail(_mailTo, "subjMailReject", "objMailReject");
|
|
// riporto in DRAFT!
|
|
DtProxy.man.taQFQ.updateQState(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev), 0, user_std.UtSn.utente);
|
|
// aggiorno!
|
|
updateBaseData();
|
|
}
|
|
/// <summary>
|
|
/// approva
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbApprove_Click(object sender, EventArgs e)
|
|
{
|
|
// invio email di stato CREATED da approvatore
|
|
string _mailTo = user_std.UtSn.emailDaUsername(DtProxy.man.taQL.getByKey(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev))[0].UserMod);
|
|
sendWFlowEmail(_mailTo, "subjMailApprove", "objMailApprove");
|
|
// approvo
|
|
DtProxy.man.taQFQ.updateQState(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev), 2, user_std.UtSn.utente);
|
|
// aggiorno!
|
|
updateBaseData();
|
|
}
|
|
/// <summary>
|
|
/// rilascia
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbRelease_Click(object sender, EventArgs e)
|
|
{
|
|
// indica rilasciato
|
|
DtProxy.man.taQFQ.updateQState(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev), 3, user_std.UtSn.utente);
|
|
// invio email di stato RELEASED ad approvatore
|
|
string _mailTo = memLayer.ML.confReadString("wfApprTo");
|
|
sendWFlowEmail(_mailTo, "subjMailRelease", "objMailRelease");
|
|
// aggiorno!
|
|
updateBaseData();
|
|
}
|
|
/// <summary>
|
|
/// determina se sia stampabile (cod stato > 0...)
|
|
/// </summary>
|
|
public bool printEnabled
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
if (IdxQState != "0") answ = true;
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// genera nuova revisione e rimanda a pagina corrente con nuova revisione...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbNewRev_Click(object sender, EventArgs e)
|
|
{
|
|
DS_Quotes.QuoteListDataTable tab = DtProxy.man.taQL.newRev(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev), user_std.UtSn.utente);
|
|
if (tab.Rows.Count > 0)
|
|
{
|
|
// seleziona l'offerta duplicata!
|
|
Response.Redirect(string.Format("Quote?QuoteType={0}&CodQuote={1}&QuoteRev={2}", tab[0].QuoteType, tab[0].CodQuote, tab[0].QuoteRev));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// verifica se utente sia admin altrimenti non vede dati...
|
|
/// </summary>
|
|
public bool userIsAdmin
|
|
{
|
|
get
|
|
{
|
|
bool answ = devicesAuthProxy.stObj.userHasRight("SuperAdmin") || devicesAuthProxy.stObj.userHasRight("Admin");
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// verifica se utente sia admin altrimenti non vede dati...
|
|
/// </summary>
|
|
public bool userIsSuper
|
|
{
|
|
get
|
|
{
|
|
bool answ = devicesAuthProxy.stObj.userHasRight("SuperUser");
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
}
|
|
} |