188 lines
5.3 KiB
C#
188 lines
5.3 KiB
C#
using CMS_SC_Data;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace CMS_SC.WebUserControls
|
|
{
|
|
public partial class mod_anagMatricole : SteamWare.UserControl
|
|
{
|
|
/// <summary>
|
|
/// selezione valore in DettScheda
|
|
/// </summary>
|
|
public event EventHandler eh_selezioneValore;
|
|
/// <summary>
|
|
/// selezione valore in DettScheda
|
|
/// </summary>
|
|
public event EventHandler eh_deleteValore;
|
|
/// <summary>
|
|
/// sollevo evento selezione
|
|
/// </summary>
|
|
protected void raiseEvent()
|
|
{
|
|
// sollevo evento nuovo valore...
|
|
if (eh_selezioneValore != null)
|
|
{
|
|
eh_selezioneValore(this, new EventArgs());
|
|
}
|
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
lbtAddNew.DataBind();
|
|
checkInsNew();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// dimensione pagina grid view
|
|
/// </summary>
|
|
public int pageSize
|
|
{
|
|
get
|
|
{
|
|
return grView.PageSize;
|
|
}
|
|
set
|
|
{
|
|
grView.PageSize = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// wrapper traduzione
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(string lemma)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma);
|
|
}
|
|
/// <summary>
|
|
/// richiesta di aggiunta record, tutto a zero!
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbAddNew_Click(object sender, EventArgs e)
|
|
{
|
|
divAddNew.Visible = !divAddNew.Visible;
|
|
checkInsNew();
|
|
}
|
|
protected void btnReset_Click(object sender, EventArgs e)
|
|
{
|
|
resetSelezione();
|
|
}
|
|
/// <summary>
|
|
/// resetto selezione
|
|
/// </summary>
|
|
private void resetSelezione()
|
|
{
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
raiseEvent();
|
|
}
|
|
/// <summary>
|
|
/// matricola selezionata!
|
|
/// </summary>
|
|
public string matrSel
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
answ = grView.SelectedDataKey["Matricola"].ToString();
|
|
}
|
|
catch
|
|
{
|
|
answ = "";
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
raiseEvent();
|
|
}
|
|
|
|
protected void grView_RowDeleted(object sender, GridViewDeletedEventArgs e)
|
|
{
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
if (eh_deleteValore != null)
|
|
{
|
|
eh_deleteValore(this, new EventArgs());
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// verifica matricole...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void txtNewMatr_TextChanged(object sender, EventArgs e)
|
|
{
|
|
checkInsNew();
|
|
}
|
|
|
|
private void checkInsNew()
|
|
{
|
|
bool enableIns = false;
|
|
if (matricola != "")
|
|
{
|
|
// verifico che NON ci sia già la matricola richiesta...
|
|
if (DtProxy.man.taEM.getByMatr(matricola).Rows.Count == 0)
|
|
{
|
|
enableIns = true;
|
|
lblOut.Text = traduci("insIsEnabled");
|
|
lblOut.ForeColor = System.Drawing.Color.Green;
|
|
}
|
|
else
|
|
{
|
|
lblOut.Text = traduci("numMatrExisting");
|
|
lblOut.ForeColor = System.Drawing.Color.Red;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblOut.Text = traduci("numMatrIsEmpty");
|
|
lblOut.ForeColor = System.Drawing.Color.Red;
|
|
}
|
|
lbtAddNew.Visible = enableIns;
|
|
//lblOut.Visible = !enableIns;
|
|
}
|
|
|
|
/// <summary>
|
|
/// matricola richiesta
|
|
/// </summary>
|
|
protected string matricola
|
|
{
|
|
get
|
|
{
|
|
return txtNewMatr.Text.Trim();
|
|
}
|
|
set
|
|
{
|
|
txtNewMatr.Text = value;
|
|
}
|
|
}
|
|
|
|
protected void lbtAddNew_Click(object sender, EventArgs e)
|
|
{
|
|
if (matricola != "")
|
|
{
|
|
// inserisco nuovo record
|
|
DtProxy.man.taEM.insertQuery(matricola, user_std.UtSn.utente, string.Format("{0} - {1}", matricola, memLayer.ML.CRS("defEM02")), "ND", ddlCodFam_addNew.SelectedValue, 0, 0, 0);
|
|
// nascondo add New
|
|
divAddNew.Visible = false;
|
|
// filtro x matricola...
|
|
((Bootstrap)this.Page.Master).searchVal= matricola;
|
|
// update! edit a unico record filtrato (meglio... primo...)
|
|
grView.EditIndex = 0;
|
|
grView.DataBind();
|
|
}
|
|
}
|
|
}
|
|
} |