Tuesday 16 May 2017

Example of Simple Sign In Form In asp.net MVC 4 Using Linq

Dear Student ,

   Please , Follow the step to create your Sign In Form in Aps.net Mvc 4

Step 1 :

     Create a Database with " Customer "  following Types


Step 2: Create a Action Result method in your Controllar with Name "SignIn"  and Follow the following Step ....

Step 3 : Create your SignIn Form in View page with following Code Step by Step ;

@model Database_Connection.Models.Customers

@{
    ViewBag.Title = "SignIn";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>SignIn</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Customers</legend>

        <div class="editor-label">
          Enter your Email Id
        </div>
        <div class="editor-field">
           <input type="email" name="email" required/>
        </div>

        <div class="editor-label">
          Enter your Mobile No 
        </div>
        <div class="editor-field">
          <input type="text" name="mobile" required/>
        </div>

        <p>
            <input type="submit" value="Sign In" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}


Let's See , your Output : 








Sunday 14 May 2017

Example of Retrieve the whole data from database using my sql in php

Dear Student ,

    Please , Follow the Step ....

1. Create a Table in mySql and insert the Data inside it.


2 . create File with dbconnect.php for connect our file to database

<?php$servername = "localhost";
$username = "root";
$password = "";
$DbName="Registration";
// Create connection
$conn = new mysqli($servername, $username, $password,$DbName);// Check connection
if ($conn->connect_error)
{  
  die("Connection failed: " . $conn->connect_error);
?>

 2. Create A file to ViewData.php for show our data from Database


 <?php

 include("dbconnect.php");

?>

</br>

</br>

</br>

<?php



$sql="SELECT Id,Name,userName,Email,Password,Sex,Mobile_No FROM registartionform";


if ($result=mysqli_query($conn,$sql))

  {

   echo "<center>

   <table border='1'>

   <tr>

   <th>ID</th>

   <th>Name</th>

   <th>User Name</th>

   <th>Email Id</th>

   <th>Password</th>

   <th>Sex</th>

   <th>Mobile No</th></tr>";

  // Fetch one and one row

    while ($row=mysqli_fetch_row($result))

    {

     echo "<tr><td>".$row[0]."</td>

<td>".$row[1]."</td>

<td>".$row[2]."</td>

<td>".$row[3]."</td>

<td>".$row[4]."</td>

<td>".$row[5]."</td>

<td>".$row[6]."<td>

<a href='edit.php'>Edit Record</a></td>"."<td>

<a href='delete.php'>Delete Record</a></td>"."</td></tr>";

    }

echo "</table></center>";

  // Free result set

  mysqli_free_result($result);

}


mysqli_close($conn);

?>

</br>

</br>

</br>

<a href="home.php">Back to Home Page</a>



3.Execute your ViewData from any web browser with following link...

localhost:80/Viewdata.php

Output :




Wednesday 10 May 2017

Example of Create , delete , Edit and View the data in Asp.net MVC Step by Step using Code First Approach

Dear Student ,

   If You want to create a Sign Up Form and Delete , Edit and View your all data in as a list format using Code First Approach. So Please Follow the Step by step Process...


Step 1 :

   Create your Model Class as per your requirements attributes but mention one things that Insert One primary key using [Key] keywords


Step 2 :


  Create one more class in Model For DbContext Class



Step 3:


Go to Controller Folder and Create a empty Controller


Step 4 :


 Create a Your own Action result For inserting the data ..

Step 5 :


 Go to Create action Method and right click add a view

@model Database_Connection.Models.Customers

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Customers</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.C_Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.C_Name)
            @Html.ValidationMessageFor(model => model.C_Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.C_Address)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.C_Address)
            @Html.ValidationMessageFor(model => model.C_Address)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.C_Mobile_No)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.C_Mobile_No)
            @Html.ValidationMessageFor(model => model.C_Mobile_No)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.C_Email_Id)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.C_Email_Id)
            @Html.ValidationMessageFor(model => model.C_Email_Id)
        </div>

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}


Step 6 :


Create one more action method for View you Data as list view 


Step 7 :


Create a view for Index Action Result for View the data

@model IEnumerable<Database_Connection.Models.Customers>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.C_Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.C_Address)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.C_Mobile_No)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.C_Email_Id)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.C_Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.C_Address)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.C_Mobile_No)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.C_Email_Id)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
            @Html.ActionLink("Details", "Details", new { id=item.Id }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.Id })
        </td>
    </tr>
}

</table>


Step 8 :


Create one more action method for delete the data from database 


Step 9 :


  Create a view for delete the data from data base 

@model Database_Connection.Models.Customers

@{
    ViewBag.Title = "Delete";
}

<h2>Delete</h2>

