Inserito detail x item in details view...

This commit is contained in:
Samuele E. Locatelli
2019-10-15 18:37:02 +02:00
parent 72e3bbc16d
commit a7bbbb7ef5
14 changed files with 279 additions and 100 deletions
@@ -0,0 +1,28 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_OOLI_detail.ascx.cs" Inherits="NKC_WF.WebUserControls.cmp_OOLI_detail" %>
<asp:GridView ID="grView" runat="server" AutoGenerateColumns="False" DataKeyNames="ItemID" DataSourceID="ods" AllowPaging="True" CssClass="table table-sm table-condensed table-striped" AllowSorting="True">
<Columns>
<asp:TemplateField HeaderText="Mat" SortExpression="MatID">
<ItemTemplate>
<asp:Label runat="server" ID="lblMatId" Text='<%# matByKey(Eval("MatID")) %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Code" SortExpression="ItemExtCode">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("ItemExtCode") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Desc" SortExpression="ItemDesc">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("ItemDesc") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ods" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="getByOfflineOrder" TypeName="AppData.DS_AppTableAdapters.ItemListTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="hfOffOrderId" DefaultValue="0" Name="OffOrdID" PropertyName="Value" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:HiddenField runat="server" ID="hfOffOrderId" />
@@ -0,0 +1,27 @@
using System;
namespace NKC_WF.WebUserControls
{
public partial class cmp_OOLI_detail : BaseUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public int OffOrdId
{
get
{
int answ = 0;
int.TryParse(hfOffOrderId.Value, out answ);
return answ;
}
set
{
hfOffOrderId.Value = value.ToString();
// faccio udpate svg...
grView.DataBind();
}
}
}
}
+42
View File
@@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <generato automaticamente>
// Codice generato da uno strumento.
//
// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se
// il codice viene rigenerato.
// </generato automaticamente>
//------------------------------------------------------------------------------
namespace NKC_WF.WebUserControls {
public partial class cmp_OOLI_detail {
/// <summary>
/// Controllo grView.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// </remarks>
protected global::System.Web.UI.WebControls.GridView grView;
/// <summary>
/// Controllo ods.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// </remarks>
protected global::System.Web.UI.WebControls.ObjectDataSource ods;
/// <summary>
/// Controllo hfOffOrderId.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// </remarks>
protected global::System.Web.UI.WebControls.HiddenField hfOffOrderId;
}
}
+35 -16
View File
@@ -1,17 +1,36 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_offOrderDetail.ascx.cs" Inherits="NKC_WF.WebUserControls.cmp_offOrderDetail" %>
<asp:DetailsView ID="detView" runat="server" Height="50px" Width="125px" AutoGenerateRows="False" DataKeyNames="OrdID" DataSourceID="ods">
<Fields>
<asp:BoundField DataField="OrdID" HeaderText="OrdID" InsertVisible="False" ReadOnly="True" SortExpression="OrdID" />
<asp:BoundField DataField="CreationDate" HeaderText="CreationDate" SortExpression="CreationDate" />
<asp:BoundField DataField="OrdStatus" HeaderText="OrdStatus" SortExpression="OrdStatus" />
<asp:BoundField DataField="StatusDesc" HeaderText="StatusDesc" ReadOnly="True" SortExpression="StatusDesc" />
<asp:BoundField DataField="NumItems" HeaderText="NumItems" SortExpression="NumItems" />
<asp:BoundField DataField="DrawFilePath" HeaderText="DrawFilePath" SortExpression="DrawFilePath" />
</Fields>
</asp:DetailsView>
<asp:ObjectDataSource ID="ods" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="getByKey" TypeName="AppData.DS_AppTableAdapters.OfflineOrderListTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="hfOffOrderId" DefaultValue="0" Name="OrdId" PropertyName="Value" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:HiddenField runat="server" ID="hfOffOrderId" />
<%@ Register Src="~/WebUserControls/cmp_OOLI_detail.ascx" TagPrefix="uc1" TagName="cmp_OOLI_detail" %>
<div class="border border-info rounded p-2 text-center mb-2">
<asp:FormView runat="server" ID="frmView" DataKeyNames="OrdID" DataSourceID="ods" OnDataBound="frmView_DataBound">
<ItemTemplate>
<div class="row">
<div class="col">
<svg width="710" height="305" viewBox='0 0 1420 710' xmlns='http://www.w3.org/2000/svg' runat="server" id="svgTable">
</svg>
<asp:Label ID="DrawFilePathLabel" runat="server" Text='<%# Eval("DrawFilePath") %>' Visible="false" />
</div>
</div>
<div class="row my-2">
<div class="col">
<asp:LinkButton runat="server" ID="lbtMakeCnc" CssClass="btn btn-success btn-block" Visible='<%# Eval("OrdStatus").ToString()=="0" %>' OnClick="lbtMakeCnc_Click"><i class="fa fa-laptop" aria-hidden="true"></i> MAKE CNC PROG</asp:LinkButton>
</div>
<div class="col">
<asp:LinkButton runat="server" ID="lbtPrintLabels" CssClass="btn btn-info btn-block" Visible='<%# Eval("OrdStatus").ToString()!="0" %>' OnClick="lbtPrintLabels_Click"><i class="fa fa-print" aria-hidden="true"></i> PRINT LABELS</asp:LinkButton>
</div>
</div>
<div class="row">
<div class="col">
<uc1:cmp_OOLI_detail runat="server" id="cmp_OOLI_detail" OffOrdId='<%# Eval("OrdID") %>' />
</div>
</div>
</ItemTemplate>
</asp:FormView>
<asp:ObjectDataSource ID="ods" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="getByKey" TypeName="AppData.DS_AppTableAdapters.OfflineOrderListTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="hfOffOrderId" DefaultValue="0" Name="OrdId" PropertyName="Value" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:HiddenField runat="server" ID="hfOffOrderId" />
</div>
@@ -1,4 +1,7 @@
using System;
using System.IO;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
namespace NKC_WF.WebUserControls
{
@@ -20,7 +23,33 @@ namespace NKC_WF.WebUserControls
set
{
hfOffOrderId.Value = value.ToString();
// faccio udpate svg...
frmView.DataBind();
}
}
protected void frmView_DataBound(object sender, EventArgs e)
{
try
{
Label filePath = (Label)frmView.FindControl("DrawFilePathLabel");
string filename = Server.MapPath(filePath.Text);
string svgRawData = File.ReadAllText(filename);
HtmlGenericControl svgControl = (HtmlGenericControl)frmView.FindControl("svgTable");
svgControl.InnerHtml = svgRawData;
}
catch (Exception exc)
{ }
}
protected void lbtMakeCnc_Click(object sender, EventArgs e)
{
}
protected void lbtPrintLabels_Click(object sender, EventArgs e)
{
}
}
}
+2 -2
View File
@@ -13,13 +13,13 @@ namespace NKC_WF.WebUserControls {
public partial class cmp_offOrderDetail {
/// <summary>
/// Controllo detView.
/// Controllo frmView.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// </remarks>
protected global::System.Web.UI.WebControls.DetailsView detView;
protected global::System.Web.UI.WebControls.FormView frmView;
/// <summary>
/// Controllo ods.
@@ -10,7 +10,6 @@
</div>
<div class="card-body">
<uc1:cmp_offOrderDetail runat="server" ID="cmp_offOrderDetail" />
<asp:GridView ID="grView" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="OrdID" DataSourceID="ods" CssClass="table table-sm table-condensed table-striped" AllowSorting="True" OnSelectedIndexChanged="grView_SelectedIndexChanged">
<SelectedRowStyle CssClass="table-info" />
<EmptyDataTemplate>
@@ -25,9 +24,7 @@
<asp:LinkButton ID="lbtSelect" runat="server" CausesValidation="False" CommandName="Select" ToolTip="Select" CssClass="btn btn-sm btn-primary"><i class="fa fa-search" aria-hidden="true"></i></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<%--<asp:BoundField DataField="OrdID" HeaderText="OrdID" InsertVisible="False" ReadOnly="True" SortExpression="OrdID" />--%>
<asp:BoundField DataField="CreationDate" HeaderText="Created" SortExpression="CreationDate" />
<%--<asp:BoundField DataField="OrdStatus" HeaderText="OrdStatus" SortExpression="OrdStatus" />--%>
<asp:BoundField DataField="StatusDesc" HeaderText="Status" ReadOnly="True" SortExpression="StatusDesc" />
<asp:BoundField DataField="NumItems" HeaderText="# Items" SortExpression="NumItems" />
</Columns>
@@ -1,8 +1,5 @@
using AppData;
using Newtonsoft.Json;
using SteamWare;
using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
namespace NKC_WF.WebUserControls
@@ -23,51 +20,6 @@ namespace NKC_WF.WebUserControls
grView.PageSize = mod_righePag.numRowPag;
}
protected Dictionary<int, string> anagMateriali
{
set
{
string jsonData = JsonConvert.SerializeObject(value);
memLayer.ML.setRSV("anagMateriali", jsonData, 60);
}
get
{
Dictionary<int, string> answ = new Dictionary<int, string>();
//cerco in redis...
string rawData = memLayer.ML.getRSV("anagMateriali");
if (!string.IsNullOrEmpty(rawData))
{
answ = JsonConvert.DeserializeObject<Dictionary<int, string>>(rawData);
}
// sennò nel DB e salvo in redis...
else
{
var tabMat = DataLayer.man.taMat.GetData();
foreach (var item in tabMat)
{
answ.Add(item.MatID, item.MatDesc);
}
// salvo in redis
anagMateriali = answ;
}
// restituisco
return answ;
}
}
public string matByKey(object _matId)
{
string answ = "";
int matId = 0;
int.TryParse(_matId.ToString(), out matId);
try
{
answ = anagMateriali[matId];
}
catch
{ }
return answ;
}
protected void chkToggle_CheckedChanged(object sender, EventArgs e)
{