Files
2017-08-25 10:14:39 +02:00

176 lines
6.9 KiB
C#

using ScheMe_Data;
using SteamWare;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ScheMe
{
public partial class VGen : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// questa è antropo - bia
if (!Page.IsPostBack)
{
// verifico se ci sia richeista x un comando tipo sel/edit
string cmd = Request.QueryString["cmd"];
if (cmd == "new")
{
// creo nuova visita in data odierna
DateTime dataVisita = DateTime.Now;
try
{
dataVisita = Convert.ToDateTime(memLayer.ML.objSessionObj("DataVisita"));
}
catch
{
dataVisita = DateTime.Now;
}
DtProxy.man.taVAC.InsertQuery(IdxPaziente, dataVisita, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
// Redirect senza creazione nuovo!
Response.Redirect("VGen?cmd=sel");
}
// se ho idxRow selezionata imposto
if (memLayer.ML.isInSessionObject("IdxRowVGen"))
{
grView.SelectedIndex = memLayer.ML.IntSessionObj("IdxRowVGen");
memLayer.ML.emptySessionVal("IdxRowVGen");
}
}
}
protected int IdxPaziente
{
get
{
return memLayer.ML.IntSessionObj("IdxPaziente");
}
}
/// <summary>
/// richiesta nuovo record
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbNew_Click(object sender, EventArgs e)
{
grView.ShowFooter = true;
}
/// <summary>
/// elenco colonne del datagrid
/// </summary>
/// <returns></returns>
protected DataColumnCollection colonneObj()
{
DS_Applicazione.VisGenDataTable tabella = new ScheMe_Data.DS_Applicazione.VisGenDataTable();
DataColumnCollection colonne = tabella.Columns;
return colonne;
}
/// <summary>
/// recupera i dati di un nuovo record contenuti nel footer di un gridView;
/// questi devono esses opportunamente nominati (es: txt{0}, dl{0}, ...)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void recuperaFooter(object sender, ObjectDataSourceMethodEventArgs e)
{
//recupero la riga footer...
DataColumnCollection colonne = colonneObj();
string nomeCol;
string tipoColonna = "";
foreach (DataColumn colonna in colonne)
{
nomeCol = colonna.ColumnName;
// cerco un textbox o quello che sia...
if (grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol)) != null)
{
tipoColonna = "textBox";
}
else if (grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol)) != null)
{
tipoColonna = "dropDownList";
}
else if (grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol)) != null)
{
tipoColonna = "checkBox";
}
else if (grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol)) != null)
{
tipoColonna = "selAjax";
}
// in base al tipo salvo negli inputparameters dell'ODS
switch (tipoColonna)
{
case "textBox":
e.InputParameters[nomeCol] = ((TextBox)grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol))).Text;
break;
case "dropDownList":
e.InputParameters[nomeCol] = ((DropDownList)grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol))).SelectedValue;
break;
case "checkBox":
e.InputParameters[nomeCol] = ((CheckBox)grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol))).Checked;
break;
default:
break;
}
tipoColonna = "";
}
// sistemo data...
e.InputParameters["DataVisita"] = Convert.ToDateTime(e.InputParameters["DataVisita"]);
e.InputParameters["Altezza"] = Convert.ToDouble(e.InputParameters["Altezza"]);
e.InputParameters["CirconfVita"] = Convert.ToDouble(e.InputParameters["CirconfVita"]);
e.InputParameters["Peso"] = Convert.ToDouble(e.InputParameters["Peso"]);
e.InputParameters["GrassoTotPerc"] = Convert.ToDouble(e.InputParameters["GrassoTotPerc"]);
e.InputParameters["GrassoViscPerc"] = Convert.ToDouble(e.InputParameters["GrassoViscPerc"]);
e.InputParameters["MassaMagraTotPerc"] = Convert.ToDouble(e.InputParameters["MassaMagraTotPerc"]);
}
/// <summary>
/// inserisce nuovo valore da footer
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lblIns_click(object sender, EventArgs e)
{
// click su inserimento, chiamo il metodo insert dell'ObjectDataSource
ods.Insert();
}
protected void lblCanc_click(object sender, EventArgs e)
{
grView.SelectedIndex = -1;
grView.ShowFooter = false;
grView.DataBind();
}
protected void ods_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
{
grView.ShowFooter = false;
}
/// <summary>
/// verifico se ci sia predicato "sel", se la data sia il valore richiesto e nel caso seleziono
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void grView_RowDataBound(object sender, GridViewRowEventArgs e)
{
string cmd = Request.QueryString["cmd"];
if (cmd == "sel")
{
try
{
if (((DS_Applicazione.VisGenRow)((DataRowView)e.Row.DataItem).Row).DataVisita == Convert.ToDateTime(memLayer.ML.StringSessionObj("DataVisita")))
{
memLayer.ML.setSessionVal("IdxRowVGen", e.Row.DataItemIndex);
Response.Redirect("VGen");
}
}
catch
{ }
}
}
}
}