Hi there
I have a radgrid with gridtemplatecolumns
In 3 of the edit item template columns I have text boxes
All 3 text boxes have standard .net required field validators which are disabled by default
However, If a user enters text in any one of the 3 text boxes then I want to enable the required field validators for the remaining 2.
If the user clears all the text boxes, then the validators should be disabled again for all 3 text boxes
In other words, either all 3 text boxes must have values, or all 3 text boxes must be empty (in either insert or edit mode) in order to validate
Does anyone know how this can be accomplished client side (and server side if poss)?
Thanks in advance :-)
I have a radgrid with gridtemplatecolumns
In 3 of the edit item template columns I have text boxes
All 3 text boxes have standard .net required field validators which are disabled by default
However, If a user enters text in any one of the 3 text boxes then I want to enable the required field validators for the remaining 2.
If the user clears all the text boxes, then the validators should be disabled again for all 3 text boxes
In other words, either all 3 text boxes must have values, or all 3 text boxes must be empty (in either insert or edit mode) in order to validate
Does anyone know how this can be accomplished client side (and server side if poss)?
Thanks in advance :-)
15 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 08 Mar 2013, 04:57 AM
Hi,
One suggestion is that you can set the ValidationGroup as shown below.
aspx:
Also check this demo for more.
Grid - Flexible Server-Side Validation
Thanks,
Shinu
One suggestion is that you can set the ValidationGroup as shown below.
aspx:
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
></
asp:TextBox
>
<
asp:RequiredFieldValidator
ControlToValidate
=
"TextBox1"
ID
=
"RequiredFieldValidator1"
ValidationGroup
=
"FormValidationGroup"
runat
=
"server"
ErrorMessage
=
"*"
></
asp:RequiredFieldValidator
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
asp:RequiredFieldValidator
ControlToValidate
=
"TextBox11"
ID
=
"RequiredFieldValidator2"
ValidationGroup
=
"FormValidationGroup"
runat
=
"server"
ErrorMessage
=
"*"
></
asp:RequiredFieldValidator
>
<
asp:TextBox
ID
=
"TextBox11"
runat
=
"server"
></
asp:TextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"TextBox12"
runat
=
"server"
></
asp:TextBox
>
<
asp:Button
ID
=
"Button3"
runat
=
"server"
Text
=
"Button"
ValidationGroup
=
"FormValidationGroup"
/>
<
asp:RequiredFieldValidator
ControlToValidate
=
"TextBox12"
ID
=
"RequiredFieldValidator3"
ValidationGroup
=
"FormValidationGroup"
runat
=
"server"
ErrorMessage
=
"*"
></
asp:RequiredFieldValidator
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
Grid - Flexible Server-Side Validation
Thanks,
Shinu
0

Sauge
Top achievements
Rank 1
answered on 08 Mar 2013, 08:50 AM
Hi Shinu
Thank you for your quick response
Perhaps I should have mentioned that I have other text boxes and controls as well that also have validation separately.
Putting the dependant ones in a group is a great idea, but then I would still need to enable/disable the validation group if I wanted to validate everything at once wouldn't I? (hope you understand what I am getting at here)
So I think I might possibly be back at square one.
Do you have any other suggestions please?
Thank you in advance :-)
I found this link which looks like it might be a solution using your suggestion of a validation group, but I don't know how to implement it within the context of a RadGrid: http://www.codeproject.com/Tips/401611/Validate-multiple-Validation-group-both-client-and
Any ideas?
Thank you for your quick response
Perhaps I should have mentioned that I have other text boxes and controls as well that also have validation separately.
Putting the dependant ones in a group is a great idea, but then I would still need to enable/disable the validation group if I wanted to validate everything at once wouldn't I? (hope you understand what I am getting at here)
So I think I might possibly be back at square one.
Do you have any other suggestions please?
Thank you in advance :-)
I found this link which looks like it might be a solution using your suggestion of a validation group, but I don't know how to implement it within the context of a RadGrid: http://www.codeproject.com/Tips/401611/Validate-multiple-Validation-group-both-client-and
Any ideas?
0

Sauge
Top achievements
Rank 1
answered on 11 Mar 2013, 08:04 AM
Anyone?
0

Jayesh Goyani
Top achievements
Rank 2
answered on 11 Mar 2013, 11:23 AM
Hello,
Please try with below code snippet.
Thanks,
Jayesh Goyani
Please try with below code snippet.
function
CheckValidation(txt1ID) {
var
txt1 = document.getElementById(txt1ID);
var
txt2 = document.getElementById(txt1ID.replace(
"TextBox1"
,
"TextBox11"
));
var
txt3 = document.getElementById(txt1ID.replace(
"TextBox1"
,
"TextBox12"
));
var
v1 = document.getElementById(txt1ID.replace(
"TextBox1"
,
"RequiredFieldValidator1"
));
var
v2 = document.getElementById(txt1ID.replace(
"TextBox1"
,
"RequiredFieldValidator2"
));
var
v3 = document.getElementById(txt1ID.replace(
"TextBox1"
,
"RequiredFieldValidator3"
));
if
((txt1.value !=
null
&& txt1.value.length > 0) || (txt2.value !=
null
&& txt2.value.length > 0) || (txt3.value !=
null
&& txt3.value.length > 0)) {
ValidatorEnable(v1,
true
);
ValidatorEnable(v2,
true
);
ValidatorEnable(v3,
true
);
}
else
{
ValidatorEnable(v1,
false
);
ValidatorEnable(v2,
false
);
ValidatorEnable(v3,
false
);
}
}
<
MasterTableView
EditMode
=
"InPlace"
Name
=
"Parent"
DataKeyNames
=
"ID"
InsertItemPageIndexAction
=
"ShowItemOnCurrentPage"
ClientDataKeyNames
=
"ID"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
UniqueName
=
"ID"
HeaderText
=
"ID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Name"
UniqueName
=
"Name"
HeaderText
=
"Name"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
></
asp:TextBox
>
<
asp:RequiredFieldValidator
ControlToValidate
=
"TextBox1"
ID
=
"RequiredFieldValidator1"
runat
=
"server"
ErrorMessage
=
"*"
Enabled
=
"false"
></
asp:RequiredFieldValidator
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
asp:RequiredFieldValidator
ControlToValidate
=
"TextBox11"
ID
=
"RequiredFieldValidator2"
runat
=
"server"
ErrorMessage
=
"*"
Enabled
=
"false"
></
asp:RequiredFieldValidator
>
<
asp:TextBox
ID
=
"TextBox11"
runat
=
"server"
></
asp:TextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"TextBox12"
runat
=
"server"
></
asp:TextBox
>
<
asp:RequiredFieldValidator
ControlToValidate
=
"TextBox12"
ID
=
"RequiredFieldValidator3"
runat
=
"server"
ErrorMessage
=
"*"
Enabled
=
"false"
></
asp:RequiredFieldValidator
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridEditCommandColumn
>
</
telerik:GridEditCommandColumn
>
</
Columns
>
</
MasterTableView
>
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item.IsInEditMode)
{
if
(e.Item
is
GridDataInsertItem)
{
GridEditableItem editItem = (GridEditableItem)e.Item;
LinkButton InsertButton = (LinkButton)editItem.FindControl(
"PerformInsertButton"
);
}
else
{
GridEditableItem editItem = (GridEditableItem)e.Item;
LinkButton updateButton = (LinkButton)editItem.FindControl(
"UpdateButton"
);
TextBox TextBox1 = (TextBox)editItem.FindControl(
"TextBox1"
);
TextBox TextBox11 = (TextBox)editItem.FindControl(
"TextBox11"
);
TextBox TextBox12 = (TextBox)editItem.FindControl(
"TextBox12"
);
RequiredFieldValidator RequiredFieldValidator1 = (RequiredFieldValidator)editItem.FindControl(
"RequiredFieldValidator1"
);
RequiredFieldValidator RequiredFieldValidator2 = (RequiredFieldValidator)editItem.FindControl(
"RequiredFieldValidator2"
);
RequiredFieldValidator RequiredFieldValidator3 = (RequiredFieldValidator)editItem.FindControl(
"RequiredFieldValidator3"
);
updateButton.Attributes.Add(
"onclick"
,
"return CheckValidation('"
+ TextBox1.ClientID +
"');"
);
}
}
}
Thanks,
Jayesh Goyani
0

Sauge
Top achievements
Rank 1
answered on 12 Mar 2013, 11:09 AM
Hi Jayesh
Thank you for your suggestion but I can't get it to work. It is accepting all values. Could the fact that I am using a master page make any difference, or have I done something else wrong?
Here is my code:
And in code behind:
I am a bit of a newbie girl so please forgive any mistakes
Thank you Jayesh :-)
Thank you for your suggestion but I can't get it to work. It is accepting all values. Could the fact that I am using a master page make any difference, or have I done something else wrong?
Here is my code:
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"cphContent"
runat
=
"Server"
>
<
script
type
=
"text/javascript"
>
function CheckValidation(txt1ID) {
var txt1 = document.getElementById(txt1ID);
var txt2 = document.getElementById(txt1ID.replace("WicketsTextBox ", "BallsBowledTextBox "));
var txt3 = document.getElementById(txt1ID.replace("WicketsTextBox ", "RunsConcededTextBox "));
var v1 = document.getElementById(txt1ID.replace("WicketsTextBox ", "RequiredFieldValidator1"));
var v2 = document.getElementById(txt1ID.replace("WicketsTextBox ", "RequiredFieldValidator2"));
var v3 = document.getElementById(txt1ID.replace("WicketsTextBox ", "RequiredFieldValidator3"));
if ((txt1.value != null && txt1.value.length > 0) || (txt2.value != null && txt2.value.length > 0) || (txt3.value != null && txt3.value.length > 0)) {
ValidatorEnable(v1, true);
ValidatorEnable(v2, true);
ValidatorEnable(v3, true);
}
else {
ValidatorEnable(v1, false);
ValidatorEnable(v2, false);
ValidatorEnable(v3, false);
}
}
</
script
>
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function RowDblClick(sender, eventArgs) {
sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
}
</
script
>
</
telerik:RadCodeBlock
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid2"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid2"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
>
</
telerik:RadAjaxLoadingPanel
>
<
telerik:RadWindowManager
ID
=
"RadWindowManager1"
runat
=
"server"
>
</
telerik:RadWindowManager
>
<
h2
>Your Results</
h2
>
<
p
>Here you can add or edit your results</
p
>
<
p
>
<
asp:Image
ID
=
"Image1"
runat
=
"server"
ToolTip
=
"Tip"
ImageUrl
=
"~/images/tip.png"
Width
=
"24px"
Height
=
"24px"
/>
Double click on a row to edit
</
p
>
<
telerik:RadGrid
runat
=
"server"
ID
=
"RadGrid2"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
Width
=
"100%"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
DataSourceID
=
"AccessDataSource1"
Skin
=
"Windows7"
CellSpacing
=
"0"
GridLines
=
"None"
PageSize
=
"5"
PagerStyle-PageButtonCount
=
"5"
PagerStyle-Position
=
"Bottom"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
/>
<
MasterTableView
Width
=
"100%"
EditMode
=
"EditForms"
CommandItemDisplay
=
"TopAndBottom"
DataKeyNames
=
"PlayerStatsID"
>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
UniqueName
=
"EditCommandColumn"
HeaderTooltip
=
"Edit Results"
>
<
ItemStyle
CssClass
=
"MyImageButton"
></
ItemStyle
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridTemplateColumn
DataField
=
"FixtureID"
DataType
=
"System.Int32"
FilterControlAltText
=
"Filter Match column"
HeaderText
=
"Match"
UniqueName
=
"Match"
>
<
EditItemTemplate
>
<
asp:Label
ID
=
"MatchLabel1"
runat
=
"server"
Text='<%# Eval("Match") %>'></
asp:Label
>
</
EditItemTemplate
>
<
InsertItemTemplate
>
<
telerik:RadComboBox
ID
=
"rcbMatch"
runat
=
"server"
DataTextField
=
"Match"
DataValueField
=
"FixtureID"
Width
=
"450"
DropDownWidth
=
"450"
SelectedValue='<%# Bind("FixtureID")%>' DataSourceID="AccessDataSource2"></
telerik:RadComboBox
>
</
InsertItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"MatchLabel2"
runat
=
"server"
Text='<%# Eval("Match") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
DataField
=
"Runs"
FilterControlAltText
=
"Filter Runs column"
HeaderText
=
"Runs"
UniqueName
=
"Runs"
DataType
=
"System.Int16"
SortExpression
=
"Runs"
>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"RunsTextBox"
runat
=
"server"
Text='<%# Bind("Runs") %>' ></
asp:TextBox
>
<
asp:RegularExpressionValidator
ID
=
"RegularExpressionValidator1"
runat
=
"server"
ErrorMessage
=
"Must be a number"
ToolTip
=
"Numbers Only"
ValidationExpression
=
"\d+"
ControlToValidate
=
"RunsTextBox"
CssClass
=
"validator"
></
asp:RegularExpressionValidator
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"RunsLabel"
runat
=
"server"
Text='<%# Eval("Runs") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"NotOut"
DataType
=
"System.Boolean"
FilterControlAltText
=
"Filter NotOut column"
HeaderText
=
"Not Out"
SortExpression
=
"NotOut"
UniqueName
=
"NotOut"
>
</
telerik:GridCheckBoxColumn
>
<
telerik:GridTemplateColumn
DataField
=
"Fours"
DataType
=
"System.Int32"
FilterControlAltText
=
"Filter Fours column"
HeaderText
=
"Fours"
SortExpression
=
"Fours"
UniqueName
=
"Fours"
>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"FoursTextBox"
runat
=
"server"
Text='<%# Bind("Fours") %>'></
asp:TextBox
>
<
asp:RegularExpressionValidator
ID
=
"RegularExpressionValidator2"
runat
=
"server"
ErrorMessage
=
"Must be a number"
ToolTip
=
"Numbers Only"
ValidationExpression
=
"\d+"
ControlToValidate
=
"FoursTextBox"
CssClass
=
"validator"
></
asp:RegularExpressionValidator
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"FoursLabel"
runat
=
"server"
Text='<%# Eval("Fours") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
DataField
=
"Sixes"
DataType
=
"System.Int32"
FilterControlAltText
=
"Filter Sixes column"
HeaderText
=
"Sixes"
SortExpression
=
"Sixes"
UniqueName
=
"Sixes"
>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"SixesTextBox"
runat
=
"server"
Text='<%# Bind("Sixes") %>'></
asp:TextBox
>
<
asp:RegularExpressionValidator
ID
=
"RegularExpressionValidator3"
runat
=
"server"
ErrorMessage
=
"Must be a number"
ToolTip
=
"Numbers Only"
ValidationExpression
=
"\d+"
ControlToValidate
=
"SixesTextBox"
CssClass
=
"validator"
></
asp:RegularExpressionValidator
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"SixesLabel"
runat
=
"server"
Text='<%# Eval("Sixes") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
DataField
=
"Wickets"
DataType
=
"System.Int32"
FilterControlAltText
=
"Filter Wickets column"
HeaderText
=
"Wickets"
SortExpression
=
"Wickets"
UniqueName
=
"Wickets"
>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"WicketsTextBox"
runat
=
"server"
Text='<%# Bind("Wickets") %>'></
asp:TextBox
>
<
asp:RequiredFieldValidator
ControlToValidate
=
"WicketsTextBox"
ID
=
"RequiredFieldValidator1"
runat
=
"server"
ErrorMessage
=
"*"
Enabled
=
"false"
></
asp:RequiredFieldValidator
>
<
asp:RegularExpressionValidator
ID
=
"RegularExpressionValidator4"
runat
=
"server"
ErrorMessage
=
"Must be a number"
ToolTip
=
"Numbers Only"
ValidationExpression
=
"\d+"
ControlToValidate
=
"WicketsTextBox"
CssClass
=
"validator"
></
asp:RegularExpressionValidator
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"WicketsLabel"
runat
=
"server"
Text='<%# Eval("Wickets") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
DataField
=
"BallsBowled"
DataType
=
"System.Int32"
FilterControlAltText
=
"Filter BallsBowled column"
HeaderText
=
"Balls Bowled"
SortExpression
=
"BallsBowled"
UniqueName
=
"BallsBowled"
>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"BallsBowledTextBox"
runat
=
"server"
Text='<%# Bind("BallsBowled") %>'></
asp:TextBox
>
<
asp:RequiredFieldValidator
ControlToValidate
=
"BallsBowledTextBox"
ID
=
"RequiredFieldValidator2"
runat
=
"server"
ErrorMessage
=
"*"
Enabled
=
"false"
></
asp:RequiredFieldValidator
>
<
asp:RegularExpressionValidator
ID
=
"RegularExpressionValidator5"
runat
=
"server"
ErrorMessage
=
"Must be a number"
ToolTip
=
"Numbers Only"
ValidationExpression
=
"\d+"
ControlToValidate
=
"BallsBowledTextBox"
CssClass
=
"validator"
></
asp:RegularExpressionValidator
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"BallsBowledLabel"
runat
=
"server"
Text='<%# Eval("BallsBowled") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
DataField
=
"RunsConceded"
DataType
=
"System.Double"
FilterControlAltText
=
"Filter RunsConceded column"
HeaderText
=
"Runs Conceded"
SortExpression
=
"RunsConceded"
UniqueName
=
"RunsConceded"
>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"RunsConcededTextBox"
runat
=
"server"
Text='<%# Bind("RunsConceded") %>'></
asp:TextBox
>
<
asp:RequiredFieldValidator
ControlToValidate
=
"RunsConcededTextBox"
ID
=
"RequiredFieldValidator3"
runat
=
"server"
ErrorMessage
=
"*"
Enabled
=
"false"
></
asp:RequiredFieldValidator
>
<
asp:RegularExpressionValidator
ID
=
"RegularExpressionValidator6"
runat
=
"server"
ErrorMessage
=
"Must be a number"
ToolTip
=
"Numbers Only"
ValidationExpression
=
"\d+"
ControlToValidate
=
"RunsConcededTextBox"
CssClass
=
"validator"
></
asp:RegularExpressionValidator
>
</
EditItemTemplate
>
<
ItemTemplate
>
<
asp:Label
ID
=
"RunsConcededLabel"
runat
=
"server"
Text='<%# Eval("RunsConceded") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridButtonColumn
ConfirmText
=
"Delete these results?"
ConfirmDialogType
=
"RadWindow"
ConfirmTitle
=
"Delete"
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
Text
=
"Delete"
UniqueName
=
"DeleteColumn"
HeaderTooltip
=
"Delete Results"
>
<
ItemStyle
HorizontalAlign
=
"Center"
CssClass
=
"MyImageButton"
></
ItemStyle
>
</
telerik:GridButtonColumn
>
</
Columns
>
<
EditFormSettings
ColumnNumber
=
"2"
CaptionDataField
=
"Match"
CaptionFormatString
=
"Edit properties of results: {0}"
InsertCaption
=
"New Results"
>
<
FormTableItemStyle
Wrap
=
"False"
></
FormTableItemStyle
>
<
FormCaptionStyle
CssClass
=
"EditFormHeader"
></
FormCaptionStyle
>
<
FormMainTableStyle
GridLines
=
"None"
CellSpacing
=
"0"
CellPadding
=
"3"
Width
=
"100%"
></
FormMainTableStyle
>
<
FormTableStyle
CellSpacing
=
"0"
CellPadding
=
"2"
Height
=
"110px"
></
FormTableStyle
>
<
FormTableAlternatingItemStyle
Wrap
=
"False"
></
FormTableAlternatingItemStyle
>
<
EditColumn
ButtonType
=
"ImageButton"
InsertText
=
"Insert Results"
UpdateText
=
"Update Results"
UniqueName
=
"EditCommandColumn1"
CancelText
=
"Cancel edit"
>
</
EditColumn
>
<
FormTableButtonRowStyle
HorizontalAlign
=
"Left"
CssClass
=
"EditFormButtonRow"
></
FormTableButtonRowStyle
>
</
EditFormSettings
>
<
NoRecordsTemplate
>
You don't have any news results yet. Click "Add New Results" to create
</
NoRecordsTemplate
>
<
CommandItemSettings
ExportToPdfText
=
"Export to PDF"
AddNewRecordText
=
"Add New Results"
></
CommandItemSettings
>
<
RowIndicatorColumn
Visible
=
"False"
>
<
HeaderStyle
Width
=
"20px"
/>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
Visible
=
"False"
>
<
HeaderStyle
Width
=
"19px"
/>
</
ExpandCollapseColumn
>
</
MasterTableView
>
<
ClientSettings
>
<
ClientEvents
OnRowDblClick
=
"RowDblClick"
></
ClientEvents
>
</
ClientSettings
>
<
FilterMenu
EnableImageSprites
=
"False"
></
FilterMenu
>
</
telerik:RadGrid
>
<
asp:AccessDataSource
ID
=
"AccessDataSource1"
runat
=
"server"
DataFile
=
"~/App_Data/ASPNetDB.mdb"
DeleteCommand
=
"DELETE FROM [tblPlayerStats] WHERE [PlayerStatsID] = ?"
InsertCommand
=
"INSERT INTO [tblPlayerStats] ([UserID], [FixtureID], [Runs], [NotOut], [RunsConceded], [Wickets], [BallsBowled], [Fours], [Sixes]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"
SelectCommand
=
"SELECT [UserID], [PlayerStatsID], [FixtureID], [Runs], [NotOut], [RunsConceded], [Wickets], [BallsBowled], [Match], [Fours], [Sixes] FROM [qryPlayerStats] WHERE ([UserID] = ?)"
UpdateCommand
=
"UPDATE [tblPlayerStats] SET [Runs] = ?, [NotOut] = ?, [RunsConceded] = ?, [Wickets] = ?, [BallsBowled] = ?, [Fours] = ?, [Sixes] = ? WHERE [PlayerStatsID] = ?"
>
<
DeleteParameters
>
<
asp:Parameter
Name
=
"PlayerStatsID"
Type
=
"Int32"
/>
</
DeleteParameters
>
<
InsertParameters
>
<
skm:MembershipUserIdParameter
Name
=
"UserId"
/>
<
asp:Parameter
Name
=
"FixtureID"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"Runs"
Type
=
"Int16"
/>
<
asp:Parameter
Name
=
"NotOut"
Type
=
"Boolean"
/>
<
asp:Parameter
Name
=
"RunsConceded"
Type
=
"Double"
/>
<
asp:Parameter
Name
=
"Wickets"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"BallsBowled"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"Fours"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"Sixes"
Type
=
"Int32"
/>
</
InsertParameters
>
<
SelectParameters
>
<
skm:MembershipUserIdParameter
Name
=
"UserId"
/>
</
SelectParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"Runs"
Type
=
"Int16"
/>
<
asp:Parameter
Name
=
"NotOut"
Type
=
"Boolean"
/>
<
asp:Parameter
Name
=
"RunsConceded"
Type
=
"Double"
/>
<
asp:Parameter
Name
=
"Wickets"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"BallsBowled"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"Fours"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"Sixes"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"PlayerStatsID"
Type
=
"Int32"
/>
</
UpdateParameters
>
</
asp:AccessDataSource
>
<
asp:AccessDataSource
ID
=
"AccessDataSource2"
runat
=
"server"
DataFile
=
"~/App_Data/ASPNetDB.mdb"
SelectCommand="SELECT [Match], FixtureID FROM qryMatchDropDown WHERE (UserID <> ?) OR (UserID IS NULL)">
<
SelectParameters
>
<
skm:MembershipUserIdParameter
Name
=
"UserId"
/>
</
SelectParameters
>
</
asp:AccessDataSource
>
</
asp:Content
>
And in code behind:
Protected
Sub
RadGrid1_ItemDataBound(sender
As
Object
, e
As
GridItemEventArgs)
If
e.Item.IsInEditMode
Then
If
TypeOf
e.Item
Is
GridDataInsertItem
Then
Dim
editItem
As
GridEditableItem =
DirectCast
(e.Item, GridEditableItem)
Dim
InsertButton
As
LinkButton =
DirectCast
(editItem.FindControl(
"PerformInsertButton"
), LinkButton)
Else
Dim
editItem
As
GridEditableItem =
DirectCast
(e.Item, GridEditableItem)
Dim
updateButton
As
LinkButton =
DirectCast
(editItem.FindControl(
"UpdateButton"
), LinkButton)
Dim
WicketsTextBox
As
TextBox =
DirectCast
(editItem.FindControl(
"WicketsTextBox "
), TextBox)
Dim
BallsBowledTextBox
As
TextBox =
DirectCast
(editItem.FindControl(
"BallsBowledTextBox "
), TextBox)
Dim
RunsConcededTextBox
As
TextBox =
DirectCast
(editItem.FindControl(
"RunsConcededTextBox "
), TextBox)
Dim
RequiredFieldValidator1
As
RequiredFieldValidator =
DirectCast
(editItem.FindControl(
"RequiredFieldValidator1"
), RequiredFieldValidator)
Dim
RequiredFieldValidator2
As
RequiredFieldValidator =
DirectCast
(editItem.FindControl(
"RequiredFieldValidator2"
), RequiredFieldValidator)
Dim
RequiredFieldValidator3
As
RequiredFieldValidator =
DirectCast
(editItem.FindControl(
"RequiredFieldValidator3"
), RequiredFieldValidator)
updateButton.Attributes.Add(
"onclick"
,
"return CheckValidation('"
+ WicketsTextBox.ClientID +
"');"
)
End
If
End
If
End
Sub
I am a bit of a newbie girl so please forgive any mistakes
Thank you Jayesh :-)
0

