or
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="frmViewUnitMaster.aspx.vb" Inherits="iTourism.WebForm1" %>
<%@ 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
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
div
>
<
table
style
=
"width:100%;"
>
<
tr
>
<
td
>
</
td
>
<
td
>
<
asp:Button
ID
=
"btnAdd"
runat
=
"server"
Text
=
"Add"
Width
=
"69px"
/>
<
asp:Label
ID
=
"lblMessage"
runat
=
"server"
Text
=
"Label"
></
asp:Label
>
</
td
>
<
td
>
</
td
>
</
tr
>
<
tr
>
<
td
>
</
td
>
<
td
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"UMGrid"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"UMGrid"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadGrid
ID
=
"UMGrid"
runat
=
"server"
AutoGenerateColumns
=
"False"
GridLines
=
"None"
AllowFilteringByColumn
=
"True"
AllowSorting
=
"True"
AutoGenerateEditColumn
=
"True"
AllowPaging
=
"True"
Width
=
"60%"
ViewStateMode
=
"Enabled"
CellPadding
=
"10"
CellSpacing
=
"10"
onupdatecommand
=
"UMGrid_UpdateCommand"
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"True"
/>
<
Scrolling
AllowScroll
=
"True"
/>
<
Selecting
AllowRowSelect
=
"True"
></
Selecting
>
</
ClientSettings
>
<
MasterTableView
EditMode
=
"EditForms"
DataKeyNames
=
"UnitCode"
>
<
Columns
>
<
telerik:GridBoundColumn
DefaultInsertValue
=
""
UniqueName
=
"UnitCode"
HeaderText
=
"UnitCode"
DataField
=
"UnitCode"
ReadOnly
=
"True"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DefaultInsertValue
=
""
UniqueName
=
"UnitDesc"
HeaderText
=
"Unit Description"
DataField
=
"Description"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
EditFormSettings
EditFormType
=
"AutoGenerated"
>
</
EditFormSettings
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
td
>
<
td
>
</
td
>
</
tr
>
</
table
>
</
div
>
</
form
>
</
body
>
</
html
>
Imports
System
Imports
System.Data
Imports
Telerik.Web.UI
Imports
System.Data.SqlClient
Public
Class
WebForm1
Inherits
System.Web.UI.Page
Dim
objclsUnitMaster
As
New
clsUnitMaster
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
UMGrid.AutoGenerateDeleteColumn =
True
UMGrid.AutoGenerateEditColumn =
True
UMGrid.DataSource = (objclsUnitMaster.GetUnitCodeList).Tables(
"UnitMaster"
)
UMGrid.DataBind()
End
Sub
Protected
Sub
btnAdd_Click(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Handles
btnAdd.Click
Response.Redirect(
"frmUnitMaster.aspx"
)
End
Sub
Private
Sub
UMGrid_ItemCommand(
ByVal
source
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridCommandEventArgs)
Handles
UMGrid.ItemCommand
If
(e.CommandName = RadGrid.UpdateCommandName)
Then
Dim
editedItem
As
GridEditableItem =
CType
(e.Item, GridEditableItem)
Dim
newValues
As
New
Hashtable
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem)
'not getting the updated value
lblMessage.Text = newValues(
"Description"
).ToString
End
If
End
Sub
Private
Sub
UMGrid_NeedDataSource(
ByVal
source
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridNeedDataSourceEventArgs)
Handles
UMGrid.NeedDataSource
UMGrid.DataSource = (objclsUnitMaster.GetUnitCodeList).Tables(
"UnitMaster"
)
UMGrid.DataBind()
End
Sub
Public
Sub
UMGrid_UpdateCommand(
ByVal
source
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridCommandEventArgs)
Handles
UMGrid.UpdateCommand
' Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
'Dim MyUserControl As UserControl = CType(e.Item.FindControl(GridEditFormItem.EditFormUserControlID), UserControl)
Dim
_UnitCode
As
Integer
= 0
Dim
_Description
As
String
=
""
Dim
_Result
As
Long
= 0
Dim
_item
As
GridEditableItem
_item = e.Item
Try
_UnitCode = Convert.ToInt32(
DirectCast
(_item(
"UnitCode"
).Controls(0), TextBox).Text)
'Unable to Get Updated Value using this also
_Description =
DirectCast
(_item(
"Description"
).Controls(0), TextBox).Text
_Result = objclsUnitMaster.UpdateUnitByCode(_UnitCode, _Description)
If
_Result = 0
Then
lblMessage.Text =
"Record Saved Successfully"
Else
lblMessage.Text =
"Error While Saving Record"
&
" - "
& _Result
End
If
'UMGrid.Rebind()
Catch
ex
As
Exception
lblMessage.Text = ex.Message
End
Try
End
Sub
End
Class
<
telerik:RadGrid
ID
=
"DataGrid"
runat
=
"server"
ClientSettings-AllowColumnsReorder
=
"true"
ClientSettings-ReorderColumnsOnClient
=
"true"
AllowPaging
=
"True"
ShowFooter
=
"True"
HorizontalAlign
=
"NotSet"
PageSize
=
"100"
Width
=
"100%"
BorderWidth
=
"0px"
FilterItemStyle-HorizontalAlign
=
"Center"
HeaderStyle-HorizontalAlign
=
"Center"
FilterItemStyle-VerticalAlign
=
"middle"
AllowSorting
=
"True"
AllowFilteringByColumn
=
"true"
>
<
MasterTableView
Dir
=
"RTL"
AutoGenerateColumns
=
"False"
AllowAutomaticDeletes
=
"false"
AllowAutomaticInserts
=
"false"
AllowAutomaticUpdates
=
"false"
AllowMultiColumnSorting
=
"true"
ClientDataKeyNames
=
"BillID"
DataKeyNames
=
"BillID"
CommandItemDisplay
=
"Top"
>
<
HeaderStyle
HorizontalAlign
=
"Center"
/>
<
FilterItemStyle
HorizontalAlign
=
"Center"
/>
<
NoRecordsTemplate
>No Records Found.</
NoRecordsTemplate
>
<
CommandItemTemplate
>
<
table
id
=
"headertable"
runat
=
"server"
align
=
"center"
>
<
tr
>
<
td
>
<
asp:ImageButton
ID
=
"btnAdd"
CommandName
=
"Insert"
ImageUrl
=
"~/Styles/images/button_Client.jpg"
runat
=
"server"
CausesValidation
=
"false"
Style
=
"cursor: hand"
AlternateText
=
"Insert New Loan"
/>
</
td
>
</
tr
>
</
table
>
</
CommandItemTemplate
>
<
Columns
>
<
telerik:GridButtonColumn
UniqueName
=
"Edit"
CommandName
=
"Edit"
ButtonType
=
"ImageButton"
ImageUrl
=
"~/Styles/images/icon_edit.gif"
Text
=
"تعديل"
HeaderText
=
"تعديل"
>
<
HeaderStyle
Width
=
"35px"
HorizontalAlign
=
"center"
/>
</
telerik:GridButtonColumn
>
<
telerik:GridButtonColumn
UniqueName
=
"Preview"
CommandName
=
"Preview"
ButtonType
=
"ImageButton"
ImageUrl
=
"~/Styles/images/icon_preview.gif"
Text
=
"فاتورة"
HeaderText
=
"فاتورة"
>
<
HeaderStyle
Width
=
"35px"
HorizontalAlign
=
"center"
/>
</
telerik:GridButtonColumn
>
<
telerik:GridBoundColumn
DataField
=
"BillID"
Visible
=
"False"
HeaderText
=
"BillID"
ReadOnly
=
"True"
SortExpression
=
"BillID"
UniqueName
=
"BillID"
/>
<
telerik:GridBoundColumn
DataField
=
"BillNumber"
Visible
=
"true"
HeaderText
=
"الرقم"
ReadOnly
=
"True"
SortExpression
=
"BillNumber"
UniqueName
=
"BillNumber"
/>
<
telerik:GridBoundColumn
DataField
=
"BillFile"
Visible
=
"true"
HeaderText
=
"الملف"
ReadOnly
=
"True"
SortExpression
=
"BillFile"
UniqueName
=
"BillFile"
/>
<
telerik:GridBoundColumn
DataField
=
"ClientName"
Visible
=
"true"
HeaderText
=
"اسم الزبون"
ReadOnly
=
"True"
SortExpression
=
"ClientName"
UniqueName
=
"ClientName"
/>
<
telerik:GridBoundColumn
DataField
=
"ClientCode"
Visible
=
"true"
HeaderText
=
"رمز الزبون"
ReadOnly
=
"True"
SortExpression
=
"ClientCode"
UniqueName
=
"ClientCode"
/>
<
telerik:GridBoundColumn
DataField
=
"Weight"
Visible
=
"true"
HeaderText
=
"الوزن كلغ"
ReadOnly
=
"True"
SortExpression
=
"Weight"
UniqueName
=
"Weight"
/>
<
telerik:GridBoundColumn
DataField
=
"BillValue"
Visible
=
"true"
HeaderText
=
"القيمة"
ReadOnly
=
"True"
SortExpression
=
"BillValue"
UniqueName
=
"BillValue"
/>
<
telerik:GridBoundColumn
DataField
=
"ClosingDate"
Visible
=
"true"
HeaderText
=
"تاريخ إغلاق الفاتورة"
ReadOnly
=
"True"
SortExpression
=
"ClosingDate"
UniqueName
=
"ClosingDate"
/>
<
telerik:GridBoundColumn
DataField
=
"ReleaseDate"
Visible
=
"true"
HeaderText
=
"السنة"
ReadOnly
=
"True"
SortExpression
=
"ReleaseDate"
UniqueName
=
"ReleaseDate"
/>
</
Columns
>
<
ExpandCollapseColumn
ButtonType
=
"ImageButton"
UniqueName
=
"ExpandColumn"
Visible
=
"False"
>
<
HeaderStyle
Width
=
"19px"
/>
</
ExpandCollapseColumn
>
<
PagerStyle
Mode
=
"NextPrevNumericAndAdvanced"
PageButtonCount
=
"20"
/>
</
MasterTableView
>
<
GroupPanel
>
<
PanelItemsStyle
CellSpacing
=
"2"
/>
</
GroupPanel
>
<
ClientSettings
AllowColumnsReorder
=
"True"
EnableRowHoverStyle
=
"true"
>
<
Selecting
AllowRowSelect
=
"true"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
Private Sub BuildDataGrid(ByVal view As Views)
Try
Dim addColumn As Action(Of GridColumn) =
Sub(column) BottomSection(Of TMGrid)("dgView").MasterTableView.Columns.Add(column)
Dim addToGrouping As Action(Of GridColumn) =
Sub(column)
BottomSection(Of TMGrid)("dgView").MasterTableView.GroupByExpressions.Add(
New GridGroupByExpression(column)
)
End Sub
With BottomSection(Of TMGrid)("dgView")
.MasterTableView.Columns.Clear()
.MasterTableView.GroupByExpressions.Clear()
Select Case view
Case Views.Daily
TMGrid.AddBoundColumn(
addColumn,
Function() "tl_date",
Function() "Date",
Function() False,
Function() "{0:MMMM d}",
Sub(column)
Dim grouping As New GridGroupByExpression()
Dim selectDate As New GridGroupByField()
selectDate.FieldName = "tl_date"
selectDate.FieldAlias = "tl_date"
selectDate.FormatString = TMGrid.SHORT_DATE_FORMAT
selectDate.HeaderText = "DATE"
selectDate.HeaderValueSeparator = ": "
Dim selectTotalHours As New GridGroupByField()
selectTotalHours.FieldName = "te_hours"
selectTotalHours.FieldAlias = "te_hours"
selectTotalHours.HeaderText = "TOTAL HOURS"
selectTotalHours.Aggregate = GridAggregateFunction.Sum
selectTotalHours.FormatString = TMGrid.HOURS
selectTotalHours.HeaderValueSeparator = ": "
Dim groupByDate As New GridGroupByField()
groupByDate.FieldName = "tl_date"
groupByDate.FieldAlias = "tl_date"
grouping.SelectFields.Add(selectDate)
grouping.SelectFields.Add(selectTotalHours)
grouping.GroupByFields.Add(groupByDate)
'grouping.Expression = "tl_date [Date], Sum(te_hours) TotalHours [Total Hours] Group By tl_date"
BottomSection(Of TMGrid)("dgView").MasterTableView.GroupByExpressions.Add(grouping)
End Sub
)
TMGrid.AddBoundColumn(
addColumn,
Function() "tc_name",
Function() "ACTIVITY",
AddressOf RequireSubactivity,
Nothing,
addToGrouping
)
TMGrid.AddBoundColumn(
addColumn,
Function() "tsc_name",
Function() "SUBACTIVITY"
)
TMGrid.AddBoundColumn(
addColumn,
Function() "te_desc",
Function() "DESCRIPTION"
)
TMGrid.AddBoundColumn(
addColumn,
Function() "te_hours",
Function() "HOURS",
Function() True,
Function() "<
a
href
=
'{0}'
>{0:#0.00}</
a
>",
Sub(column)
column.ItemStyle.HorizontalAlign = HorizontalAlign.Right
column.HeaderStyle.HorizontalAlign = HorizontalAlign.Right
column.FooterStyle.HorizontalAlign = HorizontalAlign.Right
column.Aggregate = GridAggregateFunction.Sum
column.FooterAggregateFormatString = "Total: {0:#0.00}"
End Sub
)
Case Views.Monthly
TMGrid.AddBoundColumn(
addColumn,
Function() "tl_monthname",
Function() "Month",
Function() False,
Nothing,
addToGrouping
)
TMGrid.AddBoundColumn(
addColumn,
Function() "tc_name",
Function() "ACTIVITY",
AddressOf RequireSubactivity,
Nothing,
addToGrouping
)
TMGrid.AddBoundColumn(
addColumn,
Function() "tsc_name",
Function() "SUBACTIVITY"
)
TMGrid.AddBoundColumn(
addColumn,
Function() "te_desc",
Function() "DESCRIPTION"
)
If (Convert.ToInt32(ViewState("ReportingMode")) = TMTERMSOptions.TMTERMSReportingModes.Daily) Then
TMGrid.AddBoundColumn(
addColumn,
Function() "te_hours",
Function() "HOURS",
Function() True,
Function() "{0:#0.00}",
Sub(column)
column.ItemStyle.HorizontalAlign = HorizontalAlign.Right
column.HeaderStyle.HorizontalAlign = HorizontalAlign.Right
column.FooterStyle.HorizontalAlign = HorizontalAlign.Right
column.Aggregate = GridAggregateFunction.Sum
column.FooterAggregateFormatString = "Total: {0:#0.00}"
End Sub
)
Else
TMGrid.AddBoundColumn(
addColumn,
Function() "te_hours",
Function() "HOURS",
Function() True,
Function() "<
a
href
=
'{0}'
>{0:#0.00}</
a
>",
Sub(column)
column.ItemStyle.HorizontalAlign = HorizontalAlign.Right
column.HeaderStyle.HorizontalAlign = HorizontalAlign.Right
column.FooterStyle.HorizontalAlign = HorizontalAlign.Right
column.Aggregate = GridAggregateFunction.Sum
column.FooterAggregateFormatString = "Total: {0:#0.00}"
End Sub
)
End If
TMGrid.AddBoundColumn(
addColumn,
Function() "certified_message",
Function() "CERTIFICATION"
)
TMGrid.AddBoundColumn(
addColumn,
Function() "approved_message",
Function() "APPROVAL"
)
TMGrid.AddBoundColumn(
addColumn,
Function() "te_approved_hours",
Function() "APPROVED HOURS",
Function() "{0:#,##0.00}"
)
Case Views.Annual
TMGrid.AddBoundColumn(
addColumn,
Function() "tl_year",
Function() "YEAR",
Function() False,
Nothing,
addToGrouping
)
TMGrid.AddBoundColumn(
addColumn,
Function() "tc_name",
Function() "YEAR / ACTIVITY",
AddressOf RequireSubactivity,
Nothing,
addToGrouping
)
TMGrid.AddBoundColumn(
addColumn,
Function() "tsc_name",
Function() "YEAR / ACTIVITY / SUBACTIVITY"
)
TMGrid.AddBoundColumn(
addColumn,
Function() "te_hours",
Function() "HOURS",
Function() "{0:#,##0.00}"
)
End Select
End With
Catch ex As Exception
Throw New Exception("BuildDataGrid procedure failed", ex)
End Try
End Sub