<h3>Are you sure you want to delete this?</h3>
<fieldset>
    <legend>Customers</legend>

    <div class="display-label">
         @Html.DisplayNameFor(model => model.C_Name)
    </div>
    <div class="display-field">
        @Html.DisplayFor(model => model.C_Name)
    </div>

    <div class="display-label">
         @Html.DisplayNameFor(model => model.C_Address)
    </div>
    <div class="display-field">
        @Html.DisplayFor(model => model.C_Address)
    </div>

    <div class="display-label">
         @Html.DisplayNameFor(model => model.C_Mobile_No)
    </div>
    <div class="display-field">
        @Html.DisplayFor(model => model.C_Mobile_No)
    </div>

    <div class="display-label">
         @Html.DisplayNameFor(model => model.C_Email_Id)
    </div>
    <div class="display-field">
        @Html.DisplayFor(model => model.C_Email_Id)
    </div>
</fieldset>
@using (Html.BeginForm()) {
    <p>
        <input type="submit" value="Delete" /> |
        @Html.ActionLink("Back to List", "Index")
    </p>
}


Step 10:

Create one more Action method for Edit the information from Database 



Step 11 :


 Create a view form Editing the data from Database 


@model Database_Connection.Models.Customers

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Customers</legend>

        @Html.HiddenFor(model => model.Id)

        <div class="editor-label">
            @Html.LabelFor(model => model.C_Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.C_Name)
            @Html.ValidationMessageFor(model => model.C_Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.C_Address)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.C_Address)
            @Html.ValidationMessageFor(model => model.C_Address)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.C_Mobile_No)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.C_Mobile_No)
            @Html.ValidationMessageFor(model => model.C_Mobile_No)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.C_Email_Id)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.C_Email_Id)
            @Html.ValidationMessageFor(model => model.C_Email_Id)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

Tuesday 9 May 2017

Example of Retrieve the Data from XML File in Asp.net MVC 4 using Controller and View

Dear Student ,
   
   Please , Follow the step for retrieve the data from XML File in Asp.net MVC 4 using Controller with view

Step 1 :

   Create the XML File with DataReport.xml

  <?xml version="1.0" encoding="utf-8"?>
<CusterDetails>
  <Customer>
    <name>Deepak Kumar Gupta</name>
    <product>Buiscuits</product>
    <quantity>12</quantity>
    <price>60</price>
  </Customer>
  <Customer>
    <name>Roshan Kumar Gupta</name>
    <product>Namkeen</product>
    <quantity>120</quantity>
    <price>6000</price>
  </Customer>
  </CusterDetails>


Step 2 :

 Create the Controller file With RetrieveDataFromXMLData.cs


 public ActionResult RetriveDataFromXml()
        {
            string result = "";
            XDocument xmlDoc = XDocument.Load("C:/Users/Deepak Kumar/documents/visual studio 2012/Projects/ramkola_bhagwat/ramkola_bhagwat/XMLData/DataReport.xml");
            var q = from c in xmlDoc.Descendants("Customer")
                    select (string)c.Element("name") + "-" + (string)c.Element("product") + "-" +
                        (string)c.Element("quantity") + "-" + (string)c.Element("price");
            foreach(string ar in q)
            {
                result = result + "|" + ar;
            }
            ViewBag.aaa = result;
            return View();
        }

Step 3 :

 Create ViewFile with RetriveDataFromXml.cshtml

@model ramkola_bhagwat.Models.niitEntities

@{
    ViewBag.Title = "RetriveDataFromXml";
}

<h2>RetriveDataFromXml</h2>
<p>@ViewBag.aaa</p>


Output : 


Example of retrieve the data from Arraylist in Controllar to view in asp.net MVC

Follow the Step :


1. Controller Code

        public ActionResult ArrayValue()
        {
            string names = "";
            string[] arr = new string[3] { "Deepak", "Roshan", "mahesh" };
           var quer = from string name in arr select name;
           foreach (var na in quer)
           {
               names = names + " " + na;
           }
           ViewBag.aa = names;
            return View();
        }

2. View Code

  @model ramkola_bhagwat.Models.niitEntities

@{
    ViewBag.Title = "ArrayValue";
}

<h2>ArrayValue</h2>

<p>@ViewBag.aa</p>



Output :



Monday 8 May 2017

Example of Simple login page in Php with MySql

HTML CODE 
...................................................

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Jotorres Login Form</title>
</head>
<body>
    <form method="post" action="validate_login.php" >
        <table border="1" >
            <tr>
                <td><label for="users_email">Email</label></td>
                <td><input type="text" name="users_email" id="users_email"></td>
            </tr>
            <tr>
                <td><label for="users_pass">Password</label></td>
                <td><input name="users_pass" type="password" id="users_pass"></input></td>
            </tr>
            <tr>
                <td><input type="submit" value="Submit"/>
                <td><input type="reset" value="Reset"/>
            </tr>
        </table>
    </form>
</body>
</html>

PHP CODE  

.........................................................................

<?php

// Grab User submitted information
$email = $_POST["users_email"];
$pass = $_POST["users_pass"];

// Connect to the database
$con = mysql_connect("localhost","root","");
// Make sure we connected successfully
if(! $con)
{
    die('Connection Failed'.mysql_error());
}

// Select the database to use
mysql_select_db("registration",$con);

$password = hash('sha256', $pass); // password hashing using SHA256

$res=mysql_query("SELECT userId, userName, userPass FROM users WHERE userEmail='$email'");
$row=mysql_fetch_array($res);
$count = mysql_num_rows($res); // if uname/pass correct it returns must be 1 row

