Protected
Sub RadGrid1_InsertCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles RadGrid1.InsertCommand
Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
Dim userControl As UserControl = CType(e.Item.FindControl(GridEditFormItem.EditFormUserControlID), UserControl)
Dim newRow As DataRow = Me.Ntable.NewRow
Dim newValues As Hashtable = New Hashtable
newValues(
"N") = CType(userControl.FindControl("NTextBox"), RadTextBox).Text
newValues(
"DNumber") = CType(userControl.FindControl("PNUMBER"), RadTextBox).Text.Take(13)
newValues(
"PNUMBER") = CType(userControl.FindControl("PNUMBER"), RadTextBox).Text
newValues(
"Title") = CType(userControl.FindControl("Title"), RadTextBox).Text
newValues(
"worder") = 0
newValues(
"SMRB") = CType(userControl.FindControl("SMRB"), RadTextBox).Text
newValues(
"SCAR") = CType(userControl.FindControl("SCAR"), RadTextBox).Text
newValues(
"Dposition") = CType(userControl.FindControl("Dposition"), RadTextBox).Text
newValues(
"LItems") = CType(userControl.FindControl("LItems"), RadTextBox).Text
newValues(
"QTY") = CType(userControl.FindControl("QTY"), RadTextBox).Text
newValues(
"AffectedA") = CType(userControl.FindControl("AffectedA"), RadTextBox).Text
newValues(
"Slier") = CType(userControl.FindControl("Slier"), RadTextBox).Text
newValues(
"Parer") = CType(userControl.FindControl("Parer"), RadTextBox).Text
newValues(
"QApp") = CType(userControl.FindControl("QApp"), RadTextBox).Text
newValues(
"Eer") = CType(userControl.FindControl("Eer"), RadTextBox).Text
newValues(
"Lon") = CType(userControl.FindControl("Lon"), RadTextBox).Text
newValues(
"Stus") = CType(userControl.FindControl("Stus"), RadTextBox).Text
newValues(
"Dancy") = CType(userControl.FindControl("Dancy"), RadTextBox).Text
newValues(
"cause") = 0
newValues(
"CAction") = CType(userControl.FindControl("CAction"), RadTextBox).Text
newValues(
"Subtion") = CType(userControl.FindControl("Subtion"), RadTextBox).Text
newValues(
"actiondate") = Date.Now
newValues(
"compsn") = CType(userControl.FindControl("compsn"), RadTextBox).Text
newValues(
"drcode") = 0
newValues(
"reworkordno") = CType(userControl.FindControl("reworkordno"), RadTextBox).Text
newValues(
"corractionreqyes") = CType(userControl.FindControl("corractionreqyes"), CheckBox).Checked
newValues(
"corractionreqno") = CType(userControl.FindControl("corractionreqno"), CheckBox).Checked
newValues(
"purchsig") = CType(userControl.FindControl("purchsig"), RadTextBox).Text
newValues(
"shipperno") = CType(userControl.FindControl("shipperno"), RadTextBox).Text
newValues(
"shop1") = CType(userControl.FindControl("shop1"), RadTextBox).Text
newValues(
"qainsp1") = CType(userControl.FindControl("qainsp1"), RadTextBox).Text
newValues(
"shop2") = CType(userControl.FindControl("shop2"), RadTextBox).Text
newValues(
"rqainsp2") = CType(userControl.FindControl("qainsp2"), RadTextBox).Text
newValues(
"reworkinst") = CType(userControl.FindControl("reworkinst"), RadTextBox).Text
newValues(
"min") = CType(userControl.FindControl("min"), CheckBox).Checked
newValues(
"maj") = CType(userControl.FindControl("maj"), CheckBox).Checked
newValues(
"N_ID") = (CType(Me.Ntable.Rows((Me.Ntable.Rows.Count - 1))("N_ID"), Integer) + 1001)
Try
For Each entry As DictionaryEntry In newValues
newRow(
CType(entry.Key, String)) = entry.Value
Next
Me.Ntable.Rows.Add(newRow)
Me.Ntable.AcceptChanges()
Catch ex As Exception
Dim lblError As Label = New Label()
lblError.Text =
"Unable to insert N. Reason: " + ex.Message
lblError.ForeColor = System.Drawing.Color.Red
RadGrid1.Controls.Add(lblError)
e.Canceled =
True
End Try
End Sub