fca80a1cee
modifiche ulteriori x punti Emanuele
539 lines
19 KiB
C#
539 lines
19 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using SteamWare;
|
|
using C2P_Data;
|
|
using System.Data;
|
|
|
|
namespace C2P.WebUserControls
|
|
{
|
|
public partial class mod_OffersArchive : System.Web.UI.UserControl
|
|
{
|
|
/// <summary>
|
|
/// richeista caricamento tabella (da filtro configurato)
|
|
/// </summary>
|
|
public event EventHandler eh_loadReq;
|
|
/// <summary>
|
|
/// setup al caricamento pagina...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
// al caricamento NON mostro risultati ricerca...
|
|
if (!Page.IsPostBack)
|
|
{
|
|
grView.PageSize = pageSize;
|
|
// calcolo il range dello slider...
|
|
setSliderVal();
|
|
// altri fix
|
|
grView.Visible = false;
|
|
numRes.Visible = false;
|
|
numSel = 0;
|
|
intervalloDate periodo = new intervalloDate();
|
|
periodo.fine = DateTime.Now.Date.AddDays(1);
|
|
periodo.inizio = periodo.fine.AddDays(-8);
|
|
mod_selPeriodo1.intervalloAnalisi = periodo;
|
|
}
|
|
setBtnVisib();
|
|
mod_selPeriodo1.eh_doUpdate += mod_selPeriodo1_eh_doUpdate;
|
|
}
|
|
|
|
|
|
void mod_selPeriodo1_eh_doUpdate(object sender, EventArgs e)
|
|
{
|
|
setSliderVal();
|
|
}
|
|
/// <summary>
|
|
/// calcola valori ammissibili slider
|
|
/// </summary>
|
|
private void setSliderVal()
|
|
{
|
|
// recupero data min/max...
|
|
int minDate = Convert.ToInt32(mod_selPeriodo1.intervalloAnalisi.inizio.ToString("yyMMdd0000"));
|
|
int maxDate = Convert.ToInt32(mod_selPeriodo1.intervalloAnalisi.fine.ToString("yyMMdd0000"));
|
|
DS_Quotes.QuoteFull_QDataTable tab = DtProxy.man.taQFQ.getMinMax(minDate, maxDate);
|
|
try
|
|
{
|
|
if (tab.Rows.Count > 0)
|
|
{
|
|
if (tab[0].BatchQty < tab[1].BatchQty)
|
|
{
|
|
mod_range1.minVal = tab[0].BatchQty;
|
|
mod_range1.maxVal = tab[1].BatchQty;
|
|
}
|
|
else
|
|
{
|
|
mod_range1.minVal = tab[1].BatchQty;
|
|
mod_range1.maxVal = tab[0].BatchQty;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
mod_range1.minVal = 0;
|
|
mod_range1.maxVal = 10000;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
mod_range1.minVal = 0;
|
|
mod_range1.maxVal = 10000;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// sistema visibilità button...
|
|
/// </summary>
|
|
private void setBtnVisib()
|
|
{
|
|
string baseCss = "btn btn-";
|
|
if (numSel == 0)
|
|
{
|
|
baseCss = "btn disabled btn-";
|
|
lbOpen.CssClass = baseCss + "success";
|
|
lbDelete.CssClass = baseCss + "danger";
|
|
lbDuplicate.CssClass = baseCss + "primary";
|
|
lbSimulate.CssClass = baseCss + "warning";
|
|
lbPrint.CssClass = baseCss + "info";
|
|
}
|
|
else if (numSel == 1)
|
|
{
|
|
lbOpen.CssClass = baseCss + "success";
|
|
lbDelete.CssClass = baseCss + "danger";
|
|
lbDuplicate.CssClass = baseCss + "primary";
|
|
lbSimulate.CssClass = baseCss + "warning";
|
|
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();
|
|
}
|
|
// solo se riga corrente è tipo "Q"
|
|
if (QuoteType != "Q")
|
|
{
|
|
lbSimulate.CssClass = lbSimulate.CssClass + " disabled";
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lbPrint.CssClass = baseCss + "info";
|
|
baseCss = "btn disabled btn-";
|
|
lbOpen.CssClass = baseCss + "success";
|
|
lbDelete.CssClass = baseCss + "danger";
|
|
lbDuplicate.CssClass = baseCss + "primary";
|
|
lbSimulate.CssClass = baseCss + "warning";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// numero offerte selezionate
|
|
/// </summary>
|
|
protected int numSel
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.IntSessionObj("numOffSel");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("numOffSel", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// wrapper traduzione
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(object lemma)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma.ToString());
|
|
}
|
|
/// <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;
|
|
}
|
|
}
|
|
/// <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
|
|
{
|
|
int numRow = Convert.ToInt32(DtProxy.man.taQFQ.fullDataCount(acClient.valore, acItem.valore, acMaterial.valore, mod_selPeriodo1.inizio, mod_selPeriodo1.fine, mod_range1.minValSel, mod_range1.maxValSel, rblTipo.SelectedValue, Convert.ToInt32(rblQState.SelectedValue)));
|
|
return string.Format("{0} ({1})", grView.Rows.Count, numRow);
|
|
//return string.Format("{0} ({1})", grView.Rows.Count, grView.PageSize * (grView.PageCount - 1) + grView.Rows.Count);
|
|
}
|
|
}
|
|
|
|
protected void txtCerca_TextChanged(object sender, EventArgs e)
|
|
{
|
|
doUpdate();
|
|
}
|
|
|
|
public void doUpdate()
|
|
{
|
|
grView.DataBind();
|
|
}
|
|
|
|
public void reset()
|
|
{
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
}
|
|
|
|
|
|
|
|
protected void btnCerca_Click(object sender, EventArgs e)
|
|
{
|
|
doUpdate();
|
|
}
|
|
|
|
protected void lbt_Command(object sender, CommandEventArgs e)
|
|
{
|
|
SteamWare.memLayer.ML.setSessionVal("nextObjCommand", ((LinkButton)sender).CommandArgument);
|
|
}
|
|
|
|
/// <summary>
|
|
/// richiesta ricerca e visualizzaizone con i parametri attuali...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtSearch_Click(object sender, EventArgs e)
|
|
{
|
|
// mostro il gridview!
|
|
grView.Visible = true;
|
|
numRes.Visible = true;
|
|
}
|
|
/// <summary>
|
|
/// reset ricerca
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtReset_Click(object sender, EventArgs e)
|
|
{
|
|
Response.Redirect("OffersArchive");
|
|
}
|
|
/// <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++;
|
|
#if false
|
|
// salvo riga attuale...
|
|
GridViewRow riga = ((GridViewRow)chkbox.NamingContainer);
|
|
grView.SelectedIndex = riga.DataItemIndex;
|
|
QuoteType = grView.SelectedDataKey["QuoteType"].ToString();
|
|
CodQuote = grView.SelectedDataKey["CodQuote"].ToString();
|
|
QuoteRev = grView.SelectedDataKey["QuoteRev"].ToString();
|
|
#endif
|
|
}
|
|
else
|
|
{
|
|
numSel--;
|
|
}
|
|
//grView.SelectedIndex = -1;
|
|
// fix visibilità buttons
|
|
setBtnVisib();
|
|
}
|
|
/// <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);
|
|
}
|
|
}
|
|
/// <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>
|
|
/// Apre offerta selezionata!
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbDelete_Click(object sender, EventArgs e)
|
|
{
|
|
// elimino SINGOLA offerta selezionata
|
|
DtProxy.man.taQFQ.DeleteQuery(QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev));
|
|
numSel = 0;
|
|
doUpdate();
|
|
setBtnVisib();
|
|
}
|
|
/// <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)
|
|
{
|
|
// duplico dati come simulazione...
|
|
DS_Quotes.QuoteListDataTable tab = DtProxy.man.taQL.clone("S", QuoteType, Convert.ToInt32(CodQuote), Convert.ToInt32(QuoteRev));
|
|
if (tab.Rows.Count > 0)
|
|
{
|
|
// apro pagina simulazione appena creata...
|
|
Response.Redirect(string.Format("Quote?QuoteType={0}&CodQuote={1}&QuoteRev={2}", tab[0].QuoteType, tab[0].CodQuote, tab[0].QuoteRev));
|
|
}
|
|
}
|
|
/// <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>
|
|
/// Gestione evento sort
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_Sorted(object sender, EventArgs e)
|
|
{
|
|
// aggiornare indicando con una freccia la direzione ASC/DESC del sort...
|
|
}
|
|
/// <summary>
|
|
/// dimensione pagina tabella richiesta
|
|
/// </summary>
|
|
protected int pageSize
|
|
{
|
|
get
|
|
{
|
|
int answ = 10;
|
|
try
|
|
{
|
|
answ = Convert.ToInt32(txtPageSize.Text);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// cambio valore paginazione grView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void txtPageSize_TextChanged(object sender, EventArgs e)
|
|
{
|
|
grView.PageSize = pageSize;
|
|
}
|
|
/// <summary>
|
|
/// intercetto select x eventuale verifica parametri...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void odsQuotes_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
|
|
{
|
|
if (memLayer.ML.confReadInt("_logLevel") > 6)
|
|
{
|
|
string elencoPar = string.Format("acClient: {0}{1}", acClient.valore, Environment.NewLine);
|
|
elencoPar += string.Format("acItem: {0}{1}", acItem.valore, Environment.NewLine);
|
|
elencoPar += string.Format("acMaterial: {0}{1}", acMaterial.valore, Environment.NewLine);
|
|
elencoPar += string.Format("mod_selPeriodo1 inizio: {0}{1}", mod_selPeriodo1.inizio, Environment.NewLine);
|
|
elencoPar += string.Format("mod_selPeriodo1 fine: {0}{1}", mod_selPeriodo1.fine, Environment.NewLine);
|
|
elencoPar += string.Format("mod_range1 min: {0}{1}", mod_range1.minValSel, Environment.NewLine);
|
|
elencoPar += string.Format("mod_range1 MAX: {0}{1}", mod_range1.maxValSel, Environment.NewLine);
|
|
elencoPar += string.Format("rblTipo: {0}{1}", rblTipo.SelectedValue, Environment.NewLine);
|
|
elencoPar += string.Format("rblQState: {0}{1}", rblQState.SelectedValue, Environment.NewLine);
|
|
logger.lg.scriviLog(elencoPar, tipoLog.INFO);
|
|
}
|
|
}
|
|
|
|
}
|
|
} |