302 lines
9.3 KiB
C#
302 lines
9.3 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;
|
|
|
|
namespace C2P.WebUserControls
|
|
{
|
|
public partial class mod_newQuote : System.Web.UI.UserControl
|
|
{
|
|
/// <summary>
|
|
/// evento disponibilità nuovi dati x ricerca
|
|
/// </summary>
|
|
public event EventHandler eh_newSearchData;
|
|
/// <summary>
|
|
/// evento nuovo record inserito
|
|
/// </summary>
|
|
public event EventHandler eh_newQuote;
|
|
|
|
/// <summary>
|
|
/// traduzioni dell'interfaccia
|
|
/// </summary>
|
|
private void traduciObj()
|
|
{
|
|
string cKey = acCliente.contextKey;
|
|
acCliente.labelRicerca = traduci("ac[C]liente");
|
|
acArticolo.labelRicerca = traduci("ac[A]rticolo");
|
|
lblLega.Text = traduci("ac[L]ega");
|
|
}
|
|
/// <summary>
|
|
/// wrapper traduzione
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(object lemma)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma.ToString());
|
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
traduciObj();
|
|
checkBtnNew();
|
|
}
|
|
acCliente.eh_valSelezionato += acCliente_eh_valSelezionato;
|
|
acCliente.eh_reset += acCliente_eh_reset;
|
|
acArticolo.eh_valSelezionato += acArticolo_eh_valSelezionato;
|
|
acArticolo.eh_reset += acArticolo_eh_reset;
|
|
}
|
|
|
|
void acArticolo_eh_reset(object sender, EventArgs e)
|
|
{
|
|
salvaRicerca();
|
|
}
|
|
|
|
void acArticolo_eh_valSelezionato(object sender, EventArgs e)
|
|
{
|
|
salvaRicerca();
|
|
}
|
|
/// <summary>
|
|
/// evento reset selezione valore CodCliente
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void acCliente_eh_reset(object sender, EventArgs e)
|
|
{
|
|
salvaRicerca();
|
|
}
|
|
|
|
/// <summary>
|
|
/// evento selezione valore CodCliente
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void acCliente_eh_valSelezionato(object sender, EventArgs e)
|
|
{
|
|
salvaRicerca();
|
|
}
|
|
/// <summary>
|
|
/// salva valori cercati
|
|
/// </summary>
|
|
private void salvaRicerca()
|
|
{
|
|
// salvo valore selezionato cliente
|
|
memLayer.ML.setSessionVal("codClient", acCliente.valore);
|
|
memLayer.ML.setSessionVal("CodItem", acArticolo.valore);
|
|
memLayer.ML.setSessionVal("RawMat", ddlLega.SelectedValue);
|
|
checkBtnNew();
|
|
// sollevo evento
|
|
if (eh_newSearchData != null)
|
|
{
|
|
eh_newSearchData(this, new EventArgs());
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// costo materia prima...
|
|
/// </summary>
|
|
protected decimal RawMatCost
|
|
{
|
|
get
|
|
{
|
|
decimal answ = 0;
|
|
try
|
|
{
|
|
answ += Convert.ToDecimal(txtBaseAl.Text.Replace(".", ",")); // !!!FARE verifica con gestione da internationalization
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// totale base extra inserito...
|
|
/// </summary>
|
|
protected decimal RawMatExtraCost
|
|
{
|
|
get
|
|
{
|
|
decimal answ = 0;
|
|
try
|
|
{
|
|
answ += Convert.ToDecimal(txtExtraLega.Text.Replace(".", ",")); // !!!FARE verifica con gestione da internationalization
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// totale base lega + extra inserito...
|
|
/// </summary>
|
|
protected decimal totale
|
|
{
|
|
get
|
|
{
|
|
decimal answ = 0;
|
|
try
|
|
{
|
|
answ = RawMatCost + RawMatExtraCost;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
protected void txtExtraLega_TextChanged(object sender, EventArgs e)
|
|
{
|
|
updateTot();
|
|
}
|
|
|
|
|
|
protected void txtBaseAl_TextChanged(object sender, EventArgs e)
|
|
{
|
|
updateTot();
|
|
}
|
|
/// <summary>
|
|
/// calcola totale costo Al
|
|
/// </summary>
|
|
private void updateTot()
|
|
{
|
|
lblImportoTot.Text = totale.ToString();
|
|
checkBtnNew();
|
|
}
|
|
/// <summary>
|
|
/// verifica se siano compilati i campi x abilitare creazioen nuova offerta
|
|
/// </summary>
|
|
private void checkBtnNew()
|
|
{
|
|
bool genEnab = true;
|
|
// è abilitato se abbiamo tutto: cliente, articolo, lega, costo base, qta, consegna
|
|
if (acCliente.valore == "" || acArticolo.valore == "" || ddlLega.SelectedValue == "")
|
|
{
|
|
genEnab = false;
|
|
}
|
|
if (txtBaseAl.Text == "" || txtLotto.Text == "" || ddlConsegna.SelectedValue == "")
|
|
{
|
|
genEnab = false;
|
|
}
|
|
btnNew.Enabled = genEnab;
|
|
}
|
|
/// <summary>
|
|
/// genera nuovo record
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
// se ho tutti i dati creo nuovo record!
|
|
int batchQty = 0;
|
|
try
|
|
{
|
|
batchQty = Convert.ToInt32(txtLotto.Text.Trim());
|
|
}
|
|
catch
|
|
{ }
|
|
// tento insert!
|
|
try
|
|
{
|
|
DS_Quotes.QuoteListDataTable tabRes = DtProxy.man.taQL.insNew("Q", acCliente.valore, acArticolo.valore, ddlLega.SelectedValue, RawMatCost, RawMatExtraCost, batchQty, ddlConsegna.SelectedValue, txtNote.Text.Trim());
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(String.Format("Errore in creazione nuova quote: {0}{1}", Environment.NewLine, exc));
|
|
}
|
|
// sollevo evento
|
|
if (eh_newQuote != null)
|
|
{
|
|
eh_newQuote(this, new EventArgs());
|
|
}
|
|
|
|
}
|
|
|
|
protected void txtLotto_TextChanged(object sender, EventArgs e)
|
|
{
|
|
checkBtnNew();
|
|
}
|
|
|
|
protected void txtConsegna_TextChanged(object sender, EventArgs e)
|
|
{
|
|
checkBtnNew();
|
|
}
|
|
|
|
protected void txtNote_TextChanged(object sender, EventArgs e)
|
|
{
|
|
checkBtnNew();
|
|
}
|
|
|
|
protected void ddlLega_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
salvaRicerca();
|
|
}
|
|
|
|
protected void ddlConsegna_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
checkBtnNew();
|
|
}
|
|
/// <summary>
|
|
/// carica i dati selezionati (da chiave quote...)
|
|
/// </summary>
|
|
public void loadSelData()
|
|
{
|
|
string QuoteType = memLayer.ML.StringSessionObj("QuoteType");
|
|
long CodQuote = memLayer.ML.IntSessionObj("CodQuote");
|
|
int QuoteRev = memLayer.ML.IntSessionObj("QuoteRev");
|
|
DS_Quotes.QuoteListRow riga = DtProxy.man.taQL.getByKey(QuoteType, CodQuote, QuoteRev)[0];
|
|
DS_Quotes.QuoteRMRow rigaRM = DtProxy.man.taQRM.getByKey(QuoteType, CodQuote, QuoteRev, 1)[0];
|
|
if (riga != null)
|
|
{
|
|
// imposto valori!
|
|
acCliente.selezione = riga.CodClient;
|
|
acCliente.valore = riga.CodClient;
|
|
acArticolo.selezione = riga.CodItem;
|
|
acArticolo.valore = riga.CodItem;
|
|
ddlConsegna.SelectedValue = riga.CodInco;
|
|
ddlLega.SelectedValue = riga.RawMat;
|
|
txtLotto.Text = riga.BatchQty.ToString();
|
|
txtNote.Text = riga.Note;
|
|
txtBaseAl.Text = rigaRM.RawMatCost.ToString();
|
|
txtExtraLega.Text = rigaRM.RawMatExtraCost.ToString();
|
|
}
|
|
// update filtraggio
|
|
salvaRicerca();
|
|
// check btn genera...
|
|
checkBtnNew();
|
|
}
|
|
/// <summary>
|
|
/// reset dell'offerta
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnReset_Click(object sender, EventArgs e)
|
|
{
|
|
fullReset();
|
|
}
|
|
/// <summary>
|
|
/// resetta in toto l'offerta
|
|
/// </summary>
|
|
private void fullReset()
|
|
{
|
|
acCliente.selezione = "";
|
|
acCliente.valore = "";
|
|
acArticolo.selezione = "";
|
|
acArticolo.valore = "";
|
|
ddlConsegna.SelectedValue = "";
|
|
ddlLega.SelectedValue = "";
|
|
txtLotto.Text = "";
|
|
txtNote.Text = "";
|
|
txtBaseAl.Text = "";
|
|
txtExtraLega.Text = "";
|
|
// update filtraggio
|
|
salvaRicerca();
|
|
// check btn genera...
|
|
checkBtnNew();
|
|
}
|
|
|
|
}
|
|
} |