eDosWeb/safety/Toestellen/ControleForm.aspx.cs
Luc Vandenbroucke ee9fa6be65 first
2018-12-13 09:09:17 +01:00

214 lines
No EOL
8.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
namespace safety.Toestellen
{
public partial class ControleForm : System.Web.UI.Page
{
string Action;
int? RegistryID;
int valueGroupId;
protected void Page_Load(object sender, EventArgs e)
{
int r;
if (Request.Params["Action"] == null) Action = null; else Action = Request.Params["Action"];
if (Request.Params["RegistryID"] == null || !int.TryParse(Request.Params["RegistryID"], out r)) RegistryID = null;
else { RegistryID = r; MakeNewTable(); }
General.setTitle(Master, $"Controle {Action}");
}
void MakeNewTable()
{
Telerik.Web.UI.RadNumericTextBox rnb = null;
Telerik.Web.UI.RadTextBox rtb = null;
Telerik.Web.UI.RadCheckBox rcb = null;
//CheckBox rcb = new CheckBox();
if (RegistryID > 0)
{
dsIDPBWTableAdapters.RegisterKalibratiesTitelTableAdapter rta = new dsIDPBWTableAdapters.RegisterKalibratiesTitelTableAdapter();
dsIDPBWTableAdapters.KalibratieFormTableAdapter kta = new dsIDPBWTableAdapters.KalibratieFormTableAdapter();
dsIDPBW.RegisterKalibratiesTitelDataTable rt = rta.GetData(RegistryID);
dsIDPBW.KalibratieFormDataTable kt = kta.GetData(RegistryID,null);
lRegistryID.Text = RegistryID.ToString();
lOmschrijving.Text = rt[0].OmschrijvingToestel;
lInstructie.Text = rt[0].instructie;
HtmlTableRow r;
HtmlTableCell c;
//Values
foreach (dsIDPBW.KalibratieFormRow x in kt.Rows)
{
r = new HtmlTableRow();
//1
c = new HtmlTableCell("th");
c.InnerText = x.ValueGroupID.ToString();
c.Attributes["class"] = "kalhidden";
r.Cells.Add(c);
//2
c = new HtmlTableCell("th");
c.InnerText = x.ValueNr.ToString();
c.Attributes["class"] = "kaldefault";
r.Cells.Add(c);
//3
c = new HtmlTableCell("th");
c.InnerText = x.ValueName;
c.Attributes["class"] = "kaldefault";
r.Cells.Add(c);
//4
c = new HtmlTableCell();
c.Align = "left";
c.ID = "c_" + x.ValueNr.ToString() + "_" + x.dataType;
switch (x.dataType)
{
case "N":
rnb = new Telerik.Web.UI.RadNumericTextBox();
rnb.ID = "v_" + x.ValueNr.ToString() + "_" + x.dataType;
rnb.NumberFormat.DecimalDigits = 4;
c.Controls.Add(rnb);
break;
case "T":
rtb = new Telerik.Web.UI.RadTextBox();
rtb.ID = "v_" + x.ValueNr.ToString() + "_" + x.dataType;
c.Controls.Add(rtb);
break;
case "B":
rcb = new Telerik.Web.UI.RadCheckBox();
rcb.ID = "v_" + x.ValueNr.ToString() + "_" + x.dataType;
rcb.Text = "ok";
rcb.RenderMode = Telerik.Web.UI.RenderMode.Lightweight;
rcb.AutoPostBack = false;
c.Controls.Add(rcb);
break;
default:
rtb = new Telerik.Web.UI.RadTextBox();
rtb.ID = "v_" + x.ValueNr.ToString() + "_" + x.dataType;
c.Controls.Add(rtb);
break;
}
r.Cells.Add(c);
//5
c = new HtmlTableCell("th");
if (!x.IsUnitNull()) c.InnerText = x.Unit;
c.Attributes["class"] = "kaldefault";
r.Cells.Add(c);
//7
c = new HtmlTableCell("td");
if (!x.IspreviousNull()) c.InnerText = x.previous; else c.InnerHtml = " ";
c.Attributes["class"] = "kaldefault";
r.Cells.Add(c);
KalValues.Rows.Add(r);
//6
c = new HtmlTableCell("td");
c.Attributes["class"] = "kalcomment";
if (!x.IsvalueCommentNull()) c.InnerText = x.valueComment;
r.Cells.Add(c);
}
}
}
protected void Unnamed_Click(object sender, EventArgs e)
{
Telerik.Web.UI.RadTextBox b = (Telerik.Web.UI.RadTextBox)KalForm.FindControl("Beschrijving");
dsIDPBW.TVDataTable tv = new dsIDPBW.TVDataTable();
dsIDPBWTableAdapters.QueriesTableAdapter qta = new dsIDPBWTableAdapters.QueriesTableAdapter();
Telerik.Web.UI.RadNumericTextBox rnb = null;
Telerik.Web.UI.RadTextBox rtb = null;
Telerik.Web.UI.RadCheckBox rcb = null;
CheckBox mcb = null;
for (int r = 2; r < KalValues.Rows.Count; r++)
{
if (KalValues.Rows[r].Cells.Count == 7)
{
double? dv = null;
bool? bv = null;
string sv = null;
int nr = -1;
int grp = -1;
if (int.TryParse(KalValues.Rows[r].Cells[0].InnerText, out grp) && int.TryParse(KalValues.Rows[r].Cells[1].InnerText, out nr))
{
object c = KalValues.Rows[r].Cells[3].Controls[0];
if (c is Telerik.Web.UI.RadNumericTextBox)
{
rnb = c as Telerik.Web.UI.RadNumericTextBox;
dv = rnb.Value;
}
else if (c is Telerik.Web.UI.RadCheckBox)
{
rcb = c as Telerik.Web.UI.RadCheckBox;
bv = rcb.Checked;
}
else if (c is CheckBox)
{
mcb = c as CheckBox;
bv = mcb.Checked;
}
else if (c is Telerik.Web.UI.RadTextBox)
{
rtb = c as Telerik.Web.UI.RadTextBox;
sv = rtb.Text;
}
dsIDPBW.TVRow tr = tv.NewTVRow();
tr.ID_KCO = -1;
tr.ValueNr = nr;
tr.ValueGroupID = grp;
if (bv.HasValue) tr.ValueBool = bv.Value; else tr.SetValueBoolNull();
if (dv.HasValue) tr.ValueNumber = dv.Value; else tr.SetValueNumberNull();
if (sv != null) tr.ValueText = sv; else tr.SetValueTextNull();
tv.Rows.Add(tr);
}
}
} // end for all rows
//
int? pUitvoerdeerid = int.Parse(Uitvoerder_ID.SelectedValue);
string initals = Uitvoerder_ID.SelectedItem.Text;
string url = Certificaat.Text;
int? id_kco = null;
bool? status = cStatus.Checked;
int? vgrp = null;
qta.KalibratieFormInsert(RegistryID, DatumUitvoeren.SelectedDate, pUitvoerdeerid, b.Text, vgrp, status, url, (object)tv);
Response.Redirect("~/Toestellen/Kalibraties.aspx?RegistryID=" + RegistryID.ToString(), true);
}
protected void Unnamed_Click1(object sender, EventArgs e)
{
Response.Redirect("~/Toestellen/Kalibraties.aspx?RegistryID=" + RegistryID.ToString(), true);
}
}
}