×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

how can i convert this code to cshap

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

Have you just tried a straight translation? Which parts of the vbscript syntax are you having problems with?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close