I have a RadGrid with paging enabled. I select rows using a GridClientSelectColumn, When I click the save button, I want to do something with all the rows that are selected on all pages.
However, it was only looping through the rows on the current page. I tried to fix this by temporarily turning paging off, i.e.,
This did indeed loop through every row on every page. However, every row is appearing as unchecked.
I then noticed that the selected rows are not persisted when I switch pages, so I used this method to persist them on the client side. So I have a Javascript array with the IDs of the selected rows. But is there a way to access that array in btnSave_Click?
It also looks like I can use this method to persist the selected rows on the server side. But then I'd have to select the rows with Command buttons, and I'd prefer not to do that if I don't have to.
However, it was only looping through the rows on the current page. I tried to fix this by temporarily turning paging off, i.e.,
protected
void
btnSave_Click(
object
sender, EventArgs e)
{
RadGrid1.AllowPaging =
false
;
RadGrid1.Rebind();
foreach
(GridDataItem item
in
RadGrid1.Items)
{
CheckBox chk = (CheckBox)item[
"Select"
].Controls[0];
if
(chk.Checked)
{
...
}
}
RadGrid1.AllowPaging =
true
;
RadGrid1.Rebind();
}
This did indeed loop through every row on every page. However, every row is appearing as unchecked.
I then noticed that the selected rows are not persisted when I switch pages, so I used this method to persist them on the client side. So I have a Javascript array with the IDs of the selected rows. But is there a way to access that array in btnSave_Click?
It also looks like I can use this method to persist the selected rows on the server side. But then I'd have to select the rows with Command buttons, and I'd prefer not to do that if I don't have to.
17 Answers, 1 is accepted
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 26 Apr 2013, 08:22 AM
Hello,
Thanks,
Jayesh Goyani
<
MasterTableView
DataKeyNames
=
"ID"
>
<
Columns
>
..............
...............
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
<
asp:CheckBox
ID
=
"CheckBox1"
runat
=
"server"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
<
asp:Button
ID
=
"Button1"
runat
=
"server"
Text
=
"check serverside"
OnClick
=
"Button1_Click"
/>
<
asp:HiddenField
ID
=
"HiddenField1"
runat
=
"server"
/>
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = e.Item as GridDataItem;
CheckBox CheckBox1 = item.FindControl("CheckBox1") as CheckBox;
CheckBox1.Attributes.Add("onclick", "chkClick(this,'" + item.GetDataKeyValue("ID").ToString() + "');");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string strSelectedIDCSV = HiddenField1.Value;
// you can get here CSV of ID of selected checkbox
}
function
chkClick(obj, id) {
AddorRemoveIdInHiddenField($(
"#HiddenField1"
).get(0), id, obj.checked);
}
function
AddorRemoveIdInHiddenField(hf, id, IsAdd) {
if
(hf.value ==
""
) {
hf.value =
","
;
}
if
(IsAdd ==
true
) {
if
(hf.value.indexOf(
","
+ id +
","
) == -1) {
hf.value = hf.value + id +
","
;
}
}
else
if
(IsAdd ==
false
) {
if
(hf.value.indexOf(
","
+ id +
","
) >= 0) {
hf.value = hf.value.replace(
","
+ id +
","
,
","
);
}
}
}
Thanks,
Jayesh Goyani
0
Hunter
Top achievements
Rank 1
answered on 26 Apr 2013, 01:55 PM
Thanks, Jayesh. This works great!
0
Hunter
Top achievements
Rank 1
answered on 26 Apr 2013, 05:23 PM
Actually, one question, Jayesh. How are you persisting the checkboxes on the client side? Like if you check a box on page 1, go to page 2, and go back to page 1, what makes the checkbox appear as checked?
I'm doing something like the below. The bold line in RadGrid1_RowCreated is what selects a row that had been previously selected. It worked when I was using a GridClientSelectColumn, but it doesn't work with your solution. I need to find a way to make it find the checkbox for that row and check it.
I'm doing something like the below. The bold line in RadGrid1_RowCreated is what selects a row that had been previously selected. It worked when I was using a GridClientSelectColumn, but it doesn't work with your solution. I need to find a way to make it find the checkbox for that row and check it.
<script type=
"text/javascript"
>
var
selected = {};
function
RadGrid1_RowSelected(sender, args) {
var
mailID = args.getDataKeyValue(
"MailID"
);
if
(!selected[mailID]) {
selected[mailID] =
true
;
}
}
function
RadGrid1_RowDeselected(sender, args) {
var
mailID = args.getDataKeyValue(
"MailID"
);
if
(selected[mailID]) {
selected[mailID] =
null
;
}
}
function
RadGrid1_RowCreated(sender, args) {
var
mailID = args.getDataKeyValue(
"MailID"
);
if
(selected[mailID]) {
//this doesn't work anymore
args.get_gridDataItem().set_selected(
true
);
}
}
function
GridCreated(sender, eventArgs) {
var
masterTable = sender.get_masterTableView(),
headerCheckBox = $telerik.$(masterTable.HeaderRow).find(
":checkbox"
)[0];
if
(headerCheckBox) {
headerCheckBox.checked = masterTable.get_selectedItems().length == masterTable.get_pageSize();
}
}
</script>
0
Jayesh Goyani
Top achievements
Rank 2
answered on 26 Apr 2013, 06:44 PM
Hello,
Please try with below code snippet
Let me know if any concern.
Thanks,
Jayesh Goyani
Please try with below code snippet
.
<script type=
"text/javascript"
>
var
selected = {};
function
RadGrid1_RowSelected(sender, args) {
var
mailID = args.getDataKeyValue(
"ID"
);
AddorRemoveIdInHiddenField($(
"#HiddenField1"
).get(0), mailID,
true
);
}
function
RadGrid1_RowDeselected(sender, args) {
var
mailID = args.getDataKeyValue(
"ID"
);
AddorRemoveIdInHiddenField($(
"#HiddenField1"
).get(0), mailID,
false
);
}
function
RadGrid1_RowCreated(sender, args) {
var
mailID = args.getDataKeyValue(
"ID"
);
var
hf = $(
"#HiddenField1"
).get(0);
if
(hf.value.indexOf(
","
+ mailID +
","
) >= 0) {
args.get_gridDataItem().set_selected(
true
);
}
}
function
GridCreated(sender, eventArgs) {
var
masterTable = sender.get_masterTableView(),
headerCheckBox = $telerik.$(masterTable.HeaderRow).find(
":checkbox"
)[0];
if
(headerCheckBox) {
headerCheckBox.checked = masterTable.get_selectedItems().length == masterTable.get_pageSize();
}
}
function
AddorRemoveIdInHiddenField(hf, id, IsAdd) {
if
(hf.value ==
""
) {
hf.value =
","
;
}
if
(IsAdd ==
true
) {
if
(hf.value.indexOf(
","
+ id +
","
) == -1) {
hf.value = hf.value + id +
","
;
}
}
else
if
(IsAdd ==
false
) {
if
(hf.value.indexOf(
","
+ id +
","
) >= 0) {
hf.value = hf.value.replace(
","
+ id +
","
,
","
);
}
}
}
</script>
<div>
<telerik:RadScriptManager ID=
"RadScriptManager1"
runat=
"server"
>
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID=
"RadAjaxManager1"
runat=
"server"
>
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID=
"RadGrid1"
>
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID=
"RadGrid1"
LoadingPanelID=
"RadAjaxLoadingPanel1"
/>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID=
"RadAjaxLoadingPanel1"
runat=
"server"
>
</telerik:RadAjaxLoadingPanel>
<telerik:RadWindowManager ID=
"RadWindowManager1"
runat=
"server"
>
</telerik:RadWindowManager>
<telerik:RadGrid ID=
"RadGrid1"
runat=
"server"
AutoGenerateColumns=
"false"
OnNeedDataSource=
"RadGrid1_NeedDataSource"
AllowMultiRowSelection=
"true"
PageSize=
"3"
AllowPaging=
"true"
>
<MasterTableView CommandItemDisplay=
"Top"
DataKeyNames=
"ID"
ClientDataKeyNames=
"ID"
>
<Columns>
<telerik:GridClientSelectColumn>
</telerik:GridClientSelectColumn>
<telerik:GridBoundColumn DataField=
"ID"
UniqueName=
"ID"
HeaderText=
"ID"
>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField=
"Name"
UniqueName=
"Name"
HeaderText=
"Name"
>
</telerik:GridBoundColumn>
<telerik:GridEditCommandColumn>
</telerik:GridEditCommandColumn>
</Columns>
</MasterTableView>
<ClientSettings AllowDragToGroup=
"true"
>
<Selecting AllowRowSelect=
"true"
/>
<ClientEvents OnRowCreated=
"RadGrid1_RowCreated"
OnRowSelected=
"RadGrid1_RowSelected"
OnRowDeselected=
"RadGrid1_RowDeselected"
OnGridCreated=
"GridCreated"
/>
</ClientSettings>
</telerik:RadGrid>
<br />
<asp:Button ID=
"Button1"
runat=
"server"
Text=
"Button"
OnClick=
"Button1_Click"
/>
<asp:HiddenField ID=
"HiddenField1"
runat=
"server"
/>
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
dynamic data =
new
[] {
new
{ ID = 1, Name =
"aaa"
},
new
{ ID = 2, Name =
"bbb"
},
new
{ ID = 3, Name =
"ccc"
},
new
{ ID = 4, Name =
"ddd"
},
new
{ ID = 5, Name =
"eee"
},
new
{ ID = 6, Name =
"aaa"
},
new
{ ID = 7, Name =
"bbb"
},
new
{ ID = 8, Name =
"ccc"
},
new
{ ID = 9, Name =
"ddd"
},
new
{ ID = 10, Name =
"eee"
}
};
RadGrid1.DataSource = data;
}
Let me know if any concern.
Thanks,
Jayesh Goyani
0
Hunter
Top achievements
Rank 1
answered on 29 Apr 2013, 05:31 PM
Works great, thanks!
0
rajat
Top achievements
Rank 1
answered on 15 Apr 2014, 10:17 AM
Hi Jayesh Goyani,
Please tell me how can I retrieve ids of selected rows in case of hierarchical grid.
Like if I selects a parent row and child rows of other parent row on different page then how can I find all selected rows as well as retrieve their ids.
I guess the whole procedure should follow the persistence concept when selecting and retrieving ids of rows.
Please tell me how can I retrieve ids of selected rows in case of hierarchical grid.
Like if I selects a parent row and child rows of other parent row on different page then how can I find all selected rows as well as retrieve their ids.
I guess the whole procedure should follow the persistence concept when selecting and retrieving ids of rows.
0
vikas
Top achievements
Rank 1
answered on 15 Apr 2014, 10:45 AM
Hi Jayesh Goyani,
I have the same query that rajat asked. Please help me with this.
Please tell me how can I retrieve ids of selected rows in case of hierarchical grid.
Like if I selects a parent row and child rows of other parent row on different page then how can I find all selected rows as well as retrieve their ids.
I guess the whole procedure should follow the persistence concept when selecting and retrieving ids of rows.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 15 Apr 2014, 12:23 PM
Hello,
Can you please provide your sample (dummy) data?
I will provide solution based on your data.
Thanks,
Jayesh Goyani
Can you please provide your sample (dummy) data?
I will provide solution based on your data.
Thanks,
Jayesh Goyani
0
vikas
Top achievements
Rank 1
answered on 16 Apr 2014, 05:06 AM
Thanks for replying Jayesh.
Question is same:
Please tell me how can I retrieve ids of selected rows in case of hierarchical grid.
Like if I selects a parent row and child rows of other parent row on different page then how can I find all selected rows as well as retrieve their ids.
I guess the whole procedure should follow the persistence concept when selecting and retrieving ids of rows.
Here is my code:
Code Behind:
I am also trying to apply custom paging using needdatasource in it as it will make my grid process faster.
Please do consider this as well.
Question is same:
Please tell me how can I retrieve ids of selected rows in case of hierarchical grid.
Like if I selects a parent row and child rows of other parent row on different page then how can I find all selected rows as well as retrieve their ids.
I guess the whole procedure should follow the persistence concept when selecting and retrieving ids of rows.
Here is my code:
01.
<
script
type
=
"text/javascript"
>
02.
var selected = {};
03.
function RadGrid1_RowSelected(sender, args) {
04.
var mailID = args.getDataKeyValue("MasterItemID");
05.
AddorRemoveIdInHiddenField($("#HiddenField1").get(0), mailID, true);
06.
}
07.
function RadGrid1_RowDeselected(sender, args) {
08.
var mailID = args.getDataKeyValue("MasterItemID");
09.
AddorRemoveIdInHiddenField($("#HiddenField1").get(0), mailID, false);
10.
}
11.
function RadGrid1_RowCreated(sender, args) {
12.
var mailID = args.getDataKeyValue("MasterItemID");
13.
var hf = $("#HiddenField1").get(0);
14.
if (hf.value.indexOf("," + mailID + ",") >= 0) {
15.
args.get_gridDataItem().set_selected(true);
16.
}
17.
}
18.
function GridCreated(sender, eventArgs) {
19.
var masterTable = sender.get_masterTableView(),
20.
headerCheckBox = $telerik.$(masterTable.HeaderRow).find(":checkbox")[0];
21.
22.
if (headerCheckBox) {
23.
headerCheckBox.checked = masterTable.get_selectedItems().length == masterTable.get_pageSize();
24.
}
25.
}
26.
function AddorRemoveIdInHiddenField(hf, id, IsAdd) {
27.
28.
if (hf.value == "") {
29.
hf.value = " ";
30.
}
31.
32.
if (IsAdd == true) {
33.
if (hf.value.indexOf("," + id + ",") == -1) {
34.
hf.value = hf.value + id + ",";
35.
}
36.
}
37.
else if (IsAdd == false) {
38.
if (hf.value.indexOf("," + id + ",") >= 0) {
39.
hf.value = hf.value.replace("," + id + ",", ",");
40.
}
41.
}
42.
43.
}
44.
</
script
>
<
div
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
>
</
asp:ScriptManager
>
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel2"
runat
=
"server"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
Width
=
"95%"
ShowStatusBar
=
"true"
AutoGenerateColumns
=
"False"
AllowSorting
=
"True"
AllowMultiRowSelection
=
"True"
AllowPaging
=
"True"
ShowGroupPanel
=
"true"
AllowFilteringByColumn
=
"true"
AllowCustomPaging
=
"True"
VirtualItemCount
=
"100000"
OnDetailTableDataBind
=
"RadGrid1_DetailTableDataBind"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
OnPreRender
=
"RadGrid1_PreRender"
>
<
MasterTableView
Width
=
"100%"
DataKeyNames
=
"CustomerID"
AllowMultiColumnSorting
=
"True"
HierarchyLoadMode
=
"ServerBind"
>
<
DetailTables
>
<
telerik:GridTableView
Name
=
"Orders"
Width
=
"100%"
AutoGenerateColumns
=
"False"
AllowPaging
=
"true"
>
<
Columns
>
<
telerik:GridClientSelectColumn
UniqueName
=
"Checkbox2"
/>
<
telerik:GridBoundColumn
SortExpression
=
"OrderID"
HeaderText
=
"OrderID"
HeaderButtonType
=
"TextButton"
DataField
=
"OrderID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"OrderDate"
HeaderText
=
"Date Ordered"
HeaderButtonType
=
"TextButton"
DataField
=
"OrderDate"
UniqueName
=
"OrderDate"
DataFormatString
=
"{0:D}"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"Freight"
HeaderText
=
"Freight"
HeaderButtonType
=
"TextButton"
DataField
=
"Freight"
UniqueName
=
"Freight"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridClientSelectColumn
UniqueName
=
"Checkbox1"
/>
<
telerik:GridBoundColumn
SortExpression
=
"CustomerID"
HeaderText
=
"CustomerID"
HeaderButtonType
=
"TextButton"
DataField
=
"CustomerID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"ContactName"
HeaderText
=
"Contact Name"
HeaderButtonType
=
"TextButton"
DataField
=
"ContactName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"CompanyName"
HeaderText
=
"Company"
HeaderButtonType
=
"TextButton"
DataField
=
"CompanyName"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"true"
/>
<
ClientEvents
OnRowCreated
=
"RadGrid1_RowCreated"
OnRowSelected
=
"RadGrid1_RowSelected"
OnRowDeselected
=
"RadGrid1_RowDeselected"
OnGridCreated
=
"GridCreated"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
<
br
/>
<
br
/>
<
telerik:radbutton
id
=
"RadButton1"
runat
=
"server"
text
=
"Fetch ID"
OnClick
=
"RadButton1_Click"
>
</
telerik:radbutton
>
<
asp:HiddenField
ID
=
"HiddenField1"
runat
=
"server"
/>
<
br
/>
<
br
/>
<
telerik:RadTextBox
ID
=
"FirstNameTextBox"
width
=
"100%"
AutoCompleteType
=
"FirstName"
runat
=
"server"
Label
=
"Selected Row ID:"
/>
</
telerik:RadAjaxPanel
>
</
div
>
Code Behind:
Protected Sub RadGrid1_NeedDataSource(source As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs)
If Not e.IsFromDetailTable Then
Dim startRowIndex As Integer = If((ShouldApplySortFilterOrGroup()), 0, RadGrid1.CurrentPageIndex * RadGrid1.PageSize)
Dim maximumRows As Integer = If((ShouldApplySortFilterOrGroup()), SelectCount(), RadGrid1.PageSize)
RadGrid1.AllowCustomPaging = Not ShouldApplySortFilterOrGroup()
RadGrid1.DataSource = GetDataTable("SELECT * FROM Customers")
End If
End Sub
Public Function SelectCount() As Integer
Return _maxItems
End Function
Private isGrouping As Boolean = False
Const _maxItems As Integer = 100000
Protected Sub RadGrid1_GroupsChanging(source As Object, e As GridGroupsChangingEventArgs)
isGrouping = True
If e.Action = GridGroupsChangingAction.Ungroup AndAlso RadGrid1.CurrentPageIndex > 0 Then
isGrouping = False
End If
End Sub
Public Function ShouldApplySortFilterOrGroup() As Boolean
Return RadGrid1.MasterTableView.FilterExpression <> "" OrElse (RadGrid1.MasterTableView.GroupByExpressions.Count > 0 OrElse isGrouping) OrElse RadGrid1.MasterTableView.SortExpressions.Count > 0
End Function
Protected Sub RadGrid_ColumnCreated(sender As Object, e As GridColumnCreatedEventArgs)
If TypeOf e.Column Is GridBoundColumn Then
TryCast(e.Column, GridBoundColumn).FilterControlWidth = Unit.Pixel(140)
End If
End Sub
Protected Sub RadGrid1_DetailTableDataBind(source As Object, e As Telerik.Web.UI.GridDetailTableDataBindEventArgs)
Dim dataItem As GridDataItem = DirectCast(e.DetailTableView.ParentItem, GridDataItem)
Select Case e.DetailTableView.Name
Case "Orders"
Dim CustomerID As String = dataItem.GetDataKeyValue("CustomerID").ToString()
e.DetailTableView.DataSource = GetDataTable("SELECT * FROM Orders WHERE CustomerID = '" & CustomerID & "'")
End Select
End Sub
Public Function GetDataTable(query As String) As DataTable
Dim ConnString As String = ConfigurationManager.ConnectionStrings("NorthwindConnectionString").ConnectionString
Dim conn As New SqlConnection(ConnString)
Dim adapter As New SqlDataAdapter()
adapter.SelectCommand = New SqlCommand(query, conn)
Dim myDataTable As New DataTable()
conn.Open()
Try
adapter.Fill(myDataTable)
Finally
conn.Close()
End Try
Return myDataTable
End Function
Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As EventArgs) Handles RadGrid1.PreRender
If Not Page.IsPostBack Then
RadGrid1.MasterTableView.Rebind()
'RadGrid1.MasterTableView.Items(0).Expanded = True
'RadGrid1.MasterTableView.Items(0).ChildItem.NestedTableViews(0).Items(0).Expanded = True
End If
HideExpandColumnRecursive(RadGrid1.MasterTableView)
End Sub
Public Sub HideExpandColumnRecursive(ByVal tableview As GridTableView)
Dim item As GridItem
If (tableview.Controls.Count > 0) Then
For Each item In tableview.Controls(0).Controls
If TypeOf item Is GridNestedViewItem Then
Dim nestedviewitem As GridNestedViewItem = CType(item, GridNestedViewItem)
If nestedviewitem.NestedTableViews(0).Items.Count = 0 Then
Dim cell As TableCell = nestedviewitem.NestedTableViews(0).ParentItem("expandcolumn")
cell.Controls(0).Visible = False
nestedviewitem.Visible = False
Else
hideexpandcolumnrecursive(nestedviewitem.NestedTableViews(0))
End If
End If
Next item
End If
End Sub
Protected Sub RadButton1_Click(sender As Object, e As System.EventArgs) Handles RadButton1.Click
Dim xyz As String
xyz = HiddenField1.Value
FirstNameTextBox.Text = xyz
End Sub
I am also trying to apply custom paging using needdatasource in it as it will make my grid process faster.
Please do consider this as well.
0
Hello Vikas,
You can implement the approach demonstrated in the following code-library to achieve the requested functionality:
http://www.telerik.com/support/code-library/get-selected-items-through-all-pages
Hope this helps.
Regards,
Eyup
Telerik
You can implement the approach demonstrated in the following code-library to achieve the requested functionality:
http://www.telerik.com/support/code-library/get-selected-items-through-all-pages
Hope this helps.
Regards,
Eyup
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
vikas
Top achievements
Rank 1
answered on 18 Apr 2014, 09:43 AM
Hi Eyup,
Many thanks for sample code. I used your sample code into my code for Hierarchical grid or Nested grid (till level two).
But the problem is it is not persisting selected row's value in nested grid and it is losing its selection when traversed to different page.
I want to select both parent and child rows simultaneously and requiring the column name of selected rows.
For instance if I selects a parent row and child rows of other parent row on different page then all selected rows should hold their selection.
My source code is given in previous post. Please help me with this.
Thanks
Vikas
Many thanks for sample code. I used your sample code into my code for Hierarchical grid or Nested grid (till level two).
But the problem is it is not persisting selected row's value in nested grid and it is losing its selection when traversed to different page.
I want to select both parent and child rows simultaneously and requiring the column name of selected rows.
For instance if I selects a parent row and child rows of other parent row on different page then all selected rows should hold their selection.
My source code is given in previous post. Please help me with this.
Thanks
Vikas
0
Jayesh Goyani
Top achievements
Rank 2
answered on 21 Apr 2014, 05:48 PM
Hello,
Please try with the below code snippet.
This code is not perfect but try with the above code snippet. There is one minor issue in above code i will try to resolved this issue later.
Thanks,
Jayesh Goyani
Please try with the below code snippet.
<script type=
"text/javascript"
>
var
selected = {};
function
RadGrid1_RowSelected(sender, args) {
var
gridtype = args.get_tableView().get_name() ==
"Parent"
?
"p"
:
"c"
;
var
mailID = args.get_itemIndexHierarchical() +
"-"
+ gridtype +
"-"
+ args.getDataKeyValue(
"ID"
);
AddorRemoveIdInHiddenField($(
"#HiddenField1"
).get(0), mailID,
true
);
}
function
RadGrid1_RowDeselected(sender, args) {
var
gridtype = args.get_tableView().get_name() ==
"Parent"
?
"p"
:
"c"
;
var
mailID = args.get_itemIndexHierarchical() +
"-"
+ gridtype +
"-"
+ args.getDataKeyValue(
"ID"
);
AddorRemoveIdInHiddenField($(
"#HiddenField1"
).get(0), mailID,
false
);
}
function
RadGrid1_RowCreated(sender, args) {
var
gridtype = args.get_tableView().get_name() ==
"Parent"
?
"p"
:
"c"
;
var
mailID = args.get_itemIndexHierarchical() +
"-"
+ gridtype +
"-"
+ args.getDataKeyValue(
"ID"
);
var
hf = $(
"#HiddenField1"
).get(0);
if
(hf.value.indexOf(
","
+ mailID +
","
) >= 0) {
args.get_gridDataItem().set_selected(
true
);
}
}
function
GridCreated(sender, eventArgs) {
var
masterTable = sender.get_masterTableView(),
headerCheckBox = $telerik.$(masterTable.HeaderRow).find(
":checkbox"
)[0];
if
(headerCheckBox) {
headerCheckBox.checked = masterTable.get_selectedItems().length == masterTable.get_pageSize();
}
}
function
AddorRemoveIdInHiddenField(hf, id, IsAdd) {
if
(hf.value ==
""
) {
hf.value =
","
;
}
if
(IsAdd ==
true
) {
if
(hf.value.indexOf(
","
+ id +
","
) == -1) {
hf.value = hf.value + id +
","
;
}
}
else
if
(IsAdd ==
false
) {
if
(hf.value.indexOf(
","
+ id +
","
) >= 0) {
hf.value = hf.value.replace(
","
+ id +
","
,
","
);
}
}
}
</script>
This code is not perfect but try with the above code snippet. There is one minor issue in above code i will try to resolved this issue later.
Thanks,
Jayesh Goyani
0
vikas
Top achievements
Rank 1
answered on 01 May 2014, 05:22 AM
Hi Jayesh,
I applied your above code in my sample but persistence among selected rows on different pagination is not working in it. May be something is contradicting it or I don't know.
I am attaching my code sample here and please let me know what is wrong in it regarding persistence. It would be great help.
Thanks in advance.
Design view
code behind
I applied your above code in my sample but persistence among selected rows on different pagination is not working in it. May be something is contradicting it or I don't know.
I am attaching my code sample here and please let me know what is wrong in it regarding persistence. It would be great help.
Thanks in advance.
Design view
<%@ Page Language="vb" AutoEventWireup="false" EnableSessionState="True" CodeBehind="SelectItemQuotes.aspx.vb" Inherits="ePontiV5.SelectItemQuotes" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
>Select Items</
title
>
<
link
href
=
"Styles/ePontiV5.css"
type
=
"text/css"
rel
=
"stylesheet"
/>
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
language
=
"javascript"
>
window.onresize = function () {
var w = window.innerWidth;
var h = window.innerHeight;
document.getElementById('<%=winResizedHeight.ClientID%>').value = h - 110;
var grid;
grid = $find("<%= SelectItemGrid.ClientID %>");
grid.get_element().style.height = document.getElementById('<%=winResizedHeight.ClientID%>').value + "px";
grid.repaint();
}
function SelectChildItems(headerCheckBox) {
for (var i = 0; i < $find("SelectItemGrid").get_detailTables().length; i++) {
for (var j = 0; j < $find("SelectItemGrid").get_detailTables()[i].get_dataItems().length; j++) {
$find("SelectItemGrid").get_detailTables()[i].get_dataItems()[j].set_selected(true);
}
headerCheckBox.checked = true;
}
}
function newProduct() {
var Browsername = "<%=Request.Browser.Browser %>";
if (Browsername == "Safari") {
window.open("PartInfo.aspx?GrouptypeID=00d5aceb-593c-409a-8158-4b3afda896c7", "", "top=0,width=900px,height=420px,toolbar=no,fullscreen=no,titlebar=no,scrollbars=1,resizable=yes,menubar=no,status=no,location=no,directories=no");
return false;
}
else {
// alert(Browsername);
window.open("PartInfo.aspx?GrouptypeID=00d5aceb-593c-409a-8158-4b3afda896c7", "", "top=0,width=900px,height=480px,toolbar=no,fullscreen=no,titlebar=no,scrollbars=1,resizable=yes,menubar=no,status=no,location=no,directories=no");
return false;
}
}
function RefreshProductsGrid() {
var masterTable = $find("<%= SelectItemGrid.ClientID %>").get_masterTableView();
masterTable.rebind();
}
function RefreshTasksGrid() {
var masterTable = $find("<%= SelectItemGrid.ClientID %>").get_masterTableView();
masterTable.rebind();
}
function onToolBarClientButtonClicking(sender, args) {
var button = args.get_item();
if (button.get_commandName() == "DeleteSelected") {
//args.set_cancel(!confirm('Delete all selected cost code?'));
}
else if (button.get_commandName() == "AddNewPart") {
newProduct();
return false;
}
}
function RadGridManufacturer_RowDeselected(sender, args) {
var ManufacturerID = args.getDataKeyValue("ManufacturerID");
SelectedID1 = document.getElementById("<%=SelManufacturerIDs.ClientID%>").value.toString(); //.split(",");
// if (SelectedID1[ManufacturerID]) {
// SelectedID1[ManufacturerID] = null;
// }
if (SelectedID1.search(ManufacturerID) != -1) {
SelectedID1 = SelectedID1.replace("," + ManufacturerID + "", "");
SelectedID1 = SelectedID1.replace("" + ManufacturerID + ",", "");
SelectedID1 = SelectedID1.replace("" + ManufacturerID + "", "");
}
document.getElementById("<%=SelManufacturerIDs.ClientID%>").value = SelectedID1;
//alert(document.getElementById("<%=SelManufacturerIDs.ClientID%>").value);
RefreshProductsGrid();
}
var SelectedID1 = "";
function RadGridManufacturer_RowSelected(sender, args) {
var ManufacturerID = args.getDataKeyValue("ManufacturerID");
// if (!SelectedID1[ManufacturerID]) {
// //SelectedID1[ManufacturerID] = true;
// if (SelectedID1 == "")
// SelectedID1 = "" + ManufacturerID + "";
// else
// SelectedID1 = document.getElementById("<%=SelManufacturerIDs.ClientID%>").value + "," + ManufacturerID + "";
//
// }
var dataItems1 = $find('<%=RadGridManufacturer.ClientID %>').get_masterTableView().get_selectedItems();
for (var i = 0, j = dataItems1.length; i <
j
; i++) {
var
item
=
dataItems1
[i];
document.getElementById("<%=SelManufacturerIDs.ClientID%>").value = document.getElementById("<%=SelManufacturerIDs.ClientID%>").value + "," + item.getDataKeyValue("ManufacturerID");
//alert(document.getElementById("<%=SelManufacturerIDs.ClientID%>").value);
}
//document.getElementById("<%=SelManufacturerIDs.ClientID%>").value = SelectedID1;
//alert(document.getElementById("<%=SelManufacturerIDs.ClientID%>").value);
RefreshProductsGrid();
}
</
script
>
</
telerik:RadCodeBlock
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<%--<
telerik:RadButton
ID
=
"Button1"
runat
=
"server"
Text
=
"Show Selected"
AutoPostBack
=
"True"
OnClientClicked
=
"saveSelected"
/>--%>
<
asp:HiddenField
runat
=
"server"
ID
=
"hdnShapeID"
/>
<
asp:HiddenField
runat
=
"server"
ID
=
"SelManufacturerIDs"
Value
=
"''"
/>
<
asp:HiddenField
runat
=
"server"
ID
=
"hdnSelectItemGridPageCount"
Value
=
"1"
/>
<
asp:HiddenField
runat
=
"server"
ID
=
"winResizedHeight"
Value
=
"400"
/>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
var selected = {};
if (!Object.keys) {
Object.keys = function (obj) {
var keys = [], k;
for (k in obj) {
if (Object.prototype.hasOwnProperty.call(obj, k)) {
keys.push(k);
}
}
return keys;
};
}
function onRowSelected(sender, args) {
var gridtype = args.get_tableView().get_name() == "Parent" ? "p" : "c";
var orderID = "";
if (args.get_tableView().get_name().toString() == "Parts")
orderID = args.get_itemIndexHierarchical() + "-" + gridtype + "-" + args.getDataKeyValue("ID");
else
orderID = args.get_itemIndexHierarchical() + "-" + gridtype + "-" + args.getDataKeyValue("ID1");
if (!selected[orderID]) {
selected[orderID] = true;
}
}
function onRowDeselected(sender, args) {
var gridtype = args.get_tableView().get_name() == "Parent" ? "p" : "c";
var orderID = "";
if (args.get_tableView().get_name().toString() == "Parts")
orderID = args.get_itemIndexHierarchical() + "-" + gridtype + "-" + args.getDataKeyValue("ID");
else
orderID = args.get_itemIndexHierarchical() + "-" + gridtype + "-" + args.getDataKeyValue("ID1");
if (selected[orderID]) {
delete selected[orderID];
}
}
function onRowCreated(sender, args) {
var gridtype = args.get_tableView().get_name() == "Parent" ? "p" : "c";
var orderID = "";
if (args.get_tableView().get_name().toString() == "Parts")
orderID = args.get_itemIndexHierarchical() + "-" + gridtype + "-" + args.getDataKeyValue("ID");
else
orderID = args.get_itemIndexHierarchical() + "-" + gridtype + "-" + args.getDataKeyValue("ID1");
if (selected[orderID]) {
args.get_gridDataItem().set_selected(true);
}
}
function gridCreated(sender, eventArgs) {
var masterTable = sender.get_masterTableView(),
headerCheckBox = $telerik.$(masterTable.HeaderRow).find(":checkbox")[0];
if (headerCheckBox) {
// headerCheckBox.checked = masterTable.get_selectedItems().length == masterTable.get_dataItems().length;
headerCheckBox.checked = masterTable.get_selectedItems().length == masterTable.get_pageSize();
}
}
function saveSelected() {
$get("<%= HiddenField1.ClientID %>").value = Object.keys(selected).join();
}
</
script
>
</
telerik:RadScriptBlock
>
<
div
runat
=
"server"
id
=
"ScriptTag"
></
div
>
<
telerik:RadSkinManager
ID
=
"RadSkinManager1"
runat
=
"server"
ShowChooser
=
"false"
Skin
=
"Black"
>
<
TargetControls
>
</
TargetControls
>
</
telerik:RadSkinManager
>
<
telerik:RadAjaxLoadingPanel
runat
=
"server"
ID
=
"RadAjaxLoadingPanel2"
></
telerik:RadAjaxLoadingPanel
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
></
telerik:RadAjaxLoadingPanel
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"SelectItemGrid"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"SelectItemGrid"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGridManufacturer"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGridManufacturer"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadFormDecorator
ID
=
"RadFormDecorator1"
runat
=
"server"
DecoratedControls
=
"Zone"
/>
<
div
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
/>
<
table
width
=
"1100px"
cellpadding
=
"0"
cellspacing
=
"0"
align
=
"center"
>
<
tr
>
<
td
align
=
"left"
valign
=
"top"
>
<
table
width
=
"100%"
cellpadding
=
"0"
cellspacing
=
"0"
>
<
tr
>
<
td
height
=
"50"
width
=
"5"
></
td
>
<
td
class
=
"txtSubFormHeader"
>Select Items</
td
>
<
td
width
=
"30"
class
=
"btnSections"
>
<
asp:ImageButton
ID
=
"NewProduct"
runat
=
"server"
Height
=
"20"
ImageUrl
=
"~/Images/NewPart.png"
Visible
=
"false"
OnClientClick
=
"newProduct(); return false;"
/></
td
>
<
td
width
=
"30"
class
=
"btnSections"
>
<
asp:ImageButton
ID
=
"AddItem"
runat
=
"server"
ImageUrl
=
"~/Images/UpdateButton.png"
OnClientClick
=
"javascript:getSelected();"
ToolTip
=
"Add selected items"
Height
=
"20"
/></
td
>
<
td
width
=
"30"
class
=
"btnSections"
>
<
asp:ImageButton
ID
=
"CloseSelectItem"
runat
=
"server"
Height
=
"20"
ImageUrl
=
"~/Images/close.png "
OnClientClick
=
"javascript:window.close(); return false;"
/></
td
>
<
td
width
=
"5"
></
td
>
</
tr
></
table
></
td
>
</
tr
>
<
tr
>
<
td
align
=
"left"
runat
=
"server"
id
=
"trZoneLocation"
style
=
"display: inline;"
>
<
table
cellpadding
=
"0"
cellspacing
=
"0"
border
=
"0"
width
=
"650px"
align
=
"left"
>
<
tr
>
<
td
class
=
"labelText"
height
=
"30"
width
=
"60"
>System</
td
>
<
td
class
=
"fieldText"
>
<!-- AllowCustomText="true"-->
<
telerik:RadComboBox
ID
=
"lstZone"
runat
=
"server"
Width
=
"200"
DataSourceID
=
"SqlDataZone"
MarkFirstMatch
=
"true"
DataTextField
=
"ZoneName"
DataValueField
=
"ZoneID"
AutoPostBack
=
"False"
></
telerik:RadComboBox
>
<
asp:SqlDataSource
ID
=
"SqlDataZone"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ePonti %>"
SelectCommand="SELECT ZoneID, ZoneName FROM webZones WHERE (CompanyID = @CompanyID) And ProjectID=@ProjectID ORDER BY ZoneOrder">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"CompanyID"
SessionField
=
"CompanyID"
Type
=
"String"
/>
<
asp:ControlParameter
ControlID
=
"HiddenProjectID"
Name
=
"ProjectID"
PropertyName
=
"Value"
/>
</
SelectParameters
>
</
asp:SqlDataSource
></
td
>
<
td
class
=
"labelText"
width
=
"50"
>Area</
td
>
<
td
class
=
"fieldText"
>
<!--AllowCustomText="true"-->
<
telerik:RadComboBox
ID
=
"lstLocationArea"
runat
=
"server"
Width
=
"200px"
DataSourceID
=
"SqlDataLocation"
MarkFirstMatch
=
"true"
CheckBoxes
=
"true"
DataTextField
=
"LocationName"
DataValueField
=
"LocationID"
EnableCheckAllItemsCheckBox
=
"true"
CheckedItemsTexts
=
"DisplayAllInInput"
Localization-CheckAllString
=
"All"
AutoPostBack
=
"False"
>
</
telerik:RadComboBox
>
<
asp:SqlDataSource
ID
=
"SqlDataLocation"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ePonti %>"
SelectCommand="SELECT LocationID, LocationName FROM webLocations WHERE (CompanyID = @CompanyID) AND (ProjectID = @ProjectID) Order By LocationName ">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"CompanyID"
SessionField
=
"CompanyID"
Type
=
"String"
/>
<
asp:ControlParameter
ControlID
=
"HiddenProjectID"
Name
=
"ProjectID"
PropertyName
=
"Value"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:HiddenField
ID
=
"HiddenProjectID"
runat
=
"server"
/></
td
>
<
td
class
=
"labelText"
width
=
"50"
>
<
asp:Label
ID
=
"lblQuantity"
runat
=
"server"
Text
=
"Quantity"
></
asp:Label
></
td
>
<
td
class
=
"fieldText"
>
<
telerik:RadNumericTextBox
ID
=
"txtQuantity"
Value
=
"1"
runat
=
"server"
Width
=
"100px"
ShowSpinButtons
=
"True"
>
<
NumberFormat
DecimalDigits
=
"0"
/>
</
telerik:RadNumericTextBox
></
td
>
<
td
></
td
>
</
tr
></
table
></
td
>
</
tr
>
<
tr
>
<
td
align
=
"left"
valign
=
"top"
>
<
table
width
=
"100%"
cellpadding
=
"3"
cellspacing
=
"0"
border
=
"0"
>
<
tr
align
=
"left"
valign
=
"top"
>
<
td
width
=
"10"
></
td
>
<
td
style
=
"width:260px; display:none"
>
<
telerik:RadGrid
ID
=
"RadGridManufacturer"
runat
=
"server"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"false"
AllowSorting
=
"True"
DataSourceID
=
""
GridLines
=
"None"
AllowMultiRowSelection
=
"True"
AutoGenerateColumns
=
"False"
CellSpacing
=
"0"
Height
=
"400px"
EnableLinqExpressions
=
"False"
>
<%--<
ClientSettings
EnableRowHoverStyle
=
"true"
>
<
ClientEvents
OnRowSelected
=
"RadGridManufacturer_RowSelected"
OnRowDeselected
=
"RadGridManufacturer_RowDeselected"
/>
<
Selecting
AllowRowSelect
=
"True"
/>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
SaveScrollPosition
=
"True"
ScrollHeight
=
"250px"
></
Scrolling
>
</
ClientSettings
>--%>
<
MasterTableView
DataKeyNames
=
"ManufacturerID"
ClientDataKeyNames
=
"ManufacturerID"
AutoGenerateColumns
=
"False"
AllowPaging
=
"false"
DataSourceID
=
""
>
<
Columns
>
<
telerik:GridClientSelectColumn
UniqueName
=
"ClientSelectColumn"
HeaderStyle-Width
=
"40px"
ItemStyle-Width
=
"40px"
/>
<
telerik:GridBoundColumn
DataField
=
"ManufacturerName"
HeaderText
=
"Manufacturer"
ReadOnly
=
"True"
AutoPostBackOnFilter
=
"true"
FilterControlWidth
=
"80%"
CurrentFilterFunction
=
"Contains"
SortExpression
=
"ManufacturerName"
UniqueName
=
"ManufacturerName"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:HiddenField
ID
=
"HiddenField1"
runat
=
"server"
Value
=
""
/>
<
asp:Label
ID
=
"Label2"
runat
=
"server"
Text
=
""
></
asp:Label
>
<
asp:SqlDataSource
ID
=
"SqlDataManufacturer"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ePonti %>"
SelectCommand="SELECT ManufacturerID, ManufacturerName
FROM webManufacturer
WHERE (CompanyID = @CompanyID)
Order By ManufacturerName">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"CompanyID"
SessionField
=
"CompanyID"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<%-- <
telerik:RadTreeView
ID
=
"RadTreeParts"
runat
=
"server"
CheckBoxes
=
"True"
Height
=
"400px"
OnClientNodeChecked
=
"onNodeClicking"
>
<
DataBindings
>
<
telerik:RadTreeNodeBinding
Expanded
=
"True"
></
telerik:RadTreeNodeBinding
>
</
DataBindings
>
</
telerik:RadTreeView
>--%>
</
td
>
<
td
>
<%--<
div
style
=
"overflow-y: scroll; height: 380px; width: 100%;"
>--%>
<
telerik:RadGrid
ID
=
"SelectItemGrid"
runat
=
"server"
AllowFilteringByColumn
=
"True"
AllowSorting
=
"True"
PageSize
=
"10"
GridLines
=
"None"
AllowMultiRowSelection
=
"True"
AutoGenerateColumns
=
"False"
CellSpacing
=
"0"
Height
=
"400px"
OnPreRender
=
"SelectItemGrid_PreRender"
OnNeedDataSource
=
"SelectItemGrid_NeedDataSource"
OnDetailTableDataBind
=
"SelectItemGrid_DetailTableDataBind"
ShowGroupPanel
=
"true"
ShowStatusBar
=
"true"
AllowCustomPaging
=
"True"
OnGroupsChanging
=
"RadGrid1_GroupsChanging"
OnColumnCreated
=
"RadGrid_ColumnCreated"
> <%--DataSourceID="SqlDataItems" onpagesizechanged="SelectItemGrid_PageSizeChanged"--%>
<
ClientSettings
EnableRowHoverStyle
=
"true"
>
<
ClientEvents
OnRowCreated
=
"onRowCreated"
OnRowSelected
=
"onRowSelected"
OnRowDeselected
=
"onRowDeselected"
OnGridCreated
=
"gridCreated"
/>
<
Selecting
AllowRowSelect
=
"True"
UseClientSelectColumnOnly
=
"true"
/>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
SaveScrollPosition
=
"True"
ScrollHeight
=
"255px"
></
Scrolling
>
</
ClientSettings
>
<
MasterTableView
Name
=
"Parts"
DataKeyNames
=
"ID,IsPackage"
ClientDataKeyNames
=
"ID,IsPackage"
AutoGenerateColumns
=
"False"
AllowPaging
=
"true"
HierarchyLoadMode
=
"Client"
CommandItemStyle-VerticalAlign
=
"Middle"
CommandItemStyle-HorizontalAlign
=
"Right"
CommandItemDisplay
=
"Top"
> <%--DataSourceID="SqlDataItems"--%>
<
CommandItemTemplate
>
<
telerik:RadToolBar
ID
=
"RadToolBar1"
OnButtonClick
=
"RadToolBar1_ButtonClick"
runat
=
"server"
OnClientButtonClicking
=
"onToolBarClientButtonClicking"
>
<
Items
>
<
telerik:RadToolBarButton
Text
=
"New Part"
CommandName
=
"AddNewPart"
Height
=
"20"
ToolTip
=
"New Part"
ImageUrl
=
"~/Images/Insert.gif"
></
telerik:RadToolBarButton
>
<
telerik:RadToolBarButton
Text
=
"Refresh"
CommandName
=
"RebindGrid"
ImageUrl
=
"~/Images/Refresh.gif"
></
telerik:RadToolBarButton
>
</
Items
>
</
telerik:RadToolBar
>
</
CommandItemTemplate
>
<
RowIndicatorColumn
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
DetailTables
>
<
telerik:GridTableView
Name
=
"Kits"
AutoGenerateColumns
=
"false"
DataKeyNames
=
"ID1,IsPackage"
ClientDataKeyNames
=
"ID1,IsPackage"
AllowPaging
=
"False"
Width
=
"100%"
BackColor
=
"Gray"
AllowFilteringByColumn
=
"True"
> <%--DataSourceID="SqlDataKitItems">--%>
<%--<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"ID"
MasterKeyField
=
"ID"
/>
</
ParentTableRelation
>--%>
<
Columns
>
<
telerik:GridClientSelectColumn
UniqueName
=
"ClientSelectColumn"
Visible
=
"true"
HeaderStyle-Width
=
"40px"
ItemStyle-Width
=
"40px"
/>
<
telerik:GridBoundColumn
DataField
=
"ID1"
HeaderText
=
"ID1"
ReadOnly
=
"True"
SortExpression
=
"ID1"
UniqueName
=
"ID1"
Visible
=
"False"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ManufacturerName"
HeaderText
=
"ManufacturerName"
SortExpression
=
"ManufacturerName"
UniqueName
=
"ManufacturerName"
HeaderStyle-Width
=
"250px"
ItemStyle-Width
=
"250px"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Item"
HeaderText
=
"Item"
ReadOnly
=
"True"
SortExpression
=
"Item"
UniqueName
=
"Item"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"SKU"
HeaderText
=
"SKU"
SortExpression
=
"SKU"
UniqueName
=
"SKU"
Visible
=
"False"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Category"
HeaderText
=
"Group"
SortExpression
=
"Category"
UniqueName
=
"Category"
HeaderStyle-Width
=
"150px"
ItemStyle-Width
=
"150px"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"KitItemQuantity"
DataType
=
"System.Decimal"
HeaderText
=
"Qty"
Visible
=
"false"
SortExpression
=
"KitItemQuantity"
UniqueName
=
"KitItemQuantity"
AllowFiltering
=
"False"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Price"
DataType
=
"System.Decimal"
HeaderText
=
"Price"
SortExpression
=
"Price"
UniqueName
=
"Price"
AllowFiltering
=
"False"
DataFormatString
=
"{0:F4}"
HeaderStyle-Width
=
"70px"
ItemStyle-Width
=
"70px"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"IsPackage"
DataType
=
"System.String"
Visible
=
"false"
HeaderText
=
"IsPackage"
SortExpression
=
"IsPackage"
UniqueName
=
"IsPackage"
AllowFiltering
=
"False"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"IsPackage"
DataType
=
"System.String"
Visible
=
"false"
HeaderText
=
"IsPackage"
SortExpression
=
"IsPackage"
UniqueName
=
"IsPackage"
AllowFiltering
=
"False"
></
telerik:GridBoundColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridClientSelectColumn
UniqueName
=
"ClientSelectColumn"
HeaderStyle-Width
=
"40px"
ItemStyle-Width
=
"40px"
/>
<
telerik:GridBoundColumn
DataField
=
"ID"
HeaderText
=
"ID"
ReadOnly
=
"True"
SortExpression
=
"ID"
UniqueName
=
"ID"
Visible
=
"False"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ManufacturerName"
HeaderText
=
"Manufacturer"
ReadOnly
=
"True"
AutoPostBackOnFilter
=
"true"
FilterControlWidth
=
"80%"
HeaderStyle-Width
=
"250px"
ItemStyle-Width
=
"250px"
CurrentFilterFunction
=
"Contains"
SortExpression
=
"ManufacturerName"
UniqueName
=
"ManufacturerName"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboManufacturerName"
DataSourceID
=
"SqlDataManufacturerName"
DataTextField
=
"ManufacturerName"
MarkFirstMatch
=
"true"
DataValueField
=
"ManufacturerName"
Width
=
"100%"
AppendDataBoundItems
=
"true"
SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("ManufacturerName").CurrentFilterValue %>'
runat="server" OnClientSelectedIndexChanged="ManufacturerNameIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock3"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function ManufacturerNameIndexChanged(sender, args) {
var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
tableView.filter("ManufacturerName", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Item"
HeaderText
=
"Item"
ReadOnly
=
"True"
AutoPostBackOnFilter
=
"true"
FilterControlWidth
=
"80%"
CurrentFilterFunction
=
"Contains"
SortExpression
=
"Item"
UniqueName
=
"Item"
>
<%-- <
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboItem"
DataSourceID
=
"SqlDataFilterItem"
DataTextField
=
"Item"
MarkFirstMatch
=
"true"
DataValueField
=
"Item"
Width
=
"100%"
AppendDataBoundItems
=
"true"
SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("Item").CurrentFilterValue %>'
runat="server" OnClientSelectedIndexChanged="ItemNameIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function ItemNameIndexChanged(sender, args) {
var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
tableView.filter("Item", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>--%>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"SKU"
HeaderText
=
"SKU"
SortExpression
=
"SKU"
UniqueName
=
"SKU"
Visible
=
"False"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Category"
HeaderText
=
"Group"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"Contains"
SortExpression
=
"Category"
UniqueName
=
"Category"
HeaderStyle-Width
=
"150px"
ItemStyle-Width
=
"150px"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboCategory"
DataSourceID
=
"SqlDataCategory"
DataTextField
=
"Category"
MarkFirstMatch
=
"true"
DataValueField
=
"Category"
Width
=
"100%"
AppendDataBoundItems
=
"true"
SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("Category").CurrentFilterValue %>'
runat="server" OnClientSelectedIndexChanged="CategoryNameIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock2"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function CategoryNameIndexChanged(sender, args) {
var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
tableView.filter("Category", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Price"
DataType
=
"System.Decimal"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"Contains"
HeaderText
=
"Price"
SortExpression
=
"Price"
UniqueName
=
"Price"
AllowFiltering
=
"False"
HeaderStyle-Width
=
"70px"
ItemStyle-Width
=
"70px"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"IsPackage"
DataType
=
"System.String"
Visible
=
"false"
HeaderText
=
"Price"
SortExpression
=
"IsPackage"
UniqueName
=
"IsPackage"
AllowFiltering
=
"False"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"IsPackage"
DataType
=
"System.String"
Visible
=
"false"
HeaderText
=
"IsPackage"
SortExpression
=
"IsPackage"
UniqueName
=
"IsPackage"
AllowFiltering
=
"False"
></
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
></
telerik:RadGrid
>
<%--</
div
>--%>
<
asp:SqlDataSource
ID
=
"SqlDataItems"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ePonti %>"
SelectCommand="-- all items
Select ID,Item,SKU,Category,Price,IsPackage,ManufacturerID,ManufacturerName from (
SELECT webMasterData.MasterItemID AS ID,
webMasterData.Model AS Item,
webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price,
'false' as IsPackage,webMasterData.ManufacturerID,webManufacturer.ManufacturerName,
RowNum=(ROW_NUMBER() OVER (Order By MasterItemID ))
FROM
webCategory INNER JOIN webMasterData ON webCategory.CategoryID = webMasterData.CategoryID
LEFT OUTER JOIN webManufacturer ON webMasterData.ManufacturerID = webManufacturer.ManufacturerID
WHERE (webMasterData.CompanyID = @CompanyID)
UNION
--packages
Select KitMasterItemID as ID, KitName as Item, KitSku as SKU,
'' as Category, 0 as Price, 'true' as IsPackage,'' as ManufacturerID,'' as ManufacturerName,
RowNum=(ROW_NUMBER() OVER (Order By KitMasterItemID ))
FROM webMasterKits Where
CompanyID=@CompanyID
) tmp
--Where ManufacturerID in (SELECT value FROM dbo.fn_Split(@SelManufacturerIDs, ',') AS fn_Split_1)
--Where RowNum between (@PageCount*@GridPageSize) and (@PageCount*@GridPageSize)
ORDER BY Item">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"CompanyID"
SessionField
=
"CompanyID"
/>
<
asp:ControlParameter
ControlID
=
"SelManufacturerIDs"
DefaultValue
=
""
Name
=
"SelManufacturerIDs"
PropertyName
=
"Value"
/>
<
asp:ControlParameter
ControlID
=
"hdnSelectItemGridPageCount"
DefaultValue
=
"1"
Name
=
"PageCount"
DbType
=
"Int32"
PropertyName
=
"Value"
/>
<
asp:SessionParameter
Name
=
"GridPageSize"
SessionField
=
"GridPageSize"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataManufacturerName"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ePonti %>"
SelectCommand="-- all items
Select distinct ManufacturerName from (
SELECT webMasterData.MasterItemID AS ID,
ISNULL(webManufacturer.ManufacturerName,'') + ' ' + webMasterData.Model AS Item,
webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price,
'false' as IsPackage,webMasterData.ManufacturerID,webManufacturer.ManufacturerName
FROM
webCategory INNER JOIN webMasterData ON webCategory.CategoryID = webMasterData.CategoryID
LEFT OUTER JOIN webManufacturer ON webMasterData.ManufacturerID = webManufacturer.ManufacturerID
WHERE (webMasterData.CompanyID = @CompanyID)
UNION
--packages
Select KitMasterItemID as ID, KitName as Item, KitSku as SKU,
'' as Category, 0 as Price, 'true' as IsPackage,'' as ManufacturerID,'' as ManufacturerName
FROM webMasterKits Where
CompanyID=@CompanyID
) tmp
--Where ManufacturerID in (SELECT value FROM dbo.fn_Split(@SelManufacturerIDs, ',') AS fn_Split_1)
ORDER BY ManufacturerName ">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"CompanyID"
SessionField
=
"CompanyID"
/>
<
asp:ControlParameter
ControlID
=
"SelManufacturerIDs"
DefaultValue
=
""
Name
=
"SelManufacturerIDs"
PropertyName
=
"Value"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataKitItems"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ePonti %>"
SelectCommand="/*Kit Items*/ SELECT webMasterData.MasterItemID AS ID, webMasterKits.KitMasterItemID, ISNULL(webManufacturer.ManufacturerName, '') + ' ' + webMasterData.Model AS Item, webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price, 'KitItem' AS IsPackage, webMasterKitItems.KitItemQuantity,webManufacturer.ManufacturerName FROM webManufacturer INNER JOIN webMasterData ON webManufacturer.ManufacturerID = webMasterData.ManufacturerID INNER JOIN webCategory ON webMasterData.CategoryID = webCategory.CategoryID INNER JOIN webMasterKits INNER JOIN webMasterKitItems ON webMasterKits.KitMasterItemID = webMasterKitItems.KitMasterItemID ON webMasterData.MasterItemID = webMasterKitItems.MasterItemID WHERE (webMasterKits.CompanyID = @CompanyID) AND (webMasterKits.KitMasterItemID = @ID)
/*Option Items*/
UNION
SELECT webMasterOptions.MasterOptionID AS ID, webMasterOptions.ParentMasterItemID AS KitMasterItemID, ISNULL(webManufacturer.ManufacturerName, '')
+ ' ' + webMasterData.Model AS Item, webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price, 'OptionItem' AS IsPackage, OptionQuantity as KitItemQuantity,webManufacturer.ManufacturerName
FROM webManufacturer INNER JOIN
webMasterData ON webManufacturer.ManufacturerID = webMasterData.ManufacturerID INNER JOIN
webCategory ON webMasterData.CategoryID = webCategory.CategoryID INNER JOIN
webMasterOptions ON webMasterData.MasterItemID = webMasterOptions.ChildMasterItemID
WHERE (webMasterOptions.ParentMasterItemID = @ID)">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"CompanyID"
SessionField
=
"CompanyID"
/>
<
asp:SessionParameter
Name
=
"ID"
SessionField
=
"ID"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataLinkedProjectItems"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ePonti %>"
SelectCommand="SELECT webShape.ShapeID AS ID, ISNULL(webManufacturer.ManufacturerName,'') + ' ' + webMasterData.Model AS Item, webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price FROM webCategory INNER JOIN webMasterData ON webCategory.CategoryID = webMasterData.CategoryID INNER JOIN webShape ON webMasterData.MasterItemID = webShape.MasterItemID LEFT OUTER JOIN webManufacturer ON webMasterData.ManufacturerID = webManufacturer.ManufacturerID WHERE (webMasterData.CompanyID = @CompanyID) AND (webShape.LinkID LIKE '%' + @ProjectID + '%') ORDER BY webManufacturer.ManufacturerName, webMasterData.Model">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"CompanyID"
SessionField
=
"CompanyID"
/>
<
asp:QueryStringParameter
Name
=
"ProjectID"
QueryStringField
=
"LinkID"
DefaultValue
=
"%"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataProjectItems"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ePonti %>"
SelectCommand="-- all items except package items, options
SELECT webShape.ShapeID AS ID, ISNULL(webManufacturer.ManufacturerName,'') + ' ' + webMasterData.Model AS Item, webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price, 'false' as IsPackage FROM webCategory INNER JOIN webMasterData ON webCategory.CategoryID = webMasterData.CategoryID INNER JOIN webShape ON webMasterData.MasterItemID = webShape.MasterItemID LEFT OUTER JOIN webManufacturer ON webMasterData.ManufacturerID = webManufacturer.ManufacturerID WHERE (webMasterData.CompanyID = @CompanyID) AND (webShape.ProjectID = @ProjectID) AND (webShape.ZoneID LIKE '%' + @ZoneID + '%') AND (webShape.LocationID LIKE '%' + @LocationID + '%')
AND (webShape.ProjectKitID is null OR webShape.ProjectKitID='')
AND (webShape.OptionID is null OR webShape.OptionID='')
UNION
--packages
SELECT webShape.ShapeID AS ID, ISNULL(webMasterKits.KitName, '') AS Item, webMasterKits.KitSku, '' AS Category, 0 AS Price,
'true' AS IsPackage
FROM webMasterKits INNER JOIN
webShape ON webMasterKits.KitMasterItemID = webShape.MasterItemID
WHERE (webShape.ProjectID = @ProjectID) AND (webShape.ZoneID LIKE '%' + @ZoneID + '%') AND (webShape.LocationID LIKE '%' + @LocationID + '%') AND
(webShape.ProjectKitID = webShape.ShapeID)
ORDER BY Item">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"CompanyID"
SessionField
=
"CompanyID"
/>
<
asp:QueryStringParameter
Name
=
"ProjectID"
QueryStringField
=
"ProjectID"
/>
<
asp:ControlParameter
ControlID
=
"lstZone"
DefaultValue
=
"%"
Name
=
"ZoneID"
PropertyName
=
"SelectedValue"
/>
<
asp:ControlParameter
ControlID
=
"lstLocationArea"
DefaultValue
=
"%"
Name
=
"LocationID"
PropertyName
=
"SelectedValue"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataProjectKitItems"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ePonti %>"
SelectCommand="-- package items
SELECT webShape.ShapeID AS ID, ISNULL(webManufacturer.ManufacturerName,'') + ' ' + webMasterData.Model AS Item, webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price, 'KitItem' AS IsPackage FROM webCategory INNER JOIN webMasterData ON webCategory.CategoryID = webMasterData.CategoryID INNER JOIN webShape ON webMasterData.MasterItemID = webShape.MasterItemID LEFT OUTER JOIN webManufacturer ON webMasterData.ManufacturerID = webManufacturer.ManufacturerID WHERE (webMasterData.CompanyID = @CompanyID) AND (webShape.ProjectID = @ProjectID) AND (webShape.ZoneID LIKE '%' + @ZoneID + '%') AND (webShape.LocationID LIKE '%' + @LocationID + '%')
AND (webShape.ProjectKitID = @ID)
AND (webShape.ShapeID <> webShape.ProjectKitID)
AND webShape.ProjectKitID <> ''
UNION
--Options
SELECT webShape.ShapeID AS ID, ISNULL(webManufacturer.ManufacturerName,'') + ' ' + webMasterData.Model AS Item, webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price, 'OptionItem' AS IsPackage FROM webCategory INNER JOIN webMasterData ON webCategory.CategoryID = webMasterData.CategoryID INNER JOIN webShape ON webMasterData.MasterItemID = webShape.MasterItemID LEFT OUTER JOIN webManufacturer ON webMasterData.ManufacturerID = webManufacturer.ManufacturerID
WHERE (webMasterData.CompanyID = @CompanyID)
AND (webShape.ProjectID = @ProjectID)
AND (webShape.ZoneID LIKE '%' + @ZoneID + '%') AND (webShape.LocationID LIKE '%' + @LocationID + '%')
AND (webShape.OptionID = @ID)
AND (webShape.ShapeID <> webShape.OptionID)
AND webShape.OptionID <> ''
ORDER BY Item">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"CompanyID"
SessionField
=
"CompanyID"
/>
<
asp:QueryStringParameter
Name
=
"ProjectID"
QueryStringField
=
"ProjectID"
/>
<
asp:ControlParameter
ControlID
=
"lstZone"
DefaultValue
=
"%"
Name
=
"ZoneID"
PropertyName
=
"SelectedValue"
/>
<
asp:ControlParameter
ControlID
=
"lstLocationArea"
DefaultValue
=
"%"
Name
=
"LocationID"
PropertyName
=
"SelectedValue"
/>
<
asp:SessionParameter
Name
=
"ID"
SessionField
=
"ID"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataCOItemsDuplicate"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ePonti %>"
SelectCommand="-- all items
Select ID,Item,SKU,Category,Price,IsPackage from (
SELECT webMasterData.MasterItemID AS ID,
ISNULL(webManufacturer.ManufacturerName,'') + ' ' + webMasterData.Model AS Item,
webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price,
'false' as IsPackage
FROM
webCategory INNER JOIN webMasterData ON webCategory.CategoryID = webMasterData.CategoryID
LEFT OUTER JOIN webManufacturer ON webMasterData.ManufacturerID = webManufacturer.ManufacturerID
WHERE (webMasterData.CompanyID = @CompanyID)
UNION
--packages
Select KitMasterItemID as ID, KitName as Item, KitSku as SKU,
'' as Category, 0 as Price, 'true' as IsPackage
FROM webMasterKits Where
CompanyID=@CompanyID
) tmp
Where ID in (SELECT value FROM dbo.fn_Split(@SelMasterItemIDs, ',') AS fn_Split_1)
ORDER BY Item">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"CompanyID"
SessionField
=
"CompanyID"
/>
<
asp:SessionParameter
DefaultValue
=
""
Name
=
"SelMasterItemIDs"
SessionField
=
"SelMasterItemIDs"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataLinkProjectItems"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ePonti %>"
SelectCommand="SELECT webShape.ShapeID AS ID, ISNULL(webManufacturer.ManufacturerName,'') + ' ' + webMasterData.Model AS Item, webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price FROM webCategory INNER JOIN webMasterData ON webCategory.CategoryID = webMasterData.CategoryID INNER JOIN webShape ON webMasterData.MasterItemID = webShape.MasterItemID LEFT OUTER JOIN webManufacturer ON webMasterData.ManufacturerID = webManufacturer.ManufacturerID WHERE (webMasterData.CompanyID = @CompanyID) AND (webShape.ProjectID = @ProjectID) ORDER BY webManufacturer.ManufacturerName, webMasterData.Model">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"CompanyID"
SessionField
=
"CompanyID"
/>
<
asp:QueryStringParameter
Name
=
"ProjectID"
QueryStringField
=
"LinkID"
DefaultValue
=
""
/>
</
SelectParameters
>
</
asp:SqlDataSource
></
td
>
<
td
width
=
"10"
></
td
>
</
tr
>
<
tr
>
<
td
height
=
"20"
></
td
>
</
tr
></
table
></
td
>
</
tr
></
table
>
</
div
>
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock2"
runat
=
"server"
>
<
script
type
=
"text/javascript"
language
=
"javascript"
>
function RefreshTasksGrid() {
var masterTable = $find("<%= SelectItemGrid.ClientID %>").get_masterTableView();
masterTable.rebind();
}
</
script
>
</
telerik:RadCodeBlock
>
<
div
runat
=
"server"
id
=
"divRefreshTask"
>
</
div
>
<
asp:SqlDataSource
ID
=
"SqlDataFilterItem"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ePonti %>"
SelectCommand="-- all items
Select distinct Item from (
SELECT webMasterData.MasterItemID AS ID,
ISNULL(webManufacturer.ManufacturerName,'') + ' ' + webMasterData.Model AS Item,
webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price,
'false' as IsPackage,webMasterData.ManufacturerID
FROM
webCategory INNER JOIN webMasterData ON webCategory.CategoryID = webMasterData.CategoryID
LEFT OUTER JOIN webManufacturer ON webMasterData.ManufacturerID = webManufacturer.ManufacturerID
WHERE (webMasterData.CompanyID = @CompanyID)
UNION
--packages
Select KitMasterItemID as ID, KitName as Item, KitSku as SKU,
'' as Category, 0 as Price, 'true' as IsPackage,'' as ManufacturerID
FROM webMasterKits Where
CompanyID=@CompanyID
) tmp
--Where ManufacturerID in (SELECT value FROM dbo.fn_Split(@SelManufacturerIDs, ',') AS fn_Split_1)
ORDER BY Item">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"CompanyID"
SessionField
=
"CompanyID"
/>
<
asp:ControlParameter
ControlID
=
"SelManufacturerIDs"
DefaultValue
=
""
Name
=
"SelManufacturerIDs"
PropertyName
=
"Value"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataCategory"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ePonti %>"
SelectCommand="-- all items
Select distinct Category,CategoryID from (
SELECT webMasterData.MasterItemID AS ID,
ISNULL(webManufacturer.ManufacturerName,'') + ' ' + webMasterData.Model AS Item,
webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price,
'false' as IsPackage,webMasterData.ManufacturerID,webCategory.CategoryID
FROM
webCategory INNER JOIN webMasterData ON webCategory.CategoryID = webMasterData.CategoryID
LEFT OUTER JOIN webManufacturer ON webMasterData.ManufacturerID = webManufacturer.ManufacturerID
WHERE (webMasterData.CompanyID = @CompanyID)
UNION
--packages
Select KitMasterItemID as ID, KitName as Item, KitSku as SKU,
'' as Category, 0 as Price, 'true' as IsPackage,'' as ManufacturerID,'' as CategoryID
FROM webMasterKits Where
CompanyID=@CompanyID
) tmp
ORDER BY Category">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"CompanyID"
SessionField
=
"CompanyID"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataReplaceItemGrid"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ePonti %>"
SelectCommand="-- all items
Select ID,Item,SKU,Category,Price,IsPackage,ManufacturerID,ManufacturerName ,CategoryID from (
SELECT webMasterData.MasterItemID AS ID,
ISNULL(webManufacturer.ManufacturerName,'') + ' ' + webMasterData.Model AS Item,
webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price,
'false' as IsPackage,webMasterData.ManufacturerID,webManufacturer.ManufacturerName,webCategory.CategoryID
FROM
webCategory INNER JOIN webMasterData ON webCategory.CategoryID = webMasterData.CategoryID
LEFT OUTER JOIN webManufacturer ON webMasterData.ManufacturerID = webManufacturer.ManufacturerID
WHERE (webMasterData.CompanyID = @CompanyID)
UNION
--packages
Select KitMasterItemID as ID, KitName as Item, KitSku as SKU,
'' as Category, 0 as Price, 'true' as IsPackage,'' as ManufacturerID,'' as ManufacturerName ,'' as CategoryID
FROM webMasterKits Where
CompanyID=@CompanyID
) tmp
Where CategoryID in (SELECT value FROM dbo.fn_Split(@Category, ',') AS fn_Split_1)
ORDER BY Category">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"CompanyID"
SessionField
=
"CompanyID"
/>
<
asp:SessionParameter
Name
=
"Category"
SessionField
=
"Category"
/>
<
asp:ControlParameter
ControlID
=
"SelManufacturerIDs"
DefaultValue
=
""
Name
=
"SelManufacturerIDs"
PropertyName
=
"Value"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:Label
ID
=
"Label1"
runat
=
"server"
Text
=
""
></
asp:Label
>
</
form
>
</
body
>
</
html
>
code behind
Imports Telerik.Web.UI
Imports System.Data
Imports System.Data.SqlClient
Public Class SelectItemQuotes
Inherits System.Web.UI.Page
Private Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init
Dim BrowserName As String = Request.Browser.Browser.ToString()
ScriptTag.InnerHtml = ""
If BrowserName = "Safari" Then
ScriptTag.InnerHtml = "<
script
type
=
'text/javascript'
language
=
'javascript'
>window.resizeTo(1150,600);</
script
>"
ElseIf BrowserName = "Chrome" Then
ScriptTag.InnerHtml = "<
script
type
=
'text/javascript'
language
=
'javascript'
>window.resizeTo(1150,590);</
script
>"
Else
ScriptTag.InnerHtml = "<
script
type
=
'text/javascript'
language
=
'javascript'
>window.resizeTo(1150,600);</
script
>"
End If
End Sub
Protected Sub SelectItemGrid_NeedDataSource(source As Object, e As GridNeedDataSourceEventArgs)
Dim startRowIndex As String = If((ShouldApplySortFilterOrGroup()), 0, SelectItemGrid.CurrentPageIndex * Session("GridPageSize"))
Dim maximumRows As String = If((ShouldApplySortFilterOrGroup()), SelectCount(), Session("GridPageSize"))
Dim xyz As String
xyz = (Convert.ToInt32(startRowIndex) + 1).ToString()
If Not e.IsFromDetailTable Then
SelectItemGrid.AllowCustomPaging = Not ShouldApplySortFilterOrGroup()
SelectItemGrid.DataSource = GetDataTable("Select ID,Item,SKU,Category,Price,IsPackage,ManufacturerID,ManufacturerName From (" _
& " Select ID,Item,SKU,Category,Price,IsPackage,ManufacturerID,ManufacturerName,RowNum=(ROW_NUMBER() OVER (Order By ID )) from (" _
& " SELECT webMasterData.MasterItemID AS ID, " _
& " webMasterData.Model AS Item, webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price, " _
& " 'false' as IsPackage,webMasterData.ManufacturerID,webManufacturer.ManufacturerName " _
& " FROM " _
& " webCategory INNER JOIN webMasterData ON webCategory.CategoryID = webMasterData.CategoryID " _
& " LEFT OUTER JOIN webManufacturer ON webMasterData.ManufacturerID = webManufacturer.ManufacturerID " _
& " WHERE (webMasterData.CompanyID = '" & Session("CompanyID") & "') " _
& " UNION " _
& " Select KitMasterItemID as ID, KitName as Item, KitSku as SKU,'' as Category, 0 as Price, " _
& " 'true' as IsPackage,'' as ManufacturerID,'' as ManufacturerName " _
& " FROM webMasterKits Where " _
& " CompanyID = '" & Session("CompanyID") & "') as tmp ) as tmp1 " _
& " Where RowNum between ('" + xyz + "') AND ('" + startRowIndex + "' + '" + maximumRows + "') " _
& " ORDER BY Item")
SelectItemGrid.VirtualItemCount = GetRowCount(Session("CompanyID").ToString())
End If
End Sub
Protected Sub SelectItemGrid_DetailTableDataBind(source As Object, e As Telerik.Web.UI.GridDetailTableDataBindEventArgs)
Dim dataItem As GridDataItem = DirectCast(e.DetailTableView.ParentItem, GridDataItem)
Select Case e.DetailTableView.Name
Case "Kits"
Dim ParentPartID As String = dataItem.GetDataKeyValue("ID").ToString()
e.DetailTableView.DataSource = GetDataTable("SELECT webMasterData.MasterItemID AS ID1, webMasterKits.KitMasterItemID, ISNULL(webManufacturer.ManufacturerName, '') + ' ' + webMasterData.Model AS Item, webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price, 'KitItem' AS IsPackage, webMasterKitItems.KitItemQuantity,webManufacturer.ManufacturerName FROM webManufacturer INNER JOIN webMasterData ON webManufacturer.ManufacturerID = webMasterData.ManufacturerID INNER JOIN webCategory ON webMasterData.CategoryID = webCategory.CategoryID INNER JOIN webMasterKits INNER JOIN webMasterKitItems ON webMasterKits.KitMasterItemID = webMasterKitItems.KitMasterItemID ON webMasterData.MasterItemID = webMasterKitItems.MasterItemID WHERE (webMasterKits.CompanyID = '" & Session("CompanyID") & "') AND (webMasterKits.KitMasterItemID = '" & ParentPartID & "') UNION SELECT webMasterOptions.MasterOptionID AS ID, webMasterOptions.ParentMasterItemID AS KitMasterItemID, ISNULL(webManufacturer.ManufacturerName, '') + ' ' + webMasterData.Model AS Item, webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price, 'OptionItem' AS IsPackage, OptionQuantity as KitItemQuantity,webManufacturer.ManufacturerName FROM webManufacturer INNER JOIN webMasterData ON webManufacturer.ManufacturerID = webMasterData.ManufacturerID INNER JOIN webCategory ON webMasterData.CategoryID = webCategory.CategoryID INNER JOIN webMasterOptions ON webMasterData.MasterItemID = webMasterOptions.ChildMasterItemID WHERE (webMasterOptions.ParentMasterItemID = '" & ParentPartID & "')")
End Select
End Sub
Dim ConnString As String = ConfigurationManager.ConnectionStrings("ePonti").ConnectionString
Public Function GetRowCount(CompanyID As String) As Integer
Dim demoTableName As String = " ( SELECT webMasterData.MasterItemID AS ID, webMasterData.Model AS Item, webMasterData.SKU, webCategory.CategoryName AS Category, webMasterData.Price, 'false' as IsPackage,webMasterData.ManufacturerID,webManufacturer.ManufacturerName FROM webCategory INNER JOIN webMasterData ON webCategory.CategoryID = webMasterData.CategoryID LEFT OUTER JOIN webManufacturer ON webMasterData.ManufacturerID = webManufacturer.ManufacturerID WHERE (webMasterData.CompanyID = '" & Session("CompanyID") & "') UNION Select KitMasterItemID as ID, KitName as Item, KitSku as SKU, '' as Category, 0 as Price, 'true' as IsPackage,'' as ManufacturerID,'' as ManufacturerName From webMasterKits Where (CompanyID='" & Session("CompanyID") & "') ) tmp"
Using conn As New SqlConnection(ConnString)
conn.Open()
Dim comm As New SqlCommand("SELECT COUNT(*) FROM " + demoTableName, conn)
Dim count As Integer = Convert.ToInt32(comm.ExecuteScalar())
conn.Close()
Return count
End Using
End Function
Public Function GetDataTable(ByVal query As String) As DataTable
Dim connection1 As New SqlConnection(ConnString)
Dim adapter1 As New SqlDataAdapter
adapter1.SelectCommand = New SqlCommand(query, connection1)
Dim table1 As New DataTable
connection1.Open()
Try
adapter1.Fill(table1)
Finally
connection1.Close()
End Try
Return table1
End Function
Dim _maxItems As Integer = 10000
Private isGrouping As Boolean = False
'Protected Sub SelectItemGrid_PageSizeChanged(sender As Object, e As GridPageSizeChangedEventArgs)
' SelectItemGrid.PageSize = e.NewPageSize
' SelectItemGrid.Rebind()
'End Sub
Protected Sub RadGrid1_GroupsChanging(source As Object, e As GridGroupsChangingEventArgs)
isGrouping = True
If e.Action = GridGroupsChangingAction.Ungroup AndAlso SelectItemGrid.CurrentPageIndex > 0 Then
isGrouping = False
End If
End Sub
Public Function ShouldApplySortFilterOrGroup() As Boolean
Return SelectItemGrid.MasterTableView.FilterExpression <> "" OrElse (SelectItemGrid.MasterTableView.GroupByExpressions.Count > 0 OrElse isGrouping) OrElse SelectItemGrid.MasterTableView.SortExpressions.Count > 0
End Function
Protected Sub RadGrid_ColumnCreated(sender As Object, e As GridColumnCreatedEventArgs)
If TypeOf e.Column Is GridBoundColumn Then
TryCast(e.Column, GridBoundColumn).FilterControlWidth = Unit.Pixel(140)
End If
End Sub
Public Function SelectCount() As Integer
Return _maxItems
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim chkSession As New CheckSessionPopup
Dim UserArray As ArrayList = Application("UserArrayList")
chkSession.CheckOpenerSession(UserArray, Response)
If Not Me.IsPostBack Then
SelectItemGrid.PageSize = Session("GridPageSize")
RadSkinManager1.Skin = Session("SkinID")
If Request.QueryString("QuoteID") <> Nothing Then
HiddenProjectID.Value = Request.QueryString("QuoteID")
End If
'If Request.QueryString("ChangeRequestID") <> Nothing Then
' Dim ChangeRequestID As String = Request.QueryString("ChangeRequestID")
' Dim CORAdapt As New ChangeRequestDataTableAdapters.webChangeRequestsTableAdapter
' Dim CORTbl As ChangeRequestData.webChangeRequestsDataTable = CORAdapt.GetChangeRequestByID(ChangeRequestID)
' If CORTbl.Rows.Count = 1 Then
' Dim CORRow As ChangeRequestData.webChangeRequestsRow = CORTbl.Rows(0)
' HiddenProjectID.Value = CORRow.ProjectID
' 'SqlDataZone.FilterParameters.Add(New Parameter("@ProjectID", DbType.String, CORRow.ProjectID))
' 'SqlDataLocation.FilterParameters.Add(New Parameter("@ProjectID", DbType.String, CORRow.ProjectID))
' End If
'End If
'If Request.QueryString("ProjectID") <> Nothing And Request.QueryString("ChangeRequestID") = Nothing Then
' SelectItemGrid.DataSourceID = "SqlDataProjectItems"
' SelectItemGrid.MasterTableView.DataSourceID = "SqlDataProjectItems"
' SelectItemGrid.DataBind()
' HiddenProjectID.Value = Request.QueryString("ProjectID")
' trZoneLocation.Attributes.Add("Style", "display:none;")
'ElseIf Request.QueryString("ProjectID") <> Nothing And (Request.QueryString("ChangeRequestID") = Nothing Or Request.QueryString("Action") = "Remove") Then
' SelectItemGrid.DataSourceID = "SqlDataProjectItems"
' SelectItemGrid.MasterTableView.DataSourceID = "SqlDataProjectItems"
' SelectItemGrid.MasterTableView.DetailTables(0).DataSourceID = "SqlDataProjectKitItems"
' SelectItemGrid.DataBind()
' HiddenProjectID.Value = Request.QueryString("ProjectID")
' trZoneLocation.Attributes.Add("Style", "display:inline;")
' lblQuantity.Visible = False
' txtQuantity.Visible = False
'Else
If (Request.QueryString("QuoteID") <> Nothing) Then
'SelectItemGrid.DataSourceID = "SqlDataItems"
'SelectItemGrid.MasterTableView.DataSourceID = "SqlDataItems"
'SelectItemGrid.DataBind()
'HiddenProjectID.Value = Request.QueryString("QuoteID")
'trZoneLocation.Attributes.Add("Style", "display:inline;")
If Request.QueryString("LocationID") <> Nothing Then
Dim LocationID As String = Request.QueryString("LocationID")
lstLocationArea.DataBind()
lstLocationArea.SelectedValue = LocationID
'For Each Item As Telerik.Web.UI.RadComboBoxItem In TaskInfoLocations.Items
' If Item.Value = LocationID Then
' TaskInfoLocations.SelectedValue = LocationID
' Exit For
' End If
'Next
End If
If Request.QueryString("ZoneID") <> Nothing Then
lstZone.DataBind()
lstZone.FindItemByValue(Request.QueryString("ZoneID")).Checked = True
End If
'If Request.QueryString("ZoneID") <> Nothing Then
' TaskInfoZone.DataBind()
' For Each Item As Telerik.Web.UI.RadComboBoxItem In TaskInfoZone.Items
' If Item.Value.ToString() = Request.QueryString("ZoneID").ToString() Then
' TaskInfoZone.SelectedValue = Request.QueryString("ZoneID")
' 'TryCast(Item.FindControl("CheckBox1"), CheckBox).Checked = True
' Item.Checked = True
' End If
' Next
'End If
'If Request.QueryString("COAction") = "Duplicate" Then
' SelectItemGrid.DataSourceID = "SqlDataCOItemsDuplicate"
' SelectItemGrid.MasterTableView.DataSourceID = "SqlDataCOItemsDuplicate"
' SelectItemGrid.DataBind()
' TaskInfoLocations.SelectedValue = Session("LocationID")
' TaskInfoZone.SelectedValue = Session("ZoneID")
' SelectItemGrid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None
'End If
'ElseIf (Request.QueryString("ProductID") <> Nothing) Then
' SelectItemGrid.DataSourceID = "SqlDataItems"
' SelectItemGrid.MasterTableView.DataSourceID = "SqlDataItems"
' SelectItemGrid.DataBind()
' trZoneLocation.Attributes.Add("Style", "display:none;")
'Else
' 'Change Request
' If Request.QueryString("ChangeRequestID") <> Nothing Then
' SelectItemGrid.DataSourceID = "SqlDataItems"
' SelectItemGrid.MasterTableView.DataSourceID = "SqlDataItems"
' SelectItemGrid.DataBind()
' trZoneLocation.Attributes.Add("Style", "display:inline;")
' If Request.QueryString("COAction") = "Duplicate" Then
' SelectItemGrid.DataSourceID = "SqlDataCOItemsDuplicate"
' SelectItemGrid.MasterTableView.DataSourceID = "SqlDataCOItemsDuplicate"
' SelectItemGrid.DataBind()
' TaskInfoLocations.SelectedValue = Session("LocationID")
' TaskInfoZone.SelectedValue = Session("ZoneID")
' SelectItemGrid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None
' End If
' End If
End If
'If Request.QueryString("LinkID") <> Nothing Then
' SelectItemGrid.DataSourceID = "SqlDataLinkProjectItems"
' SelectItemGrid.MasterTableView.DataSourceID = "SqlDataLinkProjectItems"
' SelectItemGrid.DataBind()
'End If
End If
End Sub
Private Sub SelectItemGrid_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles SelectItemGrid.Init
Dim menu As Telerik.Web.UI.GridFilterMenu = SelectItemGrid.FilterMenu
Dim i As Integer = 0
While i <
menu.Items.Count
If menu.Items(i)
.Text
=
"NoFilter"
Or _
menu.Items(i)
.Text
=
"Contains"
Or _
menu.Items(i)
.Text
=
"EqualTo"
Or _
menu.Items(i)
.Text
=
"StartsWith"
Or _
menu.Items(i)
.Text
=
"IsEmpty"
Then
i
= i + 1
Else
menu.Items.RemoveAt(i)
End If
End While
End Sub
Private Sub SelectItemGrid_PageIndexChanged(sender As Object, e As GridPageChangedEventArgs) Handles SelectItemGrid.PageIndexChanged
hdnSelectItemGridPageCount.Value
= e.NewPageIndex
End Sub
Protected Sub SelectItemGrid_PreRender(ByVal sender As Object, ByVal e As EventArgs) Handles SelectItemGrid.PreRender
'If Not Page.IsPostBack Then
'
SelectItemGrid.PageSize
=
10
SelectItemGrid.MasterTableView.Rebind()
'SelectItemGrid.MasterTableView.Items(0)
.Expanded
=
True
'End If
HideExpandColumnRecursive(SelectItemGrid.MasterTableView)
End Sub
Public Sub HideExpandColumnRecursive(ByVal tableView As GridTableView)
Dim nestedViewItems As GridItem() = tableView.GetItems(GridItemType.NestedView)
For Each nestedViewItem As GridNestedViewItem In nestedViewItems
For Each nestedView As GridTableView In nestedViewItem.NestedTableViews
If
nestedView.Items.Count
=
0
Then
Dim cell As
TableCell
=
nestedView
.ParentItem("ExpandColumn")
cell.Controls(0)
.Visible
=
False
cell.Text
=
" "
nestedViewItem.Visible
=
False
End If
If nestedView.HasDetailTables Then
HideExpandColumnRecursive(nestedView)
End If
Next
Next
'Dim item As GridItem
'If (tableView.Controls.Count > 0) Then
' For Each item In tableView.Controls(0).Controls
' If TypeOf item Is GridNestedViewItem Then
' Dim nestedViewItem As GridNestedViewItem = CType(item, GridNestedViewItem)
' If nestedViewItem.NestedTableViews(0).Items.Count = 0 Then
' Dim cell As TableCell = nestedViewItem.NestedTableViews(0).ParentItem("ExpandColumn")
' cell.Controls(0).Visible = False
' nestedViewItem.Visible = False
' Else
' HideExpandColumnRecursive(nestedViewItem.NestedTableViews(0))
' End If
' End If
' Next item
'End If
End Sub
Function IsWire(ByVal CompanyID As String, ByVal MasterItemID As String) As Boolean
Dim _ProdAdapt As New ProductDataTableAdapters.webMasterDataTableAdapter
Dim _ProdTbl As ProductData.webMasterDataDataTable = _ProdAdapt.GetProductByID(MasterItemID)
If (_ProdTbl.Rows.Count = 1) Then
Dim _ProdRow As ProductData.webMasterDataRow = _ProdTbl.Rows(0)
Dim _AdaptCategory As New CompanyDataTableAdapters.webCategoryTableAdapter
Dim _CatTbl As CompanyData.webCategoryDataTable = _AdaptCategory.GetCategoryByID(_ProdRow.CompanyID, _ProdRow.CategoryID)
If _CatTbl.Rows.Count = 1 Then
Dim _CatRow As CompanyData.webCategoryRow = _CatTbl.Rows(0)
If _CatRow.CategoryType.Trim = "Wire" Then
IsWire = True
Return True
End If
End If
End If
IsWire = False
Return False
End Function
Function GetProjectCostCodeID(ProjectID As String, MasterCostCodeID As String) As String
Dim _projectCostCodeAdpt As New ProjectDataTableAdapters.webProjectCostCodesTableAdapter
Dim _projectCostCodeTbl As ProjectData.webProjectCostCodesDataTable = _projectCostCodeAdpt.GetProjectCCByMasterCCID(ProjectID, MasterCostCodeID)
If _projectCostCodeTbl.Rows.Count > 0 Then
Dim _projectCostCodeRow As ProjectData.webProjectCostCodesRow = _projectCostCodeTbl.Rows(0)
GetProjectCostCodeID = _projectCostCodeRow.ProjectCostCodeID
Else
Dim ProjCostCodeID As String = Guid.NewGuid().ToString()
_projectCostCodeAdpt.Insert(ProjCostCodeID, ProjectID, MasterCostCodeID, "")
GetProjectCostCodeID = ProjCostCodeID
End If
End Function
'Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
' SelectItemGrid.AllowPaging = False
' SelectItemGrid.Rebind()
' Dim selectedKeys As New HashSet(Of String)(HiddenField1.Value.Split(New Char() {","c}, StringSplitOptions.RemoveEmptyEntries))
' Dim selectedVisible As New List(Of String)()
' Dim strSelectedIDCSV As String = HiddenField1.Value
' For Each dataItem As GridDataItem In SelectItemGrid.MasterTableView.Items
' If selectedKeys.Contains(dataItem.GetDataKeyValue("ID").ToString()) Then
' 'selectedVisible.Add(dataItem.GetDataKeyValue("CustomerID").ToString())
' selectedVisible.Add(dataItem.GetDataKeyValue("CustomerID").ToString() + " - " + dataItem.GetDataKeyValue("OrderID").ToString())
' End If
' Next
' Label1.Text = "<
b
>Currently selected:</
b
><
br
/>" + strSelectedIDCSV.Replace(",", "<
br
/>")
' SelectItemGrid.AllowPaging = True
' SelectItemGrid.Rebind()
'End Sub
'Function AddProduct(ByVal CompanyID As String, ByVal ProjectID As String, ByVal MasterItemID As String, ByVal ProjectKitID As String, ByVal OptionID As String, ByVal WireLength As Int32, ByVal LocationID As String) As String
' Dim _ProdAdapt As New ProductDataTableAdapters.webMasterDataTableAdapter
' Dim _ProdPhaseCostAdapt As New ProductDataTableAdapters.webMasterPhaseCostsTableAdapter
' Dim ProjectCostCodeID As String = ""
' Dim ShapeAdapt As New ProjectDataTableAdapters.webShape1TableAdapter
' Dim ShapePriceAdapt As New ProjectDataTableAdapters.webShapePriceTableAdapter
' 'ProjectCostCodeid
' Dim _ProdTbl As ProductData.webMasterDataDataTable = _ProdAdapt.GetProductByID(MasterItemID)
' If (_ProdTbl.Rows.Count = 1) Then
' Dim _ProdRow As ProductData.webMasterDataRow = _ProdTbl.Rows(0)
' Dim _ProdPhaseCostTbl As ProductData.webMasterPhaseCostsDataTable = _ProdPhaseCostAdapt.GetMasterPhaseCost(CompanyID, _ProdRow.MasterPhaseID)
' If _ProdPhaseCostTbl.Rows.Count = 1 Then
' Dim _ProdPhaseCostRow As ProductData.webMasterPhaseCostsRow = _ProdPhaseCostTbl.Rows(0)
' Dim ShapeID As String = Guid.NewGuid.ToString()
' Dim ZoneID As Integer = 0
' If TaskInfoZone.SelectedValue <> "" Then
' ZoneID = TaskInfoZone.SelectedValue
' End If
' If ZoneID = 0 Or LocationID = "" Then
' ClientScript.RegisterClientScriptBlock(Me.GetType(), "valid", "<
script
language
=
'javascript'
>alert('Please select System and Area before adding the items');</
script
>")
' Return ""
' End If
' If _ProdRow.CostCodeID <> "" Then
' ProjectCostCodeID = GetProjectCostCodeID(ProjectID, _ProdRow.CostCodeID)
' End If
' ShapeAdapt.Insert(ShapeID, ProjectID, CompanyID, 0, _ProdRow.MasterItemID, "", WireLength, _ProdRow.MasterPhaseID, ZoneID, LocationID, "", "", "", "New", Now(), "", ProjectCostCodeID, ProjectKitID, OptionID, _ProdRow.ExcludePOR, _ProdRow.SKU, _ProdRow.WarranteePart, _ProdRow.OneOffPart, _ProdRow.ProductDescription, _ProdRow.SalesDescription)
' 'ShapePriceAdapt.Insert(ShapeID, _ProdRow.Cost, _ProdRow.Price, _ProdPhaseCostRow.PhaseMgtLaborPrice, _ProdPhaseCostRow.PhaseDesignLaborPrice, _ProdPhaseCostRow.PhaseMiscLaborPrice, _ProdPhaseCostRow.MiscEquipAdjt, _ProdPhaseCostRow.MiscPartsAdjt, _ProdRow.Price * WireLength, _ProdRow.FixedLaborPrice, _ProdRow.FixedLaborCost, _ProdRow.EstimatedHrs * WireLength, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMiscLaborFactor, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMgtLaborFactor, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseDesignLaborFactor, _ProdRow.SalesTaxID, _ProdRow.LaborTaxID, _ProdRow.PurchaseTaxID, 0, _ProdRow.Price, _ProdRow.EstimatedHrs)
' ShapePriceAdapt.Insert(ShapeID, _ProdRow.Cost, _ProdRow.Price, _ProdPhaseCostRow.PhaseMgtLaborPrice, _ProdPhaseCostRow.PhaseDesignLaborPrice, _ProdPhaseCostRow.PhaseMiscLaborPrice, _ProdPhaseCostRow.MiscEquipAdjt, _ProdPhaseCostRow.MiscPartsAdjt, _ProdRow.Price * WireLength, _ProdRow.FixedLaborPrice, _ProdRow.FixedLaborCost, _ProdRow.EstimatedHrs, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMiscLaborFactor, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMgtLaborFactor, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseDesignLaborFactor, "", "", "", 0, _ProdRow.Price, _ProdRow.EstimatedHrs)
' Dim emailObj As New OptionEmail()
' emailObj.SendEmailByType(Session("CompanyID"), "0ecaa110-5a5f-4665-a428-49638c45ea89", Session("ResourceID"), Request.QueryString("QuoteID").ToString(), "", "", "", "", "", "", "", ShapeID, "")
' Return ShapeID
' End If
' End If
' Return ""
'End Function
Function AddProduct(ByVal CompanyID As String, ByVal ProjectID As String, ByVal MasterItemID As String, ByVal ProjectKitID As String, ByVal OptionID As String, ByVal WireLength As Int32, ByVal LocationID As String) As String
Dim _ProdAdapt As New ProductDataTableAdapters.webMasterDataTableAdapter
Dim _ProdPhaseCostAdapt As New ProductDataTableAdapters.webMasterPhaseCostsTableAdapter
Dim ShapeAdapt As New ProjectDataTableAdapters.webShape1TableAdapter
Dim ShapePriceAdapt As New ProjectDataTableAdapters.webShapePriceTableAdapter
Dim _ProdTbl As ProductData.webMasterDataDataTable = _ProdAdapt.GetProductByID(MasterItemID)
If (_ProdTbl.Rows.Count = 1) Then
Dim _ProdRow As ProductData.webMasterDataRow = _ProdTbl.Rows(0)
Dim _ProdPhaseCostTbl As ProductData.webMasterPhaseCostsDataTable = _ProdPhaseCostAdapt.GetMasterPhaseCost(CompanyID, _ProdRow.MasterPhaseID)
If _ProdPhaseCostTbl.Rows.Count = 1 Then
Dim _ProdPhaseCostRow As ProductData.webMasterPhaseCostsRow = _ProdPhaseCostTbl.Rows(0)
Dim ShapeID As String = Guid.NewGuid.ToString()
Dim ZoneID As Integer = 0
If lstZone.SelectedValue <> "" Then
ZoneID = lstZone.SelectedValue
End If
If ZoneID = 0 Or LocationID = "" Then
ClientScript.RegisterClientScriptBlock(Me.GetType(), "valid", "<
script
language
=
'javascript'
>alert('Please select System and Area before adding the items');</
script
>")
Return ""
End If
Dim ProjectCostCodeID As String = ""
Dim _CostCodeAdapt As New ProjectDataTableAdapters.webProjectCostCodesTableAdapter()
Dim dtCostCode As ProjectData.webProjectCostCodesDataTable = _CostCodeAdapt.GetProjectCCByMasterCCID(ProjectID, _ProdRow.CostCodeID)
If (dtCostCode.Rows.Count = 1) Then
Dim CostCodeRow As ProjectData.webProjectCostCodesRow = dtCostCode.Rows(0)
ProjectCostCodeID = CostCodeRow.ProjectCostCodeID
ElseIf dtCostCode.Rows.Count = 0 Then
ProjectCostCodeID = Guid.NewGuid.ToString()
_CostCodeAdapt.Insert(ProjectCostCodeID, ProjectID, _ProdRow.CostCodeID, "")
End If
_CostCodeAdapt.Dispose()
Dim Pro As New ProjectFactory
Pro.InsertPhaseCost(Session("CompanyID"), Request.QueryString("QuoteID").ToString(), _ProdRow.MasterPhaseID)
ShapeAdapt.Insert(ShapeID, ProjectID, CompanyID, 0, _ProdRow.MasterItemID, "", WireLength, _ProdRow.MasterPhaseID, ZoneID, LocationID, "", "", "", "", Now(), "", ProjectCostCodeID, ProjectKitID, OptionID, _ProdRow.ExcludePOR, _ProdRow.SKU, _ProdRow.WarranteePart, _ProdRow.OneOffPart, _ProdRow.ProductDescription, _ProdRow.SalesDescription)
'ShapePriceAdapt.Insert(ShapeID, _ProdRow.Cost, _ProdRow.Price, _ProdPhaseCostRow.PhaseMgtLaborPrice, _ProdPhaseCostRow.PhaseDesignLaborPrice, _ProdPhaseCostRow.PhaseMiscLaborPrice, _ProdPhaseCostRow.MiscEquipAdjt, _ProdPhaseCostRow.MiscPartsAdjt, _ProdRow.Price, _ProdRow.FixedLaborPrice, _ProdRow.FixedLaborCost, _ProdRow.EstimatedHrs, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMiscLaborFactor, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMgtLaborFactor, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseDesignLaborFactor, _ProdRow.SalesTaxID, _ProdRow.LaborTaxID, _ProdRow.PurchaseTaxID, 0)
ShapePriceAdapt.Insert(ShapeID, _ProdRow.Cost, _ProdRow.Price, _ProdPhaseCostRow.PhaseMgtLaborPrice, _ProdPhaseCostRow.PhaseDesignLaborPrice, _ProdPhaseCostRow.PhaseMiscLaborPrice, _ProdPhaseCostRow.MiscEquipAdjt, _ProdPhaseCostRow.MiscPartsAdjt, _ProdRow.Price * WireLength, _ProdRow.FixedLaborPrice, _ProdRow.FixedLaborCost, _ProdRow.EstimatedHrs, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMiscLaborFactor, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMgtLaborFactor, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseDesignLaborFactor, "", "", "", 0, _ProdRow.Price, _ProdRow.EstimatedHrs)
Dim emailObj As New OptionEmail()
emailObj.SendEmailByType(Session("CompanyID"), "0ecaa110-5a5f-4665-a428-49638c45ea89", Session("ResourceID"), Request.QueryString("QuoteID").ToString(), "", "", "", "", "", "", "", ShapeID, "")
Return ShapeID
End If
End If
Return ""
End Function
Protected Sub AddItem_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles AddItem.Click
Dim ProjectID As String = ""
If Request.QueryString("ChangeRequestID") <> Nothing Then
Dim CORAdapt As New ChangeRequestDataTableAdapters.webChangeRequestsTableAdapter
Dim CORTbl As ChangeRequestData.webChangeRequestsDataTable = CORAdapt.GetChangeRequestByID(Request.QueryString("ChangeRequestID").ToString())
If CORTbl.Rows.Count = 1 Then
Dim CORRow As ChangeRequestData.webChangeRequestsRow = CORTbl.Rows(0)
ProjectID = CORRow.ProjectID
End If
End If
If Request.QueryString("ProductID") <> Nothing Then
Dim _KitItemsAdapt As New ProductDataTableAdapters.webMasterKitItemsTableAdapter
Dim KitID As String = Request.QueryString("ProductID")
For Each gridRow As Telerik.Web.UI.GridItem In SelectItemGrid.SelectedItems
Dim ProductID As String = gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("ID").ToString() 'gridRow.Cells(3).Text
_KitItemsAdapt.Insert(Guid.NewGuid().ToString(), KitID, ProductID, 1)
Next
_KitItemsAdapt.Dispose()
ElseIf Request.QueryString("QuoteID") <> Nothing Then
'Dim collection As IList(Of RadComboBoxItem) = TaskInfoLocations.CheckedItems
'For Each item As RadComboBoxItem In collection
' Dim ZoneID As Integer = 0
' If TaskInfoZone.SelectedValue <> "" Then
' ZoneID = TaskInfoZone.SelectedValue
' End If
' If ZoneID = 0 Or TaskInfoLocations.SelectedValue = "" Then
' ClientScript.RegisterClientScriptBlock(Me.GetType(), "valid", "<
script
language
=
'javascript'
>alert('Please select System and Area before adding the items');</
script
>")
' Return
' End If
' Dim ShapeID As String = ""
' Dim WireLength As Int32 = 1
' For Each gridRow As Telerik.Web.UI.GridItem In SelectItemGrid.SelectedItems
' For j As Int32 = 1 To txtQuantity.Value
' Dim ProductID As String = gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("ID").ToString() 'gridRow.Cells(3).Text
' If IsWire(Session("CompanyID"), ProductID) Then
' WireLength = txtQuantity.Value
' j = txtQuantity.Value
' End If
' 'If gridRow.Cells(9).Text = "false" Then
' If gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("IsPackage").ToString() = "false" Then
' ShapeID = AddProduct(Session("CompanyID"), Request.QueryString("QuoteID").ToString(), ProductID, "", "", WireLength, item.Value)
' 'Adding Options items if any
' Dim MasterOptionID As String = ProductID 'gridRow.Cells(3).Text
' Dim _MasterOptionAdapt As New ProductDataTableAdapters.webMasterOptionsTableAdapter
' Dim _MasterOptionTbl As ProductData.webMasterOptionsDataTable = _MasterOptionAdapt.GetKitOptionsByKitID(Session("CompanyID"), ProductID)
' For Each _MasterOptionRow As ProductData.webMasterOptionsRow In _MasterOptionTbl.Rows
' For i As Int32 = 0 To _MasterOptionRow.OptionQuantity - 1
' Dim OptionWireLength As Int32 = 1
' If IsWire(Session("CompanyID"), _MasterOptionRow.ChildMasterItemID) Then
' OptionWireLength = _MasterOptionRow.OptionQuantity * WireLength
' AddProduct(Session("CompanyID"), Request.QueryString("QuoteID").ToString(), _MasterOptionRow.ChildMasterItemID, "", ShapeID, OptionWireLength, item.Value)
' 'Exit For
' i = _MasterOptionRow.OptionQuantity - 1
' Else
' AddProduct(Session("CompanyID"), Request.QueryString("QuoteID").ToString(), _MasterOptionRow.ChildMasterItemID, "", ShapeID, OptionWireLength, item.Value)
' End If
' Next
' Next
' Else
' 'if it is package
' 'If gridRow.Cells(9).Text = "true" Then
' If gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("IsPackage").ToString() = "true" Then
' Dim KitMasterItemID As String = gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("ID").ToString() ' gridRow.Cells(3).Text
' Dim _KitMasterAdapt As New ProductDataTableAdapters.webMasterKitsTableAdapter
' Dim _KitTbl As ProductData.webMasterKitsDataTable = _KitMasterAdapt.GetMasterKitItemID(Session("CompanyID").ToString(), KitMasterItemID)
' If _KitTbl.Rows.Count = 1 Then
' Dim _KitRow As ProductData.webMasterKitsRow = _KitTbl.Rows(0)
' Dim _projShape As New ProjectDataTableAdapters.webShape1TableAdapter()
' Dim ShapePriceAdapt As New ProjectDataTableAdapters.webShapePriceTableAdapter
' Dim ProjectKitID As String = Guid.NewGuid().ToString()
' _projShape.Insert(ProjectKitID, Request.QueryString("QuoteID").ToString(), Session("CompanyID"), 0, _KitRow.KitMasterItemID, 0, 1, "", 0, "", "", "", "", "", DateTime.Now, "", "", ProjectKitID, "", False, _KitRow.KitSku, False, False, "", "")
' ShapePriceAdapt.Insert(ProjectKitID, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", "", 0, 0, 0)
' Dim _KitMasterItemAdapt As New ProductDataTableAdapters.webMasterKitItemsTableAdapter
' Dim _KitMasterItemTbl As ProductData.webMasterKitItemsDataTable = _KitMasterItemAdapt.GetMasterKitItemsByKitID(KitMasterItemID)
' If _KitMasterItemTbl.Rows.Count > 0 Then
' 'Dim _KitItemsRow As ProductData.webMasterKitItemsRow = _KitMasterItemTbl.Rows(0)
' Dim KitItemWireLength As Int32 = 1
' For Each _KitItemsRow As ProductData.webMasterKitItemsRow In _KitMasterItemTbl.Rows
' For i As Int32 = 0 To _KitItemsRow.KitItemQuantity - 1
' If IsWire(Session("CompanyID"), _KitItemsRow.MasterItemID) Then
' KitItemWireLength = _KitItemsRow.KitItemQuantity
' ShapeID = AddProduct(Session("CompanyID"), Request.QueryString("QuoteID").ToString(), _KitItemsRow.MasterItemID, ProjectKitID, "", KitItemWireLength, item.Value)
' i = _KitItemsRow.KitItemQuantity - 1
' Else
' ShapeID = AddProduct(Session("CompanyID"), Request.QueryString("QuoteID").ToString(), _KitItemsRow.MasterItemID, ProjectKitID, "", KitItemWireLength, item.Value)
' End If
' 'adding Item Option
' Dim _MasterOptionAdapt As New ProductDataTableAdapters.webMasterOptionsTableAdapter
' Dim _MasterOptionTbl As ProductData.webMasterOptionsDataTable = _MasterOptionAdapt.GetKitOptionsByKitID(Session("CompanyID"), _KitItemsRow.MasterItemID)
' For Each _MasterOptionRow As ProductData.webMasterOptionsRow In _MasterOptionTbl.Rows
' Dim k As Int32
' k = 0
' For k = 0 To _MasterOptionRow.OptionQuantity - 1
' Dim OptionWireLength As Int32 = 1
' If IsWire(Session("CompanyID"), _MasterOptionRow.ChildMasterItemID) Then
' OptionWireLength = _MasterOptionRow.OptionQuantity
' AddProduct(Session("CompanyID"), Request.QueryString("QuoteID").ToString(), _MasterOptionRow.ChildMasterItemID, ProjectKitID, ShapeID, OptionWireLength, item.Value)
' k = _MasterOptionRow.OptionQuantity - 1
' Else
' AddProduct(Session("CompanyID"), Request.QueryString("QuoteID").ToString(), _MasterOptionRow.ChildMasterItemID, ProjectKitID, ShapeID, OptionWireLength, item.Value)
' End If
' Next k
' Next
' Next i
' Next
' End If
' End If
' 'ElseIf gridRow.Cells(9).Text = "OptionItem" Then
' ElseIf gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("IsPackage").ToString() = "OptionItem" Then
' ' Dim MasterOptionID As String = gridRow.Cells(3).Text
' ' Dim _MasterOptionAdapt As New ProductDataTableAdapters.webMasterOptionsTableAdapter
' ' Dim _MasterOptionTbl As ProductData.webMasterOptionsDataTable = _MasterOptionAdapt.GetProductOptionID(Session("CompanyID"), MasterOptionID)
' ' For Each _MasterOptionRow As ProductData.webMasterOptionsRow In _MasterOptionTbl.Rows
' ' For i As Int32 = 0 To _MasterOptionRow.OptionQuantity - 1
' ' Dim OptionWireLength As Int32 = 1
' ' If IsWire(Session("CompanyID"), _MasterOptionRow.ChildMasterItemID) Then
' ' OptionWireLength = _MasterOptionRow.OptionQuantity
' ' AddProduct(Session("CompanyID"), Request.QueryString("ProjectID").ToString(), _MasterOptionRow.ChildMasterItemID, "", ShapeID, OptionWireLength)
' ' Exit For
' ' Else
' ' AddProduct(Session("CompanyID"), Request.QueryString("ProjectID").ToString(), _MasterOptionRow.ChildMasterItemID, "", ShapeID, OptionWireLength)
' ' End If
' ' Next
' ' Next
' End If
' End If
' Next
' Next
'Next
Dim collection As IList(Of RadComboBoxItem) = lstLocationArea.CheckedItems
For Each item As RadComboBoxItem In collection
Dim ctr As Int32 = 0
Dim ShapeID As String = ""
Dim WireLength As Int32 = 1
For Each gridRow As GridNestedViewItem In SelectItemGrid.MasterTableView.GetItems(GridItemType.NestedView)
Dim box As CheckBox = CType(SelectItemGrid.MasterTableView.Items(ctr).FindControl("ClientSelectColumnSelectCheckBox"), CheckBox)
If box.Checked = False Then
ctr += 1
Continue For
End If
'For Each gridRow As Telerik.Web.UI.GridItem In SelectItemGrid.SelectedItems
For j As Int32 = 1 To txtQuantity.Value
Dim ProductID As String = gridRow.OwnerTableView.DataKeyValues(ctr)("ID").ToString() 'gridRow.Cells(3).Text
If IsWire(Session("CompanyID"), ProductID) Then
WireLength = txtQuantity.Value
j = txtQuantity.Value
End If
'If gridRow.Cells(9).Text = "false" Then
If gridRow.OwnerTableView.DataKeyValues(ctr)("IsPackage").ToString() = "false" Then
ShapeID = AddProduct(Session("CompanyID"), Request.QueryString("QuoteID").ToString(), ProductID, "", "", WireLength, item.Value)
End If
If gridRow.NestedTableViews.Length > 0 Then
'if it is package/option
For jctr As Int32 = 0 To gridRow.NestedTableViews(0).DataKeyValues.Count - 1
Dim Childbox As CheckBox = CType(gridRow.NestedTableViews(0).Items(jctr).FindControl("ClientSelectColumnSelectCheckBox"), CheckBox)
If Childbox.Checked = False Then
Continue For
End If
If gridRow.OwnerTableView.DataKeyValues(ctr)("IsPackage").ToString() = "true" Then
Dim KitMasterItemID As String = gridRow.NestedTableViews(0).DataKeyValues(jctr)("ID1").ToString()
' Dim KitMasterItemID As String = gridRow.OwnerTableView.DataKeyValues(jctr)("ID").ToString() 'gridRow.Cells(3).Text
Dim _KitMasterAdapt As New ProductDataTableAdapters.webMasterKitsTableAdapter
Dim _KitTbl As ProductData.webMasterKitsDataTable = _KitMasterAdapt.GetMasterKitItemID(Session("CompanyID").ToString(), KitMasterItemID)
If _KitTbl.Rows.Count = 1 Then
Dim _KitRow As ProductData.webMasterKitsRow = _KitTbl.Rows(0)
Dim ProjectKitID As String = Guid.NewGuid().ToString()
'inserting package
'Dim CORItems1 As New ChangeRequestDataTableAdapters.webChangeRequestItemsTableAdapter
ShapeID = Guid.NewGuid.ToString()
'ProjectCostCode
Dim ProjectCostCodeID As String = ""
Dim _ProdAdapt As New ProductDataTableAdapters.webMasterDataTableAdapter
Dim _ProdTbl As ProductData.webMasterDataDataTable = _ProdAdapt.GetProductByID(KitMasterItemID)
If (_ProdTbl.Rows.Count = 1) Then
Dim _ProdRow As ProductData.webMasterDataRow = _ProdTbl.Rows(0)
If _ProdRow.CostCodeID <> "" Then
ProjectCostCodeID = GetProjectCostCodeID(ProjectID, _ProdRow.CostCodeID)
End If
End If
''
'CORItems1.Insert(CORShapeID, Request.QueryString("ChangeRequestID").ToString(), _KitRow.KitMasterItemID, "New", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", "", 0, "", "", "", 1, "", "", CORShapeID, "", "", "", _KitRow.KitSku, ProjectCostCodeID, False, False, "", "")
Dim _KitMasterItemAdapt As New ProductDataTableAdapters.webMasterKitItemsTableAdapter
Dim _KitMasterItemTbl As ProductData.webMasterKitItemsDataTable = _KitMasterItemAdapt.GetMasterKitItemsByKitID(KitMasterItemID)
For Each _KitItemsRow As ProductData.webMasterKitItemsRow In _KitMasterItemTbl.Rows
'Dim _KitItemsRow As ProductData.webMasterKitItemsRow = _KitMasterItemTbl.Rows(0)
Dim KitItemWireLength As Int32 = 1
For i As Int32 = 0 To _KitItemsRow.KitItemQuantity - 1
If IsWire(Session("CompanyID"), _KitItemsRow.MasterItemID) Then
KitItemWireLength = _KitItemsRow.KitItemQuantity
ShapeID = AddProduct(Session("CompanyID"), Request.QueryString("QuoteID").ToString(), _KitItemsRow.MasterItemID, ShapeID, "", KitItemWireLength, item.Value)
i = _KitItemsRow.KitItemQuantity - 1
Else
ShapeID = AddProduct(Session("CompanyID"), Request.QueryString("QuoteID").ToString(), _KitItemsRow.MasterItemID, ShapeID, "", KitItemWireLength, item.Value)
End If
Next i
Next
End If
ElseIf gridRow.NestedTableViews(0).DataKeyValues(jctr)("IsPackage").ToString() = "OptionItem" Then
'ElseIf gridRow.OwnerTableView.DataKeyValues(jctr)("IsPackage").ToString() = "OptionItem" Then
Dim NestedProductID As String = gridRow.NestedTableViews(0).DataKeyValues(jctr)("ID1").ToString()
Dim MasterOptionID As String = gridRow.OwnerTableView.DataKeyValues(jctr)("ID").ToString() 'gridRow.Cells(3).Text
Dim _MasterOptionAdapt As New ProductDataTableAdapters.webMasterOptionsTableAdapter
Dim _MasterOptionTbl As ProductData.webMasterOptionsDataTable = _MasterOptionAdapt.GetProductOptionID(Session("CompanyID"), NestedProductID)
For Each _MasterOptionRow As ProductData.webMasterOptionsRow In _MasterOptionTbl.Rows
For i As Int32 = 0 To _MasterOptionRow.OptionQuantity - 1
Dim OptionWireLength As Int32 = 1
If IsWire(Session("CompanyID"), _MasterOptionRow.ChildMasterItemID) Then
OptionWireLength = _MasterOptionRow.OptionQuantity
AddProduct(Session("CompanyID"), Request.QueryString("QuoteID").ToString(), _MasterOptionRow.ChildMasterItemID, "", ShapeID, OptionWireLength, item.Value)
Exit For
Else
AddProduct(Session("CompanyID"), Request.QueryString("QuoteID").ToString(), _MasterOptionRow.ChildMasterItemID, "", ShapeID, OptionWireLength, item.Value)
End If
Next
Next
End If
Next
End If
Next
ctr += 1
Next ' counter
Next
ElseIf Request.QueryString("ProjectID") = Nothing Then
Dim CORShapeID As String = ""
Dim WireLength As Int32 = 1
For Each gridRow As Telerik.Web.UI.GridItem In SelectItemGrid.SelectedItems
For j As Int32 = 1 To txtQuantity.Value
Dim ProductID As String = gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("ID").ToString() 'gridRow.Cells(3).Text
If IsWire(Session("CompanyID"), ProductID) Then
WireLength = txtQuantity.Value
j = txtQuantity.Value
End If
'If gridRow.Cells(9).Text = "false" Then
If gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("IsPackage").ToString() = "false" Then
CORShapeID = AddCORProduct(Session("CompanyID"), ProjectID, Request.QueryString("ChangeRequestID").ToString(), ProductID, "", "", WireLength)
Else
'if it is package/option
If gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("IsPackage").ToString() = "true" Then
Dim KitMasterItemID As String = gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("ID").ToString() 'gridRow.Cells(3).Text
Dim _KitMasterAdapt As New ProductDataTableAdapters.webMasterKitsTableAdapter
Dim _KitTbl As ProductData.webMasterKitsDataTable = _KitMasterAdapt.GetMasterKitItemID(Session("CompanyID").ToString(), KitMasterItemID)
If _KitTbl.Rows.Count = 1 Then
Dim _KitRow As ProductData.webMasterKitsRow = _KitTbl.Rows(0)
Dim ProjectKitID As String = Guid.NewGuid().ToString()
'inserting package
Dim CORItems1 As New ChangeRequestDataTableAdapters.webChangeRequestItemsTableAdapter
CORShapeID = Guid.NewGuid.ToString()
'ProjectCostCode
Dim ProjectCostCodeID As String = ""
Dim _ProdAdapt As New ProductDataTableAdapters.webMasterDataTableAdapter
Dim _ProdTbl As ProductData.webMasterDataDataTable = _ProdAdapt.GetProductByID(KitMasterItemID)
If (_ProdTbl.Rows.Count = 1) Then
Dim _ProdRow As ProductData.webMasterDataRow = _ProdTbl.Rows(0)
If _ProdRow.CostCodeID <> "" Then
ProjectCostCodeID = GetProjectCostCodeID(ProjectID, _ProdRow.CostCodeID)
End If
End If
''
CORItems1.Insert(CORShapeID, Request.QueryString("ChangeRequestID").ToString(), _KitRow.KitMasterItemID, "New", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "", "", "", 0, "", "", "", 1, "", "", CORShapeID, "", "", "", _KitRow.KitSku, ProjectCostCodeID, False, False, "", "")
Dim _KitMasterItemAdapt As New ProductDataTableAdapters.webMasterKitItemsTableAdapter
Dim _KitMasterItemTbl As ProductData.webMasterKitItemsDataTable = _KitMasterItemAdapt.GetMasterKitItemsByKitID(KitMasterItemID)
For Each _KitItemsRow As ProductData.webMasterKitItemsRow In _KitMasterItemTbl.Rows
'Dim _KitItemsRow As ProductData.webMasterKitItemsRow = _KitMasterItemTbl.Rows(0)
For i As Int32 = 0 To _KitItemsRow.KitItemQuantity - 1
AddCORProduct(Session("CompanyID"), ProjectID, Request.QueryString("ChangeRequestID").ToString(), _KitItemsRow.MasterItemID, CORShapeID, "", 1)
Next i
Next
End If
ElseIf gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("IsPackage").ToString() = "OptionItem" Then
Dim MasterOptionID As String = gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("ID").ToString() 'gridRow.Cells(3).Text
Dim _MasterOptionAdapt As New ProductDataTableAdapters.webMasterOptionsTableAdapter
Dim _MasterOptionTbl As ProductData.webMasterOptionsDataTable = _MasterOptionAdapt.GetProductOptionID(Session("CompanyID"), MasterOptionID)
For Each _MasterOptionRow As ProductData.webMasterOptionsRow In _MasterOptionTbl.Rows
For i As Int32 = 0 To _MasterOptionRow.OptionQuantity - 1
AddCORProduct(Session("CompanyID"), ProjectID, Request.QueryString("ChangeRequestID").ToString(), _MasterOptionRow.ChildMasterItemID, "", CORShapeID, 1)
Next
Next
End If
End If
Next
Next ' counter
'Dim CORItems As New ChangeRequestDataTableAdapters.webChangeRequestItemsTableAdapter
'Dim _ProdAdapt As New ProductDataTableAdapters.webMasterDataTableAdapter
'Dim _ProdPhaseCostAdapt As New ProductDataTableAdapters.webMasterPhaseCostsTableAdapter
'For Each gridRow As Telerik.Web.UI.GridItem In SelectItemGrid.SelectedItems
' Dim ProductID As String = gridRow.Cells(3).Text
' Dim _ProdTbl As ProductData.webMasterDataDataTable = _ProdAdapt.GetProductByID(ProductID)
' If (_ProdTbl.Rows.Count = 1) Then
' Dim _ProdRow As ProductData.webMasterDataRow = _ProdTbl.Rows(0)
' Dim _ProdPhaseCostTbl As ProductData.webMasterPhaseCostsDataTable = _ProdPhaseCostAdapt.GetMasterPhaseCost(Session("CompanyID"), _ProdRow.MasterPhaseID)
' Dim ZoneID As Integer = IIf(TaskInfoZone.SelectedValue = "", 0, TaskInfoZone.SelectedValue)
' If ZoneID = 0 Or TaskInfoLocations.SelectedValue = "" Then
' ClientScript.RegisterClientScriptBlock(Me.GetType(), "valid", "<
script
language
=
'javascript'
>alert('Please select System and Area before adding the items');</
script
>")
' Return
' End If
' If _ProdPhaseCostTbl.Rows.Count = 1 Then
' Dim _ProdPhaseCostRow As ProductData.webMasterPhaseCostsRow = _ProdPhaseCostTbl.Rows(0)
' CORItems.Insert(Guid.NewGuid.ToString(), Request.QueryString("ChangeRequestID").ToString(), _ProdRow.MasterItemID, "New", _ProdRow.Cost, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseLaborPrice, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMgtLaborFactor * _ProdPhaseCostRow.PhaseMgtLaborPrice, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseDesignLaborFactor * _ProdPhaseCostRow.PhaseDesignLaborPrice, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMiscLaborFactor * _ProdPhaseCostRow.PhaseMiscLaborPrice, _ProdRow.Price * _ProdPhaseCostRow.MiscEquipAdjt, _ProdRow.Price * _ProdPhaseCostRow.MiscPartsAdjt, _ProdRow.Price, _ProdRow.FixedLaborPrice, _ProdRow.FixedLaborCost, _ProdRow.EstimatedHrs, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMiscLaborFactor, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMgtLaborFactor, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseDesignLaborFactor, _ProdRow.SalesTaxID, _ProdRow.LaborTaxID, _ProdRow.PurchaseTaxID, 0, TaskInfoLocations.SelectedValue, TaskInfoZone.SelectedValue, "", 1, "", _ProdRow.MasterPhaseID, "", "")
' End If
' End If
'Next
Else
Dim CORItems As New ChangeRequestDataTableAdapters.webChangeRequestItemsTableAdapter
Dim ShapeAdapt As New ProjectDataTableAdapters.webShape1TableAdapter
Dim ShapePriceAdapt As New ProjectDataTableAdapters.webShapePriceTableAdapter
Dim CORShapeID As String = ""
Dim WireLength As Int32 = 1
For Each gridRow As Telerik.Web.UI.GridItem In SelectItemGrid.SelectedItems
For j As Int32 = 1 To txtQuantity.Value
Dim ShapeID As String = gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("ID").ToString() 'gridRow.Cells(3).Text
Dim _ShapeTbl As ProjectData.webShape1DataTable = ShapeAdapt.GetShapeByID(Session("CompanyID").ToString(), ShapeID)
Dim _ShapePriceTbl As ProjectData.webShapePriceDataTable = ShapePriceAdapt.GetShapePriceByID(Session("CompanyID").ToString(), ShapeID)
If _ShapeTbl.Rows.Count = 1 And _ShapePriceTbl.Rows.Count = 1 Then
Dim _ShapeRow As ProjectData.webShape1Row = _ShapeTbl.Rows(0)
Dim _ShapePriceRow As ProjectData.webShapePriceRow = _ShapePriceTbl.Rows(0)
If IsWire(Session("CompanyID"), _ShapeRow.MasterItemID) Then
WireLength = txtQuantity.Value
j = txtQuantity.Value
End If
If gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("IsPackage").ToString() = "false" Then
CheckAddProjectTaxes(ProjectID, _ShapePriceRow.CostTaxID)
CheckAddProjectTaxes(ProjectID, _ShapePriceRow.LaborTaxID)
CheckAddProjectTaxes(ProjectID, _ShapePriceRow.SalesTaxID)
CORShapeID = Guid.NewGuid().ToString()
CORItems.Insert(CORShapeID, Request.QueryString("ChangeRequestID").ToString(), _ShapeRow.MasterItemID, "Removed", _ShapePriceRow.Cost, _ShapePriceRow.LaborPrice, _ShapePriceRow.MgtLaborPrice, _ShapePriceRow.DesignLaborPrice, _ShapePriceRow.MiscLaborPrice, _ShapePriceRow.EquipmentAdjustment, _ShapePriceRow.MiscPartsAdjustment, _ShapePriceRow.ExtendedPrice, _ShapePriceRow.FixedLaborPrice, _ShapePriceRow.FixedLaborCost, _ShapePriceRow.BaseLaborHours, _ShapePriceRow.MiscHours, _ShapePriceRow.MgtHours, _ShapePriceRow.DesignHours, _ShapePriceRow.SalesTaxID, _ShapePriceRow.LaborTaxID, _ShapePriceRow.CostTaxID, 0, _ShapeRow.LocationID, _ShapeRow.ZoneID, _ShapeRow.ProjectItemID, WireLength, _ShapeRow.ShapeID, _ShapeRow.PhaseID, "", "", _ShapeRow.DTEquipmentGUID, _ShapeRow.ComponentID, _ShapeRow.SKU, _ShapeRow.CostCodeID, _ShapeRow.WarranteePart, _ShapeRow.OneOffPart, _ShapeRow.ProductDescription, _ShapeRow.SalesDescription)
'CORItems.Insert(CORShapeID, Request.QueryString("ChangeRequestID").ToString(), _ShapeRow.MasterItemID, "Removed", _ShapePriceRow.Cost, _ShapePriceRow.LaborPrice, _ShapePriceRow.MgtLaborPrice, _ShapePriceRow.DesignLaborPrice, _ShapePriceRow.MiscLaborPrice, _ShapePriceRow.EquipmentAdjustment, _ShapePriceRow.MiscPartsAdjustment, _ShapePriceRow.ExtendedPrice, _ShapePriceRow.FixedLaborPrice, _ShapePriceRow.FixedLaborCost, _ShapePriceRow.BaseLaborHours, _ShapePriceRow.MiscHours, _ShapePriceRow.MgtHours, _ShapePriceRow.DesignHours, _ShapePriceRow.SalesTaxID, _ShapePriceRow.LaborTaxID, _ShapePriceRow.CostTaxID, 0, _ShapeRow.ZoneID, _ShapeRow.LocationID, _ShapeRow.ProjectItemID, _ShapeRow.WireLength, _ShapeRow.ShapeID, _ShapeRow.PhaseID, "", "")
Else
If gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("IsPackage").ToString() = "true" Then
CheckAddProjectTaxes(ProjectID, _ShapePriceRow.CostTaxID)
CheckAddProjectTaxes(ProjectID, _ShapePriceRow.LaborTaxID)
CheckAddProjectTaxes(ProjectID, _ShapePriceRow.SalesTaxID)
CORShapeID = Guid.NewGuid().ToString()
CORItems.Insert(CORShapeID, Request.QueryString("ChangeRequestID").ToString(), _ShapeRow.MasterItemID, "Removed", _ShapePriceRow.Cost, _ShapePriceRow.LaborPrice, _ShapePriceRow.MgtLaborPrice, _ShapePriceRow.DesignLaborPrice, _ShapePriceRow.MiscLaborPrice, _ShapePriceRow.EquipmentAdjustment, _ShapePriceRow.MiscPartsAdjustment, _ShapePriceRow.ExtendedPrice, _ShapePriceRow.FixedLaborPrice, _ShapePriceRow.FixedLaborCost, _ShapePriceRow.BaseLaborHours, _ShapePriceRow.MiscHours, _ShapePriceRow.MgtHours, _ShapePriceRow.DesignHours, _ShapePriceRow.SalesTaxID, _ShapePriceRow.LaborTaxID, _ShapePriceRow.CostTaxID, 0, _ShapeRow.LocationID, _ShapeRow.ZoneID, _ShapeRow.ProjectItemID, _ShapeRow.WireLength, _ShapeRow.ShapeID, _ShapeRow.PhaseID, CORShapeID, "", _ShapeRow.DTEquipmentGUID, _ShapeRow.ComponentID, _ShapeRow.SKU, _ShapeRow.CostCodeID, _ShapeRow.WarranteePart, _ShapeRow.OneOffPart, _ShapeRow.ProductDescription, _ShapeRow.SalesDescription)
Dim _KitItemShapeAdapt As New ProjectDataTableAdapters.webShape1TableAdapter
Dim _KitItemShapeTbl As ProjectData.webShape1DataTable = _KitItemShapeAdapt.GetKitShapeItemsByKitID(Session("CompanyID").ToString(), Request.QueryString("ProjectID").ToString(), _ShapeRow.ShapeID)
For Each _KitShapeRow As ProjectData.webShape1Row In _KitItemShapeTbl.Rows
AddCORRemovedProduct(Session("CompanyID"), ProjectID, Request.QueryString("ChangeRequestID").ToString(), _KitShapeRow.ShapeID, _KitShapeRow.MasterItemID, CORShapeID, "")
Next
'If _KitMasterItemTbl.Rows.Count = 1 Then
' Dim _KitItemsRow As ProductData.webMasterKitItemsRow = _KitMasterItemTbl.Rows(0)
' For i As Int32 = 0 To _KitItemsRow.KitItemQuantity - 1
' AddCORRemovedProduct(Session("CompanyID"), Request.QueryString("ProjectID").ToString(), Request.QueryString("ChangeRequestID").ToString(), _KitItemsRow.MasterItemID, CORShapeID, "")
' Next i
'End If
ElseIf gridRow.OwnerTableView.DataKeyValues(gridRow.ItemIndex)("IsPackage").ToString() = "OptionItem" Then
CheckAddProjectTaxes(ProjectID, _ShapePriceRow.CostTaxID)
CheckAddProjectTaxes(ProjectID, _ShapePriceRow.LaborTaxID)
CheckAddProjectTaxes(ProjectID, _ShapePriceRow.SalesTaxID)
CORItems.Insert(Guid.NewGuid().ToString(), Request.QueryString("ChangeRequestID").ToString(), _ShapeRow.MasterItemID, "Removed", _ShapePriceRow.Cost, _ShapePriceRow.LaborPrice, _ShapePriceRow.MgtLaborPrice, _ShapePriceRow.DesignLaborPrice, _ShapePriceRow.MiscLaborPrice, _ShapePriceRow.EquipmentAdjustment, _ShapePriceRow.MiscPartsAdjustment, _ShapePriceRow.ExtendedPrice, _ShapePriceRow.FixedLaborPrice, _ShapePriceRow.FixedLaborCost, _ShapePriceRow.BaseLaborHours, _ShapePriceRow.MiscHours, _ShapePriceRow.MgtHours, _ShapePriceRow.DesignHours, _ShapePriceRow.SalesTaxID, _ShapePriceRow.LaborTaxID, _ShapePriceRow.CostTaxID, 0, _ShapeRow.LocationID, _ShapeRow.ZoneID, _ShapeRow.ProjectItemID, _ShapeRow.WireLength, _ShapeRow.ShapeID, _ShapeRow.PhaseID, "", CORShapeID, _ShapeRow.DTEquipmentGUID, _ShapeRow.ComponentID, _ShapeRow.SKU, _ShapeRow.CostCodeID, _ShapeRow.WarranteePart, _ShapeRow.OneOffPart, _ShapeRow.ProductDescription, _ShapeRow.SalesDescription)
Dim _ProjCOItemTbl As ChangeRequestData.webChangeRequestItemsDataTable = CORItems.GetCRItemID(CORShapeID)
'If _ProjCOItemTbl.Rows.Count = 1 Then
' Dim _ProjCOItemRow As ChangeRequestData.webChangeRequestItemsRow = _ProjCOItemTbl.Rows(0)
' _ProjCOItemRow.OptionID = CORShapeID
' CORItems.Update(_ProjCOItemRow)
'End If
End If
End If
'CORItems.Insert(Guid.NewGuid.ToString(), Request.QueryString("ChangeRequestID").ToString(), _ShapeRow.MasterItemID, "Removed", _ShapePriceRow.Cost, _ShapePriceRow.LaborPrice, _ShapePriceRow.MgtLaborPrice, _ShapePriceRow.DesignLaborPrice, _ShapePriceRow.MiscLaborPrice, _ShapePriceRow.EquipmentAdjustment, _ShapePriceRow.MiscPartsAdjustment, _ShapePriceRow.ExtendedPrice, _ShapePriceRow.FixedLaborPrice, _ShapePriceRow.FixedLaborCost, _ShapePriceRow.BaseLaborHours, _ShapePriceRow.MiscHours, _ShapePriceRow.MgtHours, _ShapePriceRow.DesignHours, _ShapePriceRow.SalesTaxID, _ShapePriceRow.LaborTaxID, _ShapePriceRow.CostTaxID, _ShapePriceRow.LaborCalcMethod, _ShapeRow.LocationID, _ShapeRow.ZoneID, _ShapeRow.ProjectItemID, _ShapeRow.WireLength, _ShapeRow.ShapeID, _ShapeRow.PhaseID, _ShapeRow.ProjectKitID, _ShapeRow.OptionID)
End If
Next
Next
ShapeAdapt.Dispose()
ShapePriceAdapt.Dispose()
End If
'ClientScript.RegisterClientScriptBlock(Me.GetType(), "saved", "<
script
language
=
'javascript'
>window.opener.location.reload(true);window.close();</
script
>")
'COAction=Duplicate
If Request.QueryString("COAction") = "Duplicate" Or Request.QueryString("Action") = "Replace" Then
ClientScript.RegisterClientScriptBlock(Me.GetType(), "saved", "<
script
language
=
'javascript'
>window.opener.RefreshItemsGrid();window.close();</
script
>")
Else
ClientScript.RegisterClientScriptBlock(Me.GetType(), "saved", "<
script
language
=
'javascript'
>window.opener.RefreshItemsGrid();</
script
>")
End If
End Sub
Protected Sub RadToolBar1_ButtonClick(ByVal sender As Object, ByVal e As RadToolBarEventArgs)
End Sub
Function AddCORProduct(ByVal CompanyID As String, ByVal ProjectID As String, ByVal ChangeRequestID As String, ByVal MasterItemID As String, ByVal ProjectKitID As String, ByVal OptionID As String, ByVal WireLength As Int32) As String
Dim _ProdAdapt As New ProductDataTableAdapters.webMasterDataTableAdapter
Dim _ProdPhaseCostAdapt As New ProductDataTableAdapters.webMasterPhaseCostsTableAdapter
Dim _ProdTbl As ProductData.webMasterDataDataTable = _ProdAdapt.GetProductByID(MasterItemID)
If (_ProdTbl.Rows.Count = 1) Then
Dim _ProdRow As ProductData.webMasterDataRow = _ProdTbl.Rows(0)
Dim _ProdPhaseCostTbl As ProductData.webMasterPhaseCostsDataTable = _ProdPhaseCostAdapt.GetMasterPhaseCost(CompanyID, _ProdRow.MasterPhaseID)
If _ProdPhaseCostTbl.Rows.Count = 1 Then
Dim _ProdPhaseCostRow As ProductData.webMasterPhaseCostsRow = _ProdPhaseCostTbl.Rows(0)
Dim CORShapeID As String = Guid.NewGuid.ToString()
Dim ZoneID As Integer = 0
If lstZone.SelectedValue <> "" Then
ZoneID = lstZone.SelectedValue
End If
If ZoneID = 0 Or lstLocationArea.SelectedValue = "" Then
ClientScript.RegisterClientScriptBlock(Me.GetType(), "valid", "<
script
language
=
'javascript'
>alert('Please select System and Area before adding the items');</
script
>")
Return ""
End If
Dim CORItems As New ChangeRequestDataTableAdapters.webChangeRequestItemsTableAdapter
CheckAddProjectTaxes(ProjectID, _ProdRow.PurchaseTaxID)
CheckAddProjectTaxes(ProjectID, _ProdRow.LaborTaxID)
CheckAddProjectTaxes(ProjectID, _ProdRow.SalesTaxID)
Dim ProjectCostCodeID As String = ""
If _ProdRow.CostCodeID <> "" Then
ProjectCostCodeID = GetProjectCostCodeID(ProjectID, _ProdRow.CostCodeID)
End If
CORItems.Insert(CORShapeID, ChangeRequestID, _ProdRow.MasterItemID, "New", _ProdRow.Cost, _ProdPhaseCostRow.PhaseLaborPrice, _ProdPhaseCostRow.PhaseMgtLaborPrice, _ProdPhaseCostRow.PhaseDesignLaborPrice, _ProdPhaseCostRow.PhaseMiscLaborPrice, _ProdPhaseCostRow.PhaseMiscProductFactor, _ProdPhaseCostRow.PhaseMiscPartsFactor, _ProdRow.Price * WireLength, 0, 0, _ProdRow.EstimatedHrs, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMiscLaborFactor, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMgtLaborFactor, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseDesignLaborFactor, _ProdRow.SalesTaxID, _ProdRow.LaborTaxID, _ProdRow.PurchaseTaxID, 0, lstLocationArea.SelectedValue, ZoneID, "0", WireLength, "", _ProdRow.MasterPhaseID, ProjectKitID, OptionID, "", "", _ProdRow.SKU, ProjectCostCodeID, _ProdRow.WarranteePart, _ProdRow.OneOffPart, _ProdRow.ProductDescription, _ProdRow.SalesDescription)
Return CORShapeID
End If
End If
Return ""
End Function
Sub CheckAddProjectTaxes(ByRef ProjectID As String, ByRef TaxID As String)
If TaxID = "" Then
Return
End If
Dim _ProjTaxesAdapt As New ProjectDataTableAdapters.webTaxesTableAdapter
Dim _ProjTaxesTbl As ProjectData.webTaxesDataTable = _ProjTaxesAdapt.GetTaxbyID(ProjectID, TaxID)
If _ProjTaxesTbl.Rows.Count = 0 Then
Dim _MasterTaxAdapt As New CompanyDataTableAdapters.webMasterTaxesTableAdapter
Dim _MasterTaxTbl As CompanyData.webMasterTaxesDataTable = _MasterTaxAdapt.GetMasterTaxByID(TaxID)
If _MasterTaxTbl.Rows.Count = 1 Then
Dim _MasterTaxRow As CompanyData.webMasterTaxesRow = _MasterTaxTbl.Rows(0)
_ProjTaxesAdapt.Insert(TaxID, ProjectID, _MasterTaxRow.TaxCode, _MasterTaxRow.TaxDescription, _MasterTaxRow.SalesRate, _MasterTaxRow.LaborRate)
End If
Else
End If
End Sub
Function AddCORRemovedProduct(ByVal CompanyID As String, ByVal ProjectID As String, ByVal ChangeRequestID As String, ByVal ShapeID As String, ByVal MasterItemID As String, ByVal ProjectKitID As String, ByVal OptionID As String) As String
Dim _ProdAdapt As New ProductDataTableAdapters.webMasterDataTableAdapter
Dim _ProdPhaseCostAdapt As New ProductDataTableAdapters.webMasterPhaseCostsTableAdapter
Dim _ProdTbl As ProductData.webMasterDataDataTable = _ProdAdapt.GetProductByID(MasterItemID)
If (_ProdTbl.Rows.Count = 1) Then
Dim _ProdRow As ProductData.webMasterDataRow = _ProdTbl.Rows(0)
Dim _ProdPhaseCostTbl As ProductData.webMasterPhaseCostsDataTable = _ProdPhaseCostAdapt.GetMasterPhaseCost(CompanyID, _ProdRow.MasterPhaseID)
If _ProdPhaseCostTbl.Rows.Count = 1 Then
Dim _ProdPhaseCostRow As ProductData.webMasterPhaseCostsRow = _ProdPhaseCostTbl.Rows(0)
Dim CORShapeID As String = Guid.NewGuid.ToString()
Dim ZoneID As Integer = 0
If lstZone.SelectedValue <> "" Then
ZoneID = lstZone.SelectedValue
End If
If ZoneID = 0 Or lstLocationArea.SelectedValue = "" Then
'ClientScript.RegisterClientScriptBlock(Me.GetType(), "valid", "<
script
language
=
'javascript'
>alert('Please select System and Area before adding the items');</
script
>")
'Return ""
End If
Dim CORItems As New ChangeRequestDataTableAdapters.webChangeRequestItemsTableAdapter
CheckAddProjectTaxes(ProjectID, _ProdRow.PurchaseTaxID)
CheckAddProjectTaxes(ProjectID, _ProdRow.LaborTaxID)
CheckAddProjectTaxes(ProjectID, _ProdRow.SalesTaxID)
Dim ProjectCostCodeID As String = ""
If _ProdRow.CostCodeID <> "" Then
ProjectCostCodeID = GetProjectCostCodeID(ProjectID, _ProdRow.CostCodeID)
End If
CORItems.Insert(Guid.NewGuid().ToString(), ChangeRequestID, _ProdRow.MasterItemID, "Removed", _ProdRow.Cost, _ProdPhaseCostRow.PhaseLaborPrice, _ProdPhaseCostRow.PhaseMgtLaborPrice, _ProdPhaseCostRow.PhaseDesignLaborPrice, _ProdPhaseCostRow.PhaseMiscLaborPrice, _ProdPhaseCostRow.PhaseMiscProductFactor, _ProdPhaseCostRow.PhaseMiscPartsFactor, _ProdRow.Price, 0, 0, _ProdRow.EstimatedHrs, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMiscLaborFactor, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseMgtLaborFactor, _ProdRow.EstimatedHrs * _ProdPhaseCostRow.PhaseDesignLaborFactor, _ProdRow.SalesTaxID, _ProdRow.LaborTaxID, _ProdRow.PurchaseTaxID, 0, lstLocationArea.SelectedValue, ZoneID, "0", 1, ShapeID, _ProdRow.MasterPhaseID, ProjectKitID, OptionID, "", "", _ProdRow.SKU, ProjectCostCodeID, _ProdRow.WarranteePart, _ProdRow.OneOffPart, _ProdRow.ProductDescription, _ProdRow.SalesDescription)
Return CORShapeID
End If
End If
Return ""
End Function
End Class
0
Jayesh Goyani
Top achievements
Rank 2
answered on 01 May 2014, 08:51 AM
Hello,
If possible then can you please create one sample web application/web site and add your code in it?
Thanks,
Jayesh Goyani
If possible then can you please create one sample web application/web site and add your code in it?
Thanks,
Jayesh Goyani
0
vikas
Top achievements
Rank 1
answered on 09 May 2014, 05:06 AM
HI Jayesh,
Your code for persistence in Hierarchical grid(parent-child relation) is working fine. But there is one functionality that I think should have. The relation between parent item and their corresponding child items should remain the same even after selected rows are added and grid is created for selected rows.
For example : I have following grid:
Parent Item 1
- Child Item 1.1
- Child Item 1.2
Parent Item 2
- Child Item 2.1
- Child Item 2.2
If I select Parent Item 1 and child Item 2.2
and afterwards I select Parent Item 2 and child Item 1.1
then the grid is created in a form like this:
Parent Item 1
- Child Item 2.2
Parent Item 2
- Child Item 1.1
Instead required result should be in this form:
Parent Item 1
- Child Item 1.1
Parent Item 2
- Child Item 2.2
Relationship must be retained after parent and child selection.
If you please provide me some modifications in your above javascript code that would be a great help.
Thanks in advance.
Regards
Vikas
Your code for persistence in Hierarchical grid(parent-child relation) is working fine. But there is one functionality that I think should have. The relation between parent item and their corresponding child items should remain the same even after selected rows are added and grid is created for selected rows.
For example : I have following grid:
Parent Item 1
- Child Item 1.1
- Child Item 1.2
Parent Item 2
- Child Item 2.1
- Child Item 2.2
If I select Parent Item 1 and child Item 2.2
and afterwards I select Parent Item 2 and child Item 1.1
then the grid is created in a form like this:
Parent Item 1
- Child Item 2.2
Parent Item 2
- Child Item 1.1
Instead required result should be in this form:
Parent Item 1
- Child Item 1.1
Parent Item 2
- Child Item 2.2
Relationship must be retained after parent and child selection.
If you please provide me some modifications in your above javascript code that would be a great help.
Thanks in advance.
Regards
Vikas
0
Hello Vikas,
I would suggest that you open a formal support ticket to send us a runnable sample web site resembling your scenario. Thus, we will be able to modify the sample to match your requirements and send it back to you.
Regards,
Eyup
Telerik
I would suggest that you open a formal support ticket to send us a runnable sample web site resembling your scenario. Thus, we will be able to modify the sample to match your requirements and send it back to you.
Regards,
Eyup
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
yook
Top achievements
Rank 1
answered on 09 Mar 2017, 06:29 AM
Hi,
I have a rad grid with paging enabled.I select all rows in multiple pages using a GridClientSelectColumn. When I click on print button it prints only the records which are displayed in first page,not all records selected in multiple pages.How to fix it.
Thanks.