Friday 28 September 2018

CRUD OPERATION IN ASP.NET WEB FORM PART 1





use clinicalmanagementsystem

create table tbl_doctor

(

d_id int primary key identity,

d_name nvarchar(50) not null,

d_contact nvarchar(50) not null unique,

d_email nvarchar(50) unique,

d_dateofbirth date



)



create proc sp_insert_doctor

(

@d_name nvarchar(50) ,

@d_contact nvarchar(50) ,

@d_email nvarchar(50) ,

@d_dateofbirth date

)

AS

BEGIN

INSERT INTO tbl_doctor VALUES(

@d_name ,

@d_contact ,

@d_email ,

@d_dateofbirth



)

END





select * from tbl_doctor


CRUD OPERATION IN PHP WITH MYSQLI PART 3









<!doctype html>

<html>

<head>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">



<style type="text/css">



table,th

{

text-align: center;



}

td

{

padding: 10px;

}



</style>



</head>



<body>



<div class="col-lg-12 col-md-12 col-sm-12"  style="height: 200px;">



<form method="post">



<table>



<tr>

<td> Book Name</td>

<td> <input type="text" name="book" class="form-control" placeholder="Book Name"></td>



</tr>





<tr>

<td> Book Price</td>

<td> <input type="text" name="price" class="form-control" placeholder="Book Price"></td>



</tr>





<tr>

<td> <input type="submit" name="btnAdd" class="btn btn-info"> </td>



</tr>





</table>





</form>



</div>











<?php

include 'includes/connection.php';



if (isset($_POST['btnAdd']))

{

$book=$_POST['book'];

$price= $_POST['price'];



$sql      ="INSERT INTO `tbl_book`( `BOOK_NAME`, `BOOK_pirce`) VALUES (?,?)";



$stmt=$conn->prepare($sql);



if (!$stmt)

{

echo "<script>alert('failed to insert data.....'); </script>";

}

else

{

$stmt->bind_param('ss',$book,$price);



$stmt->execute();

$stmt->close();







}





} // button event ends here.........................................................















$sqlquery="SELECT * FROM `tbl_book` ";



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

{

echo '<table class="table table-bordered table-responsive table-striped">';

echo "<thead>

<tr>

<th>ID </th>

<th>NAME </th>

<th>PRICE </th>







 </tr>

 </thead> ";



while ($row= mysqli_fetch_assoc($result))

{



echo "<tr> <td>". $row["BOOK_ID"]." </td>  <td>". $row["BOOK_NAME"]."  </td> <td>".$row["BOOK_pirce"]." </td> </tr>";



}

echo "</table>";





 mysqli_free_result($result);





}

else 

{

# code...





}



mysqli_close($conn);



 ?>









</body>





</html>


Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...