Jayesh Goyani
Top achievements
Rank 2
answered on 12 Mar 2013, 11:28 AM
Hello,
In my previous demo code i have only do this thing for requiredfieldvalidator thats why you are able to all values.
i will provide demo with regulerexpressionvalidator after some time.
Thanks,
Jayesh Goyani
In my previous demo code i have only do this thing for requiredfieldvalidator thats why you are able to all values.
i will provide demo with regulerexpressionvalidator after some time.
Thanks,
Jayesh Goyani
0

Sauge
Top achievements
Rank 1
answered on 12 Mar 2013, 12:31 PM
Thank you very much Jayesh
You are a star :-)
You are a star :-)
0

Jayesh Goyani
Top achievements
Rank 2
answered on 12 Mar 2013, 01:21 PM
Hello,
Please create sample page/project and check below code snippet/Demo.
No need to enable/disable or RegulerExpressionValidator.
Thanks,
Jayesh Goyani
Please create sample page/project and check below code snippet/Demo.
No need to enable/disable or RegulerExpressionValidator.
<script type=
"text/javascript"
>
function
CheckValidation(txt1ID) {
var
txt1 = document.getElementById(txt1ID);
var
txt2 = document.getElementById(txt1ID.replace(
"TextBox1"
,
"TextBox11"
));
var
txt3 = document.getElementById(txt1ID.replace(
"TextBox1"
,
"TextBox12"
));
var
v1 = document.getElementById(txt1ID.replace(
"TextBox1"
,
"RequiredFieldValidator1"
));
var
v2 = document.getElementById(txt1ID.replace(
"TextBox1"
,
"RequiredFieldValidator2"
));
var
v3 = document.getElementById(txt1ID.replace(
"TextBox1"
,
"RequiredFieldValidator3"
));
if
((txt1.value !=
null
&& txt1.value.length > 0) || (txt2.value !=
null
&& txt2.value.length > 0) || (txt3.value !=
null
&& txt3.value.length > 0)) {
ValidatorEnable(v1,
true
);
ValidatorEnable(v2,
true
);
ValidatorEnable(v3,
true
);
}
else
{
ValidatorEnable(v1,
false
);
ValidatorEnable(v2,
false
);
ValidatorEnable(v3,
false
);
}
}
</script>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
telerik:RadWindowManager
ID
=
"RadWindowManager1"
runat
=
"server"
>
</
telerik:RadWindowManager
>
<
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
>
<
div
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"False"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
OnItemDataBound
=
"RadGrid1_ItemDataBound"
>
<
MasterTableView
EditMode
=
"InPlace"
InsertItemPageIndexAction
=
"ShowItemOnCurrentPage"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
UniqueName
=
"ID"
HeaderText
=
"ID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Name"
UniqueName
=
"Name"
HeaderText
=
"Name"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
></
asp:TextBox
>
<
asp:RequiredFieldValidator
ControlToValidate
=
"TextBox1"
ID
=
"RequiredFieldValidator1"
runat
=
"server"
ErrorMessage
=
"*"
Enabled
=
"false"
></
asp:RequiredFieldValidator
>
<
asp:RegularExpressionValidator
ID
=
"RegularExpressionValidator1"
runat
=
"server"
ErrorMessage
=
"Must be a number"
ToolTip
=
"Numbers Only"
ValidationExpression
=
"\d+"
ControlToValidate
=
"TextBox1"
></
asp:RegularExpressionValidator
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
asp:RequiredFieldValidator
ControlToValidate
=
"TextBox11"
ID
=
"RequiredFieldValidator2"
runat
=
"server"
ErrorMessage
=
"*"
Enabled
=
"false"
></
asp:RequiredFieldValidator
>
<
asp:TextBox
ID
=
"TextBox11"
runat
=
"server"
></
asp:TextBox
>
<
asp:RegularExpressionValidator
ID
=
"RegularExpressionValidator2"
runat
=
"server"
ErrorMessage
=
"Must be a number"
ToolTip
=
"Numbers Only"
ValidationExpression
=
"\d+"
ControlToValidate
=
"TextBox11"
></
asp:RegularExpressionValidator
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"TextBox12"
runat
=
"server"
></
asp:TextBox
>
<
asp:RequiredFieldValidator
ControlToValidate
=
"TextBox12"
ID
=
"RequiredFieldValidator3"
runat
=
"server"
ErrorMessage
=
"*"
Enabled
=
"false"
></
asp:RequiredFieldValidator
>
<
asp:RegularExpressionValidator
ID
=
"RegularExpressionValidator3"
runat
=
"server"
ErrorMessage
=
"Must be a number"
ToolTip
=
"Numbers Only"
ValidationExpression
=
"\d+"
ControlToValidate
=
"TextBox12"
>
</
asp:RegularExpressionValidator
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridEditCommandColumn
>
</
telerik:GridEditCommandColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
div
>
</
form
>
</
body
>
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
dynamic data =
new
[] {
new
{ ID = 1, Name =
"Name1"
},
new
{ ID = 2, Name =
"Name2"
},
new
{ ID = 3, Name =
"Name3"
},
new
{ ID = 4, Name =
"Name4"
},
new
{ ID = 5, Name =
"Name5"
}
};
RadGrid1.DataSource = data;
}
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item.IsInEditMode)
{
if
(e.Item
is
GridDataInsertItem)
{
GridEditableItem editItem = (GridEditableItem)e.Item;
LinkButton InsertButton = (LinkButton)editItem.FindControl(
"PerformInsertButton"
);
}
else
{
GridEditableItem editItem = (GridEditableItem)e.Item;
LinkButton updateButton = (LinkButton)editItem.FindControl(
"UpdateButton"
);
TextBox TextBox1 = (TextBox)editItem.FindControl(
"TextBox1"
);
updateButton.Attributes.Add(
"onclick"
,
"return CheckValidation('"
+ TextBox1.ClientID +
"');"
);
}
}
}
Thanks,
Jayesh Goyani
0

Sauge
Top achievements
Rank 1
answered on 18 Mar 2013, 08:00 AM
Hi Jayesh
Finally got around to giving this a go over the weekend.
Unfortunately, it isn't working. The required validation isn't being enabled at all,
I have also been trying to find other solutions to this problem, but to no avail.
Perhaps there is another route to try. To recap:
If either textbox1 or textbox2 or textbox3 have a value, then all of them must have values or none of them must have values.
So, all or none are required.
Any other ideas, perhaps using groups or something?
(This is totally doing my head in)
Thanks in advance
Finally got around to giving this a go over the weekend.
Unfortunately, it isn't working. The required validation isn't being enabled at all,
I have also been trying to find other solutions to this problem, but to no avail.
Perhaps there is another route to try. To recap:
If either textbox1 or textbox2 or textbox3 have a value, then all of them must have values or none of them must have values.
So, all or none are required.
Any other ideas, perhaps using groups or something?
(This is totally doing my head in)
Thanks in advance
0

Jayesh Goyani
Top achievements
Rank 2
answered on 19 Mar 2013, 04:36 AM
Hello,
have you checked above functionality with new page/project ?
Because i am not able to reproduce this issue.
Thanks,
Jayesh Goyani
have you checked above functionality with new page/project ?
Because i am not able to reproduce this issue.
Thanks,
Jayesh Goyani
0

Sauge
Top achievements
Rank 1
answered on 30 Mar 2013, 01:10 PM
Hi Jayesh
Yes I checked your code and it didn't work.
Having said that, according to almost every forum post and articles that I have looked at, in theory it should work so I am totally stumped as to why it doesn't
I have left it for a bit. Perhaps if I come back to it with fresh eyes I will be able to work it out.
Thank you for all your help, I really appreciate it
Yes I checked your code and it didn't work.
Having said that, according to almost every forum post and articles that I have looked at, in theory it should work so I am totally stumped as to why it doesn't
I have left it for a bit. Perhaps if I come back to it with fresh eyes I will be able to work it out.
Thank you for all your help, I really appreciate it
0
Accepted

Jayesh Goyani
Top achievements
Rank 2
answered on 31 Mar 2013, 06:23 PM
Hello,
Please check below demo.
https://skydrive.live.com/redir?resid=977B16A5E89A5236!110
Thanks,
Jayesh Goyani
Please check below demo.
https://skydrive.live.com/redir?resid=977B16A5E89A5236!110
Thanks,
Jayesh Goyani
0

Sauge
Top achievements
Rank 1
answered on 12 Apr 2013, 04:14 PM
Hi Jayesh
The link to your code example REALLY helped.
After a bit of twiddling and fiddling I got it all to work. I changed your code a little bit to this:
I also had to change my EditColumn ButtonType to a link button as the image button messed around with the validation (see this forum thread for more info). This was why the code wasn't working, even if I changed the code from linkbutton to imagebutton. So I changed my original code (below).....
.....to this (thanks to Amudha Balan)
Which achieves the same effect as an image button but without the validation problems.
Now everything works perfectly
Thank you SO much Jayesh. I really appreciate you persevering with this when even I had given up :-))
The link to your code example REALLY helped.
After a bit of twiddling and fiddling I got it all to work. I changed your code a little bit to this:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
Dim insertupdate As LinkButton
If TypeOf e.Item Is IGridInsertItem Then
insertupdate = CType(e.Item.FindControl("PerformInsertButton"), LinkButton)
Dim TextBox1 As TextBox = e.Item.FindControl("TextBox1")
insertupdate.Attributes.Add("onclick", "return CheckValidation('" + TextBox1.ClientID + "');")
Else
insertupdate = CType(e.Item.FindControl("UpdateButton"), LinkButton)
Dim TextBox1As TextBox = e.Item.FindControl("TextBox1")
insertupdate.Attributes.Add("onclick", "return CheckValidation('" + TextBox1.ClientID + "');")
End If
End If
End Sub
I also had to change my EditColumn ButtonType to a link button as the image button messed around with the validation (see this forum thread for more info). This was why the code wasn't working, even if I changed the code from linkbutton to imagebutton. So I changed my original code (below).....
<
EditColumn
ButtonType
=
"ImageButton"
InsertText
=
"Insert Results"
UpdateText
=
"Update Results"
UniqueName
=
"EditCommandColumn1"
CancelText
=
"Cancel edit"
>
</
EditColumn
>
.....to this (thanks to Amudha Balan)
<
EditColumn
ButtonType
=
"LinkButton"
InsertText="<img
src
=
'../../images/gridok.gif'
border
=
0
title
=
'some tool tip'
>" UpdateText="<
img
src
=
'../../images/gridok.gif'
border
=
0
title
=
'some tool tip'
>"
UniqueName="EditCommandColumn1" CancelText="<
img
src
=
'../../images/gridcancel.gif'
border
=
0
title
=
'some tool tip'
>" >
</
EditColumn
>
Which achieves the same effect as an image button but without the validation problems.
Now everything works perfectly
Thank you SO much Jayesh. I really appreciate you persevering with this when even I had given up :-))
0

