Files
MoonPro.net/MP-MAG/WebUserControls/cmp_elencoPedane.ascx.cs
T
2020-12-31 10:35:24 +01:00

203 lines
5.1 KiB
C#

using MagData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MP_MAG.WebUserControls
{
public partial class cmp_elencoPedane : BaseUserControl
{
#region Protected Properties
protected string lastCommand { get; set; } = "";
#endregion Protected Properties
#region Public Properties
/// <summary>
/// AL selezionato
/// </summary>
public string AlSel
{
get
{
return grView.SelectedValue.ToString();
}
}
public int PackListID
{
get
{
int answ = 0;
int.TryParse(hfPackListID.Value, out answ);
return answ;
}
set
{
hfPackListID.Value = $"{value}";
doUpdate();
}
}
#endregion Public Properties
#region Private Methods
private void Cmp_numRow_eh_doRefresh(object sender, EventArgs e)
{
grView.PageSize = cmp_numRow.numRow;
}
private void resetSelezione()
{
doUpdate();
raiseReset();
}
/// <summary>
/// Toggle buttons x add new pedana
/// </summary>
private void toggleAddNew()
{
divAddNew.Visible = !divAddNew.Visible;
lbtShowAdd.Text = divAddNew.Visible ? "Nascondi" : "Aggiungi";
int newNum = 0;
// calcolo quante pedane ho...
try
{
var tabAL = MagDataLayer.man.taEAL.getByPackList(PackListID);
newNum = tabAL.Count + 1;
}
catch
{ }
// descrizione
txtDescr.Text = $"{newNum}";
}
#endregion Private Methods
#region Protected Methods
protected void grView_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandArgument != null)
{
lastCommand = $"{e.CommandArgument}";
}
else
{
lastCommand = "";
}
}
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
{
// esegue stampa...
if (lastCommand == "print")
{
}
// se qualcuno ascolta sollevo evento nuovo valore...
raiseEvent();
}
/// <summary>
/// Creazione nuova pedana
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbkAddNew_Click(object sender, EventArgs e)
{
// FIX ME / TODO: se manca cod opr lo recupera da default
string currCodOpr = "OPR.01";
if (currProdData != null)
{
try
{
currCodOpr = currProdData.CodOpr;
}
catch
{ }
}
int TaraAL = 0;
try
{
TaraAL = SteamWare.memLayer.ML.CRI("TaraAL");
}
catch
{ }
// chiamo insert
MagDataLayer.man.taEAL.insertQuery(DateTime.Today, "PED", currCodOpr, txtDescr.Text.Trim(), PackListID, TaraAL);
// nascondo add...
toggleAddNew();
// update!!!
grView.DataBind();
}
/// <summary>
/// Avvia stampa report pedana
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtPrint_Click(object sender, EventArgs e)
{
// lancio il report x l'elenco pedane + contenuto
}
/// <summary>
/// comando reset
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtReset_Click(object sender, EventArgs e)
{
resetSelezione();
}
/// <summary>
/// Mostra btn add new
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtShowAdd_Click(object sender, EventArgs e)
{
toggleAddNew();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
cmp_numRow.numRow = 10;
grView.PageSize = cmp_numRow.numRow;
divAddNew.Visible = false;
}
cmp_numRow.eh_doRefresh += Cmp_numRow_eh_doRefresh;
}
protected void txtData_TextChanged(object sender, EventArgs e)
{
doUpdate();
}
protected void txtKeyFilt_TextChanged(object sender, EventArgs e)
{
}
#endregion Protected Methods
#region Public Methods
public void doUpdate()
{
grView.SelectedIndex = -1;
grView.DataBind();
}
#endregion Public Methods
}
}