Files
C2P/C2P/WebUserControls/mod_newQuote.ascx.cs
T
2014-02-21 17:27:29 +01:00

188 lines
5.5 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;
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>
/// totale base lega + extra inserito...
/// </summary>
protected decimal totale
{
get
{
decimal answ = 0;
try
{
answ += Convert.ToDecimal(txtBaseAl.Text.Replace(".", ",")); // !!!FARE verifica con gestioen da internationalization
}
catch
{ }
try
{
answ += Convert.ToDecimal(txtExtraLega.Text.Replace(".", ",")); // !!!FARE verifica con gestioen da internationalization
}
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 == "" || txtConsegna.Text == "")
{
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)
{
checkBtnNew();
}
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();
}
}
}