creating admno number and assign it to admno control after entering student name
@model UNIFORMMANAGER.Models.STUDENT
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>STUDENT</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.NAME, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.NAME, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NAME, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.ACNOS, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ACNOS, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ACNOS, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.HOME, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.HOME, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.HOME, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.FATHER, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.FATHER, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.FATHER, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.MOTHER, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.MOTHER, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MOTHER, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.HOUSE, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.HOUSE, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.HOUSE, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CLASS, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.CLASS, ViewBag.CityList as SelectList, "--Select Class--", new { @class = "form-control", @onChange = "SelectedValue(this)" })
@Html.ValidationMessageFor(model => model.CLASS, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.STREAM, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.STREAM, ViewBag.CityList3 as SelectList, "--Select Sex--", new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.STREAM, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.SEX, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.SEX, ViewBag.CityList2 as SelectList, "--Select Sex--", new { @class = "form-control",@onChange= "Createsula()"})
@Html.ValidationMessageFor(model => model.SEX, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.ADMNO, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ADMNO, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ADMNO, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.ACCOUNT, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ACCOUNT, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ACCOUNT, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.STATUS, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.STATUS, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.STATUS, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Rclass, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Rclass, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Rclass, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
<script>
//To get selected value an text of dropdownlist
function SelectedValue(ddlObject)
{
//Selected value of dropdownlist
var selectedValue = ddlObject.value;
//Selected text of dropdownlist
var selectedText = ddlObject.options[ddlObject.selectedIndex].innerHTML;
//alert popup with detail of seleceted value and text
alert(" Selected Value: " + selectedValue+" -- "+"Selected Text: " + selectedText ) ;
}
</script>
Here is my vb code that i have been using in ms access
Private Sub NAME_AfterUpdate()
Me!changed = "C"
If IsNull(Forms!ADDNEWsearch2017!NAME) Then
MsgBox ("Student Name can not be empty"), vbCritical
Me.Undo
Exit Sub
End If
DoCmd.RunSQL ("delaccount")
DoCmd.RunSQL ("sendsingleaccount '" & Forms!ADDNEWsearch2017!ADMNO & "'")
Dim pj As New ADODB.Recordset
Dim maxcode As Integer
Dim max As New ADODB.Recordset
pj.Open ("student"), CurrentProject.Connection, adOpenStatic, adLockOptimistic
max.Open ("max"), CurrentProject.Connection, adOpenStatic, adLockOptimistic
If Not IsNull(Me!ACCOUNT) Then
Exit Sub
End If
'If Not pj.EOF Then
'Exit Sub
'End If
If pj.EOF Then
'If Not IsNull(Me!Account) Then
'Exit Sub
End If
If max.EOF Then
maxcode = 0
Else
End If
If Not max.EOF Then
maxcode = max!maxcode
Else
' DoCmd.RunSQL ("delsystems")
maxcode = maxcode + 1
End If
'If Me!Account = "" Then
Select Case maxcode
Case 0 To 9
Me!ACCOUNT = Right(str(Year(Now)), 2) + "-0000" + Trim(str$(maxcode))
Me!ADMNO = Right(str(Year(Now)), 2) + "-0000" + Trim(str$(maxcode))
'Me!Account = "06-0000" + Trim(Str$(maxcode))
Case 10 To 99
Me!ACCOUNT = Right(str(Year(Now)), 2) + "-000" + Trim(str$(maxcode))
Me!ADMNO = Right(str(Year(Now)), 2) + "-000" + Trim(str$(maxcode))
'Me!Account = "06-000" + Trim(Str$(maxcode))
Case 100 To 999
Me!ACCOUNT = Right(str(Year(Now)), 2) + "-00" + Trim(str$(maxcode))
Me!ADMNO = Right(str(Year(Now)), 2) + "-00" + Trim(str$(maxcode))
'Me!Account = "06-00" + Trim(Str$(maxcode))
Case 1000 To 9999
Me!ACCOUNT = Right(str(Year(Now)), 2) + "-0" + Trim(str$(maxcode))
Me!ADMNO = Right(str(Year(Now)), 2) + "-0" + Trim(str$(maxcode))
'Me!Account = "06-0" + Trim(Str$(maxcode))
Case Else
Me!ACCOUNT = Right(str(Year(Now)), 2) + "-" + Trim(str$(maxcode))
Me!ADMNO = Right(str(Year(Now)), 2) + "-" + Trim(str$(maxcode))
'Me!Account = "06-" + Trim(Str$(maxcode))
End Select
End Sub