Hi, In my application I have a RadGrid who is connected to a ObjectDataSource for can filter my query before result loading (when I start my page, i used the LinqDataSource).
After to have implented the ODS, I had a error message :
I to search in the internet, and i have found this link : http://www.telerik.com/help/aspnet-ajax/grid-error-messages.html who give me a solution for my Insert problem (when I edit a DataItem all work perfectly)
After I have add this code, when I click on my Add button, the row appear in the RadGrid. In the RadGridRow. But in my RadGrid for each row I have Search Action Button who call this Event to my ItemCommand
When my Search is terminated and my RadWindows closes. This function it's call
Before, with the LinqDataSource, after using «DataBind» in «GetCompteID». The RadGrid_ItemDataBound is called for insert the «Compte» value in my row cells.
But with ODS (object data source) after my Rad RadWindows closes, I receive a same message error.
Thank you if u can help me, and sorry for my bad english :/
Good Day
Mathieu B.B
After to have implented the ODS, I had a error message :
DataBinding: 'Telerik.Web.UI.GridInsertionObject' does not contain a property with the name 'CodeComplementaireNumero'.
I to search in the internet, and i have found this link : http://www.telerik.com/help/aspnet-ajax/grid-error-messages.html who give me a solution for my Insert problem (when I edit a DataItem all work perfectly)
Case
"Add"
,
"InitInsert"
EcritureRecurrenteFacade.ObjCompte.Entity =
Nothing
UndoChange()
e.Canceled =
True
Dim
newValues
As
System.Collections.Specialized.ListDictionary =
New
System.Collections.Specialized.ListDictionary()
newValues(
"ID"
) = 0
newValues(
"CompteNumero"
) =
Nothing
newValues(
"Description"
) =
Nothing
newValues(
"CodeComplementaireNumero"
) = 0
newValues(
"Pourcentage"
) = 0
'newValues("EcritureRecurrenteID") = IIf(EcritureRecurrenteFacade.EcritureCourante IsNot Nothing, EcritureRecurrenteFacade.EcritureCourante.ID, 0)
e.Item.OwnerTableView.InsertItem(newValues)
After I have add this code, when I click on my Add button, the row appear in the RadGrid. In the RadGridRow. But in my RadGrid for each row I have Search Action Button who call this Event to my ItemCommand
Case
"SearchCompte"
' Désactive le compte courante pour empêcher les problèmes d'affichages
If
(EcritureRecurrenteFacade.ObjCompte.Entity IsNot
Nothing
)
AndAlso
(EcritureRecurrenteFacade.ObjCompte.Entity.ID > 0)
Then
EcritureRecurrenteFacade.ObjCompte.Entity =
Nothing
End
If
' Prépare la recherche
Dim
i
As
GridDataItem =
DirectCast
(e.Item, GridDataItem)
Dim
editValues
As
New
Hashtable()
i.ExtractValues(editValues)
editValues.Add(
"CompteNumeroID"
, i(
"CompteNumero"
).ClientID)
ViewState(
"extract"
) = editValues
Dim
SearchValue
As
String
=
""
If
(editValues(
"CompteNumero"
) IsNot
Nothing
)
Then
SearchValue = editValues(
"CompteNumero"
).ToString
End
If
MainMaster.CallSearchItem(GetLocalResourceString(
"SearchTitle_Compte"
), EcritureRecurrenteFacade.ObjCompte.LinqContextTypeName,
EcritureRecurrenteFacade.ObjCompte.GetPropertyName(
Function
() EcritureRecurrenteFacade.ObjCompte.GridSearchSelect),
i(
"CompteNumero"
).ClientID, EcritureRecurrenteFacade.ObjCompte.GridSearchColumn)
When my Search is terminated and my RadWindows closes. This function it's call
Private
Sub
RechercheEventCompte(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
'Select case contenant la liste de tous les champs dont la recherche est disponible.
If
(ViewState(
"extract"
) IsNot
Nothing
)
Then
Dim
Hash
As
Hashtable =
DirectCast
(ViewState(
"extract"
), Hashtable)
Dim
oldvalue
As
String
=
""
If
Hash(
"CompteNumero"
) IsNot
Nothing
Then
oldvalue = Hash(
"CompteNumero"
).ToString
End
If
Dim
ObjEventArgs
As
SearchReturnEvent =
CType
(e, SearchReturnEvent)
Select
Case
ObjEventArgs.UpdatedControlId
Case
Hash(
"CompteNumeroID"
).ToString
GetCompteByID(ObjEventArgs.IDSelect)
End
Select
End
If
End
Sub
Public
Sub
GetCompteByID(
ByVal
IdCompte
As
Integer
)
Try
' REcherche et obtention du Compte relier a la recherche
EcritureRecurrenteFacade.ObjCompte.GetByID(IdCompte)
EcritureRecurrenteFacade.ObjCompte.Entity = EcritureRecurrenteFacade.ObjCompte.SelectedTEntity
RadGridEdit.Rebind() ' BUG LINE
'RadGridEdit.DataBind()
Catch
ex
As
Exception
Throw
ex
End
Try
End
Sub
Before, with the LinqDataSource, after using «DataBind» in «GetCompteID». The RadGrid_ItemDataBound is called for insert the «Compte» value in my row cells.
Private
Sub
RadGridEdit_ItemDataBound(sender
As
Object
, e
As
GridItemEventArgs)
Handles
RadGridEdit.ItemDataBound
'Ajouter la validation de confirmation
'Le code à été mis ici pour l'ajout du script afin de permettre de désactiver les événements
If
TypeOf
e.Item
Is
GridDataItem
Then
Dim
dataItem
As
GridDataItem =
CType
(e.Item, GridDataItem)
' Permet d'inscrire la valeur de la recherche lors de insertion d'une nouvelle ligne.
If
(EcritureRecurrenteFacade.ObjCompte.Entity IsNot
Nothing
)
AndAlso
(EcritureRecurrenteFacade.ObjCompte.Entity.ID > 0)
AndAlso
(ViewState(
"extract"
) IsNot
Nothing
)
Then
If
RadGridEdit.MasterTableView.EditMode = GridEditMode.InPlace
Then
If
TypeOf
e.Item
Is
GridDataInsertItem
AndAlso
e.Item.OwnerTableView.IsItemInserted
Then
Dim
insertItem
As
GridDataInsertItem =
DirectCast
(e.Item, GridDataInsertItem)
TryCast(insertItem(
"CompteNumero"
).Controls(0), Telerik.Web.UI.RadNumericTextBox).Text =
CStr
(EcritureRecurrenteFacade.ObjCompte.Entity.Numero)
TryCast(insertItem(
"Description"
).Controls(0), TextBox).Text = EcritureRecurrenteFacade.ObjCompte.Entity.Description
ElseIf
TypeOf
e.Item
Is
GridDataItem
AndAlso
e.Item.IsInEditMode
Then
Dim
editItem
As
GridEditableItem =
DirectCast
(e.Item, GridEditableItem)
TryCast(editItem(
"CompteNumero"
).Controls(0), Telerik.Web.UI.RadNumericTextBox).Text =
CStr
(EcritureRecurrenteFacade.ObjCompte.Entity.Numero)
TryCast(editItem(
"Description"
).Controls(0), TextBox).Text = EcritureRecurrenteFacade.ObjCompte.Entity.Description
End
If
End
If
End
If
{...}
End
sub
But with ODS (object data source) after my Rad RadWindows closes, I receive a same message error.
DataBinding:
'Telerik.Web.UI.GridInsertionObject' does not contain a property with the name 'CodeComplementaireNumero'.
Thank you if u can help me, and sorry for my bad english :/
Good Day
Mathieu B.B
7 Answers, 1 is accepted
0
Hello,
I am afraid that with the provided information it is too hard to find the source of issue. Could you share your full page source code along with the code-behind file content? Thus all the people who want to help you will have better understanding of your case.
Regards,
Andrey
Telerik
I am afraid that with the provided information it is too hard to find the source of issue. Could you share your full page source code along with the code-behind file content? Thus all the people who want to help you will have better understanding of your case.
Regards,
Andrey
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0

MathieuB
Top achievements
Rank 1
answered on 25 Jun 2013, 12:29 PM
Hi Andrey,
I Thanks you for your help, I can give you the code of my webpage, but I have a Masterpage, a facade and a controller who are connected to this page. More my webpage is a WebUserControl, which includes a another WebUserControl, and it's this second who have my Grid.
WUCEntretienEcritureRecurrent.ascx
WUCEntretienEcritureRecurrent.ascx.vb
WUCEntretienEcritureRecurrentRecurrente.ascx
WUCEntretienEcritureRecurrentRecurrente.ascx.vb
But the principale source of my problem is in the WUCEntretienEcritureRecurrentRecurrente.ascx.vb.
Thank you and good day.
I Thanks you for your help, I can give you the code of my webpage, but I have a Masterpage, a facade and a controller who are connected to this page. More my webpage is a WebUserControl, which includes a another WebUserControl, and it's this second who have my Grid.
WUCEntretienEcritureRecurrent.ascx
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="WUCEntretienEcritureRecurrente.ascx.vb" Inherits=".WUCEntretienEcritureRecurrente" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Src="~/Corpo/Grid/WUCGridRecherche.ascx" TagPrefix="uc1" TagName="WUCGridRecherche" %>
<%@ Register Src="~/GL/WUCEntretienEcritureRecurrenteRepartition.ascx" TagPrefix="uc1" TagName="WUCEntretienEcritureRecurrenteRepartition" %>
<
style
type
=
"text/css"
>
</
style
>
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function resizeToFrame(arg) {
if ($find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>")) {
$find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("Resize&" + arg.height);
}
}
</
script
>
</
telerik:RadCodeBlock
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function confirmDirtyNavigation() {
var hfDirty = document.getElementById('body_DirtyFlag');
if (hfDirty) {
if (hfDirty.value == "True") {
var test = confirm("<%=GetGlobalResourceObject("General", "UnsavedInformationLost")%>");
return test;
}
}
return true;
}
function alertDirtyNavigation() {
var hfDirty = document.getElementById('body_DirtyFlag');
if (hfDirty) {
if (hfDirty.value == "True") {
ShowAlertMessage("<%=GetGlobalResourceObject("General", "SaveOrCancelChanges")%>", "Avertissement");
return false;
}
}
return true;
}
</
script
>
</
telerik:RadScriptBlock
>
<
telerik:RadAjaxManagerProxy
ID
=
"AjaxManagerProxy_Parameters"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"AjaxManagerProxy_Parameters"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"PageEntretien"
UpdatePanelRenderMode
=
"Inline"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"WUCEntretienEcritureRecurrenteRepartition"
UpdatePanelRenderMode
=
"Inline"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<%--Système de recherches--%>
<
telerik:AjaxSetting
AjaxControlID
=
"btnRecherche"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadWindowSearch"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"txbNumero"
UpdatePanelRenderMode
=
"Inline"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"WUCEntretienEcritureRecurrenteRepartition"
UpdatePanelRenderMode
=
"Inline"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"btnRechercheCompteA"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadWindowSearch"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"txbCompteDepart"
UpdatePanelRenderMode
=
"Inline"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"WUCEntretienEcritureRecurrenteRepartition"
UpdatePanelRenderMode
=
"Inline"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"btnRechercheCompteDe"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadWindowSearch"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"txbCompteFin"
UpdatePanelRenderMode
=
"Inline"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"WUCEntretienEcritureRecurrenteRepartition"
UpdatePanelRenderMode
=
"Inline"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"btnRechercheContrePartie"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadWindowSearch"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"txbContrepartie"
UpdatePanelRenderMode
=
"Inline"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"WUCEntretienEcritureRecurrenteRepartition"
UpdatePanelRenderMode
=
"Inline"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManagerProxy
>
<
asp:Panel
ID
=
"PageEntretien"
runat
=
"server"
>
<%--Zone entête action--%>
<
telerik:RadToolBar
ID
=
"ToolBarEcriture"
runat
=
"server"
AutoPostBack
=
"False"
Width
=
"100%"
Height
=
"25px"
>
<
Items
>
<
telerik:RadToolBarButton
Text="<% $Resources:toolbarText_New %>" Value="NewButton" CommandName="NewEcriture" AccessKey="A"
ImageUrl="~/Images/16X16/add.png" ImagePosition="Right">
</
telerik:RadToolBarButton
>
<
telerik:RadToolBarButton
Text="<% $Resources:toolbarText_Save %>" Value="SaveButton" CommandName="SaveEcriture" AccessKey="S"
ImageUrl="~/Images/16X16/save.png" ImagePosition="Right" Enabled="false">
</
telerik:RadToolBarButton
>
<
telerik:RadToolBarButton
Text="<% $Resources:toolbarText_Delete %>" Value="DeleteButton" CommandName="DeleteEcriture" AccessKey="D"
ImageUrl="~/Images/16X16/delete.png" ImagePosition="Right" Enabled="false">
</
telerik:RadToolBarButton
>
</
Items
>
</
telerik:RadToolBar
>
<%--Zone de sélections pour écriture manuelle--%>
<
asp:Panel
ID
=
"PanelInformationEcriture"
runat
=
"server"
>
<
table
runat
=
"server"
style
=
"width: 99%; margin-left: 5px"
>
<
tr
>
<
td
style
=
"width: 75px"
>
<
asp:Label
ID
=
"Label1"
runat
=
"server"
Text="<% $Resources:labelText_Numero %>"></
asp:Label
>
</
td
>
<
td
>
<
telerik:RadMaskedTextBox
ID
=
"txbNumero"
Mask
=
"#####"
PromptChar
=
""
runat
=
"server"
SelectionOnFocus
=
"SelectAll"
AutoPostBack
=
"True"
/>
<
telerik:RadButton
ID
=
"btnRecherche"
runat
=
"server"
AutoPostBack
=
"true"
OnClick
=
"btnRecherche_Click"
Width
=
"16px"
Height
=
"16px"
Style
=
"margin-top: 1px;"
CommandArgument
=
"Numero"
>
<
Image
ImageUrl
=
"~/Images/16X16/search.png"
/>
</
telerik:RadButton
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"width: 75px"
>
<
asp:Label
ID
=
"Label2"
runat
=
"server"
Text="<% $Resources:labelText_Reference %>"></
asp:Label
>
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"txbReference"
runat
=
"server"
Text
=
"AUTO"
></
telerik:RadTextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"width: 75px"
>
<
asp:Label
ID
=
"Label3"
runat
=
"server"
Text="<% $Resources:labelText_Description %>"></
asp:Label
>
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"txbDescription"
runat
=
"server"
Width
=
"92%"
MaxLength
=
"150"
></
telerik:RadTextBox
>
</
td
>
<
td
>
<
asp:CheckBox
ID
=
"cbxTransfertSolde"
runat
=
"server"
Text="<% $Resources:checkText_TransfertSolde %>"/>
</
td
>
</
tr
>
</
table
>
<
asp:Panel
ID
=
"Additionner"
runat
=
"server"
GroupingText="<% $Resources:groupText_Additionner %>" Width="70%" Style="margin-left: 5px">
<
table
style
=
"width: 99%; margin-left: 5px"
>
<
tr
>
<
td
style
=
"width: 170px;"
>
<
asp:Label
ID
=
"Label4"
runat
=
"server"
Text="<% $Resources:labelText_CompteDepart %>"></
asp:Label
>
</
td
>
<
td
style
=
"width: 140px"
>
<
telerik:RadMaskedTextBox
ID
=
"txbCompteDepart"
Mask
=
"## ##### ###"
PromptChar
=
""
runat
=
"server"
SelectionOnFocus
=
"SelectAll"
Width
=
"95px"
AutoPostBack
=
"true"
OnTextChanged
=
"ChargementCompteManuel_TextChanged"
/>
<
telerik:RadButton
ID
=
"btnRechercheCompteA"
runat
=
"server"
AutoPostBack
=
"true"
OnClick
=
"btnRecherche_Click"
Width
=
"16px"
Height
=
"16px"
Style
=
"margin-top: 1px;"
CommandArgument
=
"CompteDe"
>
<
Image
ImageUrl
=
"~/Images/16X16/search.png"
/>
</
telerik:RadButton
>
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"txbCompteDepartDesc"
runat
=
"server"
Width
=
"96%"
ReadOnly
=
"true"
></
telerik:RadTextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"width: 170px;"
>
<
asp:Label
ID
=
"Label5"
runat
=
"server"
Text="<% $Resources:labelText_CompteFin %>"></
asp:Label
>
</
td
>
<
td
style
=
"width: 140px"
>
<
telerik:RadMaskedTextBox
ID
=
"txbCompteFin"
Mask
=
"## ##### ###"
PromptChar
=
""
runat
=
"server"
SelectionOnFocus
=
"SelectAll"
Width
=
"95px"
AutoPostBack
=
"true"
OnTextChanged
=
"ChargementCompteManuel_TextChanged"
/>
<
telerik:RadButton
ID
=
"btnRechercheCompteDe"
runat
=
"server"
AutoPostBack
=
"true"
OnClick
=
"btnRecherche_Click"
Width
=
"16px"
Height
=
"16px"
Style
=
"margin-top: 1px;"
CommandArgument
=
"CompteA"
>
<
Image
ImageUrl
=
"~/Images/16X16/search.png"
/>
</
telerik:RadButton
>
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"txbCompteFinDesc"
runat
=
"server"
Width
=
"96%"
ReadOnly
=
"true"
></
telerik:RadTextBox
>
</
td
>
</
tr
>
</
table
>
</
asp:Panel
>
<
table
style
=
"width: 99%; margin-left: 5px"
>
<
tr
>
<
td
style
=
"width: 186px;"
>
<
asp:Label
ID
=
"Label6"
runat
=
"server"
Text="<% $Resources:labelText_ContrePartie %>"></
asp:Label
>
</
td
>
<
td
style
=
"width: 140px"
>
<
telerik:RadMaskedTextBox
ID
=
"txbContrepartie"
Mask
=
"## ##### ###"
PromptChar
=
""
runat
=
"server"
SelectionOnFocus
=
"SelectAll"
Width
=
"95px"
AutoPostBack
=
"true"
OnTextChanged
=
"ChargementCompteManuel_TextChanged"
/>
<
telerik:RadButton
ID
=
"btnRechercheContrePartie"
runat
=
"server"
AutoPostBack
=
"true"
OnClick
=
"btnRecherche_Click"
Width
=
"16px"
Height
=
"16px"
Style
=
"margin-top: 1px;"
CommandArgument
=
"CompteContre"
>
<
Image
ImageUrl
=
"~/Images/16X16/search.png"
/>
</
telerik:RadButton
>
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"txbContrepartieDesc"
runat
=
"server"
Width
=
"60.5%"
ReadOnly
=
"true"
></
telerik:RadTextBox
>
</
td
>
</
tr
>
</
table
>
<
uc1:WUCEntretienEcritureRecurrenteRepartition
runat
=
"server"
ID
=
"WUCEntretienEcritureRecurrenteRepartition"
/>
</
asp:Panel
>
</
asp:Panel
>
<
asp:LinqDataSource
ID
=
"LinqDataSource1"
runat
=
"server"
></
asp:LinqDataSource
>
WUCEntretienEcritureRecurrent.ascx.vb
Imports
PG.ACF.GL.Core.Entities.Data
Imports
PG.ACF.Core.DAL
Imports
Telerik.Web.UI
Imports
System.Reflection.PropertyInfo
Imports
System.Reflection
Imports
PG.ACF.WEB.Corpo
Imports
PG.ACF.MVC.GL.Interfaces
Imports
PG.ACF.MVC.GL.Controllers
Imports
PG.ACF.Core.Entities.Data
Imports
PG.ACF.Core.Utils
Imports
PG.ACF.GL.Core.Entities
Imports
PG.ACF.MVC.GL.Facade
Public
Class
WUCEntretienEcritureRecurrente
Inherits
BaseUserControl
#Region "Propriété de la page"
'Permet de se brancher à l'objet grille
Private
_wucObjGridEdition
As
WUCEntretienEcritureRecurrenteRepartition
Protected
Overridable
ReadOnly
Property
GridEdition()
As
WUCEntretienEcritureRecurrenteRepartition
Get
If
_wucObjGridEdition
Is
Nothing
Then
_wucObjGridEdition = TryCast(WebHelper.FindControlRecursively(Page,
"WUCEntretienEcritureRecurrenteRepartition"
), WUCEntretienEcritureRecurrenteRepartition)
End
If
Return
_wucObjGridEdition
End
Get
End
Property
' Controller EcritureRepartition
Private
_EcritureRecurrenteRepartitionController
As
New
EcritureRecurrenteRepartitionController
Public
Property
ObjEcritureRecurrenteRepartitionController()
As
EcritureRecurrenteRepartitionController
Get
If
_EcritureRecurrenteRepartitionController
Is
Nothing
Then
_EcritureRecurrenteRepartitionController =
New
EcritureRecurrenteRepartitionController()
End
If
Return
_EcritureRecurrenteRepartitionController
End
Get
Set
(
ByVal
value
As
EcritureRecurrenteRepartitionController)
_EcritureRecurrenteRepartitionController = value
End
Set
End
Property
' Controller Ecriture
Private
_EcritureRecurrenteController
As
New
EcritureRecurrenteController
Public
Property
ObjEcritureRecurrenteController()
As
EcritureRecurrenteController
Get
If
_EcritureRecurrenteController
Is
Nothing
Then
_EcritureRecurrenteController =
New
EcritureRecurrenteController()
End
If
Return
_EcritureRecurrenteController
End
Get
Set
(
ByVal
value
As
EcritureRecurrenteController)
_EcritureRecurrenteController = value
End
Set
End
Property
#End Region
#Region "Constructeur"
Private
Sub
Page_Load(sender
As
Object
, e
As
EventArgs)
Handles
Me
.Load
Dim
manager
As
RadAjaxManager = RadAjaxManager.GetCurrent(Page)
AddHandler
manager.AjaxRequest,
AddressOf
manager_AjaxRequest
'Initialiser les propriétés du UserControl de la grille d'édition
Me
.WUCEntretienEcritureRecurrenteRepartition.GridContextTypeName = ObjEcritureRecurrenteRepartitionController.LinqContextTypeName
Me
.WUCEntretienEcritureRecurrenteRepartition.GridTableName = ObjEcritureRecurrenteRepartitionController.TableNameGridSelect
Me
.WUCEntretienEcritureRecurrenteRepartition.ColumnListDisplay = ObjEcritureRecurrenteRepartitionController.GridSelectColumn
Me
.WUCEntretienEcritureRecurrenteRepartition.ManualGenerateColumn =
True
Me
.LinqDataSource1.ContextTypeName = ObjEcritureRecurrenteRepartitionController.LinqContextTypeName
Me
.LinqDataSource1.TableName = ObjEcritureRecurrenteRepartitionController.TableNameGridSelect
''Me.DataBind()
'Initialiser le UserControl de sélection, s'il existe
If
IsPostBack
Then
AdjustPageHandler(
True
)
End
If
End
Sub
#End Region
#Region "Destructor"
Private
Sub
Page_Unload(sender
As
Object
, e
As
EventArgs)
Handles
Me
.Unload
AdjustPageHandler(
False
)
End
Sub
#End Region
#Region "Evènement de la page"
Private
Sub
NewElement()
txbNumero.Text =
""
txbReference.Text =
"AUTO"
txbDescription.Text =
""
txbCompteDepart.Text =
""
txbCompteDepartDesc.Text =
""
txbCompteFin.Text =
""
txbCompteFinDesc.Text =
""
txbContrepartie.Text =
""
txbContrepartieDesc.Text =
""
cbxTransfertSolde.Checked =
False
' Une occurence existe on active le Btn Save & Delete
ToolBarEcriture.Items(1).Enabled =
False
ToolBarEcriture.Items(2).Enabled =
False
ObjEcritureRecurrenteController =
New
EcritureRecurrenteController()
EcritureRecurrenteFacade.EcritureCourante = ObjEcritureRecurrenteController.Entity
DirectCast
(
Me
.FindControlRecursively(Page,
"EcritureCourante"
), HiddenField).DataBind()
'Me.WUCEntretienEcritureRecurrenteRepartition.GridEdit.Rebind()
'Me.WUCEntretienEcritureRecurrenteRepartition.EcritureRecurrenteController = ObjEcritureRecurrenteController
'Me.WUCEntretienEcritureRecurrenteRepartition.ReloadSource()
End
Sub
Protected
Sub
ToolBarEcriture1_ButtonClick(sender
As
Object
, e
As
RadToolBarEventArgs)
Handles
ToolBarEcriture.ButtonClick
Select
Case
e.Item.Value
Case
"NewButton"
WUCEntretienEcritureRecurrenteRepartition.UndoChange()
NewElement()
Case
"SaveButton"
WUCEntretienEcritureRecurrenteRepartition.UndoChange()
SauvegarderEcriture(
True
)
Case
"DeleteButton"
Try
If
Not
EcritureRecurrenteFacade.EcritureCourante
Is
Nothing
Then
ObjEcritureRecurrenteController.Delete(EcritureRecurrenteFacade.EcritureCourante)
End
If
MainMaster.ShowSuccessMessage(GetLocalResourceString(
"Message_DeleteSuccessful"
))
NewElement()
Catch
ex
As
Exception
Throw
ex
End
Try
End
Select
End
Sub
#End Region
#Region "Handler - Création et destruction des Handler de la page"
''' <summary>
''' Permet d'ajouter des Handler sur les UserControl de base
''' </summary>
''' <param name="AddHandlerPage"></param>
''' <remarks></remarks>
Private
Sub
AdjustPageHandler(
ByVal
AddHandlerPage
As
Boolean
)
Try
If
AddHandlerPage =
False
Then
'Ajouter les Handler nécessaire pour le fonctionnement de la grille de sélection
RemoveHandler
GridEdition.ImgSave_Clicked,
AddressOf
BtnSaveClick
RemoveHandler
GridEdition.ImgDelete_Clicked,
AddressOf
BtnDeleteClick
RemoveHandler
GridEdition.SaveFailed,
AddressOf
SaveFailed
RemoveHandler
MainMaster.CallSearchItemEvent,
AddressOf
RechercheEvent
Else
'Ajouter les Handler nécessaire pour le fonctionnement de la grille de sélection
AddHandler
GridEdition.ImgSave_Clicked,
AddressOf
BtnSaveClick
AddHandler
GridEdition.ImgDelete_Clicked,
AddressOf
BtnDeleteClick
AddHandler
GridEdition.SaveFailed,
AddressOf
SaveFailed
AddHandler
MainMaster.CallSearchItemEvent,
AddressOf
RechercheEvent
End
If
Catch
ex
As
Exception
Throw
ex
End
Try
End
Sub
#End Region
#Region "Handler - Déclenché par la grille"
Private
Sub
BtnDeleteClick(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Try
Dim
idFiche
As
Integer
= TryCast(e, EventArguments).idSelect
If
Not
idFiche =
Nothing
Then
'Provient de la gille de sélection, il faut charger la fiche avant
GetEcritureRepartitionByID(idFiche)
End
If
If
Not
ObjEcritureRecurrenteRepartitionController.SelectedTEntity
Is
Nothing
Then
ObjEcritureRecurrenteRepartitionController.Delete(ObjEcritureRecurrenteRepartitionController.SelectedTEntity)
End
If
Dim
objRadGrid
As
RadGrid = GridEdition.GridEdit
' TryCast(TryCast(sender, WUCGridEdition).FindControl("RadGridEdit"), RadGrid)
objRadGrid.Rebind()
Catch
ex
As
Exception
Throw
ex
End
Try
End
Sub
Private
Sub
BtnSaveClick(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Try
Save(sender, e)
Catch
ex
As
EntityValidationException
Throw
ex
Catch
ex
As
Exception
Throw
ex
End
Try
End
Sub
''' <summary>
''' Si l'enregistrement ne fonctionne pas, le radgrid reme les valeur original, cette fonction permet de remettre les valeurs saisie
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private
Sub
SaveFailed(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
'RemEttre les valeurs de l'entité en coursa d'enregistrement dans la fenêtre
Dim
objRadGrid
As
RadGrid = GridEdition.GridEdit
' TryCast(TryCast(sender, WUCGridEdition).FindControl("RadGridEdit"), RadGrid)
Dim
objGridManager
As
GridEditManager
If
objRadGrid.MasterTableView.IsItemInserted =
False
Then
'Édition
objGridManager = TryCast(objRadGrid.EditItems(0), Telerik.Web.UI.GridDataItem).EditManager
DirectCast
(objGridManager.GetColumnEditor(
"CompteNumero"
), Telerik.Web.UI.GridNumericColumnEditor).Text = ObjEcritureRecurrenteRepartitionController.Entity.Compte.NumeroToDisplay
DirectCast
(objGridManager.GetColumnEditor(
"Description"
), Telerik.Web.UI.GridTextBoxColumnEditor).Text = ObjEcritureRecurrenteRepartitionController.Entity.Description
DirectCast
(objGridManager.GetColumnEditor(
"Pourcentage"
), Telerik.Web.UI.GridNumericColumnEditor).Text = Convert.ToString(ObjEcritureRecurrenteRepartitionController.Entity.Pourcentage)
DirectCast
(objGridManager.GetColumnEditor(
"CodeComplementaireNumero"
), Telerik.Web.UI.GridDropDownColumnEditor).SelectedIndex = Convert.ToInt32(ObjEcritureRecurrenteRepartitionController.Entity.CodeComplementaireID)
' Permet de supprimer l'écriture si aucune Repartition en cas d'erreur (ne semble plus utile et donc pas tester)
'Dim IdCourante As Integer = EcritureRecurrenteFacade.EcritureCourante.ID
'If (ObjEcritureRecurrenteRepartitionController.GetRepartitionByEcritureID(IdCourante).Count = 0) Then
' If Not EcritureRecurrenteFacade.EcritureCourante Is Nothing Then
' ObjEcritureRecurrenteController.Delete(EcritureRecurrenteFacade.EcritureCourante)
' End If
'End If
Else
'Insert
objGridManager =
DirectCast
(objRadGrid.MasterTableView.GetInsertItem, Telerik.Web.UI.GridDataInsertItem).EditManager
End
If
End
Sub
#End Region
#Region "Fonction Privé de la page"
Private
Sub
SauvegarderEcriture(
Optional
IsUpdate
As
Boolean
=
False
)
Try
' =================================
' Gestion de l'écriture
' =================================
Dim
Numero
As
String
= txbNumero.Text
ObjEcritureRecurrenteController.GetEcritureRecurrenteByNumero(
CInt
(Numero))
ObjEcritureRecurrenteController.Entity = ObjEcritureRecurrenteController.SelectedTEntity
If
(ObjEcritureRecurrenteController.Entity.ID = 0)
Or
IsUpdate =
True
Then
Dim
Reference
As
String
= txbReference.Text
Dim
OldRef
As
String
=
Nothing
If
(Reference.Equals(
"AUTO"
))
Then
Dim
Ref
As
Integer
=
New
ParametresController().Entity.ProchainNumeroEcriture
Reference = Convert.ToString(Ref)
End
If
If
(IsUpdate =
False
)
AndAlso
ObjEcritureRecurrenteController.Entity IsNot
Nothing
Then
' L'écriture a déjà été créer
ObjEcritureRecurrenteRepartitionController.Entity.EcritureRecurrente = ObjEcritureRecurrenteController.Entity
ObjEcritureRecurrenteRepartitionController.Entity.EcritureRecurrenteID = ObjEcritureRecurrenteController.Entity.ID
ElseIf
IsUpdate =
False
Then
' Il faut créer l'écriture
ObjEcritureRecurrenteController.Entity =
New
EcritureRecurrente()
End
If
ObjEcritureRecurrenteController.Entity.Reference = Reference
ObjEcritureRecurrenteController.Entity.Description = txbDescription.Text
ObjEcritureRecurrenteController.Entity.Numero =
CLng
(txbNumero.Text)
ObjEcritureRecurrenteController.Entity.TransfertSolde = cbxTransfertSolde.Checked
' Liaison des comptes
ObjEcritureRecurrenteController.Entity.CompteDe = EcritureRecurrenteFacade.ObjCompte.GetCompteByNumero(
CLng
(txbCompteDepart.Text))
ObjEcritureRecurrenteController.Entity.CompteA = EcritureRecurrenteFacade.ObjCompte.GetCompteByNumero(
CLng
(txbCompteFin.Text))
ObjEcritureRecurrenteController.Entity.CompteContrePartie = EcritureRecurrenteFacade.ObjCompte.GetCompteByNumero(
CLng
(txbContrepartie.Text))
ObjEcritureRecurrenteController.Entity.CompteDeID = EcritureRecurrenteFacade.ObjCompte.GetCompteByNumero(
CLng
(txbCompteDepart.Text)).ID
ObjEcritureRecurrenteController.Entity.CompteAID = EcritureRecurrenteFacade.ObjCompte.GetCompteByNumero(
CLng
(txbCompteFin.Text)).ID
ObjEcritureRecurrenteController.Entity.CompteContrePartieID = EcritureRecurrenteFacade.ObjCompte.GetCompteByNumero(
CLng
(txbContrepartie.Text)).ID
ObjEcritureRecurrenteController.Save(ObjEcritureRecurrenteController.Entity)
EcritureRecurrenteFacade.EcritureCourante = ObjEcritureRecurrenteController.Entity
If
(txbReference.Text.Equals(
"AUTO"
))
Then
GrandLivreFacade.IncrementerNumeroEcriture()
End
If
txbReference.Text = ObjEcritureRecurrenteController.Entity.Reference
If
(IsUpdate)
Then
MainMaster.ShowSuccessMessage(
CStr
(GetGlobalResourceObject(GlobalConsts.GlobalResources.General,
"successfullyCompletedSave"
)))
End
If
End
If
Catch
ex
As
EntityValidationException
For
CtrBrokenRules = 0
To
ex.BrokenRules.Count - 1
Dim
NewError
As
New
CustomValidator
NewError.IsValid =
False
NewError.ErrorMessage = ex.BrokenRules(CtrBrokenRules).Description
Page.Validators.Add(NewError)
Next
Throw
ex
Catch
ex
As
Exception
If
(txbNumero.Text.Equals(
""
))
Then
Dim
NewError
As
New
CustomValidator
NewError.IsValid =
False
NewError.ErrorMessage = GetLocalResourceString(
"MessageError_NoNumero"
)
Page.Validators.Add(NewError)
txbNumero.Focus()
End
If
If
(ObjEcritureRecurrenteController.Entity.CompteDe.ID = 0)
Or
(ObjEcritureRecurrenteController.Entity.CompteDe
Is
Nothing
)
Then
Dim
NewError
As
New
CustomValidator
NewError.IsValid =
False
NewError.ErrorMessage = GetLocalResourceString(
"MessageError_NoCompteDepart"
)
Page.Validators.Add(NewError)
End
If
If
(ObjEcritureRecurrenteController.Entity.CompteA.ID = 0)
Or
(ObjEcritureRecurrenteController.Entity.CompteA
Is
Nothing
)
Then
Dim
NewError
As
New
CustomValidator
NewError.IsValid =
False
NewError.ErrorMessage = GetLocalResourceString(
"MessageError_NoCompteFin"
)
Page.Validators.Add(NewError)
End
If
If
(ObjEcritureRecurrenteController.Entity.CompteContrePartie.ID = 0)
Or
(ObjEcritureRecurrenteController.Entity.CompteContrePartie
Is
Nothing
)
Then
Dim
NewError
As
New
CustomValidator
NewError.IsValid =
False
NewError.ErrorMessage = GetLocalResourceString(
"MessageError_NoCompteContrepartie"
)
Page.Validators.Add(NewError)
End
If
Throw
ex
End
Try
End
Sub
Private
Sub
Save(
ByVal
Sender
As
Object
, e
As
System.EventArgs)
Try
Dim
objRadGrid
As
RadGrid = GridEdition.GridEdit
' TryCast(TryCast(Sender, WUCGridEdition).FindControl("RadGridEdit"), RadGrid)
If
Not
objRadGrid
Is
Nothing
Then
'Valider si on est en ajout de ligne
Dim
objRadGridEditManager
As
GridEditManager
If
objRadGrid.MasterTableView.IsItemInserted =
False
Then
'Édition
objRadGridEditManager = TryCast(objRadGrid.EditItems(0), Telerik.Web.UI.GridDataItem).EditManager
Else
'Insert
objRadGridEditManager =
DirectCast
(objRadGrid.MasterTableView.GetInsertItem, Telerik.Web.UI.GridDataInsertItem).EditManager
End
If
If
Not
objRadGridEditManager
Is
Nothing
Then
If
objRadGrid.MasterTableView.IsItemInserted =
False
Then
'Obtenir l'objet de la BD avant de le modifier
ObjEcritureRecurrenteRepartitionController.GetByID(
DirectCast
(e, PG.ACF.WEB.Corpo.EventArguments).idSelect)
ObjEcritureRecurrenteRepartitionController.Entity = ObjEcritureRecurrenteRepartitionController.SelectedTEntity
End
If
' =================================
' Gestion de l'écriture
' =================================
SauvegarderEcriture()
' =================================
' Sauvegarde de la répartition
' =================================
' Obtention des valeurs particulière des liaisons
Dim
ValueCompte
As
String
=
DirectCast
(objRadGridEditManager.GetColumnEditor(
"CompteNumero"
), Telerik.Web.UI.GridNumericColumnEditor).Text
Me
.WUCEntretienEcritureRecurrenteRepartition.GetCompteByNumber(ValueCompte)
Dim
CodeID
As
Integer
=
CInt
(
DirectCast
(objRadGridEditManager.GetColumnEditor(
"CodeComplementaireNumero"
), Telerik.Web.UI.GridDropDownColumnEditor).SelectedValue)
' Association des liaisons
ObjEcritureRecurrenteRepartitionController.Entity.CompteID = EcritureRecurrenteFacade.ObjCompte.Entity.ID
' Me.WUCEntretienEcritureRecurrenteRepartition.CompteController.Entity.ID
If
(CodeID = 0)
Then
ObjEcritureRecurrenteRepartitionController.Entity.CodeComplementaireID =
Nothing
Else
ObjEcritureRecurrenteRepartitionController.Entity.CodeComplementaireID = CodeID
' EcritureFacade.ObtenirListeCodeComplementaire(Code - 1).ID
End
If
ObjEcritureRecurrenteRepartitionController.Entity.EcritureRecurrente = ObjEcritureRecurrenteController.Entity
' Association des valeurs direct
ObjEcritureRecurrenteRepartitionController.Entity.Description =
DirectCast
(objRadGridEditManager.GetColumnEditor(
"Description"
), Telerik.Web.UI.GridTextBoxColumnEditor).Text
ObjEcritureRecurrenteRepartitionController.Entity.Pourcentage = Convert.ToDecimal(
DirectCast
(objRadGridEditManager.GetColumnEditor(
"Pourcentage"
), Telerik.Web.UI.GridNumericColumnEditor).Text)
' Rafraichir la grille avec le Where
ObjEcritureRecurrenteRepartitionController.Save(ObjEcritureRecurrenteRepartitionController.Entity)
EcritureRecurrenteFacade.EcritureCourante = ObjEcritureRecurrenteController.Entity
DirectCast
(
Me
.FindControlRecursively(Page,
"EcritureCourante"
), HiddenField).DataBind()
'Me.WUCEntretienEcritureRecurrenteRepartition.EcritureRecurrenteController = ObjEcritureRecurrenteController
'Me.WUCEntretienEcritureRecurrenteRepartition.ReloadSource()
' Une occurence existe on active le Btn Save & Delete
ToolBarEcriture.Items(1).Enabled =
True
ToolBarEcriture.Items(2).Enabled =
True
MainMaster.ShowSuccessMessage(
CStr
(GetGlobalResourceObject(GlobalConsts.GlobalResources.General,
"successfullyCompletedSave"
)))
End
If
End
If
Catch
ex
As
EntityValidationException
For
CtrBrokenRules = 0
To
ex.BrokenRules.Count - 1
Dim
NewError
As
New
CustomValidator
NewError.IsValid =
False
NewError.ErrorMessage = ex.BrokenRules(CtrBrokenRules).Description
Page.Validators.Add(NewError)
Next
Throw
ex
Catch
ex
As
Exception
If
(ObjEcritureRecurrenteRepartitionController.Entity.CompteID = 0)
Then
Dim
NewError
As
New
CustomValidator
NewError.IsValid =
False
NewError.ErrorMessage = GetLocalResourceString(
"MessageError_NoCompte"
)
Page.Validators.Add(NewError)
End
If
If
(ObjEcritureRecurrenteRepartitionController.Entity.Pourcentage =
Decimal
.Zero)
Then
Dim
NewError
As
New
CustomValidator
NewError.IsValid =
False
NewError.ErrorMessage = GetLocalResourceString(
"MessageError_InvalidPercent"
)
Page.Validators.Add(NewError)
End
If
Throw
ex
End
Try
End
Sub
Private
Sub
GetEcritureRepartitionByID(
ByVal
ID
As
Integer
)
ObjEcritureRecurrenteRepartitionController.GetByID(ID)
If
Not
ObjEcritureRecurrenteRepartitionController.SelectedTEntity
Is
Nothing
Then
ObjEcritureRecurrenteRepartitionController.Entity = ObjEcritureRecurrenteRepartitionController.SelectedTEntity
End
If
End
Sub
Private
Sub
ChargerInformationEcriture()
txbNumero.Text =
CStr
(EcritureRecurrenteFacade.EcritureCourante.Numero)
txbReference.Text =
CStr
(EcritureRecurrenteFacade.EcritureCourante.Reference)
txbDescription.Text = EcritureRecurrenteFacade.EcritureCourante.Description
cbxTransfertSolde.Checked = EcritureRecurrenteFacade.EcritureCourante.TransfertSolde
txbCompteDepart.Text = EcritureRecurrenteFacade.EcritureCourante.CompteA.NumeroToDisplay
txbCompteFin.Text = EcritureRecurrenteFacade.EcritureCourante.CompteDe.NumeroToDisplay
txbContrepartie.Text = EcritureRecurrenteFacade.EcritureCourante.CompteContrePartie.NumeroToDisplay
txbCompteDepartDesc.Text = EcritureRecurrenteFacade.EcritureCourante.CompteA.Description
txbCompteFinDesc.Text = EcritureRecurrenteFacade.EcritureCourante.CompteDe.Description
txbContrepartieDesc.Text = EcritureRecurrenteFacade.EcritureCourante.CompteContrePartie.Description
End
Sub
#End Region
#Region "ParametersAJAX - AjaxRequest"
Protected
Sub
manager_AjaxRequest(sender
As
Object
, e
As
Telerik.Web.UI.AjaxRequestEventArgs)
Dim
Action()
As
String
= e.Argument.Split(
CChar
(
"&"
))
Select
Case
Action(0)
Case
"Resize"
PageEntretien.Height = Unit.Pixel(
CInt
(Action(1)))
PanelInformationEcriture.Height = Unit.Pixel(280)
Dim
TailleReelEntretien
As
Integer
=
CInt
(Action(1)) - 280
DirectCast
(
Me
.FindControlRecursively(Page,
"HeightPage"
), HiddenField).Value =
CStr
(TailleReelEntretien)
End
Select
End
Sub
#End Region
#Region "Gestion du Dirty"
Private
Sub
ResetDirtyFlag()
DirectCast
(
Me
.FindControlRecursively(Page,
"DirtyFlag"
), HiddenField).Value =
"False"
End
Sub
Private
Sub
UndoChange()
'Annuler tous les changements en cours, si c'Est le cas
ResetDirtyFlag()
End
Sub
#End Region
#Region "Appel de la recherche"
Protected
Sub
btnRecherche_Click(sender
As
Object
, e
As
EventArgs)
Dim
Button
As
RadButton =
DirectCast
(sender, RadButton)
Dim
ClientID
As
String
=
String
.Empty
Select
Case
Button.CommandArgument.ToString
Case
"Numero"
MainMaster.CallSearchItem(GetLocalResourceString(
"SearchTitle_Ecriture"
), ObjEcritureRecurrenteController.LinqContextTypeName,
ObjEcritureRecurrenteController.GetPropertyName(
Function
() ObjEcritureRecurrenteController.GridSearchSelect),
txbNumero.ClientID, ObjEcritureRecurrenteController.GridSearchColumn)
Case
"CompteDe"
ClientID = txbCompteDepart.ClientID
Case
"CompteA"
ClientID = txbCompteFin.ClientID
Case
"CompteContre"
ClientID = txbContrepartie.ClientID
End
Select
If
(
Not
ClientID =
String
.Empty)
Then
MainMaster.CallSearchItem(GetLocalResourceString(
"SearchTitle_Compte"
), EcritureRecurrenteFacade.ObjCompte.LinqContextTypeName,
EcritureRecurrenteFacade.ObjCompte.GetPropertyName(
Function
() EcritureRecurrenteFacade.ObjCompte.GridSearchSelect),
ClientID, EcritureRecurrenteFacade.ObjCompte.GridSearchColumn)
End
If
End
Sub
Private
Sub
RechercheEvent(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
'Select case contenant la liste de tous les champs dont la recherche est disponible.
Dim
ObjEventArgs
As
SearchReturnEvent =
CType
(e, SearchReturnEvent)
Select
Case
ObjEventArgs.UpdatedControlId
Case
txbNumero.ClientID
GetEcritureByID(ObjEventArgs.IDSelect)
EcritureRecurrenteFacade.EcritureCourante = ObjEcritureRecurrenteController.Entity
DirectCast
(
Me
.FindControlRecursively(Page,
"EcritureCourante"
), HiddenField).DataBind()
'Me.WUCEntretienEcritureRecurrenteRepartition.EcritureRecurrenteController = ObjEcritureRecurrenteController
'Me.WUCEntretienEcritureRecurrenteRepartition.ReloadSource()
' Une occurence existe on active le Btn Save & Delete
ToolBarEcriture.Items(1).Enabled =
True
ToolBarEcriture.Items(2).Enabled =
True
Case
Else
GetCompteByID(ObjEventArgs.UpdatedControlId, ObjEventArgs.IDSelect)
End
Select
End
Sub
Private
Sub
GetEcritureByID(
ByVal
IdEcriture
As
Integer
)
Try
' Recherche et obtention du Compte relier a la recherche
ObjEcritureRecurrenteController.GetByID(IdEcriture)
ObjEcritureRecurrenteController.Entity = ObjEcritureRecurrenteController.SelectedTEntity
EcritureRecurrenteFacade.EcritureCourante = ObjEcritureRecurrenteController.Entity
' Affichager des informations à l'écran
ChargerInformationEcriture()
Catch
ex
As
Exception
Throw
ex
End
Try
End
Sub
Private
Sub
GetCompteByID(
ByVal
ControlID
As
String
,
ByVal
IdCompte
As
Integer
)
Try
' Recherche et obtention du Compte relier a la recherche
EcritureRecurrenteFacade.ObjCompte.GetByID(IdCompte)
EcritureRecurrenteFacade.ObjCompte.Entity = EcritureRecurrenteFacade.ObjCompte.SelectedTEntity
If
(EcritureRecurrenteFacade.ObjCompte.Entity IsNot
Nothing
)
Then
Select
Case
ControlID
Case
txbCompteDepart.ClientID
txbCompteDepart.Text = EcritureRecurrenteFacade.ObjCompte.Entity.NumeroToDisplay
txbCompteDepartDesc.Text = EcritureRecurrenteFacade.ObjCompte.Entity.Description
Case
txbCompteFin.ClientID
txbCompteFin.Text = EcritureRecurrenteFacade.ObjCompte.Entity.NumeroToDisplay
txbCompteFinDesc.Text = EcritureRecurrenteFacade.ObjCompte.Entity.Description
Case
txbContrepartie.ClientID
txbContrepartie.Text = EcritureRecurrenteFacade.ObjCompte.Entity.NumeroToDisplay
txbContrepartieDesc.Text = EcritureRecurrenteFacade.ObjCompte.Entity.Description
End
Select
End
If
Catch
ex
As
Exception
Throw
ex
End
Try
End
Sub
#End Region
Protected
Sub
txbNumero_TextChanged(sender
As
Object
, e
As
EventArgs)
Handles
txbNumero.TextChanged
Dim
Numero
As
String
= txbNumero.Text.Trim
If
(ObjEcritureRecurrenteController.GetEcritureRecurrenteByNumero(
CInt
(Numero),
True
) IsNot
Nothing
)
Then
ObjEcritureRecurrenteController.Entity = ObjEcritureRecurrenteController.SelectedTEntity
EcritureRecurrenteFacade.EcritureCourante = ObjEcritureRecurrenteController.Entity
DirectCast
(
Me
.FindControlRecursively(Page,
"EcritureCourante"
), HiddenField).DataBind()
ChargerInformationEcriture()
'Me.WUCEntretienEcritureRecurrenteRepartition.EcritureRecurrenteController = ObjEcritureRecurrenteController
'Me.WUCEntretienEcritureRecurrenteRepartition.ReloadSource()
End
If
End
Sub
Protected
Sub
ChargementCompteManuel_TextChanged(sender
As
Object
, e
As
EventArgs)
Dim
TextBox
As
RadMaskedTextBox =
DirectCast
(sender, RadMaskedTextBox)
'Dim ClientID() As String = TextBox.ClientID.Split(CChar("__"))
Select
Case
TextBox.ID
Case
"txbCompteDepart"
txbCompteDepart.Text = EcritureRecurrenteFacade.ObjCompte.GetCompteByNumero(
CLng
(TextBox.Text)).NumeroToDisplay
txbCompteDepartDesc.Text = EcritureRecurrenteFacade.ObjCompte.SelectedTEntity.Description
Case
"txbCompteFin"
txbCompteFin.Text = EcritureRecurrenteFacade.ObjCompte.GetCompteByNumero(
CLng
(TextBox.Text)).NumeroToDisplay
txbCompteFinDesc.Text = EcritureRecurrenteFacade.ObjCompte.SelectedTEntity.Description
Case
"txbContrepartie"
txbContrepartie.Text = EcritureRecurrenteFacade.ObjCompte.GetCompteByNumero(
CLng
(TextBox.Text)).NumeroToDisplay
txbContrepartieDesc.Text = EcritureRecurrenteFacade.ObjCompte.SelectedTEntity.Description
End
Select
End
Sub
End
Class
WUCEntretienEcritureRecurrentRecurrente.ascx
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="WUCEntretienEcritureRecurrenteRepartition.ascx.vb" Inherits=".WUCEntretienEcritureRecurrenteRepartition" %>
<%@ Import Namespace="PG.ACF.MVC.GL.Facade" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Src="~/Corpo/Grid/WUCGridRecherche.ascx" TagPrefix="uc1" TagName="WUCGridRecherche" %>
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function resizeToFrame(arg) {
if ($find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>")) {
$find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("Resize&" + arg.height);
}
}
</
script
>
</
telerik:RadCodeBlock
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function confirmDirtyNavigation() {
var hfDirty = document.getElementById('body_DirtyFlag');
if (hfDirty) {
if (hfDirty.value == "True") {
var test = confirm("<%=GetGlobalResourceObject("General", "UnsavedInformationLost")%>");
return test;
}
}
return true;
}
function alertDirtyNavigation() {
var hfDirty = document.getElementById('body_DirtyFlag');
if (hfDirty) {
if (hfDirty.value == "True") {
ShowAlertMessage("<%=GetGlobalResourceObject("General", "SaveOrCancelChanges")%>", "Avertissement");
return false;
}
}
return true;
}
function onPanelBarItemClicked(sender, args) {
if (args.get_item().get_commandName() == "Add") {
if (!confirmDirtyNavigation()) {
return false;
}
ResetDirty();
//Ajouter une nouvelle ligne. Le paramètre "InitInsert" est OBLIGATOIRE et DOIT être écrit EXACTEMENT comme il est inscrit
$find('<%= RadGridEdit.ClientID%>').get_masterTableView().fireCommand("InitInsert");
}
//TODO : Bloc Save
// if (args.get_item().get_commandName() == "Save") {
// if (!alertDirtyNavigation()) {
// return false;
// }
// $find('<%= RadGridEdit.ClientID%>').get_masterTableView().fireCommand(args.get_item().get_commandName());
// }
}
</
script
>
</
telerik:RadScriptBlock
>
<
telerik:RadAjaxManagerProxy
ID
=
"AjaxManagerProxy_GridEdit"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"AjaxManagerProxy_GridEdit"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGridEdit"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGridEdit"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGridEdit"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadWindowSearch"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManagerProxy
>
<
asp:Panel
ID
=
"Content"
runat
=
"server"
>
<
h2
>Le total est réparti comme suit:</
h2
>
<
telerik:RadGrid
ID
=
"RadGridEdit"
AllowSorting
=
"True"
Width
=
"100%"
Height
=
"100%"
AllowAutomaticInserts
=
"true"
CellPadding
=
"0"
BorderWidth
=
"0"
GridLines
=
"None"
AllowPaging
=
"True"
runat
=
"server"
AutoGenerateColumns
=
"false"
DataSourceID
=
"odsEcriture"
AllowCustomPaging
=
"false"
>
<
PagerStyle
Visible
=
"true"
></
PagerStyle
>
<
ClientSettings
EnableRowHoverStyle
=
"true"
AllowKeyboardNavigation
=
"true"
>
<
Scrolling
UseStaticHeaders
=
"true"
AllowScroll
=
"true"
/>
<
Selecting
AllowRowSelect
=
"true"
/>
<
Resizing
AllowColumnResize
=
"true"
AllowResizeToFit
=
"true"
/>
</
ClientSettings
>
<
MasterTableView
AutoGenerateColumns
=
"True"
DataKeyNames
=
"ID"
ClientDataKeyNames
=
"ID"
IsFilterItemExpanded
=
"false"
EditMode
=
"InPlace"
CommandItemDisplay
=
"Top"
TableLayout
=
"Fixed"
ShowFooter
=
"true"
AllowPaging
=
"false"
ViewStateMode
=
"Inherit"
>
<
PagerStyle
PageSizeControlType
=
"None"
/>
<
ItemStyle
Height
=
"27px"
/>
<
AlternatingItemStyle
Height
=
"27px"
/>
<
CommandItemTemplate
>
<
div
>
<
telerik:RadToolBar
ID
=
"RadToolBarWUCGridFilter"
runat
=
"server"
Width
=
"100%"
Height
=
"25px"
OnClientButtonClicked
=
"onPanelBarItemClicked"
>
<
Items
>
<
telerik:RadToolBarButton
Text="<% $Resources:toolbar_addRepartition %>" Value="AddButton" CommandName="Add" AccessKey="A"
ImageUrl="~/Images/16X16/add.png" ImagePosition="Right"></
telerik:RadToolBarButton
>
</
Items
>
</
telerik:RadToolBar
>
</
div
>
</
CommandItemTemplate
>
<
Columns
>
<
telerik:GridTemplateColumn
UniqueName
=
"TemplateColumn"
ShowFilterIcon
=
"false"
AllowFiltering
=
"false"
HeaderStyle-Width
=
"70px"
HeaderText
=
"Action"
HeaderStyle-HorizontalAlign
=
"Left"
>
<
HeaderStyle
Width
=
"70px"
/>
<
ItemStyle
BorderWidth
=
"0px"
/>
<
InsertItemTemplate
>
<
asp:ImageButton
ID
=
"ImgSave"
runat
=
"server"
ToolTip
=
""
CommandName
=
"SaveSelected"
ImageUrl
=
"~/Images/16X16/save.png"
Visible
=
"true"
Height
=
"14px"
Width
=
"14px"
BorderWidth
=
"0px"
/>
<
asp:ImageButton
ID
=
"ImgUndo"
runat
=
"server"
ToolTip
=
""
CommandName
=
"UndoSelected"
ImageUrl
=
"~/Images/16X16/Undo.png"
Visible
=
"true"
Height
=
"14px"
Width
=
"14px"
BorderWidth
=
"0px"
/>
<
asp:ImageButton
ID
=
"ImgSearchGL"
runat
=
"server"
ToolTip
=
"RechercheGL"
CommandName
=
"SearchCompte"
ImageUrl
=
"~/Images/16X16/Search.png"
Visible
=
"true"
Height
=
"14px"
Width
=
"14px"
BorderWidth
=
"0px"
/>
</
InsertItemTemplate
>
<
EditItemTemplate
>
<
asp:ImageButton
ID
=
"ImgSave"
runat
=
"server"
ToolTip
=
""
CommandName
=
"SaveSelected"
ImageUrl
=
"~/Images/16X16/save.png"
Visible
=
"true"
Height
=
"14px"
Width
=
"14px"
BorderWidth
=
"0px"
/>
<
asp:ImageButton
ID
=
"ImgUndo"
runat
=
"server"
ToolTip
=
""
CommandName
=
"UndoSelected"
ImageUrl
=
"~/Images/16X16/Undo.png"
Visible
=
"true"
Height
=
"14px"
Width
=
"14px"
BorderWidth
=
"0px"
/>
<
asp:ImageButton
ID
=
"ImgSearchGL"
runat
=
"server"
ToolTip
=
"RechercheGL"
CommandName
=
"SearchCompte"
ImageUrl
=
"~/Images/16X16/Search.png"
Visible
=
"true"
Height
=
"14px"
Width
=
"14px"
BorderWidth
=
"0px"
/>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:ImageButton
ID
=
"ImgEdit"
runat
=
"server"
ToolTip
=
""
CommandName
=
"EditSelected"
AccessKey
=
" "
ImageUrl
=
"~/Images/16X16/Edit.png"
Height
=
"14px"
Width
=
"14px"
BorderWidth
=
"0px"
/>
<
asp:ImageButton
ID
=
"ImgDelete"
runat
=
"server"
ToolTip
=
""
CommandName
=
"DeleteSelected"
ImageUrl
=
"~/Images/16X16/Delete.png"
Height
=
"14px"
Width
=
"14px"
BorderWidth
=
"0px"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
asp:Panel
>
<
asp:LinqDataSource
ID
=
"LinqDataSource1"
runat
=
"server"
/>
<
asp:ObjectDataSource
ID
=
"odsCodeComplementaire"
runat
=
"server"
SelectMethod
=
"getFormatDescription"
TypeName
=
"PG.ACF.MVC.GL.Controllers.CodeComplementaireController"
/>
<
asp:HiddenField
ID
=
"EcritureCourante"
runat
=
"server"
Value="<%# EcritureRecurrenteFacade.getCurrentEcritureID%>"/>
<
asp:ObjectDataSource
ID
=
"odsEcriture"
runat
=
"server"
SelectMethod
=
"GetListeID"
TypeName
=
"PG.ACF.MVC.GL.Controllers.EcritureRecurrenteRepartitionController"
>
<
SelectParameters
>
<
asp:ControlParameter
ControlID
=
"EcritureCourante"
PropertyName
=
"Value"
DefaultValue
=
"0"
Name
=
"EcritureID"
Type
=
"Int32"
></
asp:ControlParameter
>
</
SelectParameters
>
</
asp:ObjectDataSource
>
WUCEntretienEcritureRecurrentRecurrente.ascx.vb
Imports
PG.ACF.GL.Core.Entities.Data
Imports
PG.ACF.Core.DAL
Imports
Telerik.Web.UI
Imports
System.Reflection.PropertyInfo
Imports
System.Reflection
Imports
PG.ACF.WEB.Corpo
Imports
PG.ACF.MVC.GL.Interfaces
Imports
PG.ACF.MVC.GL.Controllers
Imports
PG.ACF.MVC.GL.Facade
Imports
PG.ACF.Core.Entities.Data
Imports
PG.ACF.Core.Utils
Imports
PG.ACF.GL.Core.Entities
Imports
PG.ACF.MVC.Core.Classes
Imports
PG.ACF.WEB.Corpo.Grid
Public
Class
WUCEntretienEcritureRecurrenteRepartition
Inherits
BaseUserControl
#Region "Propriété de la page"
Public
Property
GridContextTypeName
As
String
=
String
.Empty
Public
Property
GridTableName
As
String
=
String
.Empty
Public
Property
ManualGenerateColumn
As
Boolean
=
True
'Private ChampsRechercheCourante As String = String.Empty
Public
ReadOnly
Property
GridEdit
As
RadGrid
Get
Return
RadGridEdit
End
Get
End
Property
' Propriété de la grille
Private
_columnListDisplay
As
List(Of GridPropertyColumn)
Public
Property
ColumnListDisplay()
As
List(Of GridPropertyColumn)
Get
Return
_columnListDisplay
End
Get
Set
(
ByVal
value
As
List(Of GridPropertyColumn))
_columnListDisplay = value
End
Set
End
Property
' Controlleur des écritures
Private
_EcritureRecurrenteController
As
New
EcritureRecurrenteController
Public
Property
EcritureRecurrenteController()
As
EcritureRecurrenteController
Get
If
_EcritureRecurrenteController
Is
Nothing
Then
_EcritureRecurrenteController =
New
EcritureRecurrenteController()
End
If
Return
_EcritureRecurrenteController
End
Get
Set
(
ByVal
value
As
EcritureRecurrenteController)
_EcritureRecurrenteController = value
End
Set
End
Property
' Controlleur des écritures
Private
_EcritureRecurrenteRepartitionController
As
New
EcritureRecurrenteRepartitionController
Public
Property
EcritureRecurrenteRepartitionController()
As
EcritureRecurrenteRepartitionController
Get
If
_EcritureRecurrenteRepartitionController
Is
Nothing
Then
_EcritureRecurrenteRepartitionController =
New
EcritureRecurrenteRepartitionController()
End
If
Return
_EcritureRecurrenteRepartitionController
End
Get
Set
(
ByVal
value
As
EcritureRecurrenteRepartitionController)
_EcritureRecurrenteRepartitionController = value
End
Set
End
Property
#End Region
#Region "Constructeur"
Private
Sub
Page_Load(sender
As
Object
, e
As
EventArgs)
Handles
Me
.Load
Dim
manager
As
RadAjaxManager = RadAjaxManager.GetCurrent(Page)
AddHandler
manager.AjaxRequest,
AddressOf
manager_AjaxRequest
'Initialiser le LinqDataSource
LinqDataSource1.ContextTypeName = GridContextTypeName
LinqDataSource1.TableName = GridTableName
'LinqDataSource1.Where = "EcritureRecurrenteID = @EcritureRecurrenteID"
'LinqDataSource1.WhereParameters.Add("EcritureRecurrenteID", DbType.Int32, Convert.ToString(EcritureRecurrenteController.Entity.ID))
'Ajouter un Handler pour gérer le retour de la recherche
AddHandler
MainMaster.CallSearchItemEvent,
AddressOf
RechercheEventCompte
End
Sub
'Public Sub ReloadSource()
' If (LinqDataSource1.WhereParameters.Count = 0) Then
' LinqDataSource1.Where = "EcritureRecurrenteID = @EcritureRecurrenteID"
' LinqDataSource1.WhereParameters.Add("EcritureRecurrenteID", DbType.Int32, Convert.ToString(EcritureRecurrenteController.Entity.ID))
' Else
' LinqDataSource1.WhereParameters("EcritureRecurrenteID").DefaultValue = Convert.ToString(EcritureRecurrenteController.Entity.ID)
' End If
' RadGridEdit.Rebind()
'End Sub
Private
Sub
Page_Init(sender
As
Object
, e
As
EventArgs)
Handles
Me
.Init
'Ajouter les colonnes
If
ManualGenerateColumn
Then
RadGridEdit.AutoGenerateColumns =
False
RadGridEdit.MasterTableView.AutoGenerateColumns =
False
RadGridEdit.MasterTableView.EnableColumnsViewState =
False
ColumnListDisplay = EcritureRecurrenteRepartitionController.GridSelectColumn
GridFunction.AddColumnToGrid(RadGridEdit, ColumnListDisplay)
End
If
End
Sub
#End Region
#Region "Appel de la recherche"
Private
Sub
RechercheEventCompte(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
'Select case contenant la liste de tous les champs dont la recherche est disponible.
If
(ViewState(
"extract"
) IsNot
Nothing
)
Then
Dim
Hash
As
Hashtable =
DirectCast
(ViewState(
"extract"
), Hashtable)
Dim
oldvalue
As
String
=
""
If
Hash(
"CompteNumero"
) IsNot
Nothing
Then
oldvalue = Hash(
"CompteNumero"
).ToString
End
If
Dim
ObjEventArgs
As
SearchReturnEvent =
CType
(e, SearchReturnEvent)
Select
Case
ObjEventArgs.UpdatedControlId
Case
Hash(
"CompteNumeroID"
).ToString
GetCompteByID(ObjEventArgs.IDSelect)
End
Select
End
If
End
Sub
Public
Sub
GetCompteByID(
ByVal
IdCompte
As
Integer
)
Try
' REcherche et obtention du Compte relier a la recherche
EcritureRecurrenteFacade.ObjCompte.GetByID(IdCompte)
EcritureRecurrenteFacade.ObjCompte.Entity = EcritureRecurrenteFacade.ObjCompte.SelectedTEntity
EcritureRecurrenteRepartitionController.Entity.Compte = EcritureRecurrenteFacade.ObjCompte.Entity
EcritureRecurrenteRepartitionController.Entity.CodeComplementaireID = 0
If
(
Not
RadGridEdit.MasterTableView.IsItemInserted)
Or
(RadGridEdit.Items.Count > 0
And
RadGridEdit.MasterTableView.IsItemInserted)
Then
RadGridEdit.Rebind()
Else
Dim
Hash
As
Hashtable =
DirectCast
(ViewState(
"extract"
), Hashtable)
'RadGridEdit.DataBind()
End
If
'RadGridEdit.Rebind()
'RadGridEdit.DataBind()
Catch
ex
As
Exception
Throw
ex
End
Try
End
Sub
Public
Sub
GetCompteByNumber(
ByVal
Numero
As
String
)
Try
' REcherche et obtention du Compte relier a la recherche
EcritureRecurrenteFacade.ObjCompte.GetCompteByNumero(
CLng
(Numero))
EcritureRecurrenteFacade.ObjCompte.Entity = EcritureRecurrenteFacade.ObjCompte.SelectedTEntity
Catch
ex
As
Exception
Throw
ex
End
Try
End
Sub
#End Region
#Region "ParametersAJAX - AjaxRequest"
Protected
Sub
manager_AjaxRequest(sender
As
Object
, e
As
Telerik.Web.UI.AjaxRequestEventArgs)
Dim
Action()
As
String
= e.Argument.Split(
CChar
(
"&"
))
Select
Case
Action(0)
Case
"Resize"
Dim
Taille
As
Integer
=
CInt
(
DirectCast
(
Me
.FindControlRecursively(Page,
"HeightPage"
), HiddenField).Value)
RadGridEdit.Height = Unit.Pixel(Taille)
GridFunction.SetPageSizeGrid(RadGridEdit, Taille,
CInt
(27))
'TODO Enlever propriété ObjgridFunction
End
Select
End
Sub
#End Region
#Region "RadGridEdit - Event"
Private
Sub
RadGridEdit_ItemCommand(sender
As
Object
, e
As
GridCommandEventArgs)
Handles
RadGridEdit.ItemCommand
Select
Case
e.CommandName
Case
"EditSelected"
UndoChange()
'Annuler les changements des autres lignes, s'il y a lieu, le client n'a pas enregistrer les chamgements en cours sur la fiche courante mais veut quand même faire une autre action
'Éditer la bonne ligne.
Dim
IndexRowSelect
As
Integer
=
DirectCast
(e.Item, GridDataItem).ItemIndex
RadGridEdit.EditIndexes.Add(IndexRowSelect)
RadGridEdit.DataBind()
Case
"DeleteSelected"
UndoChange()
'Annuler les changements des autres lignes, s'il y a lieu, le client n'a pas enregistrer les chamgements en cours sur la fiche courante mais veut quand même faire une autre action
OnImgDeleteCliked(
New
EventArguments(
CInt
(
DirectCast
(e.Item, GridDataItem).GetDataKeyValue(
"ID"
).ToString)))
Me
.RadGridEdit.Rebind()
Case
"UndoSelected"
Dim
IndexRowSelect
As
Integer
=
DirectCast
(e.Item, GridDataItem).ItemIndex
'Valider si on est en ajout de ligne
If
RadGridEdit.MasterTableView.IsItemInserted =
False
Then
RadGridEdit.EditIndexes.Clear()
Else
RadGridEdit.MasterTableView.IsItemInserted =
False
End
If
UndoChange()
'Annuler les changements des autres lignes, s'il y a lieu, le client n'a pas enregistrer les chamgements en cours sur la fiche courante mais veut quand même faire une autre action
Me
.RadGridEdit.Rebind()
Case
"SaveSelected"
Dim
IndexRowSelect
As
Integer
=
DirectCast
(e.Item, GridDataItem).ItemIndex
'Valider si on est en ajout de ligne
Try
If
RadGridEdit.MasterTableView.IsItemInserted =
False
Then
OnImgSaveCliked(
New
EventArguments(
CInt
(
DirectCast
(e.Item, GridDataItem).GetDataKeyValue(
"ID"
).ToString)))
RadGridEdit.EditIndexes.Clear()
Me
.RadGridEdit.Rebind()
Else
' Lorsqu'on ajout un nouvel élement
OnImgSaveCliked(
New
EventArguments(0))
RadGridEdit.MasterTableView.IsItemInserted =
False
Me
.RadGridEdit.Rebind()
End
If
ResetDirtyFlag()
EcritureRecurrenteFacade.ObjCompte.Entity =
Nothing
RadGridEdit.MasterTableView.InsertItem()
Catch
ex
As
Exception
'S'il y a une erreur, ne pas continuer le traitement normal.
RadGridEdit.DataBind()
OnSaveFailed(
New
EventArguments(
Nothing
))
End
Try
Case
"SearchCompte"
' Désactive le compte courante pour empêcher les problèmes d'affichages
If
(EcritureRecurrenteFacade.ObjCompte.Entity IsNot
Nothing
)
AndAlso
(EcritureRecurrenteFacade.ObjCompte.Entity.ID > 0)
Then
EcritureRecurrenteFacade.ObjCompte.Entity =
Nothing
End
If
' Prépare la recherche
Dim
i
As
GridDataItem =
DirectCast
(e.Item, GridDataItem)
Dim
editValues
As
New
Hashtable()
i.ExtractValues(editValues)
editValues.Add(
"CompteNumeroID"
, i(
"CompteNumero"
).ClientID)
ViewState(
"extract"
) = editValues
Dim
SearchValue
As
String
=
""
If
(editValues(
"CompteNumero"
) IsNot
Nothing
)
Then
SearchValue = editValues(
"CompteNumero"
).ToString
End
If
MainMaster.CallSearchItem(GetLocalResourceString(
"SearchTitle_Compte"
), EcritureRecurrenteFacade.ObjCompte.LinqContextTypeName,
EcritureRecurrenteFacade.ObjCompte.GetPropertyName(
Function
() EcritureRecurrenteFacade.ObjCompte.GridSearchSelect),
i(
"CompteNumero"
).ClientID, EcritureRecurrenteFacade.ObjCompte.GridSearchColumn)
Case
"Add"
,
"InitInsert"
'TODO : Quand ajouts repart depuis EDIT tous est OK
' Si Ajouts depuis nouvelle écriture, problème car codeCompl pas Init
EcritureRecurrenteFacade.ObjCompte.Entity =
Nothing
UndoChange()
e.Canceled =
True
Dim
newValues
As
System.Collections.Specialized.ListDictionary =
New
System.Collections.Specialized.ListDictionary()
newValues(
"CompteNumero"
) =
Nothing
newValues(
"Description"
) =
Nothing
newValues(
"CodeComplementaireNumero"
) =
Nothing
newValues(
"Pourcentage"
) =
Nothing
'e.Item.OwnerTableView.InsertItem(newValues)
'RadGridEdit.MasterTableView.DataBind()
'RadGridEdit.Rebind()
RadGridEdit.MasterTableView.InsertItem(newValues)
If
(RadGridEdit.MasterTableView.Items.Count = 0)
And
RadGridEdit.MasterTableView.IsItemInserted
Then
End
If
End
Select
End
Sub
Public
Sub
UndoChange()
'Annuler tous les changements en cours, si c'Est le cas
ResetDirtyFlag()
If
RadGridEdit.MasterTableView.IsItemInserted =
False
Then
RadGridEdit.EditIndexes.Clear()
Else
RadGridEdit.MasterTableView.IsItemInserted =
False
End
If
End
Sub
Private
Sub
RadGridEdit_PreRender(sender
As
Object
, e
As
EventArgs)
Handles
RadGridEdit.PreRender
If
Not
IsPostBack
Then
GridFunction.FormatGridDisplay(RadGridEdit, ColumnListDisplay)
RadGridEdit.Rebind()
End
If
End
Sub
Private
Sub
RadGridEdit_ItemCreated(sender
As
Object
, e
As
GridItemEventArgs)
Handles
RadGridEdit.ItemCreated
If
TypeOf
e.Item
Is
GridEditableItem
AndAlso
e.Item.IsInEditMode
Then
Dim
item
As
GridEditableItem =
DirectCast
(e.Item, GridEditableItem)
If
ColumnListDisplay IsNot
Nothing
Then
For
Each
GridColumn
As
GridPropertyColumn
In
ColumnListDisplay
Dim
editor
As
IGridColumnEditor = item.EditManager.GetColumnEditor(GridColumn.ColumnName)
WebHelper.AddIsDirtyHandler(Page,
CType
(editor, Control))
Next
End
If
End
If
End
Sub
Private
Sub
RadGridEdit_ItemDataBound(sender
As
Object
, e
As
GridItemEventArgs)
Handles
RadGridEdit.ItemDataBound
'Ajouter la validation de confirmation
'Le code à été mis ici pour l'ajout du script afin de permettre de désactiver les événements
If
TypeOf
e.Item
Is
GridDataItem
Then
Dim
dataItem
As
GridDataItem =
CType
(e.Item, GridDataItem)
' Permet d'inscrire la valeur de la recherche lors de insertion d'une nouvelle ligne.
If
(EcritureRecurrenteFacade.ObjCompte.Entity IsNot
Nothing
)
AndAlso
(EcritureRecurrenteFacade.ObjCompte.Entity.ID > 0)
AndAlso
(ViewState(
"extract"
) IsNot
Nothing
)
Then
If
RadGridEdit.MasterTableView.EditMode = GridEditMode.InPlace
Then
If
TypeOf
e.Item
Is
GridDataInsertItem
AndAlso
e.Item.OwnerTableView.IsItemInserted
Then
Dim
insertItem
As
GridDataInsertItem =
DirectCast
(e.Item, GridDataInsertItem)
TryCast(insertItem(
"CompteNumero"
).Controls(0), Telerik.Web.UI.RadNumericTextBox).Text =
CStr
(EcritureRecurrenteFacade.ObjCompte.Entity.Numero)
TryCast(insertItem(
"Description"
).Controls(0), TextBox).Text = EcritureRecurrenteFacade.ObjCompte.Entity.Description
ElseIf
TypeOf
e.Item
Is
GridDataItem
AndAlso
e.Item.IsInEditMode
Then
Dim
editItem
As
GridEditableItem =
DirectCast
(e.Item, GridEditableItem)
TryCast(editItem(
"CompteNumero"
).Controls(0), Telerik.Web.UI.RadNumericTextBox).Text =
CStr
(EcritureRecurrenteFacade.ObjCompte.Entity.Numero)
TryCast(editItem(
"Description"
).Controls(0), TextBox).Text = EcritureRecurrenteFacade.ObjCompte.Entity.Description
End
If
End
If
End
If
' Désactiver la colonne des codes complémentaire si le paramètre n'est pas activé.
Dim
GestionCode
As
Boolean
= EcritureRecurrenteFacade.ObjParametre.Entity.GestionCodeComplementaire
' Permet via la gestion Manuel des colonnes de créer le RadCombo
If
(ManualGenerateColumn)
Then
If
TypeOf
e.Item
Is
GridEditableItem
AndAlso
e.Item.IsInEditMode
Then
Dim
item1
As
GridEditableItem = TryCast(e.Item, GridEditableItem)
Dim
combo
As
RadComboBox = TryCast(item1.EditManager.GetColumnEditor(
"CodeComplementaireNumero"
), GridDropDownListColumnEditor).ComboBoxControl
'Dim combo As RadComboBox = TryCast(item1.EditManager.GetColumnEditor("CodeComplementaireID"), GridDropDownListColumnEditor).ComboBoxControl
combo.Width = Unit.Pixel(150)
combo.Height = Unit.Pixel(100)
If
Not
GestionCode
Then
combo.Visible =
False
End
If
End
If
End
If
Dim
ImgEdit
As
ImageButton = TryCast(dataItem(
"TemplateColumn"
).FindControl(
"ImgEdit"
), ImageButton)
If
ImgEdit IsNot
Nothing
Then
ImgEdit.OnClientClick =
"return confirmDirtyNavigation()"
End
If
Dim
ImgDelete
As
ImageButton = TryCast(dataItem(
"TemplateColumn"
).FindControl(
"ImgDelete"
), ImageButton)
If
ImgDelete IsNot
Nothing
Then
ImgDelete.OnClientClick =
"javascript:if(confirmDirtyNavigation()) {if(!confirm('Voulez-vous vraiment supprimer cette fiche?')){return false;}; }else{return false;}"
End
If
Dim
ImgUndo
As
ImageButton = TryCast(dataItem(
"TemplateColumn"
).FindControl(
"ImgUndo"
), ImageButton)
If
ImgUndo IsNot
Nothing
Then
ImgUndo.OnClientClick =
"javascript:if(!confirmDirtyNavigation()) {if(!confirm('Voulez-vous vraiment annuler les modifications en cours?')){return false;}; }else{return true;}"
End
If
End
If
If
TypeOf
e.Item
Is
GridEditableItem
AndAlso
e.Item.IsInEditMode
Then
'Lorsqu'un item est en mode édition
GridFunction.FormatGridEdit(e.Item, ColumnListDisplay)
End
If
End
Sub
#End Region
#Region "Public - EventHandler"
Public
Event
ImgSave_Clicked
As
EventHandler
Protected
Overridable
Sub
OnImgSaveCliked(e
As
EventArguments)
RaiseEvent
ImgSave_Clicked(
Me
, e)
End
Sub
Public
Event
ImgDelete_Clicked
As
EventHandler
Protected
Overridable
Sub
OnImgDeleteCliked(e
As
EventArguments)
RaiseEvent
ImgDelete_Clicked(
Me
, e)
End
Sub
Public
Event
SaveFailed
As
EventHandler
Protected
Overridable
Sub
OnSaveFailed(e
As
EventArguments)
RaiseEvent
SaveFailed(
Me
, e)
End
Sub
#End Region
#Region "Gestion du Dirty"
Private
Sub
ResetDirtyFlag()
DirectCast
(
Me
.FindControlRecursively(Page,
"DirtyFlag"
), HiddenField).Value =
"False"
End
Sub
#End Region
End
Class
But the principale source of my problem is in the WUCEntretienEcritureRecurrentRecurrente.ascx.vb.
Thank you and good day.
0
Hello,
Thank you for providing your source code.
I reviewed your source code and noticed numerous places where you call
Regards,
Andrey
Telerik
Thank you for providing your source code.
I reviewed your source code and noticed numerous places where you call
RadGridEdit.DataBind()
method. In case you are binding to Object DataSource calling the DataBind() method of RadGrid could break the binding logic and thus cause the issue you are observing, please remove these calls and if needed replace them with Rebind() calls and check whether you get the expected behavior.Regards,
Andrey
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0

MathieuB
Top achievements
Rank 1
answered on 28 Jun 2013, 12:22 PM
Hi Audrey,
Yes, When I test a differents method, I have trying to remove all DataBind/Rebind, but I had none refresh of my grid. After I have trying to replace my Databind by a Rebind. But I have always the same probleme, that my grid lost the reference of CodeComplementaire, after my Search Windows closing :/
Thank you for your help
Mathieu.
Yes, When I test a differents method, I have trying to remove all DataBind/Rebind, but I had none refresh of my grid. After I have trying to replace my Databind by a Rebind. But I have always the same probleme, that my grid lost the reference of CodeComplementaire, after my Search Windows closing :/
Thank you for your help
Mathieu.
0
Hello,
You should remove all calls to DataBind() because they are not supported. Then use only Rebind() method calls and if you are still unable to achieve your goal please upload a runnable version of your project using some sharing service. Then all people who want to help you will be able to test/debug the project and thus help you achieve your goal.
Additionally, please note that my name is Andrey, not Audrey.
Regards,
Andrey
Telerik
You should remove all calls to DataBind() because they are not supported. Then use only Rebind() method calls and if you are still unable to achieve your goal please upload a runnable version of your project using some sharing service. Then all people who want to help you will be able to test/debug the project and thus help you achieve your goal.
Additionally, please note that my name is Andrey, not Audrey.
Regards,
Andrey
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0

MathieuB
Top achievements
Rank 1
answered on 03 Jul 2013, 02:40 PM
Hello,
I'm sorry for bad username reading, I have read too quickly. But for my problem I already have change DataBind by Rebind and my problem is always present. But, I have another solution who allow me to keep the LinqDataSource. I push at «e.result» of my LinqDataSource by the Selecting event the Filtring TableName and all is OK.
Private
Sub
LinqDataSource1_Selecting(sender
As
Object
, e
As
LinqDataSourceSelectEventArgs)
Handles
LinqDataSource1.Selecting
If
(EcritureRecurrenteController.Entity.ID = 0)
And
(EcritureRecurrenteFacade.EcritureCourante IsNot
Nothing
)
Then
EcritureRecurrenteController.Entity = (EcritureRecurrenteFacade.EcritureCourante)
End
If
e.Result = EcritureRecurrenteRepartitionController.GridSelectParam(EcritureRecurrenteController.Entity.ID)
End
Sub
Thank you for your help
Good day to you.
Regards, Mathieu
P.S : How can I make my topic resolve with my own answer.
0
Hi,
I am glad that you were able to resolve your issue.
About your other question, I am afraid you could not mark your own reply as an answer with the current version of our system. However, I will forward your suggestion to the team responsible for the forum system for consideration.
Regards,
Andrey
Telerik
I am glad that you were able to resolve your issue.
About your other question, I am afraid you could not mark your own reply as an answer with the current version of our system. However, I will forward your suggestion to the team responsible for the forum system for consideration.
Regards,
Andrey
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.