if( $count == 1 && $row['userPass']==$password ) {
echo 'Successful';
} else {
echo "Incorrect Credentials, Try again...";

}?>

OUPUT :

                                       Successful


Saturday 22 April 2017

Example of Fibonacci Series in C

Dear Student ,

   
   Let's See , Example of Fibonacci Series with Source code with Output .



      

                                    #include<stdio.h>
                                    #include<conio.h>
                                    void main()
                                    {
                                          int num=10,a=0,b=1,c;
                                  printf("%d",a);
                                   printf("%d",b);
     
                                          while(num>=2)
                                               {
                                                      c=a+b;
                                                      printf("%d",c);
                                                       a=b;
                                                        b=c;
                                                         num--;
                                                }
                                                           getch();
                                        }

                                                 

Wednesday 19 April 2017

Example of Multiplication of two matrix in C

Dear Students ,

    Let's see your Answer with code .


#include <stdio.h>
#include<conio.h>
int main()
{
 // these are variables declared

  int row, col, row1, col1, i, j, k, sum = 0;

// These are array to store the value
  int first[5][5], second[5][5], multiply[5][5];

  printf("Enter the number of rows and columns of first matrix\n");
  scanf("%d%d", &row, &col);
  printf("Enter the elements of first matrix\n");

  for (i = 0; i < row; i++)
    for (j = 0; j < col; j++)
      scanf("%d", &first[i][j]);

  printf("Enter the number of rows and columns of second matrix\n");
  scanf("%d%d", &row1, &col1);

  if (col != row1)
    printf("Matrices with entered orders can't be multiplied with each other.\n");
  else
  {
    printf("Enter the elements of second matrix\n");

    for (i = 0; i < row1; i++)
      for (j = 0; j < col1; j++)
        scanf("%d", &second[i][j]);

    for (i = 0; i < row; i++) {
      for (j = 0; j < col1; j++) {
        for (k = 0; k < row1; k++) {
          sum = sum + first[i][k]*second[k][j];
        }

        multiply[i][j] = sum;
        sum = 0;
      }
    }

    printf("Product of entered matrices:-\n");

    for (i = 0; i < row; i++) {
      for (j = 0; j < col1; j++)
        printf("%d ", multiply[i][j]);

      printf("\n");
    }
  }
     getch();
  return 0;
}



Tuesday 18 April 2017

Example of Palindrome number in C

Dear Students ,

Q.   Do you know ? What is Palindrome number ?

Ans . If yes , then good otherwise no worry .

Let's See . What is Palindrome number .



Palindrome Numbers are those number which we could read from any side either left or right but value are same .

Example :

     num=123454321

Let's see example with program.

            #include<stdio.h>
           #include<conio.h>

            void main()
            {
                   int num,temp,rem,sum=0;

                     printf("Enter your Number : ");
                      scanf("%d",&num);

                     temp=num;
                     while(num>0)
                      {
                             rem=num%10;
                             sum=sum*10+rem;
                             num=num/10;
                   }
                    if(sum==temp)
                      {
                         printf("Number is Palindrome ");
                        }
                      else
                          {
                            printf("Number is not Palindrome ");
                          }
                            getch();
            }


Monday 17 April 2017

A program for prime number to check whether the given number is prime or not in C

Dear Students ,

   Do you know ? 
     
Q .   What is prime Numbers ?

Ans . Prime numbers or those number which are divided by 1 or it'self . It's mean only two times .

For Example : 

    num= 7;

  if you try to divide the above number , you will get only two time reminder 0 when you divide by 1 and divide by 7 between 1 to num numbers .  


Let's Example with program : 

    #include<stdio.h>
    #include<conio.h>
    void main()
    {
       int num , i,d=0;
         printf("Enter your Number : ");
        scanf("%d",&num);
       
        for(i=1;i<=num;i++) 
         {
             if(num%i==0)
              {
                  d++;
               }
          }
          
         if(d==2)
         {
           printf("Number is Prime ");
         }
        else
          {
            printf("Number is not Prime");
         }
  getch();
    }

  Your OutPut : 


How to write a program for Armstrong number in C .

Dear Students ,

  It's a very simple for you . First of all , we need to know that what is ARMSTRONG number .Did you know ? If yes ,"It's very Good " and if you don't know ,"No Worry ".Let's See....


    Armstrong numbers are those number which is calculate with each other of Que of Digits and Find out the total of these calculation if total equal your number .  

For Example :

  153 = 1*1*1+5*5*5+3*3*3

  153  = 153

 R.H.S=L.H.S

Example :

   #include<stdio.h>
   #include<conio.h>
   void main()
   {
     int num,rem,temp,sum=0;
     printf("Enter your Number : ");
     scanf("%d",&num);
     temp=num;
    while(num>0)
      {
         rem=num%10;
         sum=sum+rem*rem*rem;
         num=num/10;
      }

       if(temp==sum)
       {
           printf("Number is Armstrong .");
       }
       else
        {
           printf("Number is Not Armstrong ");
        }
      getch();
}


Your OutPut :