Files
MoonPro.net/MP-ADM/WebUserControls/mod_approvProd.ascx.cs
T
2018-12-20 17:56:45 +01:00

161 lines
4.4 KiB
C#

using SteamWare;
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MP_ADM.WebUserControls
{
public partial class mod_approvProd : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
grView.PageSize = pageSize;
}
}
/// <summary>
/// dimensione pagina
/// </summary>
public int pageSize
{
get
{
int answ = 10;
try
{
answ = Convert.ToInt32(txtPageSize.Text);
}
catch
{ }
return answ;
}
set
{
txtPageSize.Text = value.ToString();
}
}
/// <summary>
/// wrapper traduzione
/// </summary>
/// <param name="lemma"></param>
/// <returns></returns>
public string traduci(object lemma)
{
return user_std.UtSn.Traduci(lemma.ToString());
}
/// <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");
}
else
{
chkbox.ToolTip = traduci("btnDeselAll");
}
foreach (GridViewRow riga in grView.Rows)
{
((CheckBox)riga.FindControl("chkSelect")).Checked = isChecked;
}
}
/// <summary>
/// conferma dati produzione verso As400
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtApprovaProd_Click(object sender, EventArgs e)
{
foreach (GridViewRow riga in grView.Rows)
{
int IdxODL = 0;
DateTime DataRif = DateTime.Now.Date;
if (((CheckBox)riga.FindControl("chkSelect")).Checked && ((CheckBox)riga.FindControl("chkSelect")).Visible)
{
try
{
IdxODL = Convert.ToInt32(((Label)riga.FindControl("lblIdxODL")).Text);
DataRif = Convert.ToDateTime(((Label)riga.FindControl("lblDataRif")).Text);
}
catch
{ }
MapoDb.DataLayer.obj.taAs400.insProdAs400(IdxODL, DataRif);
}
}
grView.DataBind();
}
/// <summary>
/// salvo comando
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbt_Command(object sender, CommandEventArgs e)
{
SteamWare.memLayer.ML.setSessionVal("nextObjCommand", ((LinkButton)sender).CommandArgument);
}
/// <summary>
/// evento selezione riga: salvo tempo e qta nei campi input...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
{
// ricavo i dati selezionati
int IdxODL = 0;
DateTime DataRif = DateTime.Now.Date;
try
{
IdxODL = Convert.ToInt32(grView.SelectedDataKey[0]);
DataRif = Convert.ToDateTime(grView.SelectedDataKey[1]);
}
catch
{ }
// gestione buttons approvazione
string _comando = "";
if (SteamWare.memLayer.ML.isInSessionObject("nextObjCommand"))
{
_comando = SteamWare.memLayer.ML.StringSessionObj("nextObjCommand");
SteamWare.memLayer.ML.emptySessionVal("nextObjCommand");
}
switch (_comando)
{
case "Approva":
MapoDb.DataLayer.obj.taAs400.insProdAs400(IdxODL, DataRif);
break;
default:
break;
}
grView.SelectedIndex = -1;
grView.DataBind();
}
/// <summary>
/// cambio dim pagina
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void txtPageSize_TextChanged(object sender, EventArgs e)
{
grView.PageSize = pageSize;
}
/// <summary>
/// effettua caricamento interventi pending
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtImportPending_Click(object sender, EventArgs e)
{
// forzo rilettura dati da approvare...
MapoDb.DataLayer.obj.taAs400.ImportDati_ElencoConfermeProd();
// update tab...
grView.DataBind();
}
}
}