322 lines
11 KiB
C#
322 lines
11 KiB
C#
using C2P_Data;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace C2P
|
|
{
|
|
public partial class RevisionHistory : SteamWare.UserPage
|
|
{
|
|
/// <summary>
|
|
/// richiesta caricamento tabella (da filtro configurato)
|
|
/// </summary>
|
|
public event EventHandler eh_loadReq;
|
|
/// <summary>
|
|
/// sistema visibilità button...
|
|
/// </summary>
|
|
private void setBtnVisib()
|
|
{
|
|
string baseCss = "btn btn-";
|
|
if (numSel == 0)
|
|
{
|
|
baseCss = "btn disabled btn-";
|
|
lbOpen.CssClass = baseCss + "success";
|
|
lbDuplicate.CssClass = baseCss + "warning";
|
|
lbSimulate.CssClass = baseCss + "danger";
|
|
lbPrint.CssClass = baseCss + "info";
|
|
}
|
|
else if (numSel == 1)
|
|
{
|
|
lbOpen.CssClass = baseCss + "success";
|
|
lbDuplicate.CssClass = baseCss + "warning";
|
|
lbSimulate.CssClass = baseCss + "danger";
|
|
lbPrint.CssClass = baseCss + "info";
|
|
|
|
// cerco riga selezionata...
|
|
CheckBox chkBox;
|
|
for (int i = 0; i < grView.Rows.Count; i++)
|
|
{
|
|
grView.SelectedIndex = i;
|
|
chkBox = ((CheckBox)grView.SelectedRow.FindControl("chkSelect"));
|
|
if (chkBox.Checked)
|
|
{
|
|
QuoteType = grView.SelectedDataKey["QuoteType"].ToString();
|
|
CodQuote = grView.SelectedDataKey["CodQuote"].ToString();
|
|
QuoteRev = grView.SelectedDataKey["QuoteRev"].ToString();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lbPrint.CssClass = baseCss + "info";
|
|
baseCss = "btn disabled btn-";
|
|
lbOpen.CssClass = baseCss + "success";
|
|
lbDuplicate.CssClass = baseCss + "warning";
|
|
lbSimulate.CssClass = baseCss + "danger";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// numero offerte selezionate
|
|
/// </summary>
|
|
protected int numSel
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.IntSessionObj("numOffSel");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("numOffSel", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Tipo Quote
|
|
/// </summary>
|
|
protected string QuoteType
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("LastQuoteType");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("LastQuoteType", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Codice Quote
|
|
/// </summary>
|
|
protected string CodQuote
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("LastCodQuote");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("LastCodQuote", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Revisione
|
|
/// </summary>
|
|
protected string QuoteRev
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("LastQuoteRev");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("LastQuoteRev", value);
|
|
}
|
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
/// <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>
|
|
/// stringa formattata del numero di record mostrati
|
|
/// </summary>
|
|
public string numRecords
|
|
{
|
|
get
|
|
{
|
|
return string.Format("{0} ({1})", grView.Rows.Count, grView.PageSize * (grView.PageCount - 1) + grView.Rows.Count);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// seleziona/deseleziona le righe indicate...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSelAll_Click(object sender, EventArgs e)
|
|
{
|
|
// seleziono tutti i valori visibili nel datagrid
|
|
CheckBox chkbox = ((CheckBox)sender);
|
|
bool isChecked = chkbox.Checked;
|
|
if (!isChecked)
|
|
{
|
|
chkbox.ToolTip = traduci("btnSelAll");
|
|
numSel = 0;
|
|
}
|
|
else
|
|
{
|
|
chkbox.ToolTip = traduci("btnDeselAll");
|
|
numSel = grView.Rows.Count;
|
|
}
|
|
foreach (GridViewRow riga in grView.Rows)
|
|
{
|
|
((CheckBox)riga.FindControl("chkSelect")).Checked = isChecked;
|
|
}
|
|
setBtnVisib();
|
|
}
|
|
/// <summary>
|
|
/// gestione singolo click
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSel_Click(object sender, EventArgs e)
|
|
{
|
|
CheckBox chkbox = ((CheckBox)sender);
|
|
bool isChecked = chkbox.Checked;
|
|
if (isChecked)
|
|
{
|
|
numSel++;
|
|
}
|
|
else
|
|
{
|
|
numSel--;
|
|
}
|
|
//grView.SelectedIndex = -1;
|
|
// fix visibilità buttons
|
|
setBtnVisib();
|
|
} /// <summary>
|
|
/// Apre offerta selezionata!
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbOpen_Click(object sender, EventArgs e)
|
|
{
|
|
// apro con link nuova offerta!
|
|
Response.Redirect(string.Format("Quote?QuoteType={0}&CodQuote={1}&QuoteRev={2}", QuoteType, CodQuote, QuoteRev));
|
|
}
|
|
/// <summary>
|
|
/// duplica offerta selezionata
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbDuplicate_Click(object sender, EventArgs e)
|
|
{
|
|
// duplica offerta!
|
|
DS_Quotes.QuoteListDataTable tab = DtProxy.man.taQL.clone(QuoteType, 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));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// crea nuova simulazioen da offerta selezionata
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbSimulate_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
/// <summary>
|
|
/// stampa offerta(e) selezionata(e)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbPrint_Click(object sender, EventArgs e)
|
|
{
|
|
// genero un nuovo ticket x la richiesta di stampa...
|
|
int ticket = 0;
|
|
try
|
|
{
|
|
ticket = DtProxy.man.taRPT.reserveTicket("SchedaCosto", user_std.UtSn.userNameAD)[0].Ticket;
|
|
}
|
|
catch
|
|
{
|
|
ticket = 0;
|
|
}
|
|
bool togliSegnaposto = true;
|
|
if (ticket > 0)
|
|
{
|
|
//DS_Quotes.QuoteFull_QRow rigaQuote;
|
|
// salvo i valori selezionati con il ticket corrente (eliminando reservation...)
|
|
foreach (GridViewRow riga in grView.Rows)
|
|
{
|
|
if (((CheckBox)riga.FindControl("chkSelect")).Checked)
|
|
{
|
|
grView.SelectedIndex = riga.DataItemIndex;
|
|
// ricavo dati della riga x inserire in elenco richieste stampa...
|
|
DtProxy.man.taRPT.insertNew(ticket, "SchedaCosto", string.Format("QuoteType={0}&CodQuote={1}&QuoteRev={2}", grView.SelectedDataKey["QuoteType"], grView.SelectedDataKey["CodQuote"], grView.SelectedDataKey["QuoteRev"]), user_std.UtSn.userNameAD, DateTime.Now, togliSegnaposto);
|
|
togliSegnaposto = false;
|
|
}
|
|
}
|
|
// rimando a pagina di stampa reports...
|
|
Response.Redirect(string.Format("RepOffers?ticket={0}", ticket));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// salvo e vado a dettaglio!
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
// verifico parametri riga scelta
|
|
QuoteType = grView.SelectedDataKey["QuoteType"].ToString();
|
|
CodQuote = grView.SelectedDataKey["CodQuote"].ToString();
|
|
QuoteRev = grView.SelectedDataKey["QuoteRev"].ToString();
|
|
// verifico tipo di caricamento...
|
|
string _comando = "";
|
|
if (SteamWare.memLayer.ML.isInSessionObject("nextObjCommand"))
|
|
{
|
|
_comando = SteamWare.memLayer.ML.StringSessionObj("nextObjCommand");
|
|
SteamWare.memLayer.ML.emptySessionVal("nextObjCommand");
|
|
}
|
|
switch (_comando)
|
|
{
|
|
case "load":
|
|
memLayer.ML.setSessionVal("QuoteType", QuoteType);
|
|
memLayer.ML.setSessionVal("CodQuote", CodQuote);
|
|
memLayer.ML.setSessionVal("QuoteRev", QuoteRev);
|
|
// sollevo evento
|
|
if (eh_loadReq != null)
|
|
{
|
|
eh_loadReq(this, new EventArgs());
|
|
}
|
|
break;
|
|
case "toDetail":
|
|
// rimando a dettaglio!
|
|
Response.Redirect(string.Format("QuoteDet?QuoteType={0}&CodQuote={1}&QuoteRev={2}", QuoteType, CodQuote, QuoteRev));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
} |