Navisa
Top achievements
Rank 1
answered on 15 Oct 2013, 11:36 AM
Hi Jayesh,
Thank you for reply to this problem.
I had this problem in my project. So I used your code in it but it does not work correctly.
I have a template field in radgrid (GoodsFactors_FactorNoTextBox) that is not forced to be filled. But in the case that it has a value, then some other fields such as FactorAmountTextBox should be filled(need required field validator to set enabled).
I used your codes in my form but in edit and insert mode of grid, the validator doesn't fire.
I put my codes here. Would you plz check it and tell me what's wrong?
Thanks a lot.
Purchase.aspx
<%@ Page Title="خرید" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
ViewStateMode="Enabled" Inherits="Forms_PurchaseRequest" CodeBehind="PurchaseRequest.aspx.cs" %>
<%--<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">--%>
<asp:Content ID="Content2" ContentPlaceHolderID="cphMain" runat="Server">
<style type="text/css">
.style24
{
width: 1407px;
}
.style31
{
height: 13px;
}
.headerStyle1
{
background-image: none;
background-color: Green;
}
div.RadGrid .specificHeader
{
background-image: none;
background: #80BFBF;
}
div.RadGrid .specificHeader2
{
background-image: none;
background: #DFBFFF;
}
div.RadGrid .specificHeader3
{
background-image: none;
background: #E7D9FF;
}
div.RadGrid .specificHeader4
{
background-image: none;
background: #D2F4FF;
}
div.RadGrid .specificHeader5
{
background-image: none;
background: #FFF2E6;
}
.style49
{
width: 108px;
height: 25px;
}
.style56
{
width: 108px;
height: 24px;
}
.style59
{
height: 25px;
}
.style60
{
width: 134px;
}
.style61
{
width: 134px;
height: 25px;
}
.style62
{
width: 203px;
}
.style63
{
height: 25px;
width: 203px;
}
.style64
{
width: 134px;
height: 24px;
}
.style65
{
width: 203px;
height: 24px;
}
.style66
{
height: 24px;
}
</style>
<jq:JQLoader ID="JQLoader1" runat="server" />
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
//var myPicker = myArray[0];
function RowDblClick(sender, eventArgs) {
sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
}
function gridRowLeave(sender, eventArgs) {
}
function gridCreated(sender, args) {
// if (sender.get_editIndexes && sender.get_editIndexes().length > 0) {
// document.getElementById("OutPut").innerHTML = sender.get_editIndexes().join();
// }
// else {
// document.getElementById("OutPut").innerHTML = "";
// }
}
// function CheckValidation(txt1ID) {
// var txt1 = document.getElementById(txt1ID);
// var txt2 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "FactorAmountTextBox"));
// //var txt3 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "GoodsFactors_PriceTextBox"));
// //var v1 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "rfv0"));
// var v2 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "rfv5"));
// //var v3 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "rfv7"));
// if ((txt1.value != null && txt1.value != '0') && txt1.value.length > 0) {
// if (txt2.value == null) {
// //ValidatorEnable(v1, true);
// ValidatorEnable(v2, true);
// //ValidatorEnable(v3, true);
// }
// }
// else {
// //ValidatorEnable(v1, false);
// ValidatorEnable(v2, false);
// //ValidatorEnable(v3, false);
// }
// }
function ValueChanged(index) {
var grid = $find("<%=RadGrid1.ClientID %>"); //grid id
if (grid) {
var MasterTable = grid.get_masterTableView();
var Row = MasterTable.get_dataItems()[index];
var txtFacNo = Row.findElement("GoodsFactors_FactorNoTextBox"); //gridcolumns
var rfvAmount = Row.findElement("rfv5"); //required validator
if (txtFacNo.value != null && txtFacNo.value != '0') {
//ValidatorEnable(rfvAmount,true);
rfvAmount.disabled = false;
}
else {
rfvAmount.disabled = true;
}
}
}
</script>
<script type="text/javascript">
function CheckValidation(txt1ID) {
var txt1 = document.getElementById(txt1ID);
var txt2 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "FactorAmountTextBox"));
//var txt3 = document.getElementById(txt1ID.replace("TextBox1", "TextBox12"));
var v1 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "RequiredFieldValidator1"));
var v2 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "RequiredFieldValidator2"));
//var v3 = document.getElementById(txt1ID.replace("TextBox1", "RequiredFieldValidator3"));
if ((txt1.value != null && txt1.value.length > 0)){ //&& (txt2.value==null || txt2.value=='0')){ //|| (txt2.value != null && txt2.value.length > 0)) {
ValidatorEnable(v1, true);
ValidatorEnable(v2, true);
// ValidatorEnable(v3, true);
}
else {
ValidatorEnable(v1, false);
ValidatorEnable(v2, false);
// ValidatorEnable(v3, false);
}
}
</script>
</telerik:RadCodeBlock>
<telerik:RadAjaxManager ID="AjaxManager1" runat="server" EnableAJAX="true">
<AjaxSettings>
<%-- <telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="RadWindowsManager1" />
</UpdatedControls>
</telerik:AjaxSetting>--%>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
</telerik:RadAjaxLoadingPanel>
<%-- <telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="RadWindowsManager1" />
</UpdatedControls>
</telerik:AjaxSetting>--%>
<table>
<tr>
<td align="center" class="style24">
<%-- <telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="RadWindowsManager1" />
</UpdatedControls>
</telerik:AjaxSetting>--%>
<div style="margin: 0 auto; direction: rtl;">
<table style="direction: rtl; vertical-align: baseline; border-right-style: hidden; background-color: #FFF2E6;"
frame="vsides" align="right" width="100%">
<tr>
<td dir="rtl" align="right" class="style31"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6; background-color: #FFD8B0"
colspan="4">
<asp:Label ID="Label13" runat="server" Font-Bold="True" ForeColor="#CC3300" Text="مشخصات درخواست"></asp:Label>
<asp:Label ID="lblFactorNo" runat="server" Text="شماره فاکتور" Font-Bold="True" Visible="False"></asp:Label>
<telerik:RadTextBox ID="RadtxtEorgNo0" runat="server" Visible="False">
<PasswordStrengthSettings CalculationWeightings="50;15;15;20" IndicatorElementBaseStyle="riStrengthBar"
IndicatorElementID="" MinimumLowerCaseCharacters="2" MinimumNumericCharacters="2"
MinimumSymbolCharacters="2" MinimumUpperCaseCharacters="2" OnClientPasswordStrengthCalculating=""
PreferredPasswordLength="10" RequiresUpperAndLowerCaseCharacters="True" ShowIndicator="False"
TextStrengthDescriptions="Very Weak;Weak;Medium;Strong;Very Strong" TextStrengthDescriptionStyles="riStrengthBarL0;riStrengthBarL1;riStrengthBarL2;riStrengthBarL3;riStrengthBarL4;riStrengthBarL5;" />
</telerik:RadTextBox>
</td>
</tr>
<tr>
<td dir="rtl" align="left" class="style64"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;">
<asp:Label ID="Label1" runat="server" Text="شماره EORG" Font-Bold="True"
Font-Size="Smaller"></asp:Label>
</td>
<td dir="rtl" align="right"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;"
class="style65">
<telerik:RadTextBox ID="RadtxtEorgNo" runat="server" Width="100px"
ValidationGroup="lookup" ontextchanged="RadtxtEorgNo_TextChanged">
<PasswordStrengthSettings CalculationWeightings="50;15;15;20" IndicatorElementBaseStyle="riStrengthBar"
IndicatorElementID="" MinimumLowerCaseCharacters="2" MinimumNumericCharacters="2"
MinimumSymbolCharacters="2" MinimumUpperCaseCharacters="2" OnClientPasswordStrengthCalculating=""
PreferredPasswordLength="10" RequiresUpperAndLowerCaseCharacters="True" ShowIndicator="False"
TextStrengthDescriptions="Very Weak;Weak;Medium;Strong;Very Strong" TextStrengthDescriptionStyles="riStrengthBarL0;riStrengthBarL1;riStrengthBarL2;riStrengthBarL3;riStrengthBarL4;riStrengthBarL5;" />
</telerik:RadTextBox>
<asp:Label ID="lblAlert1" runat="server" Font-Bold="True" ForeColor="#FF0066"
Text="*" Visible="False" Font-Size="Large"></asp:Label>
<br />
</td>
<td dir="rtl" align="left" class="style56"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;">
<asp:Label ID="Label4" runat="server" Text="تاريخ درخواست" Font-Size="Smaller"></asp:Label>
</td>
<td dir="rtl" align="right"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;"
valign="top" class="style66">
<jq:JQDatePicker ID="JQDPKfromDate" runat="server" Regional="fa" DateFormat="YMD"
AnimationType="Default" WeekHeader="sauterday"
OnTextChanged="JQDPKfactorDate_TextChanged" Font-Overline="False"></jq:JQDatePicker>
<asp:Label ID="lblAlert2" runat="server" Font-Bold="True" ForeColor="#FF0066"
Text="*" Visible="False" Font-Size="Large"></asp:Label>
</td>
</tr>
<tr>
<td dir="rtl" align="left" class="style60"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;">
<asp:Label ID="Label2" runat="server" Text="معاونت درخواست كننده"
Font-Size="Smaller"></asp:Label>
</td>
<td dir="rtl" align="right"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;"
class="style62">
<telerik:RadComboBox ID="RadcmbDep" runat="server" Width="166px" AutoPostBack="True"
DataSourceID="SqlDataSource14" OnSelectedIndexChanged="RadCmbDeptName_OnSelectedIndexChanged"
DataTextField="DepartmentName" DataValueField="DepartmentFK"
>
</telerik:RadComboBox>
</td>
<td dir="rtl" align="left" class="style49"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;">
<asp:Label ID="Label5" runat="server" Text="واحد استفاده كننده" Font-Size="Smaller"
></asp:Label>
</td>
<td dir="rtl" align="right"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;">
<telerik:RadComboBox ID="RadcmbSubDep" runat="server" AutoPostBack="true" OnSelectedIndexChanged="RadCmbSubDeptName_OnSelectedIndexChanged"
Width="164px" DataSourceID="SqlDataSource15" DataTextField="SubDepartmentName"
DataValueField="SubDepartmentFK">
</telerik:RadComboBox>
</td>
</tr>
<tr>
<td dir="rtl" align="left" class="style61"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;"
valign="top">
<asp:Label ID="Label3" runat="server" Text="طبقه بندي كالا" Font-Size="Smaller"></asp:Label>
</td>
<td dir="rtl" align="right" class="style63"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;"
valign="top">
<telerik:RadComboBox ID="RadcmbGoodsType" runat="server" OnSelectedIndexChanged="RadcmbGoodsType_SelectedIndexChanged"
AutoPostBack="True">
</telerik:RadComboBox>
<br />
<br />
</td>
<td dir="rtl" align="left" class="style59"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;"
valign="top">
<asp:Label ID="lblDescription" runat="server" Text="توضیحات"
Font-Size="Smaller"></asp:Label>
</td>
<td dir="rtl" align="right" class="style59"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;"
valign="top">
<telerik:RadTextBox ID="rdtxtDescription" Runat="server" TextMode="MultiLine"
Width="280px" ontextchanged="rdtxtDescription_TextChanged">
</telerik:RadTextBox>
<telerik:RadButton ID="RadbtnInsert" runat="server" Skin="Sunset" Text="ثبت درخواست"
OnClick="RadButton1_Click" ValidationGroup="savemode">
</telerik:RadButton>
<telerik:RadButton ID="radbtnSearch" runat="server"
OnClick="RadbtnSearch_Click" Text="جستجو"
BackColor="#9999FF" Skin="Web20" ValidationGroup="searchmode">
</telerik:RadButton>
<telerik:RadButton ID="RadbtnEdit" runat="server" Skin="Sunset" Text="ویرایش" OnClick="RadbtnEdit_Click">
</telerik:RadButton>
<telerik:RadButton ID="rdbtnClear" runat="server" OnClick="rdbtnClear_Click" Text="پاک کن">
</telerik:RadButton>
</td>
</tr>
</table>
<asp:Panel ID="pnlGrid1" runat="server" ScrollBars="Both" Width="100%">
<table width="100%">
<tr>
<td align="center" dir="rtl" lang="fa" style="background-color: #FFD8B0">
<asp:Label ID="lblEorgNo0" runat="server" Font-Bold="True" ForeColor="#990000">درخواست شماره</asp:Label>
<asp:Label ID="lblEorgNo" runat="server" Font-Bold="True" ForeColor="#990000"></asp:Label>
<br />
</td>
</tr>
<tr>
<td align="center" dir="rtl" lang="fa" style="background-color: #FFD8B0">
<asp:ValidationSummary ID="vls1" runat="server" BackColor="#CCFFFF"
Font-Italic="True" Font-Names="Tahoma" HeaderText="موارد زیر را درج نمایید:"
Height="166px" ValidationGroup="request" Width="306px" Font-Bold="True" />
</td>
</tr>
</table>
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"
CellSpacing="0" GridLines="None" OnDeleteCommand="RadGrid1_DeleteCommand1" OnInsertCommand="RadGrid1_InsertCommand1"
OnItemCreated="RadGrid1_ItemCreated" OnItemDataBound="RadGrid1_ItemDataBound"
OnItemDeleted="RadGrid1_ItemDeleted1"
OnItemUpdated="RadGrid1_ItemUpdated1" OnNeedDataSource="RadGrid1_NeedDataSource1"
OnPreRender="RadGrid1_PreRender1"
OnUpdateCommand="RadGrid1_UpdateCommand1" Width="100%"
OnItemCommand="RadGrid1_ItemCommand" Skin="Vista">
<ValidationSettings ValidationGroup="request" />
<ClientSettings AllowColumnsReorder="True" EnableRowHoverStyle="True"
ReorderColumnsOnClient="True">
</ClientSettings>
<MasterTableView AllowAutomaticUpdates="false" CommandItemDisplay="TopAndBottom"
CommandItemSettings-AddNewRecordText="اضافه نمودن سطر جدید" CommandItemSettings-RefreshText="بروز رسانی"
DataKeyNames="GoodsFactors_ID">
<CommandItemSettings ExportToCsvImageUrl="mvwres://Telerik.Web.UI, Version=2011.2.712.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.ExportToCsv.gif"
ExportToExcelImageUrl="mvwres://Telerik.Web.UI, Version=2011.2.712.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.ExportToExcel.gif"
ExportToPdfImageUrl="mvwres://Telerik.Web.UI, Version=2011.2.712.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.ExportToPdf.gif"
ExportToPdfText="Export to PDF" ExportToWordImageUrl="mvwres://Telerik.Web.UI, Version=2011.2.712.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.ExportToWord.gif" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
</ExpandCollapseColumn>
<Columns>
<telerik:GridTemplateColumn FooterText="" HeaderText="ردیف">
<ItemTemplate>
<%# Container.DataSetIndex + 1 %>
</ItemTemplate>
<ItemStyle Width="10px" />
<HeaderStyle Width="10px" />
<FooterStyle Width="10px" />
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="GoodsFactors_ID" DataType="System.Int32" FilterControlAltText="Filter GoodsFactors_PurchaseFK column"
HeaderText="GoodsFactors_PurchaseFK" SortExpression="GoodsFactors_ID" UniqueName="GoodsFactors_ID"
Visible="False">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="Purchase_EorgNo" FilterControlAltText="Filter Purchase_EorgNo column"
HeaderText="شماره EORG" SortExpression="Purchase_EorgNo" UniqueName="Purchase_EorgNo"
Visible="False">
<EditItemTemplate>
<asp:TextBox ID="Purchase_EorgNoTextBox" runat="server" Text='<%# Bind("Purchase_EorgNo") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Purchase_EorgNoLabel" runat="server" Text='<%# Eval("Purchase_EorgNo") %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="GoodsDetails_Title" FilterControlAltText="Filter column2 column"
HeaderText="نام کالا" UniqueName="column2">
<EditItemTemplate>
<telerik:RadComboBox ID="GoodsDetails_TitleRadComboBox" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource3" DataTextField="GoodsDetails_Title" DataValueField="GoodsDetails_ID"
ExpandDirection="Up" OnItemDataBound="GoodsDetails_TitleRadComboBox_ItemDataBound"
Style="margin-left: 0px; margin-bottom: 4px" Width="105px"
AppendDataBoundItems="True" ValidationGroup="request">
</telerik:RadComboBox>
<asp:RequiredFieldValidator ID="rfv1" runat="server"
ControlToValidate="GoodsDetails_TitleRadComboBox" Display="Dynamic"
ErrorMessage="نام کالا" Font-Bold="True" Font-Italic="True"
ForeColor="Red" SetFocusOnError="True" ValidationGroup="request"
Font-Size="Large">*</asp:RequiredFieldValidator>
<br />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="GoodsDetails_TitleLabel" runat="server" Text='<%# Eval("GoodsDetails_Title") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader5" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="RequestAmount" DataType="System.Int32" FilterControlAltText="Filter GoodsFactors_PurchasedCountOrAmount column"
HeaderText="تعداد درخواستی" SortExpression="RequestAmount" UniqueName="GoodsFactors_PurchasedCountOrAmount">
<EditItemTemplate>
<asp:TextBox ID="RequestAmountTextBox" runat="server"
Text='<%# Bind("RequestAmount") %>' Width="71px"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfv2" runat="server"
ControlToValidate="RequestAmountTextBox" Display="Dynamic"
ErrorMessage="تعداد درخواستی" Font-Bold="True" Font-Italic="True" ForeColor="Red"
ValidationGroup="request" Font-Size="Large">*</asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="RequestAmountLabel" runat="server" Text='<%# Eval("RequestAmount") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader5" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="ReqUnit" FilterControlAltText="Filter column column"
HeaderText="واحد شمارش" UniqueName="column">
<EditItemTemplate>
<telerik:RadComboBox ID="RadComboBox3" runat="server" DataSourceID="SqlDataSource12"
DataTextField="Units_Title" DataValueField="Units_ID"
AppendDataBoundItems="True" Width="104px">
</telerik:RadComboBox>
<asp:RequiredFieldValidator ID="rvf3" runat="server"
ControlToValidate="RadComboBox3" Display="Dynamic" ErrorMessage="واحد شمارش"
Font-Bold="True" Font-Italic="True" ForeColor="Red"
ValidationGroup="request" Font-Size="Large">*</asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="RequestUnitLabel" runat="server" Text='<%# Eval("ReqUnit") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader5" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="GoodsFactors_FactorNo" FilterControlAltText="Filter GoodsFactors_FactorNo column"
HeaderText="شماره فاکتور" SortExpression="GoodsFactors_FactorNo" UniqueName="GoodsFactors_FactorNo">
<EditItemTemplate>
<asp:TextBox ID="GoodsFactors_FactorNoTextBox" runat="server"
Text='<%# Bind("GoodsFactors_FactorNo") %>' Width="80px"
AutoPostBack="True"
ontextchanged="GoodsFactors_FactorNoTextBox_TextChanged"></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="GoodsFactors_FactorNoTextBox" ID="RequiredFieldValidator1"
runat="server" ErrorMessage="*" Enabled="false" ValidationGroup="request"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Must be a number"
ToolTip="Numbers Only" ValidationExpression="\d+" ControlToValidate="GoodsFactors_FactorNoTextBox"></asp:RegularExpressionValidator>
<%-- <asp:CustomValidator ID="CustomValidator1" runat="server"
ControlToValidate="GoodsFactors_FactorNoTextBox"
onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>--%>
<%--<asp:RequiredFieldValidator ID="rfv0" runat="server" Display="None"
Enabled="False" ErrorMessage="شماره فاکتور"
ControlToValidate="GoodsFactors_FactorNoTextBox" ValidationGroup="request">*</asp:RequiredFieldValidator>--%>
<%--<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="GoodsFactors_FactorNoTextBox" ErrorMessage="تست"></asp:RegularExpressionValidator>--%>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="GoodsFactors_FactorNoLabel" runat="server" Text='<%# Eval("GoodsFactors_FactorNo") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader4" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="GoodsFactors_FactorDate" FilterControlAltText="Filter GoodsFactors_FactorDate column"
HeaderStyle-CssClass="specificHeader3" HeaderText="تاریخ فاکتور" SortExpression="GoodsFactors_FactorDate"
UniqueName="GoodsFactors_FactorDate">
<EditItemTemplate>
<jq:JQDatePicker ID="JQDatePicker1" runat="server" AnimationType="Default" DateFormat="YMD"
Enabled="true" OnTextChanged="JQDatePicker1_TextChanged" Regional="fa" WeekHeader="sauterday"
Width="70px"></jq:JQDatePicker>
<%--<asp:RequiredFieldValidator ID="rfv4" runat="server"
ControlToValidate="JQDatePicker1" Display="Dynamic" ErrorMessage="تاریخ فاکتور"
Font-Bold="True" Font-Size="Large" ForeColor="Red" ValidationGroup="request">*</asp:RequiredFieldValidator>--%>
</EditItemTemplate>
<ItemTemplate>
<jq:JQDatePicker ID="JQDatePicker2" runat="server" AnimationType="Default" Date='<%#Eval("GoodsFactors_FactorDate") %>'
DateFormat="YMD" Enabled="false" ForeColor="DarkBlue" Regional="fa" WeekHeader="sauterday"
Width="70px"></jq:JQDatePicker>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader4" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="FactorAmount" DataType="System.Int32" FilterControlAltText="Filter GoodsFactors_FactorCountOrAmount column"
HeaderText="تعداد خریداری شده" SortExpression="FactorAmount" UniqueName="GoodsFactors_FactorCountOrAmount">
<EditItemTemplate>
<asp:TextBox ID="FactorAmountTextBox" runat="server"
Text='<%# Bind("FactorAmount") %>' Width="71px" AutoPostBack="True" ></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="FactorAmountTextBox" ID="RequiredFieldValidator2"
runat="server" ErrorMessage="*" Enabled="false" ValidationGroup="request"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Must be a number"
ToolTip="Numbers Only" ValidationExpression="\d+" ControlToValidate="FactorAmountTextBox"></asp:RegularExpressionValidator>
<%-- <asp:RequiredFieldValidator ID="rfv5" runat="server"
ControlToValidate="FactorAmountTextBox"
ErrorMessage="تعداد خریداری شده" Font-Size="Large" ForeColor="Red"
ValidationGroup="request" Display="Dynamic" Enabled="False">*</asp:RequiredFieldValidator>--%>
<%--<asp:CustomValidator ID="CustomValidator2" runat="server"
ControlToValidate="FactorAmountTextBox" Display="Dynamic"
ErrorMessage="درج تعداد الزامیست"
onservervalidate="CustomValidator2_ServerValidate"
ValidationGroup="request">*</asp:CustomValidator>--%>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="FactorAmountLabel" runat="server" Text='<%# Eval("FactorAmount") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader4" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="FactorUnit" FilterControlAltText="Filter column3 column"
HeaderText="واحد شمارش" UniqueName="column3">
<EditItemTemplate>
<telerik:RadComboBox ID="RadComboBox2" runat="server" DataSourceID="SqlDataSource12"
DataTextField="Units_Title" DataValueField="Units_ID"
AppendDataBoundItems="True" Width="80px">
</telerik:RadComboBox>
<%--<asp:RequiredFieldValidator ID="rfv6" runat="server"
ControlToValidate="RadComboBox2" Display="Dynamic"
ErrorMessage="واحد شمارش(فاکتور)" Font-Size="Large" ForeColor="Red"
ValidationGroup="request">*</asp:RequiredFieldValidator>--%>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="FactorUnitLabel" runat="server" Text='<%# Eval("FactorUnit") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader4" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="GoodsFactors_Price" DataType="System.Double"
FilterControlAltText="Filter GoodsFactors_Price column" HeaderText="قیمت واحد"
SortExpression="GoodsFactors_Price" UniqueName="GoodsFactors_Price">
<EditItemTemplate>
<asp:TextBox ID="GoodsFactors_PriceTextBox" runat="server"
Text='<%# Bind("GoodsFactors_Price") %>' Width="58px"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfv7" runat="server"
ControlToValidate="GoodsFactors_PriceTextBox" Display="None"
ErrorMessage="قیمت واحد" Font-Size="Large" ForeColor="Red"
ValidationGroup="request" Enabled="False">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server"
ControlToValidate="GoodsFactors_PriceTextBox" ErrorMessage="تست3"></asp:RegularExpressionValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="GoodsFactors_PriceLabel" runat="server" Text='<%# Eval("GoodsFactors_Price") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader4" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="GoodsFactors_TotalPrice" DataType="System.Double"
FilterControlAltText="Filter GoodsFactors_TotalPrice column" HeaderText="قیمت کل"
SortExpression="GoodsFactors_TotalPrice" UniqueName="GoodsFactors_TotalPrice">
<EditItemTemplate>
<asp:TextBox ID="GoodsFactors_TotalPriceTextBox" runat="server"
Text='<%# Bind("GoodsFactors_TotalPrice") %>' Width="84px"></asp:TextBox>
<%--<asp:RequiredFieldValidator ID="rfv8" runat="server"
ControlToValidate="GoodsFactors_TotalPriceTextBox" Display="Dynamic"
ErrorMessage="قیمت کل" Font-Size="Large" ForeColor="Red"
ValidationGroup="request">*</asp:RequiredFieldValidator>--%>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="GoodsFactors_TotalPriceLabel" runat="server" Text='<%# Eval("GoodsFactors_TotalPrice") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader4" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="Stores_Name" FilterControlAltText="Filter column4 column"
HeaderText="فروشگاه" UniqueName="Stores">
<EditItemTemplate>
<telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource11"
DataTextField="Stores_Name" DataValueField="Stores_ID"
AppendDataBoundItems="True" Width="99px">
</telerik:RadComboBox>
<%--<asp:RequiredFieldValidator ID="rfv9" runat="server"
ControlToValidate="RadComboBox1" Display="Dynamic"
ErrorMessage="نام فروشگاه" Font-Size="Large" ForeColor="Red"
ValidationGroup="request">*</asp:RequiredFieldValidator>--%>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Stores_NameLabel" runat="server" Text='<%# Eval("Stores_Name") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader4" />
</telerik:GridTemplateColumn>
<telerik:GridEditCommandColumn ButtonType="ImageButton" FooterStyle-Width="60px"
HeaderStyle-Width="60px" HeaderText="ویرایش" ItemStyle-Width="60px" UniqueName="EditCommandColumn">
<FooterStyle Width="60px" />
<HeaderStyle Width="60px" />
<ItemStyle CssClass="MyImageButton" HorizontalAlign="Center" />
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmDialogType="Classic"
ConfirmText="آیا مطمئن هستید؟" ConfirmTitle="حذف" FooterStyle-Width="40px" HeaderStyle-Width="40px"
HeaderText="حذف" ItemStyle-Width="40px" Text="حذف" UniqueName="DeleteColumn">
<FooterStyle Width="40px" />
<HeaderStyle Width="40px" />
<ItemStyle CssClass="MyImageButton" HorizontalAlign="Center" />
</telerik:GridButtonColumn>
</Columns>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<FilterMenu EnableImageSprites="False">
</FilterMenu>
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
</HeaderContextMenu>
</telerik:RadGrid>
<br />
<telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server" TextBoxStyle-Width="30px">
</telerik:GridTextBoxColumnEditor>
<telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server" NumericTextBox-Width="40px"
NumericTextBox-DataType="Number" NumericTextBox-NumberFormat-DecimalDigits="0">
</telerik:GridNumericColumnEditor>
<telerik:GridNumericColumnEditor ID="GridNumericColumnEditor2" runat="server" NumericTextBox-Width="30px"
NumericTextBox-DataType="Number" NumericTextBox-NumberFormat-DecimalDigits="0">
</telerik:GridNumericColumnEditor>
<telerik:GridDropDownListColumnEditor ID="GridDropDownListColumnEditor1" runat="server"
DropDownStyle-Width="80px" DropDownStyle-CssClass="radDDLFarsi">
</telerik:GridDropDownListColumnEditor>
<telerik:GridDropDownListColumnEditor ID="GridDropDownListColumnEditor2" runat="server"
DropDownStyle-Width="80px" DropDownStyle-CssClass="radDDLFarsi">
</telerik:GridDropDownListColumnEditor>
</asp:Panel>
</div>
</td>
</tr>
</table>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
</telerik:RadWindowManager>
<asp:RequiredFieldValidator ID="rfvEorg" runat="server"
ControlToValidate="RadtxtEorgNo"
Display="Dynamic" Font-Bold="False"
Font-Italic="True" Font-Size="X-Small" ForeColor="#CC33FF"
SetFocusOnError="True" ValidationGroup="searchmode"
ErrorMessage="شماره درخواست را وارد نمایید!"
Enabled="False" Visible="False"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="rfvEorg1" runat="server"
ControlToValidate="RadtxtEorgNo"
Display="Dynamic" Font-Bold="False"
Font-Italic="True" Font-Size="X-Small" ForeColor="#CC33FF"
SetFocusOnError="True" ValidationGroup="savemode"
ErrorMessage="شماره درخواست را وارد نمایید!"
Enabled="False" Visible="False"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="rfvDate" runat="server"
ControlToValidate="JQDPKfromDate" Display="Dynamic"
ErrorMessage="تاریخ را وارد نمایید!"
Font-Italic="True" Font-Size="X-Small"
ForeColor="#CC33FF" ValidationGroup="savemode"
Enabled="False" Visible="False"></asp:RequiredFieldValidator>
<asp:SqlDataSource ID="SqlDataS" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT [GoodsFactors_FactorDate], [GoodsFactors_FactorNo], [GoodsFactors_ID] FROM [GoodsFactors]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT [GoodsType_ID], [GoodsType_Title] FROM [GoodsType]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT [GoodsDetails_ID], [GoodsDetails_Title] FROM [GoodsDetails]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT [Units_ID], [Units_Title] FROM [Units]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource6" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource7" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource8" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource15" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT MyKey, SubDepartmentFK, SubDepartmentName, DepartmentFK FROM SubDepartments WHERE (SubDepartmentFK <> 34)">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource9" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource11" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT [Stores_ID], [Stores_Name] FROM [Stores]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource14" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT DISTINCT DepartmentFK, DepartmentName, SubDepartmentFK FROM SubDepartments WHERE (DepartmentFK <> 34) AND (DepartmentFK = SubDepartmentFK)">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource12" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT [Units_ID], [Units_Title] FROM [Units]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource13" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT GoodsDetails_Title, GoodsType_ID, GoodsDetails_ID FROM View_GoodsDetail WHERE (GoodsType_ID = @TypeFK)">
<SelectParameters>
<asp:ControlParameter ControlID="RadcmbGoodsType" Name="TypeFK" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
-------------------------
Purchase.aspx.cs
using System;
using System.Data;
using System.Data.Objects;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Linq;
using System.Drawing;
using Telerik.Web.UI;
using System.Data.SqlClient;
using JQControls;
using System.Collections;
public partial class Forms_PurchaseRequest : System.Web.UI.Page
{
public SupplierModel.AppSupplierEntities DbContext = new SupplierModel.AppSupplierEntities();
private string npgridMessage = null;
private string nlgridMessage = null;
protected void Page_Load(object sender, EventArgs e)
{
// RadGrdRequestPurchase.MasterTableView.EditMode = GridEditMode.InPlace;
RadGrid1.MasterTableView.EditMode = GridEditMode.InPlace;
//RadGrdNewsPaper.MasterTableView.EditMode = GridEditMode.InPlace;
//SqlDataSource1.SelectCommand = "select NewsPaperNames_ID,NewsPaperNames_Name from NewsPaperNames ";
//SqlDataSource2.SelectCommand = "select Mykey, Name From View_JustLocalDepartments";
SqlDataSource2.SelectCommand = "SELECT GoodsType_ID,GoodsType_Title FROM GoodsType";// نوع كالا
//SqlDataSource3.SelectCommand = "Select GoodsDetails_ID, GoodsDetails_Title from View_GoodsName";// نام كالا
SqlDataSource4.SelectCommand = "Select GoodsFactors_PurchasedCountOrAmount from GoodsFactors";//تعداد درخواستي
//SqlDataSource5.SelectCommand = "Select Units_ID , Units_Title from Units"; // واحد شمارش
SqlDataSource6.SelectCommand = "Select GoodsFactor_ID,GoodsFactor_FactorNo from GoodsFactors";//شماره فاكتور
SqlDataSource7.SelectCommand = "Select GoodsFactor_FactorDate from GoodsFactors";// تاريخ فاكتور
SqlDataSource8.SelectCommand = "Select Stores_ID, Stores_Name from Stores";// نام فروشگاه
SqlDataSource9.SelectCommand= "select Mykey, Name From View_JustLocalDepartments";
//SqlDataSource14.SelectCommand = DataLayer.frmAgency.sdsJustLocalDepartments;
// SqlDataSource15.SelectCommand = DataLayer.frmAgency.sdsSubDepartments("1");
if (Page.IsPostBack == false)
{
Initialize();
updateDatePickerSettings();
}
}
private void Initialize()
{
FillCombo.FillTypeOf(RadcmbGoodsType, "GoodsCategory", null);
//RadcmbDep.AppendDataBoundItems = true;
//RadcmbDep.Items.Add(new RadComboBoxItem(" ","-1"));
//FillCombo.FillTypeOf(RadcmbDep, "LocalDepartments", null);
//FillCombo.FillTypeOf(RadcmbSubDep, "SubDepartmentAll", null);
RadcmbDep.Enabled = false;
string EorgNo = RadtxtEorgNo.Text;
string FactorNo = RadtxtEorgNo0.Text;
//RadGrdRequestPurchase.DataSource = DbContext.spPurchaseSelect();
//RadGrid1.DataSource = DbContext.spPurchaseSelect(EorgNo);
lblEorgNo0.Visible = false;
RadbtnEdit.Enabled = false;
rdbtnClear.Enabled = false;
int GoodsTypeFK = Convert.ToInt32(RadcmbGoodsType.SelectedValue.ToString());
SqlDataSource3.SelectCommand = "SELECT GoodsDetails_ID, GoodsDetails_Title FROM GoodsDetails where GoodsDetails_GoodsTypeFK=" + GoodsTypeFK;
// RadGrdRequestPurchase.DataSource = DbContext.spPurchaseSelect(EorgNo,FactorNo);
// MultiView1.ActiveViewIndex = -1;
}
protected void updateDatePickerSettings()
{
JQLoader1.Theme = JQTheme.UILightness;
JQDatePicker jqd = ((JQDatePicker)(this.FindControl("ctl00$cphMain$RadGrid1$ctl00$ctl04$JQDatePicker1")));
}
private void DisplayNewspaperMessage(string text)
{
//RadGrdNewsPaper.Controls.Add(new LiteralControl(string.Format("<span style='color:red'>{0}</span>", text)));
}
protected void RegisterforCombos()
{
this.RadcmbGoodsType.DataBind();
//RadComboBox details = FindControl("GoodsDetails_TitleRadComboBox") as RadComboBox;
//details.DataBind();
}
private void SetNewspaperMessage(string message)
{
npgridMessage = message;
}
private void SetNewsLetterMessage(string message)
{
nlgridMessage = message;
}
protected void RadGrid1_Unload(object sender, EventArgs e)
{
if (DbContext != null)
DbContext.Dispose();
}
protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
{
try
{
GridEditableItem item = e.Item as GridEditableItem;
Hashtable values = new Hashtable();
item.ExtractValues(values);
SupplierModel.NewsLetterPurchase customer = new SupplierModel.NewsLetterPurchase();
item.UpdateValues(customer);
RadComboBox cmbToMonth = item.FindControl("GirdCmbToMonth") as RadComboBox;
customer.NewsLetterPurchase_ToMonthFK = Int32.Parse(cmbToMonth.SelectedValue);
DbContext.AddToNewsLetterPurchases(customer);
DbContext.SaveChanges();
SetNewsLetterMessage("سطر جدید با موفقیت درج گردید!");
//ChangeHeader("EditCommandColumn");
// RadGrdNewsPaperPurchase.Rebind();
}
catch (Exception ex)
{
SetNewsLetterMessage("خطا در درج : " + ex.InnerException.Message);
}
}
protected void RadGrid1_DeleteCommand(object sender, GridCommandEventArgs e)
{
string customerID = (e.Item as GridDataItem).GetDataKeyValue("NewsLetterPurchase_ID").ToString();
int id = Int32.Parse(customerID);
SupplierModel.NewsLetterPurchase customer = DbContext.NewsLetterPurchases.Where(p => p.NewsLetterPurchase_ID == id).FirstOrDefault();
DbContext.DeleteObject(customer);
DbContext.SaveChanges();
}
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(nlgridMessage))
{
//DisplayNewsletterMessage(nlgridMessage);
}
}
protected void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)
{
GridEditableItem item = (GridEditableItem)e.Item;
String id = item.GetDataKeyValue("GoodsFactors_ID").ToString();
if (e.Exception != null)
{
e.KeepInEditMode = true;
e.ExceptionHandled = true;
SetNewsLetterMessage("کد " + id + " ویرایش نگردید. خطا : " + e.Exception.Message);
}
else
{
SetNewsLetterMessage("کد " + id + " با موفقیت ویرایش گردید!");
RadbtnEdit.Enabled = true;
rdbtnClear.Enabled = true;
radbtnSearch.Enabled = true;
}
}
protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e)
{
RadbtnEdit.Enabled = true;
rdbtnClear.Enabled = true;
radbtnSearch.Enabled = true;
if (e.Exception != null)
{
e.ExceptionHandled = true;
SetNewsLetterMessage("خطا در درج : " + e.Exception.Message);
}
else
{
SetNewsLetterMessage("سطر جدید با موفقیت درج گردید!");
}
}
protected void RadGrid1_ItemDeleted(object source, GridDeletedEventArgs e)
{
GridDataItem dataItem = (GridDataItem)e.Item;
String id = dataItem.GetDataKeyValue("NewsLetterPurchase_NewsLetterFK").ToString();
if (e.Exception != null)
{
e.ExceptionHandled = true;
SetNewsLetterMessage("Product with ID " + id + " cannot be deleted. Reason: " + e.Exception.Message);
}
else
{
SetNewsLetterMessage("Product with ID " + id + " is deleted!");
}
}
protected void RadGrdNewsPaperPurchase_ItemDataBound(object sender, GridItemEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
if (e.Item is GridDataItem && e.Item.IsInEditMode && e.Item.DataSetIndex > -1)
{
//RadComboBox cmbToMonth = editedItem.FindControl("GirdCmbToMonth") as RadComboBox;
string purchaseID = (editedItem.GetDataKeyValue("GoodsFactors_ID")).ToString();
int id = Int32.Parse(purchaseID);
SupplierModel.GoodsFactor purchase = DbContext.GoodsFactors.Where(p => p.GoodsFactors_PurchaseFK == id).FirstOrDefault();
//cmbToMonth.SelectedValue = (np.NewsLetterPurchase_ToMonthFK).ToString();
}
}
//SecondGrid
protected void RadGrdNewsPaper_Unload(object sender, EventArgs e)
{
if (DbContext != null)
DbContext.Dispose();
}
protected void RadGrid1_ItemUpdated1(object sender, GridUpdatedEventArgs e)
{
GridEditableItem item = (GridEditableItem)e.Item;
String id = item.GetDataKeyValue("GoodsFactors_ID").ToString();
if (e.Exception != null)
{
e.KeepInEditMode = true;
e.ExceptionHandled = true;
SetNewspaperMessage("کد " + id + " ویرایش نگردید. خطا : " + e.Exception.Message);
}
else
{
RadbtnEdit.Enabled = true;
rdbtnClear.Enabled = true;
radbtnSearch.Enabled = true;
SetNewspaperMessage("کد " + id + " با موفقیت ویرایش گردید!");
}
}
protected void RadGrid1_UpdateCommand1(object sender, GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
string PurchaseID = editedItem.GetDataKeyValue("GoodsFactors_ID").ToString();
int id = Int32.Parse(PurchaseID);
SupplierModel.GoodsFactor fac = DbContext.GoodsFactors.Where(current => current.GoodsFactors_ID == id).FirstOrDefault();
editedItem.UpdateValues(fac);
string strJQDName = "ctl00$cphMain$RadGrid1$ctl00$ctl";
if (e.Item is GridEditableItem)
{
GridDataItem item = e.Item as GridDataItem;
if (e.Item.DataSetIndex < 6)
strJQDName += "0" + (e.Item.DataSetIndex + 4).ToString() + "$JQDatePicker1";
else
strJQDName += (e.Item.DataSetIndex + 4).ToString() + "$JQDatePicker1";
}
JQDatePicker jqd = ((JQDatePicker)(this.FindControl(strJQDName)));
fac.GoodsFactors_FactorDate = jqd.Date;
RadComboBox cmbGoodsDetails = editedItem.FindControl("GoodsDetails_TitleRadComboBox") as RadComboBox;
fac.GoodsFactors_GoodsDetailsFK = Int32.Parse(cmbGoodsDetails.SelectedValue);
RadComboBox cmbStores = editedItem.FindControl("RadComboBox1") as RadComboBox;
if (cmbStores.SelectedValue == "-1")
fac.GoodsFactors_StoresFK = 1;
else
fac.GoodsFactors_StoresFK = Int32.Parse(cmbStores.SelectedValue);
TextBox txtReqAmount = editedItem.FindControl("RequestAmountTextBox") as TextBox;
fac.GoodsFactors_PurchasedCountOrAmount = Int32.Parse(txtReqAmount.Text);
TextBox txtFacAmount = editedItem.FindControl("FactorAmountTextBox") as TextBox;
fac.GoodsFactors_FactorCountOrAmount = Int32.Parse(txtFacAmount.Text);
RadComboBox cmbUnitFK2 = editedItem.FindControl("RadComboBox3") as RadComboBox; // Request UnitFK
fac.GoodsFactors_ReqUnitsFK = Int32.Parse(cmbUnitFK2.SelectedValue);
TextBox txtFactorNo = editedItem.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
fac.GoodsFactors_FactorNo = txtFactorNo.Text;
TextBox txtPrice = editedItem.FindControl("GoodsFactors_PriceTextBox") as TextBox;
fac.GoodsFactors_Price = float.Parse(txtPrice.Text);
TextBox txtTotalPrice = editedItem.FindControl("GoodsFactors_TotalPriceTextBox") as TextBox;
fac.GoodsFactors_TotalPrice = float.Parse(txtTotalPrice.Text);
RadComboBox cmbFactorUnit = editedItem.FindControl("RadComboBox2") as RadComboBox;
fac.GoodsFactors_UnitsFK = Int32.Parse(cmbFactorUnit.SelectedValue);
//if (txtFactorNo.Text != null)
//{
//GridTemplateColumnEditor editor = (GridTemplateColumnEditor)editedItem.EditManager.GetColumnEditor("GoodsFactors_FactorNo");
//RequiredFieldValidator validator = new RequiredFieldValidator();
//validator.ID = "rfv5";
//validator.ForeColor = System.Drawing.ColorTranslator.FromHtml("#D21528");
//validator.ControlToValidate = "GoodsFactors_PriceTextBox";
//validator.ErrorMessage = "تعداد خرید";
//txtPrice.Controls.Add(validator);
//-------------------------------------------------------------
//if (txtPrice.Text == "" || float.Parse(txtPrice.Text) == 0)
// rfv7.EnableClientScript = true;
//else
// rfv7.EnableClientScript = false;
//MessageBoxOK.Show("قیمت را وارد کنید!");
//}
DbContext.SaveChanges();
RadGrid1.Rebind();
RadGrid1.MasterTableView.ClearEditItems();
RadbtnEdit.Enabled = true;
rdbtnClear.Enabled = true;
radbtnSearch.Enabled = true;
}
protected void RadGrid1_NeedDataSource1(object sender, GridNeedDataSourceEventArgs e)
{
string EorgNo = RadtxtEorgNo.Text;
string FactorNo = RadtxtEorgNo0.Text;
RadGrid1.DataSource = DbContext.spPurchaseSelect(EorgNo, FactorNo);
}
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridEditableItem editItem = (GridEditableItem)e.Item;
ImageButton updateButton = (ImageButton)editItem.FindControl("UpdateButton");
TextBox GoodsFactors_FactorNoTextBox = (TextBox)editItem.FindControl("GoodsFactors_FactorNoTextBox");
int index = editItem.ItemIndex;
// updateButton.Attributes.Add("onclick", "return CheckValidation('" + GoodsFactors_FactorNoTextBox.ClientID + "');");
//updateButton.Attributes.Add("onclick", "return ValueChanged('" + index + "');");
}
if ((e.Item is GridDataInsertItem) && e.Item.IsInEditMode)
{
RadComboBox cmbStores = e.Item.FindControl("RadComboBox1") as RadComboBox;
cmbStores.Items.Add(new RadComboBoxItem(" ", "-1"));
RadComboBox cmbGoodsDetails = e.Item.FindControl("GoodsDetails_TitleRadComboBox") as RadComboBox;
cmbGoodsDetails.Items.Add(new RadComboBoxItem(" ", "-1"));
RadComboBox cmbUnitFK1 = e.Item.FindControl("RadComboBox2") as RadComboBox; // Factor UnitFK
cmbUnitFK1.Items.Add(new RadComboBoxItem(" ", "-1"));
RadComboBox cmbUnitFK2 = e.Item.FindControl("RadComboBox3") as RadComboBox; // Request UnitFK
cmbUnitFK2.Items.Add(new RadComboBoxItem(" ", "-1"));
int GoodsTypeFK = Convert.ToInt32(RadcmbGoodsType.SelectedValue.ToString());
SqlDataSource3.SelectCommand = "SELECT GoodsDetails_ID, GoodsDetails_Title FROM GoodsDetails where GoodsDetails_GoodsTypeFK=" + GoodsTypeFK;
}
else if ((e.Item is GridEditableItem) && e.Item.IsInEditMode)
{
//GridEditableItem editItem = (GridEditableItem)e.Item;
//LinkButton updateButton = editItem.FindControl("UpdateButton") as LinkButton;
//TextBox FactorNoTextBox = editItem.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
//TextBox FactorAmount = (TextBox)editItem.FindControl("FactorAmountTextBox");
//TextBox FactorPrice = (TextBox)editItem.FindControl("GoodsFactors_PriceTextBox");
//updateButton.Attributes.Add("onclick", "return CheckValidation('" + FactorAmount.ClientID + "');");
//RadComboBox cmbStores = e.Item.FindControl("RadComboBox1") as RadComboBox;
//cmbStores.Items.Add(new RadComboBoxItem(" ", "-1"));
//RadComboBox cmbGoodsDetails = e.Item.FindControl("GoodsDetails_TitleRadComboBox") as RadComboBox;
//cmbGoodsDetails.Items.Add(new RadComboBoxItem(" ", "-1"));
//RadComboBox cmbUnitFK1 = e.Item.FindControl("RadComboBox2") as RadComboBox; // Factor UnitFK
//cmbUnitFK1.Items.Add(new RadComboBoxItem(" ", "-1"));
//RadComboBox cmbUnitFK2 = e.Item.FindControl("RadComboBox3") as RadComboBox; // Request UnitFK
//cmbUnitFK2.Items.Add(new RadComboBoxItem(" ", "-1"));
int GoodsTypeFK = Convert.ToInt32(RadcmbGoodsType.SelectedValue.ToString());
SqlDataSource3.SelectCommand = "SELECT GoodsDetails_ID, GoodsDetails_Title FROM GoodsDetails where GoodsDetails_GoodsTypeFK=" + GoodsTypeFK;
}
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
if (e.Item is GridDataItem && !(e.Item.IsInEditMode))
{
string purID = (editedItem.GetDataKeyValue("GoodsFactors_ID")).ToString();
int id = Int32.Parse(purID);
SupplierModel.GoodsFactor factor = DbContext.GoodsFactors.Where(p => p.GoodsFactors_ID == id).FirstOrDefault();
}
if (e.Item is GridDataItem && e.Item.IsInEditMode && e.Item.DataSetIndex > -1)
{
// RadTextBox txtFacNo = e.Item.FindControl("GoodsFactors_FactorNoTextBox") as RadTextBox;
if (e.Item.IsInEditMode)
{
if (e.Item is GridDataInsertItem)
{
GridEditableItem editItem = (GridEditableItem)e.Item;
LinkButton InsertButton = (LinkButton)editItem.FindControl("PerformInsertButton");
//}
//else
//{
//GridEditableItem editItem = (GridEditableItem)e.Item;
ImageButton updateButton = (ImageButton)editItem.FindControl("UpdateButton");
TextBox GoodsFactors_FactorNoTextBox = (TextBox)editItem.FindControl("GoodsFactors_FactorNoTextBox");
//int index = editItem.ItemIndex;
updateButton.Attributes.Add("onclick", "return CheckValidation('" + GoodsFactors_FactorNoTextBox.ClientID + "');");
//updateButton.Attributes.Add("onclick", "return ValueChanged('"+index+"');");
}
}
string purID = (editedItem.GetDataKeyValue("GoodsFactors_ID")).ToString();
int id = Int32.Parse(purID);
SupplierModel.GoodsFactor factor = DbContext.GoodsFactors.Where(p => p.GoodsFactors_ID == id).FirstOrDefault();
RadComboBox cmbGoodsDetails = editedItem.FindControl("GoodsDetails_TitleRadComboBox") as RadComboBox;
cmbGoodsDetails.Items.Add(new RadComboBoxItem(" ", "-1"));
RadComboBox cmbStores = editedItem.FindControl("RadComboBox1") as RadComboBox;
//cmbStores.Items.Add(new RadComboBoxItem(" ", "-1"));// yek satre khali dar combo ijad mikonad.
RadComboBox cmbUnitFK1 = editedItem.FindControl("RadComboBox2") as RadComboBox; // Factor UnitFK
//cmbUnitFK1.Items.Add(new RadComboBoxItem(" ", "-1"));
RadComboBox cmbUnitFK2 = editedItem.FindControl("RadComboBox3") as RadComboBox; // Request UnitFK
//cmbUnitFK2.Items.Add(new RadComboBoxItem(" ", "-1"));
string strJQDName = "ctl00$cphMain$RadGrid1$ctl00$ctl";
if (e.Item.DataSetIndex < 6)
strJQDName += "0" + (e.Item.DataSetIndex + 4).ToString() + "$JQDatePicker1";
else
strJQDName += (e.Item.DataSetIndex + 4).ToString() + "$JQDatePicker1";
JQDatePicker jqd = new JQDatePicker();
jqd.Enabled = true;
jqd = ((JQDatePicker)(this.FindControl(strJQDName)));
jqd.Date = factor.GoodsFactors_FactorDate;
TextBox txtReqAmount = editedItem.FindControl("RequestAmountTextBox") as TextBox;
TextBox txtFacAmount = editedItem.FindControl("FactorAmountTextBox") as TextBox;
TextBox txtFactorNo = editedItem.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
TextBox txtPrice = editedItem.FindControl("GoodsFactors_PriceTextBox") as TextBox;
TextBox txtTotalPrice = editedItem.FindControl("GoodsFactors_TotalPriceTextBox") as TextBox;
//ImageButton updateButton = (ImageButton)editedItem.FindControl("UpdateButton");
//updateButton.Attributes.Add("onclick", "return CheckValidation('" + txtFactorNo.ClientID + "');");
}
}
protected void RadGrid1_InsertCommand1(object sender, GridCommandEventArgs e)
{
try
{
if (RadtxtEorgNo.Text != "")
{
// *** ==========================================================================
GridEditableItem item = e.Item as GridEditableItem;
Hashtable values = new Hashtable();
item.ExtractValues(values);
int ReqAmount;
int FacAmount;
float Price;
float TotalPrice;
string FactorNo;
string date= item.FindControl("JQDatePicker1").ToString() as string;
RadComboBox cmbGoodsDetails = item.FindControl("GoodsDetails_TitleRadComboBox") as RadComboBox;
int? GoodsDetailsFK = Int32.Parse(cmbGoodsDetails.SelectedValue);
if (GoodsDetailsFK == -1)
GoodsDetailsFK = null;
RadComboBox cmbStores = item.FindControl("RadComboBox1") as RadComboBox;
int? StoresFK = Int32.Parse(cmbStores.SelectedValue);
if (StoresFK == -1)
StoresFK = null;
RadComboBox cmbUnitFK1 = item.FindControl("RadComboBox2") as RadComboBox; // Factor UnitFK
int? UnitFK = Int32.Parse(cmbUnitFK1.SelectedValue);
if (UnitFK == -1)
UnitFK = null;
RadComboBox cmbUnitFK2 = item.FindControl("RadComboBox3") as RadComboBox; // Request UnitFK
int? UnitFK2 = Int32.Parse(cmbUnitFK2.SelectedValue);
if (UnitFK2 == -1)
UnitFK2 = null;
string strJQDName = "ctl00$cphMain$RadGrid1$ctl00$ctl02$ctl02$JQDatePicker1";
JQDatePicker jqd = ((JQDatePicker)(this.FindControl(strJQDName)));
TextBox txtReqAmount = item.FindControl("RequestAmountTextBox") as TextBox;
if (txtReqAmount.Text != null && txtReqAmount.Text != "")
ReqAmount = Int32.Parse(txtReqAmount.Text);
else
ReqAmount = 0;
TextBox txtFacAmount = item.FindControl("FactorAmountTextBox") as TextBox;
if (txtFacAmount.Text != null && txtFacAmount.Text != "")
FacAmount = Int32.Parse(txtFacAmount.Text);
else
FacAmount = 0;
TextBox txtFactorNo = item.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
if (txtFactorNo.Text != null && txtFactorNo.Text != "")
FactorNo = txtFactorNo.Text;
else
FactorNo = null;
TextBox txtPrice = item.FindControl("GoodsFactors_PriceTextBox") as TextBox;
if (txtPrice.Text != null && txtPrice.Text != "")
Price = float.Parse(txtPrice.Text);
else
Price = 0;
TextBox txtTotalPrice = item.FindControl("GoodsFactors_TotalPriceTextBox") as TextBox;
if (txtTotalPrice.Text != null && txtTotalPrice.Text != "")
TotalPrice = float.Parse(txtTotalPrice.Text);
else
TotalPrice = 0;
if (date!=null)
{
DbContext.spPurchaseInsert3(FactorNo, lblEorgNo.Text, GoodsDetailsFK, UnitFK2, jqd.Date, TotalPrice, Price, FacAmount, ReqAmount, StoresFK, UnitFK);
}
else
{
DbContext.spPurchaseInsert3(txtFactorNo.Text, lblEorgNo.Text, GoodsDetailsFK, UnitFK2, null, TotalPrice, Price, FacAmount, ReqAmount, StoresFK, UnitFK);
}
DbContext.SaveChanges();
//Fill();
RadGrid1.Rebind();
//RadGrid1.MasterTableView.ClearEditItems();
MessageBoxOK.Show("سطر جدید با موفقیت درج گردید!");
RadbtnEdit.Enabled = true;
rdbtnClear.Enabled = true;
radbtnSearch.Enabled = true;
//ChangeHeader("EditCommandColumn");
}
else
{
MessageBoxOK.Show("شماره درخواست را وارد نمایید!");
//System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml("#F7D1FA");
//RadtxtEorgNo.BackColor = color;
}
}
catch (Exception ex)
{
SetNewspaperMessage("خطا در درج : " + ex.InnerException.Message);
}
}
protected void RadButton1_Click(object sender, EventArgs e)
{
if (RadtxtEorgNo.Text != "" && JQDPKfromDate.Text != "")
{
lblAlert1.Visible = false;
lblAlert2.Visible = false;
string Eorg = RadtxtEorgNo.Text;
string Department = RadcmbDep.SelectedValue;
string SubDepartment = RadcmbSubDep.SelectedValue;
int UserFK = MyWebApplication.Sessions.AuthenticatedUser.UserID;
DateTime UseDate = System.DateTime.Now;
int DepFK = Int32.Parse(Department);
int SubDepFK = Int32.Parse(SubDepartment);
string Desc = rdtxtDescription.Text;
//rfvDate.Enabled = true;
//rfvDate.Visible = true;
ObjectParameter output1 = new ObjectParameter("checkDuplicate", typeof(Int32));
DbContext.spPurchaseInsertCheck(RadtxtEorgNo.Text, output1);
string GoodType = RadcmbGoodsType.SelectedValue.ToString();
int GoodsTypeFK = Convert.ToInt32(GoodType);
//ObjectParameter output2 = new ObjectParameter("GoodsTypeFK",typeof(Int32));
int chk = Convert.ToInt32(output1.Value.ToString());
if (chk == 1 && Eorg != "")
{
MessageBoxOK.Show("درخواستی با این شماره قبلا ثبت شده است!");
//Clear();
//SearchRequest(Eorg);
}
else if (Eorg != "" && JQDPKfromDate.Text!="")
{
DbContext.spPurchaseInsert2(JQDPKfromDate.Date, Eorg, DepFK, SubDepFK, 0, GoodsTypeFK, Desc, UserFK, UseDate);
DbContext.SaveChanges();
MessageBoxOK.Show("درخواست با موفقیت ثبت گردید.");
lblEorgNo.Visible = true;
lblEorgNo0.Visible = true;
lblEorgNo.Text = RadtxtEorgNo.Text;
RadGrid1.Rebind();
RadbtnEdit.Enabled = true;
RadbtnInsert.Enabled = false;
rdbtnClear.Enabled = true;
}
}
else if (RadtxtEorgNo.Text == "" && JQDPKfromDate.Text == "")
{
MessageBoxOK.Show("درج شماره درخواست و تاریخ الزامیست!");
lblAlert1.Visible = true;
lblAlert2.Visible = true;
}
else if (RadtxtEorgNo.Text == "" && JQDPKfromDate.Text != "")
{
MessageBoxOK.Show("درج شماره درخواست الزامیست!");
lblAlert1.Visible = true;
lblAlert2.Visible = false;
}
else if (RadtxtEorgNo.Text != "" && JQDPKfromDate.Text == "")
{
MessageBoxOK.Show("درج تاریخ الزامیست!");
lblAlert2.Visible = true;
lblAlert1.Visible = false;
}
}
protected void RadbtnFactorInsert_Click(object sender, EventArgs e)
{
string FactorNo = RadtxtEorgNo0.Text;
string EorgNo = RadtxtEorgNo.Text;
// DbContext.spPurchaseInsert3(FactorNo,EorgNo);
MessageBoxOK.Show("شماره فاکتور با موفقیت ثبت گردید.");
}
protected void RadbtnInsertGoods_Click(object sender, EventArgs e)
{
//RadGrid1.Visible = true;
//MultiView1.ActiveViewIndex = 0;
}
protected void RadbtnSearch_Click(object sender, EventArgs e)
{
if ((RadtxtEorgNo.Text == "") && (RadtxtEorgNo0.Text == ""))
{
MessageBoxOK.Show("لطفاً شماره درخواست را وارد نمایید!");
lblAlert1.Visible = true;
//System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml("#F7D1FA");
//RadtxtEorgNo.BackColor = System.Drawing.ColorTranslator.FromHtml("#F7D1FA");
//RadtxtEorgNo.BorderColor= System.Drawing.ColorTranslator.FromHtml("#9933FF");
//RadtxtEorgNo.BorderStyle = BorderStyle.Dotted;
// img1.Visible = true;
}
//rfvDate.Visible = false;
//SupplierModel.Purchase pur=DbContext.Purchases
if ((RadtxtEorgNo.Text != "")) //||(RadtxtEorgNo0.Text!=""))
{
lblAlert1.Visible = false;
lblAlert2.Visible = false;
RadtxtEorgNo.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");
//RadtxtEorgNo.BackColor = System.Drawing.Color.Transparent;
//RadtxtEorgNo.BorderColor = System.Drawing.Color.Transparent;
// MultiView1.ActiveViewIndex = 0;
string eorg= RadtxtEorgNo.Text;
ObjectParameter output1 = new ObjectParameter("DepFK",typeof(Int32));
ObjectParameter output2 = new ObjectParameter("SubDep",typeof(Int32));
ObjectParameter output3 = new ObjectParameter("EorgNumber",typeof(Char));
ObjectParameter output4 = new ObjectParameter("RequestDate",typeof(DateTime));
ObjectParameter output5 = new ObjectParameter("GoodsTypeFK", typeof(Int32));
ObjectParameter output6 = new ObjectParameter("valid", typeof(Boolean));
DbContext.spPurchaseSearch(RadtxtEorgNo.Text, RadtxtEorgNo0.Text, output1, output2,output3,output4,output5,output6);
//string validEorg = output3.Value.ToString();
int valid = Convert.ToInt32(output6.Value);
if (valid != 0) // Eorg Number vojud darad.
{
SupplierModel.Purchase pur = DbContext.Purchases.Where(p => p.Purchase_EorgNo == eorg).First();
RadcmbDep.SelectedValue = output1.Value.ToString();
RadcmbDep.SelectedValue = pur.Purchase_ReqSubDepartmentFK.ToString();
RadcmbSubDep.SelectedValue = output2.Value.ToString();
RadcmbGoodsType.SelectedValue = output5.Value.ToString();
rdtxtDescription.Text = pur.Purchase_Description;
//string strJQDName = "ctl00$cphMain$ctl00$ctl";
//strJQDName +="0" + JQDPKfromDate.ToString() + "$JQDatePicker1";
if (output4.Value != null)
{
JQDPKfromDate.Date = pur.Purchase_Date;
}
//if (RadtxtEorgNo.Text == "")
//{
// RadtxtEorgNo.Text = output3.Value.ToString();
//}
RadGrid1.Rebind();
lblEorgNo0.Visible = true;
lblEorgNo.Visible = true;
lblEorgNo.Text = RadtxtEorgNo.Text;
RadbtnEdit.Enabled = true;
RadbtnInsert.Enabled = false;
rdbtnClear.Enabled = true;
}
else {
MessageBoxOK.Show("این شماره درخواست وجود ندارد!");
Clear();
RadGrid1.Rebind();
lblEorgNo0.Visible = false;
lblEorgNo.Visible = false;
RadbtnEdit.Enabled = false;
RadbtnInsert.Enabled = true;
rdbtnClear.Enabled = false;
radbtnSearch.Enabled = true;
}
}
}
protected void RadGrid1_ItemDeleted1(object sender, GridDeletedEventArgs e)
{
}
protected void RadGrid1_DeleteCommand1(object sender, GridCommandEventArgs e)
{
string PurchaseID = (e.Item as GridDataItem).GetDataKeyValue("GoodsFactors_ID").ToString();
int id = Int32.Parse(PurchaseID);
SupplierModel.GoodsFactor Factor = DbContext.GoodsFactors.Where(p => p.GoodsFactors_ID == id).FirstOrDefault();
DbContext.DeleteObject(Factor);
DbContext.SaveChanges();
RadbtnEdit.Enabled = true;
rdbtnClear.Enabled = true;
radbtnSearch.Enabled = true;
}
protected void RadcmbGoodsType_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
int GoodsTypeFK = Convert.ToInt32(RadcmbGoodsType.SelectedValue.ToString());
SqlDataSource3.SelectCommand = "SELECT GoodsDetails_ID, GoodsDetails_Title FROM GoodsDetails where GoodsDetails_GoodsTypeFK="+ GoodsTypeFK;
RadGrid1.Rebind();
if (RadcmbGoodsType.SelectedIndex == 4) // agar mashinAlAte edari entekhab shavad.
{
int SubDepFK = Convert.ToInt32(RadcmbSubDep.SelectedValue);
SupplierModel.SubDepartment SubDep = DbContext.SubDepartments.Where(s => s.DepartmentFK != 34 && s.SubDepartmentFK == SubDepFK).First();
string DepFK = SubDep.DepartmentFK.ToString();
RadcmbDep.SelectedValue = DepFK;
RadcmbDep.Enabled = true;
//SqlDataSource14.SelectCommand = "SELECT DISTINCT DepartmentFK, DepartmentName, SubDepartmentFK FROM SubDepartments WHERE (DepartmentFK <> 34) AND (DepartmentFK = SubDepartmentFK)";
}
else
RadcmbDep.Enabled = false;
}
protected void JQDPKfactorDate_TextChanged(object sender, EventArgs e)
{
//AgencySearch();
rdbtnClear.Enabled = true;
}
private void SearchRequest(string EorgNo)
{
ObjectParameter output1 = new ObjectParameter("DepFK", typeof(Int32));
ObjectParameter output2 = new ObjectParameter("SubDep", typeof(Int32));
ObjectParameter output3 = new ObjectParameter("EorgNumber", typeof(Char));
ObjectParameter output4 = new ObjectParameter("RequestDate", typeof(DateTime));
ObjectParameter output5 = new ObjectParameter("GoodsTypeFK", typeof(Int32));
ObjectParameter output6 = new ObjectParameter("valid", typeof(Boolean));
DbContext.spPurchaseSearch(EorgNo, null, output1, output2, output3, output4, output5,output6);
RadcmbDep.SelectedValue = output1.Value.ToString();
RadcmbSubDep.SelectedValue = output2.Value.ToString();
RadcmbGoodsType.SelectedValue = output5.Value.ToString();
lblEorgNo0.Visible = true;
lblEorgNo.Text = RadtxtEorgNo.Text;
if (output4.Value != null)
{
JQDPKfromDate.Text = output4.Value.ToString();
}
if (RadtxtEorgNo.Text == "")
{
RadtxtEorgNo.Text = output3.Value.ToString();
}
RadGrid1.Rebind();
RadbtnEdit.Enabled = true;
RadbtnInsert.Enabled = false;
}
protected void RadcmbSubDep_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
}
protected void FillCascadedCombos(string DeptFK)
{
//SqlDataSource15.SelectCommand = "select SubDepartmentFK, SubDepartmentName From SubDepartments WHERE DepartmentFK=" + DeptFK;
}
protected void RadCmbDeptName_OnSelectedIndexChanged(object sender, EventArgs e)
{
// RadComboBox cmb = (RadComboBox)sender;
//FillCascadedCombos(RadcmbDep.SelectedValue);
}
protected void RadCmbSubDeptName_OnSelectedIndexChanged(object sender, EventArgs e)
{
//RadComboBox cmb = (RadComboBox)sender;
}
protected void RadCmbDeptName_OnSelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
//RadComboBox cmb = (RadComboBox)sender;
// FillCascadedCombos(RadcmbDep.SelectedValue);
}
protected void RadCmbSubDeptName_OnSelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
//if (RadcmbGoodsType.SelectedIndex != 4)
//{
RadComboBox cmSubDep = (RadComboBox)sender;
string SubDep = cmSubDep.SelectedValue.ToString();
int SubDepFK = Convert.ToInt32(SubDep); // SubDepartmentFK
SupplierModel.SubDepartment SubDep1 = DbContext.SubDepartments.Where(s => s.DepartmentFK != 34 && s.SubDepartmentFK == SubDepFK).First();
string DepFK = SubDep1.DepartmentFK.ToString();
RadcmbDep.SelectedValue = DepFK;
//}
}
protected void RadGrid1_PreRender1(object sender, EventArgs e)
{
RadcmbGoodsType.DataBind();
}
public void RegisterForEventValidation()
{
//string UniqueID;
}
protected void RadbtnEdit_Click(object sender, EventArgs e)
{
lblAlert1.Visible = false;
lblAlert2.Visible = false;
string Eorg = RadtxtEorgNo.Text;
string Department = RadcmbDep.SelectedValue;
string SubDepartment = RadcmbSubDep.SelectedValue;
int UserFK = MyWebApplication.Sessions.AuthenticatedUser.UserID;
DateTime UseDate = System.DateTime.Now;
int DepFK = Int32.Parse(Department);
int SubDepFK = Int32.Parse(SubDepartment);
string Desc = rdtxtDescription.Text;
string GoodType = RadcmbGoodsType.SelectedValue.ToString();
int GoodsTypeFK = Convert.ToInt32(GoodType);
DbContext.spPurchaseInsert2(JQDPKfromDate.Date, Eorg, DepFK, SubDepFK, 1,GoodsTypeFK,Desc,UserFK,UseDate);
DbContext.SaveChanges();
lblEorgNo0.Visible = true;
lblEorgNo.Text = RadtxtEorgNo.Text;
RadGrid1.Rebind();
//SearchRequest(Eorg);
MessageBoxOK.Show("درخواست با موفقیت ویرایش گردید!");
}
protected void JQDatePicker1_TextChanged(object sender, EventArgs e)
{
//SearchRequest(RadtxtEorgNo.Text);
}
protected void GoodsDetails_TitleRadComboBox_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
{
}
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.EditCommandName)
{
RadGrid1.MasterTableView.IsItemInserted = false;
RadbtnEdit.Enabled = false;
rdbtnClear.Enabled = false;
radbtnSearch.Enabled = false;
//--- VALIDATION ---- \\
//GridEditableItem editItem = (GridEditableItem)e.Item;
//ImageButton updateButton = editItem.FindControl("Update") as ImageButton;
//TextBox FactorNoTextBox = editItem.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
//TextBox FactorAmount = (TextBox)editItem.FindControl("FactorAmountTextBox");
//TextBox FactorPrice = (TextBox)editItem.FindControl("GoodsFactors_PriceTextBox");
//updateButton.Attributes.Add("onclick", "return CheckValidation('" + FactorNoTextBox.ClientID + "');");
//--- END OF VALIDATION ---- \\
//RadComboBox cmb = (RadComboBox)sender;
// GridEditableItem editedItem = sender as GridEditableItem;
//GridEditableItem editedItem = e.Item as GridEditableItem;
//RadComboBox CmbDeptName = editedItem.FindControl("RadCmbDeptName") as RadComboBox;
//RadComboBox CmbSubDeptName = editedItem.FindControl("RadCmbSubDeptName") as RadComboBox;
//string s = CmbDeptName.SelectedValue;
//FillCombo.FillTypeOf(CmbSubDeptName, "SubDepartment", CmbDeptName.SelectedValue);
}
if (e.CommandName == RadGrid.InitInsertCommandName)
{
RadbtnEdit.Enabled = false;
rdbtnClear.Enabled = false;
radbtnSearch.Enabled = false;
RadGrid1.MasterTableView.ClearEditItems();
var masterTableView = RadGrid1.MasterTableView;
var column = masterTableView.GetColumn("EditCommandColumn");
column.HeaderText = "ویرایش";
}
if (e.CommandName == RadGrid.CancelCommandName)
{
ChangeHeader("EditCommandColumn");
RadbtnEdit.Enabled = true;
rdbtnClear.Enabled = true;
radbtnSearch.Enabled = true;
}
if (e.CommandName == RadGrid.UpdateCommandName)
{
//--- VALIDATION ---- \\
Page.ClientScript.RegisterStartupScript(this.GetType(), "Call My Function", "ValueChanged()", true);
//GridEditableItem editItem = (GridEditableItem)e.Item;
//ImageButton updateButton = editItem.FindControl("Update") as ImageButton;
//TextBox FactorNoTextBox = editItem.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
//TextBox FactorAmount = (TextBox)editItem.FindControl("FactorAmountTextBox");
//TextBox FactorPrice = (TextBox)editItem.FindControl("GoodsFactors_PriceTextBox");
//updateButton.Attributes.Add("onclick", "return CheckValidation('" + FactorNoTextBox.ClientID + "');");
//--- END OF VALIDATION ---- \\
}
}
private void ChangeHeader(string ColName)
{
var masterTableView = RadGrid1.MasterTableView;
var column = masterTableView.GetColumn("EditCommandColumn");
column.HeaderText = "ویرایش";
}
protected void rdbtnClear_Click(object sender, EventArgs e)
{
Clear();
}
public void Clear()
{
lblEorgNo.Visible = false;
lblEorgNo.Text = "";
lblEorgNo0.Visible = false;
RadtxtEorgNo.Text = "";
RadcmbDep.SelectedIndex = 0;
RadcmbSubDep.SelectedIndex = 0;
RadcmbGoodsType.SelectedIndex = 0;
JQDPKfromDate.Text = null;
RadbtnEdit.Enabled = false;
RadbtnInsert.Enabled = true;
rdbtnClear.Enabled = false;
RadGrid1.Rebind();
rdtxtDescription.Text = "";
}
public void Fill()
{
string eorg = RadtxtEorgNo.Text;
ObjectParameter output1 = new ObjectParameter("DepFK", typeof(Int32));
ObjectParameter output2 = new ObjectParameter("SubDep", typeof(Int32));
ObjectParameter output3 = new ObjectParameter("EorgNumber", typeof(Char));
ObjectParameter output4 = new ObjectParameter("RequestDate", typeof(DateTime));
ObjectParameter output5 = new ObjectParameter("GoodsTypeFK", typeof(Int32));
ObjectParameter output6 = new ObjectParameter("valid", typeof(Boolean));
DbContext.spPurchaseSearch(RadtxtEorgNo.Text, RadtxtEorgNo0.Text, output1, output2, output3, output4, output5,output6);
SupplierModel.Purchase pur = DbContext.Purchases.Where(p => p.Purchase_EorgNo == eorg).First();
RadcmbDep.SelectedValue = output1.Value.ToString();
RadcmbDep.SelectedValue = pur.Purchase_ReqSubDepartmentFK.ToString();
RadcmbSubDep.SelectedValue = output2.Value.ToString();
RadcmbGoodsType.SelectedValue = output5.Value.ToString();
rdtxtDescription.Text = pur.Purchase_Description;
if (output4.Value != null)
{
JQDPKfromDate.Date = pur.Purchase_Date;
}
}
protected void RadtxtEorgNo_TextChanged(object sender, EventArgs e)
{
rdbtnClear.Enabled = true;
}
protected void rdtxtDescription_TextChanged(object sender, EventArgs e)
{
rdbtnClear.Enabled = true;
}
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
if (args.Value.ToString() != "")
{
}
}
protected void CustomValidator2_ServerValidate(object source, ServerValidateEventArgs args)
{
//GridEditableItem item = source.
//TextBox txtFacAmount = this.RadGrid1.FindControl("FactorAmountTextBox") as TextBox;
//TextBox txtFactorNo = this.RadGrid1.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
//if (args.Value.Length > 2)
//{
// args.IsValid = true;
//}
//else
// args.IsValid = false;
}
protected void GoodsFactors_FactorNoTextBox_TextChanged(object sender, EventArgs e)
{
//return "ValueChanged();";
//GridEditableItem edititem = e.item as GridEditableItem;
//TextBox txtFactorNo=RadGrid1.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
//Page.ClientScript.RegisterStartupScript(this.GetType(), "Call My Function", "CheckValidation('" + txtFactorNo.ClientID + "');",true);
}
}
Thank you for reply to this problem.
I had this problem in my project. So I used your code in it but it does not work correctly.
I have a template field in radgrid (GoodsFactors_FactorNoTextBox) that is not forced to be filled. But in the case that it has a value, then some other fields such as FactorAmountTextBox should be filled(need required field validator to set enabled).
I used your codes in my form but in edit and insert mode of grid, the validator doesn't fire.
I put my codes here. Would you plz check it and tell me what's wrong?
Thanks a lot.
Purchase.aspx
<%@ Page Title="خرید" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
ViewStateMode="Enabled" Inherits="Forms_PurchaseRequest" CodeBehind="PurchaseRequest.aspx.cs" %>
<%--<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">--%>
<asp:Content ID="Content2" ContentPlaceHolderID="cphMain" runat="Server">
<style type="text/css">
.style24
{
width: 1407px;
}
.style31
{
height: 13px;
}
.headerStyle1
{
background-image: none;
background-color: Green;
}
div.RadGrid .specificHeader
{
background-image: none;
background: #80BFBF;
}
div.RadGrid .specificHeader2
{
background-image: none;
background: #DFBFFF;
}
div.RadGrid .specificHeader3
{
background-image: none;
background: #E7D9FF;
}
div.RadGrid .specificHeader4
{
background-image: none;
background: #D2F4FF;
}
div.RadGrid .specificHeader5
{
background-image: none;
background: #FFF2E6;
}
.style49
{
width: 108px;
height: 25px;
}
.style56
{
width: 108px;
height: 24px;
}
.style59
{
height: 25px;
}
.style60
{
width: 134px;
}
.style61
{
width: 134px;
height: 25px;
}
.style62
{
width: 203px;
}
.style63
{
height: 25px;
width: 203px;
}
.style64
{
width: 134px;
height: 24px;
}
.style65
{
width: 203px;
height: 24px;
}
.style66
{
height: 24px;
}
</style>
<jq:JQLoader ID="JQLoader1" runat="server" />
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
//var myPicker = myArray[0];
function RowDblClick(sender, eventArgs) {
sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
}
function gridRowLeave(sender, eventArgs) {
}
function gridCreated(sender, args) {
// if (sender.get_editIndexes && sender.get_editIndexes().length > 0) {
// document.getElementById("OutPut").innerHTML = sender.get_editIndexes().join();
// }
// else {
// document.getElementById("OutPut").innerHTML = "";
// }
}
// function CheckValidation(txt1ID) {
// var txt1 = document.getElementById(txt1ID);
// var txt2 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "FactorAmountTextBox"));
// //var txt3 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "GoodsFactors_PriceTextBox"));
// //var v1 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "rfv0"));
// var v2 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "rfv5"));
// //var v3 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "rfv7"));
// if ((txt1.value != null && txt1.value != '0') && txt1.value.length > 0) {
// if (txt2.value == null) {
// //ValidatorEnable(v1, true);
// ValidatorEnable(v2, true);
// //ValidatorEnable(v3, true);
// }
// }
// else {
// //ValidatorEnable(v1, false);
// ValidatorEnable(v2, false);
// //ValidatorEnable(v3, false);
// }
// }
function ValueChanged(index) {
var grid = $find("<%=RadGrid1.ClientID %>"); //grid id
if (grid) {
var MasterTable = grid.get_masterTableView();
var Row = MasterTable.get_dataItems()[index];
var txtFacNo = Row.findElement("GoodsFactors_FactorNoTextBox"); //gridcolumns
var rfvAmount = Row.findElement("rfv5"); //required validator
if (txtFacNo.value != null && txtFacNo.value != '0') {
//ValidatorEnable(rfvAmount,true);
rfvAmount.disabled = false;
}
else {
rfvAmount.disabled = true;
}
}
}
</script>
<script type="text/javascript">
function CheckValidation(txt1ID) {
var txt1 = document.getElementById(txt1ID);
var txt2 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "FactorAmountTextBox"));
//var txt3 = document.getElementById(txt1ID.replace("TextBox1", "TextBox12"));
var v1 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "RequiredFieldValidator1"));
var v2 = document.getElementById(txt1ID.replace("GoodsFactors_FactorNoTextBox", "RequiredFieldValidator2"));
//var v3 = document.getElementById(txt1ID.replace("TextBox1", "RequiredFieldValidator3"));
if ((txt1.value != null && txt1.value.length > 0)){ //&& (txt2.value==null || txt2.value=='0')){ //|| (txt2.value != null && txt2.value.length > 0)) {
ValidatorEnable(v1, true);
ValidatorEnable(v2, true);
// ValidatorEnable(v3, true);
}
else {
ValidatorEnable(v1, false);
ValidatorEnable(v2, false);
// ValidatorEnable(v3, false);
}
}
</script>
</telerik:RadCodeBlock>
<telerik:RadAjaxManager ID="AjaxManager1" runat="server" EnableAJAX="true">
<AjaxSettings>
<%-- <telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="RadWindowsManager1" />
</UpdatedControls>
</telerik:AjaxSetting>--%>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
</telerik:RadAjaxLoadingPanel>
<%-- <telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="RadWindowsManager1" />
</UpdatedControls>
</telerik:AjaxSetting>--%>
<table>
<tr>
<td align="center" class="style24">
<%-- <telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="RadWindowsManager1" />
</UpdatedControls>
</telerik:AjaxSetting>--%>
<div style="margin: 0 auto; direction: rtl;">
<table style="direction: rtl; vertical-align: baseline; border-right-style: hidden; background-color: #FFF2E6;"
frame="vsides" align="right" width="100%">
<tr>
<td dir="rtl" align="right" class="style31"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6; background-color: #FFD8B0"
colspan="4">
<asp:Label ID="Label13" runat="server" Font-Bold="True" ForeColor="#CC3300" Text="مشخصات درخواست"></asp:Label>
<asp:Label ID="lblFactorNo" runat="server" Text="شماره فاکتور" Font-Bold="True" Visible="False"></asp:Label>
<telerik:RadTextBox ID="RadtxtEorgNo0" runat="server" Visible="False">
<PasswordStrengthSettings CalculationWeightings="50;15;15;20" IndicatorElementBaseStyle="riStrengthBar"
IndicatorElementID="" MinimumLowerCaseCharacters="2" MinimumNumericCharacters="2"
MinimumSymbolCharacters="2" MinimumUpperCaseCharacters="2" OnClientPasswordStrengthCalculating=""
PreferredPasswordLength="10" RequiresUpperAndLowerCaseCharacters="True" ShowIndicator="False"
TextStrengthDescriptions="Very Weak;Weak;Medium;Strong;Very Strong" TextStrengthDescriptionStyles="riStrengthBarL0;riStrengthBarL1;riStrengthBarL2;riStrengthBarL3;riStrengthBarL4;riStrengthBarL5;" />
</telerik:RadTextBox>
</td>
</tr>
<tr>
<td dir="rtl" align="left" class="style64"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;">
<asp:Label ID="Label1" runat="server" Text="شماره EORG" Font-Bold="True"
Font-Size="Smaller"></asp:Label>
</td>
<td dir="rtl" align="right"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;"
class="style65">
<telerik:RadTextBox ID="RadtxtEorgNo" runat="server" Width="100px"
ValidationGroup="lookup" ontextchanged="RadtxtEorgNo_TextChanged">
<PasswordStrengthSettings CalculationWeightings="50;15;15;20" IndicatorElementBaseStyle="riStrengthBar"
IndicatorElementID="" MinimumLowerCaseCharacters="2" MinimumNumericCharacters="2"
MinimumSymbolCharacters="2" MinimumUpperCaseCharacters="2" OnClientPasswordStrengthCalculating=""
PreferredPasswordLength="10" RequiresUpperAndLowerCaseCharacters="True" ShowIndicator="False"
TextStrengthDescriptions="Very Weak;Weak;Medium;Strong;Very Strong" TextStrengthDescriptionStyles="riStrengthBarL0;riStrengthBarL1;riStrengthBarL2;riStrengthBarL3;riStrengthBarL4;riStrengthBarL5;" />
</telerik:RadTextBox>
<asp:Label ID="lblAlert1" runat="server" Font-Bold="True" ForeColor="#FF0066"
Text="*" Visible="False" Font-Size="Large"></asp:Label>
<br />
</td>
<td dir="rtl" align="left" class="style56"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;">
<asp:Label ID="Label4" runat="server" Text="تاريخ درخواست" Font-Size="Smaller"></asp:Label>
</td>
<td dir="rtl" align="right"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;"
valign="top" class="style66">
<jq:JQDatePicker ID="JQDPKfromDate" runat="server" Regional="fa" DateFormat="YMD"
AnimationType="Default" WeekHeader="sauterday"
OnTextChanged="JQDPKfactorDate_TextChanged" Font-Overline="False"></jq:JQDatePicker>
<asp:Label ID="lblAlert2" runat="server" Font-Bold="True" ForeColor="#FF0066"
Text="*" Visible="False" Font-Size="Large"></asp:Label>
</td>
</tr>
<tr>
<td dir="rtl" align="left" class="style60"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;">
<asp:Label ID="Label2" runat="server" Text="معاونت درخواست كننده"
Font-Size="Smaller"></asp:Label>
</td>
<td dir="rtl" align="right"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;"
class="style62">
<telerik:RadComboBox ID="RadcmbDep" runat="server" Width="166px" AutoPostBack="True"
DataSourceID="SqlDataSource14" OnSelectedIndexChanged="RadCmbDeptName_OnSelectedIndexChanged"
DataTextField="DepartmentName" DataValueField="DepartmentFK"
>
</telerik:RadComboBox>
</td>
<td dir="rtl" align="left" class="style49"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;">
<asp:Label ID="Label5" runat="server" Text="واحد استفاده كننده" Font-Size="Smaller"
></asp:Label>
</td>
<td dir="rtl" align="right"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;">
<telerik:RadComboBox ID="RadcmbSubDep" runat="server" AutoPostBack="true" OnSelectedIndexChanged="RadCmbSubDeptName_OnSelectedIndexChanged"
Width="164px" DataSourceID="SqlDataSource15" DataTextField="SubDepartmentName"
DataValueField="SubDepartmentFK">
</telerik:RadComboBox>
</td>
</tr>
<tr>
<td dir="rtl" align="left" class="style61"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;"
valign="top">
<asp:Label ID="Label3" runat="server" Text="طبقه بندي كالا" Font-Size="Smaller"></asp:Label>
</td>
<td dir="rtl" align="right" class="style63"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;"
valign="top">
<telerik:RadComboBox ID="RadcmbGoodsType" runat="server" OnSelectedIndexChanged="RadcmbGoodsType_SelectedIndexChanged"
AutoPostBack="True">
</telerik:RadComboBox>
<br />
<br />
</td>
<td dir="rtl" align="left" class="style59"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;"
valign="top">
<asp:Label ID="lblDescription" runat="server" Text="توضیحات"
Font-Size="Smaller"></asp:Label>
</td>
<td dir="rtl" align="right" class="style59"
style="border-style: hidden; border-width: inherit; border-color: #FFF2E6;"
valign="top">
<telerik:RadTextBox ID="rdtxtDescription" Runat="server" TextMode="MultiLine"
Width="280px" ontextchanged="rdtxtDescription_TextChanged">
</telerik:RadTextBox>
<telerik:RadButton ID="RadbtnInsert" runat="server" Skin="Sunset" Text="ثبت درخواست"
OnClick="RadButton1_Click" ValidationGroup="savemode">
</telerik:RadButton>
<telerik:RadButton ID="radbtnSearch" runat="server"
OnClick="RadbtnSearch_Click" Text="جستجو"
BackColor="#9999FF" Skin="Web20" ValidationGroup="searchmode">
</telerik:RadButton>
<telerik:RadButton ID="RadbtnEdit" runat="server" Skin="Sunset" Text="ویرایش" OnClick="RadbtnEdit_Click">
</telerik:RadButton>
<telerik:RadButton ID="rdbtnClear" runat="server" OnClick="rdbtnClear_Click" Text="پاک کن">
</telerik:RadButton>
</td>
</tr>
</table>
<asp:Panel ID="pnlGrid1" runat="server" ScrollBars="Both" Width="100%">
<table width="100%">
<tr>
<td align="center" dir="rtl" lang="fa" style="background-color: #FFD8B0">
<asp:Label ID="lblEorgNo0" runat="server" Font-Bold="True" ForeColor="#990000">درخواست شماره</asp:Label>
<asp:Label ID="lblEorgNo" runat="server" Font-Bold="True" ForeColor="#990000"></asp:Label>
<br />
</td>
</tr>
<tr>
<td align="center" dir="rtl" lang="fa" style="background-color: #FFD8B0">
<asp:ValidationSummary ID="vls1" runat="server" BackColor="#CCFFFF"
Font-Italic="True" Font-Names="Tahoma" HeaderText="موارد زیر را درج نمایید:"
Height="166px" ValidationGroup="request" Width="306px" Font-Bold="True" />
</td>
</tr>
</table>
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"
CellSpacing="0" GridLines="None" OnDeleteCommand="RadGrid1_DeleteCommand1" OnInsertCommand="RadGrid1_InsertCommand1"
OnItemCreated="RadGrid1_ItemCreated" OnItemDataBound="RadGrid1_ItemDataBound"
OnItemDeleted="RadGrid1_ItemDeleted1"
OnItemUpdated="RadGrid1_ItemUpdated1" OnNeedDataSource="RadGrid1_NeedDataSource1"
OnPreRender="RadGrid1_PreRender1"
OnUpdateCommand="RadGrid1_UpdateCommand1" Width="100%"
OnItemCommand="RadGrid1_ItemCommand" Skin="Vista">
<ValidationSettings ValidationGroup="request" />
<ClientSettings AllowColumnsReorder="True" EnableRowHoverStyle="True"
ReorderColumnsOnClient="True">
</ClientSettings>
<MasterTableView AllowAutomaticUpdates="false" CommandItemDisplay="TopAndBottom"
CommandItemSettings-AddNewRecordText="اضافه نمودن سطر جدید" CommandItemSettings-RefreshText="بروز رسانی"
DataKeyNames="GoodsFactors_ID">
<CommandItemSettings ExportToCsvImageUrl="mvwres://Telerik.Web.UI, Version=2011.2.712.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.ExportToCsv.gif"
ExportToExcelImageUrl="mvwres://Telerik.Web.UI, Version=2011.2.712.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.ExportToExcel.gif"
ExportToPdfImageUrl="mvwres://Telerik.Web.UI, Version=2011.2.712.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.ExportToPdf.gif"
ExportToPdfText="Export to PDF" ExportToWordImageUrl="mvwres://Telerik.Web.UI, Version=2011.2.712.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Default.Grid.ExportToWord.gif" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
</ExpandCollapseColumn>
<Columns>
<telerik:GridTemplateColumn FooterText="" HeaderText="ردیف">
<ItemTemplate>
<%# Container.DataSetIndex + 1 %>
</ItemTemplate>
<ItemStyle Width="10px" />
<HeaderStyle Width="10px" />
<FooterStyle Width="10px" />
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="GoodsFactors_ID" DataType="System.Int32" FilterControlAltText="Filter GoodsFactors_PurchaseFK column"
HeaderText="GoodsFactors_PurchaseFK" SortExpression="GoodsFactors_ID" UniqueName="GoodsFactors_ID"
Visible="False">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="Purchase_EorgNo" FilterControlAltText="Filter Purchase_EorgNo column"
HeaderText="شماره EORG" SortExpression="Purchase_EorgNo" UniqueName="Purchase_EorgNo"
Visible="False">
<EditItemTemplate>
<asp:TextBox ID="Purchase_EorgNoTextBox" runat="server" Text='<%# Bind("Purchase_EorgNo") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Purchase_EorgNoLabel" runat="server" Text='<%# Eval("Purchase_EorgNo") %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="GoodsDetails_Title" FilterControlAltText="Filter column2 column"
HeaderText="نام کالا" UniqueName="column2">
<EditItemTemplate>
<telerik:RadComboBox ID="GoodsDetails_TitleRadComboBox" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource3" DataTextField="GoodsDetails_Title" DataValueField="GoodsDetails_ID"
ExpandDirection="Up" OnItemDataBound="GoodsDetails_TitleRadComboBox_ItemDataBound"
Style="margin-left: 0px; margin-bottom: 4px" Width="105px"
AppendDataBoundItems="True" ValidationGroup="request">
</telerik:RadComboBox>
<asp:RequiredFieldValidator ID="rfv1" runat="server"
ControlToValidate="GoodsDetails_TitleRadComboBox" Display="Dynamic"
ErrorMessage="نام کالا" Font-Bold="True" Font-Italic="True"
ForeColor="Red" SetFocusOnError="True" ValidationGroup="request"
Font-Size="Large">*</asp:RequiredFieldValidator>
<br />
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="GoodsDetails_TitleLabel" runat="server" Text='<%# Eval("GoodsDetails_Title") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader5" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="RequestAmount" DataType="System.Int32" FilterControlAltText="Filter GoodsFactors_PurchasedCountOrAmount column"
HeaderText="تعداد درخواستی" SortExpression="RequestAmount" UniqueName="GoodsFactors_PurchasedCountOrAmount">
<EditItemTemplate>
<asp:TextBox ID="RequestAmountTextBox" runat="server"
Text='<%# Bind("RequestAmount") %>' Width="71px"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfv2" runat="server"
ControlToValidate="RequestAmountTextBox" Display="Dynamic"
ErrorMessage="تعداد درخواستی" Font-Bold="True" Font-Italic="True" ForeColor="Red"
ValidationGroup="request" Font-Size="Large">*</asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="RequestAmountLabel" runat="server" Text='<%# Eval("RequestAmount") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader5" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="ReqUnit" FilterControlAltText="Filter column column"
HeaderText="واحد شمارش" UniqueName="column">
<EditItemTemplate>
<telerik:RadComboBox ID="RadComboBox3" runat="server" DataSourceID="SqlDataSource12"
DataTextField="Units_Title" DataValueField="Units_ID"
AppendDataBoundItems="True" Width="104px">
</telerik:RadComboBox>
<asp:RequiredFieldValidator ID="rvf3" runat="server"
ControlToValidate="RadComboBox3" Display="Dynamic" ErrorMessage="واحد شمارش"
Font-Bold="True" Font-Italic="True" ForeColor="Red"
ValidationGroup="request" Font-Size="Large">*</asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="RequestUnitLabel" runat="server" Text='<%# Eval("ReqUnit") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader5" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="GoodsFactors_FactorNo" FilterControlAltText="Filter GoodsFactors_FactorNo column"
HeaderText="شماره فاکتور" SortExpression="GoodsFactors_FactorNo" UniqueName="GoodsFactors_FactorNo">
<EditItemTemplate>
<asp:TextBox ID="GoodsFactors_FactorNoTextBox" runat="server"
Text='<%# Bind("GoodsFactors_FactorNo") %>' Width="80px"
AutoPostBack="True"
ontextchanged="GoodsFactors_FactorNoTextBox_TextChanged"></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="GoodsFactors_FactorNoTextBox" ID="RequiredFieldValidator1"
runat="server" ErrorMessage="*" Enabled="false" ValidationGroup="request"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Must be a number"
ToolTip="Numbers Only" ValidationExpression="\d+" ControlToValidate="GoodsFactors_FactorNoTextBox"></asp:RegularExpressionValidator>
<%-- <asp:CustomValidator ID="CustomValidator1" runat="server"
ControlToValidate="GoodsFactors_FactorNoTextBox"
onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>--%>
<%--<asp:RequiredFieldValidator ID="rfv0" runat="server" Display="None"
Enabled="False" ErrorMessage="شماره فاکتور"
ControlToValidate="GoodsFactors_FactorNoTextBox" ValidationGroup="request">*</asp:RequiredFieldValidator>--%>
<%--<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="GoodsFactors_FactorNoTextBox" ErrorMessage="تست"></asp:RegularExpressionValidator>--%>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="GoodsFactors_FactorNoLabel" runat="server" Text='<%# Eval("GoodsFactors_FactorNo") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader4" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="GoodsFactors_FactorDate" FilterControlAltText="Filter GoodsFactors_FactorDate column"
HeaderStyle-CssClass="specificHeader3" HeaderText="تاریخ فاکتور" SortExpression="GoodsFactors_FactorDate"
UniqueName="GoodsFactors_FactorDate">
<EditItemTemplate>
<jq:JQDatePicker ID="JQDatePicker1" runat="server" AnimationType="Default" DateFormat="YMD"
Enabled="true" OnTextChanged="JQDatePicker1_TextChanged" Regional="fa" WeekHeader="sauterday"
Width="70px"></jq:JQDatePicker>
<%--<asp:RequiredFieldValidator ID="rfv4" runat="server"
ControlToValidate="JQDatePicker1" Display="Dynamic" ErrorMessage="تاریخ فاکتور"
Font-Bold="True" Font-Size="Large" ForeColor="Red" ValidationGroup="request">*</asp:RequiredFieldValidator>--%>
</EditItemTemplate>
<ItemTemplate>
<jq:JQDatePicker ID="JQDatePicker2" runat="server" AnimationType="Default" Date='<%#Eval("GoodsFactors_FactorDate") %>'
DateFormat="YMD" Enabled="false" ForeColor="DarkBlue" Regional="fa" WeekHeader="sauterday"
Width="70px"></jq:JQDatePicker>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader4" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="FactorAmount" DataType="System.Int32" FilterControlAltText="Filter GoodsFactors_FactorCountOrAmount column"
HeaderText="تعداد خریداری شده" SortExpression="FactorAmount" UniqueName="GoodsFactors_FactorCountOrAmount">
<EditItemTemplate>
<asp:TextBox ID="FactorAmountTextBox" runat="server"
Text='<%# Bind("FactorAmount") %>' Width="71px" AutoPostBack="True" ></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="FactorAmountTextBox" ID="RequiredFieldValidator2"
runat="server" ErrorMessage="*" Enabled="false" ValidationGroup="request"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Must be a number"
ToolTip="Numbers Only" ValidationExpression="\d+" ControlToValidate="FactorAmountTextBox"></asp:RegularExpressionValidator>
<%-- <asp:RequiredFieldValidator ID="rfv5" runat="server"
ControlToValidate="FactorAmountTextBox"
ErrorMessage="تعداد خریداری شده" Font-Size="Large" ForeColor="Red"
ValidationGroup="request" Display="Dynamic" Enabled="False">*</asp:RequiredFieldValidator>--%>
<%--<asp:CustomValidator ID="CustomValidator2" runat="server"
ControlToValidate="FactorAmountTextBox" Display="Dynamic"
ErrorMessage="درج تعداد الزامیست"
onservervalidate="CustomValidator2_ServerValidate"
ValidationGroup="request">*</asp:CustomValidator>--%>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="FactorAmountLabel" runat="server" Text='<%# Eval("FactorAmount") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader4" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="FactorUnit" FilterControlAltText="Filter column3 column"
HeaderText="واحد شمارش" UniqueName="column3">
<EditItemTemplate>
<telerik:RadComboBox ID="RadComboBox2" runat="server" DataSourceID="SqlDataSource12"
DataTextField="Units_Title" DataValueField="Units_ID"
AppendDataBoundItems="True" Width="80px">
</telerik:RadComboBox>
<%--<asp:RequiredFieldValidator ID="rfv6" runat="server"
ControlToValidate="RadComboBox2" Display="Dynamic"
ErrorMessage="واحد شمارش(فاکتور)" Font-Size="Large" ForeColor="Red"
ValidationGroup="request">*</asp:RequiredFieldValidator>--%>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="FactorUnitLabel" runat="server" Text='<%# Eval("FactorUnit") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader4" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="GoodsFactors_Price" DataType="System.Double"
FilterControlAltText="Filter GoodsFactors_Price column" HeaderText="قیمت واحد"
SortExpression="GoodsFactors_Price" UniqueName="GoodsFactors_Price">
<EditItemTemplate>
<asp:TextBox ID="GoodsFactors_PriceTextBox" runat="server"
Text='<%# Bind("GoodsFactors_Price") %>' Width="58px"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfv7" runat="server"
ControlToValidate="GoodsFactors_PriceTextBox" Display="None"
ErrorMessage="قیمت واحد" Font-Size="Large" ForeColor="Red"
ValidationGroup="request" Enabled="False">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server"
ControlToValidate="GoodsFactors_PriceTextBox" ErrorMessage="تست3"></asp:RegularExpressionValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="GoodsFactors_PriceLabel" runat="server" Text='<%# Eval("GoodsFactors_Price") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader4" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="GoodsFactors_TotalPrice" DataType="System.Double"
FilterControlAltText="Filter GoodsFactors_TotalPrice column" HeaderText="قیمت کل"
SortExpression="GoodsFactors_TotalPrice" UniqueName="GoodsFactors_TotalPrice">
<EditItemTemplate>
<asp:TextBox ID="GoodsFactors_TotalPriceTextBox" runat="server"
Text='<%# Bind("GoodsFactors_TotalPrice") %>' Width="84px"></asp:TextBox>
<%--<asp:RequiredFieldValidator ID="rfv8" runat="server"
ControlToValidate="GoodsFactors_TotalPriceTextBox" Display="Dynamic"
ErrorMessage="قیمت کل" Font-Size="Large" ForeColor="Red"
ValidationGroup="request">*</asp:RequiredFieldValidator>--%>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="GoodsFactors_TotalPriceLabel" runat="server" Text='<%# Eval("GoodsFactors_TotalPrice") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader4" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn DataField="Stores_Name" FilterControlAltText="Filter column4 column"
HeaderText="فروشگاه" UniqueName="Stores">
<EditItemTemplate>
<telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource11"
DataTextField="Stores_Name" DataValueField="Stores_ID"
AppendDataBoundItems="True" Width="99px">
</telerik:RadComboBox>
<%--<asp:RequiredFieldValidator ID="rfv9" runat="server"
ControlToValidate="RadComboBox1" Display="Dynamic"
ErrorMessage="نام فروشگاه" Font-Size="Large" ForeColor="Red"
ValidationGroup="request">*</asp:RequiredFieldValidator>--%>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Stores_NameLabel" runat="server" Text='<%# Eval("Stores_Name") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle CssClass="specificHeader4" />
</telerik:GridTemplateColumn>
<telerik:GridEditCommandColumn ButtonType="ImageButton" FooterStyle-Width="60px"
HeaderStyle-Width="60px" HeaderText="ویرایش" ItemStyle-Width="60px" UniqueName="EditCommandColumn">
<FooterStyle Width="60px" />
<HeaderStyle Width="60px" />
<ItemStyle CssClass="MyImageButton" HorizontalAlign="Center" />
</telerik:GridEditCommandColumn>
<telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmDialogType="Classic"
ConfirmText="آیا مطمئن هستید؟" ConfirmTitle="حذف" FooterStyle-Width="40px" HeaderStyle-Width="40px"
HeaderText="حذف" ItemStyle-Width="40px" Text="حذف" UniqueName="DeleteColumn">
<FooterStyle Width="40px" />
<HeaderStyle Width="40px" />
<ItemStyle CssClass="MyImageButton" HorizontalAlign="Center" />
</telerik:GridButtonColumn>
</Columns>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<FilterMenu EnableImageSprites="False">
</FilterMenu>
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
</HeaderContextMenu>
</telerik:RadGrid>
<br />
<telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server" TextBoxStyle-Width="30px">
</telerik:GridTextBoxColumnEditor>
<telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server" NumericTextBox-Width="40px"
NumericTextBox-DataType="Number" NumericTextBox-NumberFormat-DecimalDigits="0">
</telerik:GridNumericColumnEditor>
<telerik:GridNumericColumnEditor ID="GridNumericColumnEditor2" runat="server" NumericTextBox-Width="30px"
NumericTextBox-DataType="Number" NumericTextBox-NumberFormat-DecimalDigits="0">
</telerik:GridNumericColumnEditor>
<telerik:GridDropDownListColumnEditor ID="GridDropDownListColumnEditor1" runat="server"
DropDownStyle-Width="80px" DropDownStyle-CssClass="radDDLFarsi">
</telerik:GridDropDownListColumnEditor>
<telerik:GridDropDownListColumnEditor ID="GridDropDownListColumnEditor2" runat="server"
DropDownStyle-Width="80px" DropDownStyle-CssClass="radDDLFarsi">
</telerik:GridDropDownListColumnEditor>
</asp:Panel>
</div>
</td>
</tr>
</table>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
</telerik:RadWindowManager>
<asp:RequiredFieldValidator ID="rfvEorg" runat="server"
ControlToValidate="RadtxtEorgNo"
Display="Dynamic" Font-Bold="False"
Font-Italic="True" Font-Size="X-Small" ForeColor="#CC33FF"
SetFocusOnError="True" ValidationGroup="searchmode"
ErrorMessage="شماره درخواست را وارد نمایید!"
Enabled="False" Visible="False"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="rfvEorg1" runat="server"
ControlToValidate="RadtxtEorgNo"
Display="Dynamic" Font-Bold="False"
Font-Italic="True" Font-Size="X-Small" ForeColor="#CC33FF"
SetFocusOnError="True" ValidationGroup="savemode"
ErrorMessage="شماره درخواست را وارد نمایید!"
Enabled="False" Visible="False"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="rfvDate" runat="server"
ControlToValidate="JQDPKfromDate" Display="Dynamic"
ErrorMessage="تاریخ را وارد نمایید!"
Font-Italic="True" Font-Size="X-Small"
ForeColor="#CC33FF" ValidationGroup="savemode"
Enabled="False" Visible="False"></asp:RequiredFieldValidator>
<asp:SqlDataSource ID="SqlDataS" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT [GoodsFactors_FactorDate], [GoodsFactors_FactorNo], [GoodsFactors_ID] FROM [GoodsFactors]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT [GoodsType_ID], [GoodsType_Title] FROM [GoodsType]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT [GoodsDetails_ID], [GoodsDetails_Title] FROM [GoodsDetails]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT [Units_ID], [Units_Title] FROM [Units]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource6" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource7" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource8" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource15" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT MyKey, SubDepartmentFK, SubDepartmentName, DepartmentFK FROM SubDepartments WHERE (SubDepartmentFK <> 34)">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource9" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
ProviderName="System.Data.SqlClient"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource11" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT [Stores_ID], [Stores_Name] FROM [Stores]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource14" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT DISTINCT DepartmentFK, DepartmentName, SubDepartmentFK FROM SubDepartments WHERE (DepartmentFK <> 34) AND (DepartmentFK = SubDepartmentFK)">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource12" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT [Units_ID], [Units_Title] FROM [Units]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource13" runat="server" ConnectionString="<%$ ConnectionStrings:SupplierConnectionString %>"
SelectCommand="SELECT GoodsDetails_Title, GoodsType_ID, GoodsDetails_ID FROM View_GoodsDetail WHERE (GoodsType_ID = @TypeFK)">
<SelectParameters>
<asp:ControlParameter ControlID="RadcmbGoodsType" Name="TypeFK" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
</asp:Content>
Purchase.aspx.cs
using System;
using System.Data;
using System.Data.Objects;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Linq;
using System.Drawing;
using Telerik.Web.UI;
using System.Data.SqlClient;
using JQControls;
using System.Collections;
public partial class Forms_PurchaseRequest : System.Web.UI.Page
{
public SupplierModel.AppSupplierEntities DbContext = new SupplierModel.AppSupplierEntities();
private string npgridMessage = null;
private string nlgridMessage = null;
protected void Page_Load(object sender, EventArgs e)
{
// RadGrdRequestPurchase.MasterTableView.EditMode = GridEditMode.InPlace;
RadGrid1.MasterTableView.EditMode = GridEditMode.InPlace;
//RadGrdNewsPaper.MasterTableView.EditMode = GridEditMode.InPlace;
//SqlDataSource1.SelectCommand = "select NewsPaperNames_ID,NewsPaperNames_Name from NewsPaperNames ";
//SqlDataSource2.SelectCommand = "select Mykey, Name From View_JustLocalDepartments";
SqlDataSource2.SelectCommand = "SELECT GoodsType_ID,GoodsType_Title FROM GoodsType";// نوع كالا
//SqlDataSource3.SelectCommand = "Select GoodsDetails_ID, GoodsDetails_Title from View_GoodsName";// نام كالا
SqlDataSource4.SelectCommand = "Select GoodsFactors_PurchasedCountOrAmount from GoodsFactors";//تعداد درخواستي
//SqlDataSource5.SelectCommand = "Select Units_ID , Units_Title from Units"; // واحد شمارش
SqlDataSource6.SelectCommand = "Select GoodsFactor_ID,GoodsFactor_FactorNo from GoodsFactors";//شماره فاكتور
SqlDataSource7.SelectCommand = "Select GoodsFactor_FactorDate from GoodsFactors";// تاريخ فاكتور
SqlDataSource8.SelectCommand = "Select Stores_ID, Stores_Name from Stores";// نام فروشگاه
SqlDataSource9.SelectCommand= "select Mykey, Name From View_JustLocalDepartments";
//SqlDataSource14.SelectCommand = DataLayer.frmAgency.sdsJustLocalDepartments;
// SqlDataSource15.SelectCommand = DataLayer.frmAgency.sdsSubDepartments("1");
if (Page.IsPostBack == false)
{
Initialize();
updateDatePickerSettings();
}
}
private void Initialize()
{
FillCombo.FillTypeOf(RadcmbGoodsType, "GoodsCategory", null);
//RadcmbDep.AppendDataBoundItems = true;
//RadcmbDep.Items.Add(new RadComboBoxItem(" ","-1"));
//FillCombo.FillTypeOf(RadcmbDep, "LocalDepartments", null);
//FillCombo.FillTypeOf(RadcmbSubDep, "SubDepartmentAll", null);
RadcmbDep.Enabled = false;
string EorgNo = RadtxtEorgNo.Text;
string FactorNo = RadtxtEorgNo0.Text;
//RadGrdRequestPurchase.DataSource = DbContext.spPurchaseSelect();
//RadGrid1.DataSource = DbContext.spPurchaseSelect(EorgNo);
lblEorgNo0.Visible = false;
RadbtnEdit.Enabled = false;
rdbtnClear.Enabled = false;
int GoodsTypeFK = Convert.ToInt32(RadcmbGoodsType.SelectedValue.ToString());
SqlDataSource3.SelectCommand = "SELECT GoodsDetails_ID, GoodsDetails_Title FROM GoodsDetails where GoodsDetails_GoodsTypeFK=" + GoodsTypeFK;
// RadGrdRequestPurchase.DataSource = DbContext.spPurchaseSelect(EorgNo,FactorNo);
// MultiView1.ActiveViewIndex = -1;
}
protected void updateDatePickerSettings()
{
JQLoader1.Theme = JQTheme.UILightness;
JQDatePicker jqd = ((JQDatePicker)(this.FindControl("ctl00$cphMain$RadGrid1$ctl00$ctl04$JQDatePicker1")));
}
private void DisplayNewspaperMessage(string text)
{
//RadGrdNewsPaper.Controls.Add(new LiteralControl(string.Format("<span style='color:red'>{0}</span>", text)));
}
protected void RegisterforCombos()
{
this.RadcmbGoodsType.DataBind();
//RadComboBox details = FindControl("GoodsDetails_TitleRadComboBox") as RadComboBox;
//details.DataBind();
}
private void SetNewspaperMessage(string message)
{
npgridMessage = message;
}
private void SetNewsLetterMessage(string message)
{
nlgridMessage = message;
}
protected void RadGrid1_Unload(object sender, EventArgs e)
{
if (DbContext != null)
DbContext.Dispose();
}
protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
{
try
{
GridEditableItem item = e.Item as GridEditableItem;
Hashtable values = new Hashtable();
item.ExtractValues(values);
SupplierModel.NewsLetterPurchase customer = new SupplierModel.NewsLetterPurchase();
item.UpdateValues(customer);
RadComboBox cmbToMonth = item.FindControl("GirdCmbToMonth") as RadComboBox;
customer.NewsLetterPurchase_ToMonthFK = Int32.Parse(cmbToMonth.SelectedValue);
DbContext.AddToNewsLetterPurchases(customer);
DbContext.SaveChanges();
SetNewsLetterMessage("سطر جدید با موفقیت درج گردید!");
//ChangeHeader("EditCommandColumn");
// RadGrdNewsPaperPurchase.Rebind();
}
catch (Exception ex)
{
SetNewsLetterMessage("خطا در درج : " + ex.InnerException.Message);
}
}
protected void RadGrid1_DeleteCommand(object sender, GridCommandEventArgs e)
{
string customerID = (e.Item as GridDataItem).GetDataKeyValue("NewsLetterPurchase_ID").ToString();
int id = Int32.Parse(customerID);
SupplierModel.NewsLetterPurchase customer = DbContext.NewsLetterPurchases.Where(p => p.NewsLetterPurchase_ID == id).FirstOrDefault();
DbContext.DeleteObject(customer);
DbContext.SaveChanges();
}
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(nlgridMessage))
{
//DisplayNewsletterMessage(nlgridMessage);
}
}
protected void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)
{
GridEditableItem item = (GridEditableItem)e.Item;
String id = item.GetDataKeyValue("GoodsFactors_ID").ToString();
if (e.Exception != null)
{
e.KeepInEditMode = true;
e.ExceptionHandled = true;
SetNewsLetterMessage("کد " + id + " ویرایش نگردید. خطا : " + e.Exception.Message);
}
else
{
SetNewsLetterMessage("کد " + id + " با موفقیت ویرایش گردید!");
RadbtnEdit.Enabled = true;
rdbtnClear.Enabled = true;
radbtnSearch.Enabled = true;
}
}
protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e)
{
RadbtnEdit.Enabled = true;
rdbtnClear.Enabled = true;
radbtnSearch.Enabled = true;
if (e.Exception != null)
{
e.ExceptionHandled = true;
SetNewsLetterMessage("خطا در درج : " + e.Exception.Message);
}
else
{
SetNewsLetterMessage("سطر جدید با موفقیت درج گردید!");
}
}
protected void RadGrid1_ItemDeleted(object source, GridDeletedEventArgs e)
{
GridDataItem dataItem = (GridDataItem)e.Item;
String id = dataItem.GetDataKeyValue("NewsLetterPurchase_NewsLetterFK").ToString();
if (e.Exception != null)
{
e.ExceptionHandled = true;
SetNewsLetterMessage("Product with ID " + id + " cannot be deleted. Reason: " + e.Exception.Message);
}
else
{
SetNewsLetterMessage("Product with ID " + id + " is deleted!");
}
}
protected void RadGrdNewsPaperPurchase_ItemDataBound(object sender, GridItemEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
if (e.Item is GridDataItem && e.Item.IsInEditMode && e.Item.DataSetIndex > -1)
{
//RadComboBox cmbToMonth = editedItem.FindControl("GirdCmbToMonth") as RadComboBox;
string purchaseID = (editedItem.GetDataKeyValue("GoodsFactors_ID")).ToString();
int id = Int32.Parse(purchaseID);
SupplierModel.GoodsFactor purchase = DbContext.GoodsFactors.Where(p => p.GoodsFactors_PurchaseFK == id).FirstOrDefault();
//cmbToMonth.SelectedValue = (np.NewsLetterPurchase_ToMonthFK).ToString();
}
}
//SecondGrid
protected void RadGrdNewsPaper_Unload(object sender, EventArgs e)
{
if (DbContext != null)
DbContext.Dispose();
}
protected void RadGrid1_ItemUpdated1(object sender, GridUpdatedEventArgs e)
{
GridEditableItem item = (GridEditableItem)e.Item;
String id = item.GetDataKeyValue("GoodsFactors_ID").ToString();
if (e.Exception != null)
{
e.KeepInEditMode = true;
e.ExceptionHandled = true;
SetNewspaperMessage("کد " + id + " ویرایش نگردید. خطا : " + e.Exception.Message);
}
else
{
RadbtnEdit.Enabled = true;
rdbtnClear.Enabled = true;
radbtnSearch.Enabled = true;
SetNewspaperMessage("کد " + id + " با موفقیت ویرایش گردید!");
}
}
protected void RadGrid1_UpdateCommand1(object sender, GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
string PurchaseID = editedItem.GetDataKeyValue("GoodsFactors_ID").ToString();
int id = Int32.Parse(PurchaseID);
SupplierModel.GoodsFactor fac = DbContext.GoodsFactors.Where(current => current.GoodsFactors_ID == id).FirstOrDefault();
editedItem.UpdateValues(fac);
string strJQDName = "ctl00$cphMain$RadGrid1$ctl00$ctl";
if (e.Item is GridEditableItem)
{
GridDataItem item = e.Item as GridDataItem;
if (e.Item.DataSetIndex < 6)
strJQDName += "0" + (e.Item.DataSetIndex + 4).ToString() + "$JQDatePicker1";
else
strJQDName += (e.Item.DataSetIndex + 4).ToString() + "$JQDatePicker1";
}
JQDatePicker jqd = ((JQDatePicker)(this.FindControl(strJQDName)));
fac.GoodsFactors_FactorDate = jqd.Date;
RadComboBox cmbGoodsDetails = editedItem.FindControl("GoodsDetails_TitleRadComboBox") as RadComboBox;
fac.GoodsFactors_GoodsDetailsFK = Int32.Parse(cmbGoodsDetails.SelectedValue);
RadComboBox cmbStores = editedItem.FindControl("RadComboBox1") as RadComboBox;
if (cmbStores.SelectedValue == "-1")
fac.GoodsFactors_StoresFK = 1;
else
fac.GoodsFactors_StoresFK = Int32.Parse(cmbStores.SelectedValue);
TextBox txtReqAmount = editedItem.FindControl("RequestAmountTextBox") as TextBox;
fac.GoodsFactors_PurchasedCountOrAmount = Int32.Parse(txtReqAmount.Text);
TextBox txtFacAmount = editedItem.FindControl("FactorAmountTextBox") as TextBox;
fac.GoodsFactors_FactorCountOrAmount = Int32.Parse(txtFacAmount.Text);
RadComboBox cmbUnitFK2 = editedItem.FindControl("RadComboBox3") as RadComboBox; // Request UnitFK
fac.GoodsFactors_ReqUnitsFK = Int32.Parse(cmbUnitFK2.SelectedValue);
TextBox txtFactorNo = editedItem.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
fac.GoodsFactors_FactorNo = txtFactorNo.Text;
TextBox txtPrice = editedItem.FindControl("GoodsFactors_PriceTextBox") as TextBox;
fac.GoodsFactors_Price = float.Parse(txtPrice.Text);
TextBox txtTotalPrice = editedItem.FindControl("GoodsFactors_TotalPriceTextBox") as TextBox;
fac.GoodsFactors_TotalPrice = float.Parse(txtTotalPrice.Text);
RadComboBox cmbFactorUnit = editedItem.FindControl("RadComboBox2") as RadComboBox;
fac.GoodsFactors_UnitsFK = Int32.Parse(cmbFactorUnit.SelectedValue);
//if (txtFactorNo.Text != null)
//{
//GridTemplateColumnEditor editor = (GridTemplateColumnEditor)editedItem.EditManager.GetColumnEditor("GoodsFactors_FactorNo");
//RequiredFieldValidator validator = new RequiredFieldValidator();
//validator.ID = "rfv5";
//validator.ForeColor = System.Drawing.ColorTranslator.FromHtml("#D21528");
//validator.ControlToValidate = "GoodsFactors_PriceTextBox";
//validator.ErrorMessage = "تعداد خرید";
//txtPrice.Controls.Add(validator);
//-------------------------------------------------------------
//if (txtPrice.Text == "" || float.Parse(txtPrice.Text) == 0)
// rfv7.EnableClientScript = true;
//else
// rfv7.EnableClientScript = false;
//MessageBoxOK.Show("قیمت را وارد کنید!");
//}
DbContext.SaveChanges();
RadGrid1.Rebind();
RadGrid1.MasterTableView.ClearEditItems();
RadbtnEdit.Enabled = true;
rdbtnClear.Enabled = true;
radbtnSearch.Enabled = true;
}
protected void RadGrid1_NeedDataSource1(object sender, GridNeedDataSourceEventArgs e)
{
string EorgNo = RadtxtEorgNo.Text;
string FactorNo = RadtxtEorgNo0.Text;
RadGrid1.DataSource = DbContext.spPurchaseSelect(EorgNo, FactorNo);
}
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridEditableItem editItem = (GridEditableItem)e.Item;
ImageButton updateButton = (ImageButton)editItem.FindControl("UpdateButton");
TextBox GoodsFactors_FactorNoTextBox = (TextBox)editItem.FindControl("GoodsFactors_FactorNoTextBox");
int index = editItem.ItemIndex;
// updateButton.Attributes.Add("onclick", "return CheckValidation('" + GoodsFactors_FactorNoTextBox.ClientID + "');");
//updateButton.Attributes.Add("onclick", "return ValueChanged('" + index + "');");
}
if ((e.Item is GridDataInsertItem) && e.Item.IsInEditMode)
{
RadComboBox cmbStores = e.Item.FindControl("RadComboBox1") as RadComboBox;
cmbStores.Items.Add(new RadComboBoxItem(" ", "-1"));
RadComboBox cmbGoodsDetails = e.Item.FindControl("GoodsDetails_TitleRadComboBox") as RadComboBox;
cmbGoodsDetails.Items.Add(new RadComboBoxItem(" ", "-1"));
RadComboBox cmbUnitFK1 = e.Item.FindControl("RadComboBox2") as RadComboBox; // Factor UnitFK
cmbUnitFK1.Items.Add(new RadComboBoxItem(" ", "-1"));
RadComboBox cmbUnitFK2 = e.Item.FindControl("RadComboBox3") as RadComboBox; // Request UnitFK
cmbUnitFK2.Items.Add(new RadComboBoxItem(" ", "-1"));
int GoodsTypeFK = Convert.ToInt32(RadcmbGoodsType.SelectedValue.ToString());
SqlDataSource3.SelectCommand = "SELECT GoodsDetails_ID, GoodsDetails_Title FROM GoodsDetails where GoodsDetails_GoodsTypeFK=" + GoodsTypeFK;
}
else if ((e.Item is GridEditableItem) && e.Item.IsInEditMode)
{
//GridEditableItem editItem = (GridEditableItem)e.Item;
//LinkButton updateButton = editItem.FindControl("UpdateButton") as LinkButton;
//TextBox FactorNoTextBox = editItem.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
//TextBox FactorAmount = (TextBox)editItem.FindControl("FactorAmountTextBox");
//TextBox FactorPrice = (TextBox)editItem.FindControl("GoodsFactors_PriceTextBox");
//updateButton.Attributes.Add("onclick", "return CheckValidation('" + FactorAmount.ClientID + "');");
//RadComboBox cmbStores = e.Item.FindControl("RadComboBox1") as RadComboBox;
//cmbStores.Items.Add(new RadComboBoxItem(" ", "-1"));
//RadComboBox cmbGoodsDetails = e.Item.FindControl("GoodsDetails_TitleRadComboBox") as RadComboBox;
//cmbGoodsDetails.Items.Add(new RadComboBoxItem(" ", "-1"));
//RadComboBox cmbUnitFK1 = e.Item.FindControl("RadComboBox2") as RadComboBox; // Factor UnitFK
//cmbUnitFK1.Items.Add(new RadComboBoxItem(" ", "-1"));
//RadComboBox cmbUnitFK2 = e.Item.FindControl("RadComboBox3") as RadComboBox; // Request UnitFK
//cmbUnitFK2.Items.Add(new RadComboBoxItem(" ", "-1"));
int GoodsTypeFK = Convert.ToInt32(RadcmbGoodsType.SelectedValue.ToString());
SqlDataSource3.SelectCommand = "SELECT GoodsDetails_ID, GoodsDetails_Title FROM GoodsDetails where GoodsDetails_GoodsTypeFK=" + GoodsTypeFK;
}
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
if (e.Item is GridDataItem && !(e.Item.IsInEditMode))
{
string purID = (editedItem.GetDataKeyValue("GoodsFactors_ID")).ToString();
int id = Int32.Parse(purID);
SupplierModel.GoodsFactor factor = DbContext.GoodsFactors.Where(p => p.GoodsFactors_ID == id).FirstOrDefault();
}
if (e.Item is GridDataItem && e.Item.IsInEditMode && e.Item.DataSetIndex > -1)
{
// RadTextBox txtFacNo = e.Item.FindControl("GoodsFactors_FactorNoTextBox") as RadTextBox;
if (e.Item.IsInEditMode)
{
if (e.Item is GridDataInsertItem)
{
GridEditableItem editItem = (GridEditableItem)e.Item;
LinkButton InsertButton = (LinkButton)editItem.FindControl("PerformInsertButton");
//}
//else
//{
//GridEditableItem editItem = (GridEditableItem)e.Item;
ImageButton updateButton = (ImageButton)editItem.FindControl("UpdateButton");
TextBox GoodsFactors_FactorNoTextBox = (TextBox)editItem.FindControl("GoodsFactors_FactorNoTextBox");
//int index = editItem.ItemIndex;
updateButton.Attributes.Add("onclick", "return CheckValidation('" + GoodsFactors_FactorNoTextBox.ClientID + "');");
//updateButton.Attributes.Add("onclick", "return ValueChanged('"+index+"');");
}
}
string purID = (editedItem.GetDataKeyValue("GoodsFactors_ID")).ToString();
int id = Int32.Parse(purID);
SupplierModel.GoodsFactor factor = DbContext.GoodsFactors.Where(p => p.GoodsFactors_ID == id).FirstOrDefault();
RadComboBox cmbGoodsDetails = editedItem.FindControl("GoodsDetails_TitleRadComboBox") as RadComboBox;
cmbGoodsDetails.Items.Add(new RadComboBoxItem(" ", "-1"));
RadComboBox cmbStores = editedItem.FindControl("RadComboBox1") as RadComboBox;
//cmbStores.Items.Add(new RadComboBoxItem(" ", "-1"));// yek satre khali dar combo ijad mikonad.
RadComboBox cmbUnitFK1 = editedItem.FindControl("RadComboBox2") as RadComboBox; // Factor UnitFK
//cmbUnitFK1.Items.Add(new RadComboBoxItem(" ", "-1"));
RadComboBox cmbUnitFK2 = editedItem.FindControl("RadComboBox3") as RadComboBox; // Request UnitFK
//cmbUnitFK2.Items.Add(new RadComboBoxItem(" ", "-1"));
string strJQDName = "ctl00$cphMain$RadGrid1$ctl00$ctl";
if (e.Item.DataSetIndex < 6)
strJQDName += "0" + (e.Item.DataSetIndex + 4).ToString() + "$JQDatePicker1";
else
strJQDName += (e.Item.DataSetIndex + 4).ToString() + "$JQDatePicker1";
JQDatePicker jqd = new JQDatePicker();
jqd.Enabled = true;
jqd = ((JQDatePicker)(this.FindControl(strJQDName)));
jqd.Date = factor.GoodsFactors_FactorDate;
TextBox txtReqAmount = editedItem.FindControl("RequestAmountTextBox") as TextBox;
TextBox txtFacAmount = editedItem.FindControl("FactorAmountTextBox") as TextBox;
TextBox txtFactorNo = editedItem.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
TextBox txtPrice = editedItem.FindControl("GoodsFactors_PriceTextBox") as TextBox;
TextBox txtTotalPrice = editedItem.FindControl("GoodsFactors_TotalPriceTextBox") as TextBox;
//ImageButton updateButton = (ImageButton)editedItem.FindControl("UpdateButton");
//updateButton.Attributes.Add("onclick", "return CheckValidation('" + txtFactorNo.ClientID + "');");
}
}
protected void RadGrid1_InsertCommand1(object sender, GridCommandEventArgs e)
{
try
{
if (RadtxtEorgNo.Text != "")
{
// *** ==========================================================================
GridEditableItem item = e.Item as GridEditableItem;
Hashtable values = new Hashtable();
item.ExtractValues(values);
int ReqAmount;
int FacAmount;
float Price;
float TotalPrice;
string FactorNo;
string date= item.FindControl("JQDatePicker1").ToString() as string;
RadComboBox cmbGoodsDetails = item.FindControl("GoodsDetails_TitleRadComboBox") as RadComboBox;
int? GoodsDetailsFK = Int32.Parse(cmbGoodsDetails.SelectedValue);
if (GoodsDetailsFK == -1)
GoodsDetailsFK = null;
RadComboBox cmbStores = item.FindControl("RadComboBox1") as RadComboBox;
int? StoresFK = Int32.Parse(cmbStores.SelectedValue);
if (StoresFK == -1)
StoresFK = null;
RadComboBox cmbUnitFK1 = item.FindControl("RadComboBox2") as RadComboBox; // Factor UnitFK
int? UnitFK = Int32.Parse(cmbUnitFK1.SelectedValue);
if (UnitFK == -1)
UnitFK = null;
RadComboBox cmbUnitFK2 = item.FindControl("RadComboBox3") as RadComboBox; // Request UnitFK
int? UnitFK2 = Int32.Parse(cmbUnitFK2.SelectedValue);
if (UnitFK2 == -1)
UnitFK2 = null;
string strJQDName = "ctl00$cphMain$RadGrid1$ctl00$ctl02$ctl02$JQDatePicker1";
JQDatePicker jqd = ((JQDatePicker)(this.FindControl(strJQDName)));
TextBox txtReqAmount = item.FindControl("RequestAmountTextBox") as TextBox;
if (txtReqAmount.Text != null && txtReqAmount.Text != "")
ReqAmount = Int32.Parse(txtReqAmount.Text);
else
ReqAmount = 0;
TextBox txtFacAmount = item.FindControl("FactorAmountTextBox") as TextBox;
if (txtFacAmount.Text != null && txtFacAmount.Text != "")
FacAmount = Int32.Parse(txtFacAmount.Text);
else
FacAmount = 0;
TextBox txtFactorNo = item.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
if (txtFactorNo.Text != null && txtFactorNo.Text != "")
FactorNo = txtFactorNo.Text;
else
FactorNo = null;
TextBox txtPrice = item.FindControl("GoodsFactors_PriceTextBox") as TextBox;
if (txtPrice.Text != null && txtPrice.Text != "")
Price = float.Parse(txtPrice.Text);
else
Price = 0;
TextBox txtTotalPrice = item.FindControl("GoodsFactors_TotalPriceTextBox") as TextBox;
if (txtTotalPrice.Text != null && txtTotalPrice.Text != "")
TotalPrice = float.Parse(txtTotalPrice.Text);
else
TotalPrice = 0;
if (date!=null)
{
DbContext.spPurchaseInsert3(FactorNo, lblEorgNo.Text, GoodsDetailsFK, UnitFK2, jqd.Date, TotalPrice, Price, FacAmount, ReqAmount, StoresFK, UnitFK);
}
else
{
DbContext.spPurchaseInsert3(txtFactorNo.Text, lblEorgNo.Text, GoodsDetailsFK, UnitFK2, null, TotalPrice, Price, FacAmount, ReqAmount, StoresFK, UnitFK);
}
DbContext.SaveChanges();
//Fill();
RadGrid1.Rebind();
//RadGrid1.MasterTableView.ClearEditItems();
MessageBoxOK.Show("سطر جدید با موفقیت درج گردید!");
RadbtnEdit.Enabled = true;
rdbtnClear.Enabled = true;
radbtnSearch.Enabled = true;
//ChangeHeader("EditCommandColumn");
}
else
{
MessageBoxOK.Show("شماره درخواست را وارد نمایید!");
//System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml("#F7D1FA");
//RadtxtEorgNo.BackColor = color;
}
}
catch (Exception ex)
{
SetNewspaperMessage("خطا در درج : " + ex.InnerException.Message);
}
}
protected void RadButton1_Click(object sender, EventArgs e)
{
if (RadtxtEorgNo.Text != "" && JQDPKfromDate.Text != "")
{
lblAlert1.Visible = false;
lblAlert2.Visible = false;
string Eorg = RadtxtEorgNo.Text;
string Department = RadcmbDep.SelectedValue;
string SubDepartment = RadcmbSubDep.SelectedValue;
int UserFK = MyWebApplication.Sessions.AuthenticatedUser.UserID;
DateTime UseDate = System.DateTime.Now;
int DepFK = Int32.Parse(Department);
int SubDepFK = Int32.Parse(SubDepartment);
string Desc = rdtxtDescription.Text;
//rfvDate.Enabled = true;
//rfvDate.Visible = true;
ObjectParameter output1 = new ObjectParameter("checkDuplicate", typeof(Int32));
DbContext.spPurchaseInsertCheck(RadtxtEorgNo.Text, output1);
string GoodType = RadcmbGoodsType.SelectedValue.ToString();
int GoodsTypeFK = Convert.ToInt32(GoodType);
//ObjectParameter output2 = new ObjectParameter("GoodsTypeFK",typeof(Int32));
int chk = Convert.ToInt32(output1.Value.ToString());
if (chk == 1 && Eorg != "")
{
MessageBoxOK.Show("درخواستی با این شماره قبلا ثبت شده است!");
//Clear();
//SearchRequest(Eorg);
}
else if (Eorg != "" && JQDPKfromDate.Text!="")
{
DbContext.spPurchaseInsert2(JQDPKfromDate.Date, Eorg, DepFK, SubDepFK, 0, GoodsTypeFK, Desc, UserFK, UseDate);
DbContext.SaveChanges();
MessageBoxOK.Show("درخواست با موفقیت ثبت گردید.");
lblEorgNo.Visible = true;
lblEorgNo0.Visible = true;
lblEorgNo.Text = RadtxtEorgNo.Text;
RadGrid1.Rebind();
RadbtnEdit.Enabled = true;
RadbtnInsert.Enabled = false;
rdbtnClear.Enabled = true;
}
}
else if (RadtxtEorgNo.Text == "" && JQDPKfromDate.Text == "")
{
MessageBoxOK.Show("درج شماره درخواست و تاریخ الزامیست!");
lblAlert1.Visible = true;
lblAlert2.Visible = true;
}
else if (RadtxtEorgNo.Text == "" && JQDPKfromDate.Text != "")
{
MessageBoxOK.Show("درج شماره درخواست الزامیست!");
lblAlert1.Visible = true;
lblAlert2.Visible = false;
}
else if (RadtxtEorgNo.Text != "" && JQDPKfromDate.Text == "")
{
MessageBoxOK.Show("درج تاریخ الزامیست!");
lblAlert2.Visible = true;
lblAlert1.Visible = false;
}
}
protected void RadbtnFactorInsert_Click(object sender, EventArgs e)
{
string FactorNo = RadtxtEorgNo0.Text;
string EorgNo = RadtxtEorgNo.Text;
// DbContext.spPurchaseInsert3(FactorNo,EorgNo);
MessageBoxOK.Show("شماره فاکتور با موفقیت ثبت گردید.");
}
protected void RadbtnInsertGoods_Click(object sender, EventArgs e)
{
//RadGrid1.Visible = true;
//MultiView1.ActiveViewIndex = 0;
}
protected void RadbtnSearch_Click(object sender, EventArgs e)
{
if ((RadtxtEorgNo.Text == "") && (RadtxtEorgNo0.Text == ""))
{
MessageBoxOK.Show("لطفاً شماره درخواست را وارد نمایید!");
lblAlert1.Visible = true;
//System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml("#F7D1FA");
//RadtxtEorgNo.BackColor = System.Drawing.ColorTranslator.FromHtml("#F7D1FA");
//RadtxtEorgNo.BorderColor= System.Drawing.ColorTranslator.FromHtml("#9933FF");
//RadtxtEorgNo.BorderStyle = BorderStyle.Dotted;
// img1.Visible = true;
}
//rfvDate.Visible = false;
//SupplierModel.Purchase pur=DbContext.Purchases
if ((RadtxtEorgNo.Text != "")) //||(RadtxtEorgNo0.Text!=""))
{
lblAlert1.Visible = false;
lblAlert2.Visible = false;
RadtxtEorgNo.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");
//RadtxtEorgNo.BackColor = System.Drawing.Color.Transparent;
//RadtxtEorgNo.BorderColor = System.Drawing.Color.Transparent;
// MultiView1.ActiveViewIndex = 0;
string eorg= RadtxtEorgNo.Text;
ObjectParameter output1 = new ObjectParameter("DepFK",typeof(Int32));
ObjectParameter output2 = new ObjectParameter("SubDep",typeof(Int32));
ObjectParameter output3 = new ObjectParameter("EorgNumber",typeof(Char));
ObjectParameter output4 = new ObjectParameter("RequestDate",typeof(DateTime));
ObjectParameter output5 = new ObjectParameter("GoodsTypeFK", typeof(Int32));
ObjectParameter output6 = new ObjectParameter("valid", typeof(Boolean));
DbContext.spPurchaseSearch(RadtxtEorgNo.Text, RadtxtEorgNo0.Text, output1, output2,output3,output4,output5,output6);
//string validEorg = output3.Value.ToString();
int valid = Convert.ToInt32(output6.Value);
if (valid != 0) // Eorg Number vojud darad.
{
SupplierModel.Purchase pur = DbContext.Purchases.Where(p => p.Purchase_EorgNo == eorg).First();
RadcmbDep.SelectedValue = output1.Value.ToString();
RadcmbDep.SelectedValue = pur.Purchase_ReqSubDepartmentFK.ToString();
RadcmbSubDep.SelectedValue = output2.Value.ToString();
RadcmbGoodsType.SelectedValue = output5.Value.ToString();
rdtxtDescription.Text = pur.Purchase_Description;
//string strJQDName = "ctl00$cphMain$ctl00$ctl";
//strJQDName +="0" + JQDPKfromDate.ToString() + "$JQDatePicker1";
if (output4.Value != null)
{
JQDPKfromDate.Date = pur.Purchase_Date;
}
//if (RadtxtEorgNo.Text == "")
//{
// RadtxtEorgNo.Text = output3.Value.ToString();
//}
RadGrid1.Rebind();
lblEorgNo0.Visible = true;
lblEorgNo.Visible = true;
lblEorgNo.Text = RadtxtEorgNo.Text;
RadbtnEdit.Enabled = true;
RadbtnInsert.Enabled = false;
rdbtnClear.Enabled = true;
}
else {
MessageBoxOK.Show("این شماره درخواست وجود ندارد!");
Clear();
RadGrid1.Rebind();
lblEorgNo0.Visible = false;
lblEorgNo.Visible = false;
RadbtnEdit.Enabled = false;
RadbtnInsert.Enabled = true;
rdbtnClear.Enabled = false;
radbtnSearch.Enabled = true;
}
}
}
protected void RadGrid1_ItemDeleted1(object sender, GridDeletedEventArgs e)
{
}
protected void RadGrid1_DeleteCommand1(object sender, GridCommandEventArgs e)
{
string PurchaseID = (e.Item as GridDataItem).GetDataKeyValue("GoodsFactors_ID").ToString();
int id = Int32.Parse(PurchaseID);
SupplierModel.GoodsFactor Factor = DbContext.GoodsFactors.Where(p => p.GoodsFactors_ID == id).FirstOrDefault();
DbContext.DeleteObject(Factor);
DbContext.SaveChanges();
RadbtnEdit.Enabled = true;
rdbtnClear.Enabled = true;
radbtnSearch.Enabled = true;
}
protected void RadcmbGoodsType_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
int GoodsTypeFK = Convert.ToInt32(RadcmbGoodsType.SelectedValue.ToString());
SqlDataSource3.SelectCommand = "SELECT GoodsDetails_ID, GoodsDetails_Title FROM GoodsDetails where GoodsDetails_GoodsTypeFK="+ GoodsTypeFK;
RadGrid1.Rebind();
if (RadcmbGoodsType.SelectedIndex == 4) // agar mashinAlAte edari entekhab shavad.
{
int SubDepFK = Convert.ToInt32(RadcmbSubDep.SelectedValue);
SupplierModel.SubDepartment SubDep = DbContext.SubDepartments.Where(s => s.DepartmentFK != 34 && s.SubDepartmentFK == SubDepFK).First();
string DepFK = SubDep.DepartmentFK.ToString();
RadcmbDep.SelectedValue = DepFK;
RadcmbDep.Enabled = true;
//SqlDataSource14.SelectCommand = "SELECT DISTINCT DepartmentFK, DepartmentName, SubDepartmentFK FROM SubDepartments WHERE (DepartmentFK <> 34) AND (DepartmentFK = SubDepartmentFK)";
}
else
RadcmbDep.Enabled = false;
}
protected void JQDPKfactorDate_TextChanged(object sender, EventArgs e)
{
//AgencySearch();
rdbtnClear.Enabled = true;
}
private void SearchRequest(string EorgNo)
{
ObjectParameter output1 = new ObjectParameter("DepFK", typeof(Int32));
ObjectParameter output2 = new ObjectParameter("SubDep", typeof(Int32));
ObjectParameter output3 = new ObjectParameter("EorgNumber", typeof(Char));
ObjectParameter output4 = new ObjectParameter("RequestDate", typeof(DateTime));
ObjectParameter output5 = new ObjectParameter("GoodsTypeFK", typeof(Int32));
ObjectParameter output6 = new ObjectParameter("valid", typeof(Boolean));
DbContext.spPurchaseSearch(EorgNo, null, output1, output2, output3, output4, output5,output6);
RadcmbDep.SelectedValue = output1.Value.ToString();
RadcmbSubDep.SelectedValue = output2.Value.ToString();
RadcmbGoodsType.SelectedValue = output5.Value.ToString();
lblEorgNo0.Visible = true;
lblEorgNo.Text = RadtxtEorgNo.Text;
if (output4.Value != null)
{
JQDPKfromDate.Text = output4.Value.ToString();
}
if (RadtxtEorgNo.Text == "")
{
RadtxtEorgNo.Text = output3.Value.ToString();
}
RadGrid1.Rebind();
RadbtnEdit.Enabled = true;
RadbtnInsert.Enabled = false;
}
protected void RadcmbSubDep_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
}
protected void FillCascadedCombos(string DeptFK)
{
//SqlDataSource15.SelectCommand = "select SubDepartmentFK, SubDepartmentName From SubDepartments WHERE DepartmentFK=" + DeptFK;
}
protected void RadCmbDeptName_OnSelectedIndexChanged(object sender, EventArgs e)
{
// RadComboBox cmb = (RadComboBox)sender;
//FillCascadedCombos(RadcmbDep.SelectedValue);
}
protected void RadCmbSubDeptName_OnSelectedIndexChanged(object sender, EventArgs e)
{
//RadComboBox cmb = (RadComboBox)sender;
}
protected void RadCmbDeptName_OnSelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
//RadComboBox cmb = (RadComboBox)sender;
// FillCascadedCombos(RadcmbDep.SelectedValue);
}
protected void RadCmbSubDeptName_OnSelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
//if (RadcmbGoodsType.SelectedIndex != 4)
//{
RadComboBox cmSubDep = (RadComboBox)sender;
string SubDep = cmSubDep.SelectedValue.ToString();
int SubDepFK = Convert.ToInt32(SubDep); // SubDepartmentFK
SupplierModel.SubDepartment SubDep1 = DbContext.SubDepartments.Where(s => s.DepartmentFK != 34 && s.SubDepartmentFK == SubDepFK).First();
string DepFK = SubDep1.DepartmentFK.ToString();
RadcmbDep.SelectedValue = DepFK;
//}
}
protected void RadGrid1_PreRender1(object sender, EventArgs e)
{
RadcmbGoodsType.DataBind();
}
public void RegisterForEventValidation()
{
//string UniqueID;
}
protected void RadbtnEdit_Click(object sender, EventArgs e)
{
lblAlert1.Visible = false;
lblAlert2.Visible = false;
string Eorg = RadtxtEorgNo.Text;
string Department = RadcmbDep.SelectedValue;
string SubDepartment = RadcmbSubDep.SelectedValue;
int UserFK = MyWebApplication.Sessions.AuthenticatedUser.UserID;
DateTime UseDate = System.DateTime.Now;
int DepFK = Int32.Parse(Department);
int SubDepFK = Int32.Parse(SubDepartment);
string Desc = rdtxtDescription.Text;
string GoodType = RadcmbGoodsType.SelectedValue.ToString();
int GoodsTypeFK = Convert.ToInt32(GoodType);
DbContext.spPurchaseInsert2(JQDPKfromDate.Date, Eorg, DepFK, SubDepFK, 1,GoodsTypeFK,Desc,UserFK,UseDate);
DbContext.SaveChanges();
lblEorgNo0.Visible = true;
lblEorgNo.Text = RadtxtEorgNo.Text;
RadGrid1.Rebind();
//SearchRequest(Eorg);
MessageBoxOK.Show("درخواست با موفقیت ویرایش گردید!");
}
protected void JQDatePicker1_TextChanged(object sender, EventArgs e)
{
//SearchRequest(RadtxtEorgNo.Text);
}
protected void GoodsDetails_TitleRadComboBox_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
{
}
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.EditCommandName)
{
RadGrid1.MasterTableView.IsItemInserted = false;
RadbtnEdit.Enabled = false;
rdbtnClear.Enabled = false;
radbtnSearch.Enabled = false;
//--- VALIDATION ---- \\
//GridEditableItem editItem = (GridEditableItem)e.Item;
//ImageButton updateButton = editItem.FindControl("Update") as ImageButton;
//TextBox FactorNoTextBox = editItem.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
//TextBox FactorAmount = (TextBox)editItem.FindControl("FactorAmountTextBox");
//TextBox FactorPrice = (TextBox)editItem.FindControl("GoodsFactors_PriceTextBox");
//updateButton.Attributes.Add("onclick", "return CheckValidation('" + FactorNoTextBox.ClientID + "');");
//--- END OF VALIDATION ---- \\
//RadComboBox cmb = (RadComboBox)sender;
// GridEditableItem editedItem = sender as GridEditableItem;
//GridEditableItem editedItem = e.Item as GridEditableItem;
//RadComboBox CmbDeptName = editedItem.FindControl("RadCmbDeptName") as RadComboBox;
//RadComboBox CmbSubDeptName = editedItem.FindControl("RadCmbSubDeptName") as RadComboBox;
//string s = CmbDeptName.SelectedValue;
//FillCombo.FillTypeOf(CmbSubDeptName, "SubDepartment", CmbDeptName.SelectedValue);
}
if (e.CommandName == RadGrid.InitInsertCommandName)
{
RadbtnEdit.Enabled = false;
rdbtnClear.Enabled = false;
radbtnSearch.Enabled = false;
RadGrid1.MasterTableView.ClearEditItems();
var masterTableView = RadGrid1.MasterTableView;
var column = masterTableView.GetColumn("EditCommandColumn");
column.HeaderText = "ویرایش";
}
if (e.CommandName == RadGrid.CancelCommandName)
{
ChangeHeader("EditCommandColumn");
RadbtnEdit.Enabled = true;
rdbtnClear.Enabled = true;
radbtnSearch.Enabled = true;
}
if (e.CommandName == RadGrid.UpdateCommandName)
{
//--- VALIDATION ---- \\
Page.ClientScript.RegisterStartupScript(this.GetType(), "Call My Function", "ValueChanged()", true);
//GridEditableItem editItem = (GridEditableItem)e.Item;
//ImageButton updateButton = editItem.FindControl("Update") as ImageButton;
//TextBox FactorNoTextBox = editItem.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
//TextBox FactorAmount = (TextBox)editItem.FindControl("FactorAmountTextBox");
//TextBox FactorPrice = (TextBox)editItem.FindControl("GoodsFactors_PriceTextBox");
//updateButton.Attributes.Add("onclick", "return CheckValidation('" + FactorNoTextBox.ClientID + "');");
//--- END OF VALIDATION ---- \\
}
}
private void ChangeHeader(string ColName)
{
var masterTableView = RadGrid1.MasterTableView;
var column = masterTableView.GetColumn("EditCommandColumn");
column.HeaderText = "ویرایش";
}
protected void rdbtnClear_Click(object sender, EventArgs e)
{
Clear();
}
public void Clear()
{
lblEorgNo.Visible = false;
lblEorgNo.Text = "";
lblEorgNo0.Visible = false;
RadtxtEorgNo.Text = "";
RadcmbDep.SelectedIndex = 0;
RadcmbSubDep.SelectedIndex = 0;
RadcmbGoodsType.SelectedIndex = 0;
JQDPKfromDate.Text = null;
RadbtnEdit.Enabled = false;
RadbtnInsert.Enabled = true;
rdbtnClear.Enabled = false;
RadGrid1.Rebind();
rdtxtDescription.Text = "";
}
public void Fill()
{
string eorg = RadtxtEorgNo.Text;
ObjectParameter output1 = new ObjectParameter("DepFK", typeof(Int32));
ObjectParameter output2 = new ObjectParameter("SubDep", typeof(Int32));
ObjectParameter output3 = new ObjectParameter("EorgNumber", typeof(Char));
ObjectParameter output4 = new ObjectParameter("RequestDate", typeof(DateTime));
ObjectParameter output5 = new ObjectParameter("GoodsTypeFK", typeof(Int32));
ObjectParameter output6 = new ObjectParameter("valid", typeof(Boolean));
DbContext.spPurchaseSearch(RadtxtEorgNo.Text, RadtxtEorgNo0.Text, output1, output2, output3, output4, output5,output6);
SupplierModel.Purchase pur = DbContext.Purchases.Where(p => p.Purchase_EorgNo == eorg).First();
RadcmbDep.SelectedValue = output1.Value.ToString();
RadcmbDep.SelectedValue = pur.Purchase_ReqSubDepartmentFK.ToString();
RadcmbSubDep.SelectedValue = output2.Value.ToString();
RadcmbGoodsType.SelectedValue = output5.Value.ToString();
rdtxtDescription.Text = pur.Purchase_Description;
if (output4.Value != null)
{
JQDPKfromDate.Date = pur.Purchase_Date;
}
}
protected void RadtxtEorgNo_TextChanged(object sender, EventArgs e)
{
rdbtnClear.Enabled = true;
}
protected void rdtxtDescription_TextChanged(object sender, EventArgs e)
{
rdbtnClear.Enabled = true;
}
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
if (args.Value.ToString() != "")
{
}
}
protected void CustomValidator2_ServerValidate(object source, ServerValidateEventArgs args)
{
//GridEditableItem item = source.
//TextBox txtFacAmount = this.RadGrid1.FindControl("FactorAmountTextBox") as TextBox;
//TextBox txtFactorNo = this.RadGrid1.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
//if (args.Value.Length > 2)
//{
// args.IsValid = true;
//}
//else
// args.IsValid = false;
}
protected void GoodsFactors_FactorNoTextBox_TextChanged(object sender, EventArgs e)
{
//return "ValueChanged();";
//GridEditableItem edititem = e.item as GridEditableItem;
//TextBox txtFactorNo=RadGrid1.FindControl("GoodsFactors_FactorNoTextBox") as TextBox;
//Page.ClientScript.RegisterStartupScript(this.GetType(), "Call My Function", "CheckValidation('" + txtFactorNo.ClientID + "');",true);
}
}
0
Hi Navisa,
Since it is impossible to create a runnable project from the provided code snippets, please remove all irrelevant to the issue code and isolate a sample scenario that could be tested on our side. Preferably, open a regular support ticket with sample, runnable project so we could test it locally and provide you with a solution if possible.
Regards,
Konstantin Dikov
Telerik
Since it is impossible to create a runnable project from the provided code snippets, please remove all irrelevant to the issue code and isolate a sample scenario that could be tested on our side. Preferably, open a regular support ticket with sample, runnable project so we could test it locally and provide you with a solution if possible.
Regards,
Konstantin Dikov
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.