ce1157bc49
fix molti punti segnalati da Emanuele
486 lines
17 KiB
C#
486 lines
17 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>
|
|
/// 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");
|
|
}
|
|
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;
|
|
}
|
|
/// <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...
|
|
int IdxQS = 0;
|
|
try
|
|
{
|
|
IdxQS = DtProxy.man.taQFQ.getByKey(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev), "N")[0].IdxQState;
|
|
}
|
|
catch
|
|
{ }
|
|
IdxQState = IdxQS.ToString();
|
|
Status = traduci(string.Format("IdxQState-{0:D2}", IdxQS));
|
|
setBtnVisibility();
|
|
mod_Q_Quot1.doUpdate();
|
|
}
|
|
/// <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("");
|
|
}
|
|
/// <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("");
|
|
}
|
|
/// <summary>
|
|
/// Calcola css dato valore prezzo offerto vs importi full cost e min price
|
|
/// </summary>
|
|
/// <param name="FullCost"></param>
|
|
/// <param name="MinPrice"></param>
|
|
/// <param name="PriceOff"></param>
|
|
/// <returns></returns>
|
|
public string priceVsCost(object _FullCost, object _MinPrice, object _PriceOff)
|
|
{
|
|
string answ = "";
|
|
double FullCost = 0;
|
|
double MinPrice = 0;
|
|
double PriceOff = 0;
|
|
try
|
|
{
|
|
FullCost = Convert.ToDouble(_FullCost);
|
|
MinPrice = Convert.ToDouble(_MinPrice);
|
|
PriceOff = Convert.ToDouble(_PriceOff);
|
|
}
|
|
catch
|
|
{ }
|
|
if (PriceOff > MinPrice)
|
|
{
|
|
answ = "allOk";
|
|
}
|
|
else if (PriceOff > FullCost)
|
|
{
|
|
answ = "warnOrange";
|
|
}
|
|
else
|
|
{
|
|
answ = "warnRed";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <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":
|
|
if (prevReq == req) mod_Q_Header1.toggleMode();
|
|
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":
|
|
if (prevReq == req) 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;
|
|
divStato3.Visible = true;
|
|
btnGetPdf.Visible = true;
|
|
break;
|
|
default:
|
|
divStato0.Visible = false;
|
|
divStato1.Visible = false;
|
|
divStato2.Visible = false;
|
|
divStato3.Visible = false;
|
|
btnGetPdf.Visible = false;
|
|
break;
|
|
}
|
|
}
|
|
/// <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);
|
|
// aggiorno!
|
|
updateBaseData();
|
|
}
|
|
|
|
/// <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));
|
|
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>
|
|
/// rifiuta e riporta in draft
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbReject_Click(object sender, EventArgs e)
|
|
{
|
|
// cambio stato offerta da draft!
|
|
DtProxy.man.taQFQ.updateQState(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev), 0);
|
|
// aggiorno!
|
|
updateBaseData();
|
|
}
|
|
/// <summary>
|
|
/// approva
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbApprove_Click(object sender, EventArgs e)
|
|
{
|
|
// cambio stato offerta da draft!
|
|
DtProxy.man.taQFQ.updateQState(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev), 2);
|
|
// aggiorno!
|
|
updateBaseData();
|
|
}
|
|
/// <summary>
|
|
/// rilascia
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbRelease_Click(object sender, EventArgs e)
|
|
{
|
|
// cambio stato offerta da draft!
|
|
DtProxy.man.taQFQ.updateQState(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev), 3);
|
|
// 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));
|
|
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));
|
|
}
|
|
}
|
|
}
|
|
} |