how can i convert this code to cshap
how can i convert this code to cshap
(OP)
CODE --> vb
Private Sub NAME_AfterUpdate() Me!changed = "C" If IsNull(Forms!studentsearch!ADDNEW!NAME) Then MsgBox ("Student Name can not be empty"), vbCritical Me.Undo Exit Sub End If DoCmd.RunSQL ("delaccount") DoCmd.RunSQL ("sendsingleaccount '" & Forms!studentsearch!ADDNEW!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 'DoCmd.RunSQL ("deltrcode") 'Loop End Sub
i would want to assign the newly created admno number and account into the respective fields please help
. the above code works well in msaccess now i want to use the same code in MVC asp.net
here
CODE -->
@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(m => m.CLASS, new SelectList(Enum.GetValues(typeof(UNIFORMMANAGER.Models.TeaType))), "--Select Class--", new { @class = "form-control" }) @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 Stream--", 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(m => m.SEX, new SelectList(Enum.GetValues(typeof(UNIFORMMANAGER.Models.SexType))), "--Select Sex--", new { @class = "form-control" }) @Html.ValidationMessageFor(model => model.SEX, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.STDTYPE, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.DropDownListFor(m => m.STDTYPE, new SelectList(Enum.GetValues(typeof(UNIFORMMANAGER.Models.STDType))), "--Select STDTYPE--", new { @class = "form-control" }) @Html.ValidationMessageFor(model => model.STDTYPE, "", 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.Attendence, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.TextBox("Attendence", DateTime.Now.ToShortDateString(), new { htmlAttributes = new { @class = "form-control input-datepicker", @style = "display:none", @placeholder = "dd/mm/yyyy", @readonly = "readonly" } }) @Html.ValidationMessageFor(model => model.Attendence, "", 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 ) ; } <a href="~/Views/STUDENTs/Create.cshtml">~/Views/STUDENTs/Create.cshtml</a> </script> <script type='text/javascript'> window.onload = function () { document.getElementById("Attendence").style.display = 'none'; //document.getElementById("divthree").style.display = 'none'; $('label[for="Attendence"]').hide(); } </script>
RE: how can i convert this code to cshap