Ajax Auto Complete Tutorial With Source Code
For Beginners
First We Have To Create An Database.I am Using Sql Server For Database.
create table CART
(
ITEM_ID int Primary key identity(1,1),
Item_Name varchar(50),
Quantity int
)
insert into CART Values('Milk',10)
insert into CART Values('Soap',10)
insert into CART Values('Juice',10)
insert into CART Values('Jelly',10)
insert into CART Values('Toffee',10)
insert into CART Values('Tea',10)
insert into CART Values('Ice Cream',10)
insert into CART Values('Coffee',10)
insert into CART Values('Rice',10)
insert into CART Values('Risk',10)
Then You Open A Visual Studio And Select Asp Empty Website.
Then You Have To Create And Connection String So there Is web.config located there so open it
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.; Initial Catalog=Practice2AutoComplete; Integrated Security=True"/>
</connectionStrings>
Friday, 12 September 2014
Thursday, 30 January 2014
Simple Forn For Student In PHP
Simple Forn For Student In PHP
<html>
<head>
</head>
<body>
<form action="" method="POST">
<table>
<tr><td>First Name:</td><td><input type="text" name="fname" /></td></tr>
<tr><td>Last Name:</td><td><input type="text" name="lname" /></td></tr>
<tr><td>Email:</td><td><input type="text" name="email" /></td></tr>
<tr><td>Gender:</td><td>Male<input type="radio" name="gen" value="Male" />Female<input type="radio" name="gen" value="Female" /></td></tr>
<tr><td>Country:</td><td><select name="con">
<option>Pakistan</option>
<option>London</option>
<option>Paris</option>
</select></td>
</tr>
<tr><td>Hobbies:</td><td>Long Drive<input type="checkbox" name="h[]" value="driving" />Cricket<input type="checkbox" value="Cricket" name="h[]" />xBox<input type="checkbox" value="Xbox" name="h[]" /></td></tr>
</table>
<input type="submit" />
<input name="reset" type="reset" />
</form>
<?php
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$gen = $_POST['gen'];
$con = $_POST['con'];
$val = $_POST['h'];
$c = count($val);
echo '<table border="1" style="font-size:25px; font-family:tahoma; color:green;">';
echo '<tr align="center"><td colspan="2">YOUR INFORMATION</td><tr>';
echo '<tr><td>Your Name:</td><td>'.$fname.'</td></tr>';
echo '<tr><td>Your Last Name:</td><td>'.$lname.'</td></tr>';
echo '<tr><td>Your Email:</td><td>'.$email.'</td></tr>';
echo '<tr><td>Your Gender:</td><td>'.$gen.'</td></tr>';
echo '<tr><td>Your Country:</td><td>'.$con.'</td></tr>';
if (empty($val))
{
echo 'No Hobbies';
}
else
{
}
echo '</table>';
?>
</body>
</html>
<head>
</head>
<body>
<form action="" method="POST">
<table>
<tr><td>First Name:</td><td><input type="text" name="fname" /></td></tr>
<tr><td>Last Name:</td><td><input type="text" name="lname" /></td></tr>
<tr><td>Email:</td><td><input type="text" name="email" /></td></tr>
<tr><td>Gender:</td><td>Male<input type="radio" name="gen" value="Male" />Female<input type="radio" name="gen" value="Female" /></td></tr>
<tr><td>Country:</td><td><select name="con">
<option>Pakistan</option>
<option>London</option>
<option>Paris</option>
</select></td>
</tr>
<tr><td>Hobbies:</td><td>Long Drive<input type="checkbox" name="h[]" value="driving" />Cricket<input type="checkbox" value="Cricket" name="h[]" />xBox<input type="checkbox" value="Xbox" name="h[]" /></td></tr>
</table>
<input type="submit" />
<input name="reset" type="reset" />
</form>
<?php
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$gen = $_POST['gen'];
$con = $_POST['con'];
$val = $_POST['h'];
$c = count($val);
echo '<table border="1" style="font-size:25px; font-family:tahoma; color:green;">';
echo '<tr align="center"><td colspan="2">YOUR INFORMATION</td><tr>';
echo '<tr><td>Your Name:</td><td>'.$fname.'</td></tr>';
echo '<tr><td>Your Last Name:</td><td>'.$lname.'</td></tr>';
echo '<tr><td>Your Email:</td><td>'.$email.'</td></tr>';
echo '<tr><td>Your Gender:</td><td>'.$gen.'</td></tr>';
echo '<tr><td>Your Country:</td><td>'.$con.'</td></tr>';
if (empty($val))
{
echo 'No Hobbies';
}
else
{
}
echo '</table>';
?>
</body>
</html>
Login With Session And Customer Add In PHP For Beginners
Login With Session And Customer Add In PHP For Beginners
Index.php
html
<h2 align=Right>Please Login ....</h2>
<form Action="Index.php" Method="POST">
<table border=1 CellPadding=5 CellSpacing=5 align=Right>
<tr>
<td>UserName</td>
<td><Input Type=Text name=txtName Required /></td>
</tr>
<tr>
<td>Password</td>
<td><Input Type=Password name=txtPass Required></td>
</tr>
<tr>
<td>.</td>
<td Align=Right><Input Type=Submit name=btnLogin value=Login></td>
</tr>
</table>
</form>
<form Action="Index.php" Method="POST">
<table border=1 CellPadding=5 CellSpacing=5 align=Right>
<tr>
<td>UserName</td>
<td><Input Type=Text name=txtName Required /></td>
</tr>
<tr>
<td>Password</td>
<td><Input Type=Password name=txtPass Required></td>
</tr>
<tr>
<td>.</td>
<td Align=Right><Input Type=Submit name=btnLogin value=Login></td>
</tr>
</table>
</form>
php
<?php
session_start();
$_SESSION['UName'] = "";
if(isset($_POST['btnLogin']))
{
$UN = $_POST['txtName'];
$UP = $_POST['txtPass'];
$A = mysql_connect("LocalHost","root","");
mysql_select_db("AirLineDB",$A);
$B = mysql_query("Select UID from tblUsers where UName='$UN' and UPass='$UP'",$A);
mysql_close($A);
if(mysql_num_rows($B)>0)
{
$_SESSION['UName']=$UN;
echo "<meta http-equiv='Refresh'; Content='0; URL=Home.php';>";
}
else
{ $Err="Try again...."; }
}
?>
session_start();
$_SESSION['UName'] = "";
if(isset($_POST['btnLogin']))
{
$UN = $_POST['txtName'];
$UP = $_POST['txtPass'];
$A = mysql_connect("LocalHost","root","");
mysql_select_db("AirLineDB",$A);
$B = mysql_query("Select UID from tblUsers where UName='$UN' and UPass='$UP'",$A);
mysql_close($A);
if(mysql_num_rows($B)>0)
{
$_SESSION['UName']=$UN;
echo "<meta http-equiv='Refresh'; Content='0; URL=Home.php';>";
}
else
{ $Err="Try again...."; }
}
?>
Home.php
html
<h2 align=Center>Add New Customer</h2>
<form action="Home.php" Method="POST">
<table border=1 CellPadding=5 CellSpacing=5 Align=center>
<tr align=center BGColor=aqua><td colspan=2>Flight Information</td></tr>
<tr>
<td>Customer Name</td>
<td><input type=Text name=txtName Required></td>
</tr>
<tr>
<td>Customer N-I-C</td>
<td><input type=Text name=txtCNIC Required></td>
</tr>
<tr>
<td>Select AirLine</td>
<td><Select name=cmbAL Style=Width:145>
<option Selected>Emirates</option>
<option>Lufthansa</option>
<option>Air Blue</option>
<option>Bhoja Air</option>
<option>Fly Dubai</option>
<option>P-I-A</option>
</select></td>
</tr>
<tr>
<td>From City</td>
<td><Select name=cmbFC Style=Width:145>
<option>Karachi</option>
<option Selected>Lahore</option>
<option>Islamabad</option>
<option>Hyderabad</option>
<option>Peshawar</option>
<option>Quetta</option>
</select></td>
</tr>
<tr>
<td>To City</td>
<td><Select name=cmbTC Style=Width:145>
<option Selected>Karachi</option>
<option>Lahore</option>
<option>Islamabad</option>
<option>Hyderabad</option>
<option>Peshawar</option>
<option>Quetta</option>
</select></td>
</tr>
<tr>
<td>Enter Fare</td>
<td><input type=Text name=txtFare Required></td>
</tr>
<tr>
<td>.</td>
<td align=right><input type=Submit name=btnSave value=Save></td>
</tr>
</table>
</form>
<form action="Home.php" Method="POST">
<table border=1 CellPadding=5 CellSpacing=5 Align=center>
<tr align=center BGColor=aqua><td colspan=2>Flight Information</td></tr>
<tr>
<td>Customer Name</td>
<td><input type=Text name=txtName Required></td>
</tr>
<tr>
<td>Customer N-I-C</td>
<td><input type=Text name=txtCNIC Required></td>
</tr>
<tr>
<td>Select AirLine</td>
<td><Select name=cmbAL Style=Width:145>
<option Selected>Emirates</option>
<option>Lufthansa</option>
<option>Air Blue</option>
<option>Bhoja Air</option>
<option>Fly Dubai</option>
<option>P-I-A</option>
</select></td>
</tr>
<tr>
<td>From City</td>
<td><Select name=cmbFC Style=Width:145>
<option>Karachi</option>
<option Selected>Lahore</option>
<option>Islamabad</option>
<option>Hyderabad</option>
<option>Peshawar</option>
<option>Quetta</option>
</select></td>
</tr>
<tr>
<td>To City</td>
<td><Select name=cmbTC Style=Width:145>
<option Selected>Karachi</option>
<option>Lahore</option>
<option>Islamabad</option>
<option>Hyderabad</option>
<option>Peshawar</option>
<option>Quetta</option>
</select></td>
</tr>
<tr>
<td>Enter Fare</td>
<td><input type=Text name=txtFare Required></td>
</tr>
<tr>
<td>.</td>
<td align=right><input type=Submit name=btnSave value=Save></td>
</tr>
</table>
</form>
PHP
<?php
session_start();
if($_SESSION['UName']=="")
{ echo "<meta http-equiv='Refresh'; Content='0; URL=Index.php';>"; exit; }
if(isset($_GET['A']))
{
$AID = $_GET['A'];
$A = mysql_connect("LocalHost","root","");
mysql_select_db("AirLineDB",$A);
mysql_query("Update tblAirLine set Status='False' Where AID='$AID'",$A);
mysql_close($A);
}
?>
<?php
if(isset($_POST['btnSave']))
{
$PN = $_POST['txtName'];
$NC = $_POST['txtCNIC'];
$AL = $_POST['cmbAL'];
$FC = $_POST['cmbFC'];
$TC = $_POST['cmbTC'];
$FR = $_POST['txtFare'];
$A = mysql_connect("LocalHost","root","");
mysql_select_db("AirLineDB",$A);
mysql_query("Insert into tblAirLine values ('','$PN','$NC','$AL','$FC','$TC','$FR','True')",$A);
mysql_close($A);
}
?>
session_start();
if($_SESSION['UName']=="")
{ echo "<meta http-equiv='Refresh'; Content='0; URL=Index.php';>"; exit; }
if(isset($_GET['A']))
{
$AID = $_GET['A'];
$A = mysql_connect("LocalHost","root","");
mysql_select_db("AirLineDB",$A);
mysql_query("Update tblAirLine set Status='False' Where AID='$AID'",$A);
mysql_close($A);
}
?>
<?php
if(isset($_POST['btnSave']))
{
$PN = $_POST['txtName'];
$NC = $_POST['txtCNIC'];
$AL = $_POST['cmbAL'];
$FC = $_POST['cmbFC'];
$TC = $_POST['cmbTC'];
$FR = $_POST['txtFare'];
$A = mysql_connect("LocalHost","root","");
mysql_select_db("AirLineDB",$A);
mysql_query("Insert into tblAirLine values ('','$PN','$NC','$AL','$FC','$TC','$FR','True')",$A);
mysql_close($A);
}
?>
Basic Salary Method In PHP For Beginners
Basic Salary Method In PHP For Beginners
<html>
<head>
<title>PHP Salary Calculator</title>
</head>
<body>
<form action="" method="post" >
<table>
<tr>
<td>
Full Name:</td><td><input type="text" name="fname"
/></td></tr>
<tr>
<td>
Basic Salary:</td><td><input type="text" name="salary"
required="required"/></td></tr>
</table>
<input type="submit" value="Calculate" /> <input type="reset" />
</form>
<?php
$fname = $_POST['fname'];
$salary = $_POST['salary'];
$show_CA = '';
$show_MA = '';
$show_HR = '';
$CA_Calculate ='' ;
$MA_Calculate = '';
$HR_Calculate = '';
$itax = '';
if($salary > 30000)
{
if($salary > 50000)
{
$itax =$salary * 3 / 100;
}
$show_CA = 20;
$show_MA = 30;
$show_HR = 40;
$CA_Calculate = $salary * $show_CA /100 ;
$MA_Calculate = $salary * $show_MA /100 ;
$HR_Calculate = $salary * $show_HR /100 ;
}
else if( $salary > 25000)
{
$show_CA = 15;
$show_MA = 20;
$show_HR = 30;
$CA_Calculate = $salary * $show_CA /100 ;
$MA_Calculate = $salary * $show_MA /100 ;
$HR_Calculate = $salary * $show_HR /100 ;
}
else if( $salary > 20000)
{
$show_CA = 10;
$show_MA = 15;
$show_HR = 25;
$CA_Calculate = $salary * $show_CA /100 ;
$MA_Calculate = $salary * $show_MA /100 ;
$HR_Calculate = $salary * $show_HR /100 ;
}
else if( $salary < 20000)
{
$show_CA = 'fixed';
$show_MA = 'fixed';
$show_HR = 'fixed';
$CA_Calculate = 1000;
$MA_Calculate = 1500 ;
$HR_Calculate =2000 ;
}
$cal_salary = $salary + $CA_Calculate + $MA_Calculate + $HR_Calculate;
$pfund = $salary * 10 /100;
$netsalary = $cal_salary - ($pfund + $itax);
echo '<table style="font-family:tahoma;" width="25%"><tr><td >Full Name</td><td colspan="2" align="center" style="font-weight:bold;" >' .$fname . '</td></tr>';
echo '<tr><td>Basic Salary</td><td colspan="2" align="center" style="color:red;">' .$salary . '</td></tr>';
echo '<tr><td>CA</td><td>' .$show_CA . '%</td><td>'.$CA_Calculate.'</td></tr>';
echo '<tr><td>MA</td><td>' .$show_MA . '%</td><td>'.$MA_Calculate.'</td></tr>';
echo '<tr><td>HR</td><td>' .$show_HR . '%</td><td>'.$HR_Calculate.'</td></tr>';
echo '<tr><td>PFUND</td><td>10%</td><td>'.$pfund.'</td></tr>';
echo '<tr><td>ITax</td><td>3%</td><td>'.$itax.'</td></tr>';
echo '<tr><td>Net Salary</td><td style="color:green; font-size:30px;" colspan="2" align="center">'.$netsalary.'</td></tr>';
echo '<table>';
?>
</body>
</html>
<head>
<title>PHP Salary Calculator</title>
</head>
<body>
<form action="" method="post" >
<table>
<tr>
<td>
Full Name:</td><td><input type="text" name="fname"
/></td></tr>
<tr>
<td>
Basic Salary:</td><td><input type="text" name="salary"
required="required"/></td></tr>
</table>
<input type="submit" value="Calculate" /> <input type="reset" />
</form>
<?php
$fname = $_POST['fname'];
$salary = $_POST['salary'];
$show_CA = '';
$show_MA = '';
$show_HR = '';
$CA_Calculate ='' ;
$MA_Calculate = '';
$HR_Calculate = '';
$itax = '';
if($salary > 30000)
{
if($salary > 50000)
{
$itax =$salary * 3 / 100;
}
$show_CA = 20;
$show_MA = 30;
$show_HR = 40;
$CA_Calculate = $salary * $show_CA /100 ;
$MA_Calculate = $salary * $show_MA /100 ;
$HR_Calculate = $salary * $show_HR /100 ;
}
else if( $salary > 25000)
{
$show_CA = 15;
$show_MA = 20;
$show_HR = 30;
$CA_Calculate = $salary * $show_CA /100 ;
$MA_Calculate = $salary * $show_MA /100 ;
$HR_Calculate = $salary * $show_HR /100 ;
}
else if( $salary > 20000)
{
$show_CA = 10;
$show_MA = 15;
$show_HR = 25;
$CA_Calculate = $salary * $show_CA /100 ;
$MA_Calculate = $salary * $show_MA /100 ;
$HR_Calculate = $salary * $show_HR /100 ;
}
else if( $salary < 20000)
{
$show_CA = 'fixed';
$show_MA = 'fixed';
$show_HR = 'fixed';
$CA_Calculate = 1000;
$MA_Calculate = 1500 ;
$HR_Calculate =2000 ;
}
$cal_salary = $salary + $CA_Calculate + $MA_Calculate + $HR_Calculate;
$pfund = $salary * 10 /100;
$netsalary = $cal_salary - ($pfund + $itax);
echo '<table style="font-family:tahoma;" width="25%"><tr><td >Full Name</td><td colspan="2" align="center" style="font-weight:bold;" >' .$fname . '</td></tr>';
echo '<tr><td>Basic Salary</td><td colspan="2" align="center" style="color:red;">' .$salary . '</td></tr>';
echo '<tr><td>CA</td><td>' .$show_CA . '%</td><td>'.$CA_Calculate.'</td></tr>';
echo '<tr><td>MA</td><td>' .$show_MA . '%</td><td>'.$MA_Calculate.'</td></tr>';
echo '<tr><td>HR</td><td>' .$show_HR . '%</td><td>'.$HR_Calculate.'</td></tr>';
echo '<tr><td>PFUND</td><td>10%</td><td>'.$pfund.'</td></tr>';
echo '<tr><td>ITax</td><td>3%</td><td>'.$itax.'</td></tr>';
echo '<tr><td>Net Salary</td><td style="color:green; font-size:30px;" colspan="2" align="center">'.$netsalary.'</td></tr>';
echo '<table>';
?>
</body>
</html>
Monday, 13 January 2014
Small Inventory Software For Beginners In C#
Small Inventory Software For Beginners In C#
ds = new InventoryDataSet();
pta = new InventoryDataSetTableAdapters.ProductsTableAdapter();
int id = GenerateBookID();
ds.Products.Columns["ProductID"].AutoIncrement = true;
ds.Products.Columns["ProductID"].AutoIncrementSeed = id;
ds.Products.Columns["ProductID"].AutoIncrementStep = 1;
PopulateID();
txtProductID.DataBindings.Add("Text", ds.Products, "ProductID");
}
private void frmAddProduct_Load(object sender, EventArgs e)
{
dtpDate.MaxDate = DateTime.Today;
dtpDate.Value = DateTime.Today;
}
private int GenerateBookID()
{
try
{
int id;
if (pta.Connection.State == ConnectionState.Closed)
{
pta.Connection.Open();
}
string cmd = "Select Count(ProductID) from products";
pta.Adapter.SelectCommand = new SqlCommand(cmd, pta.Connection);
int result = (int)pta.Adapter.SelectCommand.ExecuteScalar();
if (result == 0)
{
id = 700;
}
else
{
cmd = "Select Max(ProductID) from products";
pta.Adapter.SelectCommand = new SqlCommand(cmd, pta.Connection);
id = (int)pta.Adapter.SelectCommand.ExecuteScalar() + 1;
}
return id;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return -1;
}
}
private void PopulateID()
{
ds.Products.Clear();
row = ds.Products.NewProductsRow();
ds.Products.Rows.Add(row);
}
pta = new InventoryDataSetTableAdapters.ProductsTableAdapter();
int id = GenerateBookID();
ds.Products.Columns["ProductID"].AutoIncrement = true;
ds.Products.Columns["ProductID"].AutoIncrementSeed = id;
ds.Products.Columns["ProductID"].AutoIncrementStep = 1;
PopulateID();
txtProductID.DataBindings.Add("Text", ds.Products, "ProductID");
}
private void frmAddProduct_Load(object sender, EventArgs e)
{
dtpDate.MaxDate = DateTime.Today;
dtpDate.Value = DateTime.Today;
}
private int GenerateBookID()
{
try
{
int id;
if (pta.Connection.State == ConnectionState.Closed)
{
pta.Connection.Open();
}
string cmd = "Select Count(ProductID) from products";
pta.Adapter.SelectCommand = new SqlCommand(cmd, pta.Connection);
int result = (int)pta.Adapter.SelectCommand.ExecuteScalar();
if (result == 0)
{
id = 700;
}
else
{
cmd = "Select Max(ProductID) from products";
pta.Adapter.SelectCommand = new SqlCommand(cmd, pta.Connection);
id = (int)pta.Adapter.SelectCommand.ExecuteScalar() + 1;
}
return id;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return -1;
}
}
private void PopulateID()
{
ds.Products.Clear();
row = ds.Products.NewProductsRow();
ds.Products.Rows.Add(row);
}
private void ADDBTN_Click(object sender, EventArgs e)
{try
{
row["ProductID"] = txtProductID.Text;
row["Name"] = txtName.Text;
row["Price"] = txtPrice.Text;
row["PurchaseDate"] = dtpDate.Value;
pta.Adapter.Update(ds.Products);
MessageBox.Show("Product data Add SuccesFully");
ClearText();
}
catch (Exception ex)
{
MessageBox.Show("Product data not added");
ds.RejectChanges();
}
}
{
if (!cancelling)
{
error = false;
if (string.IsNullOrEmpty(txtName.Text))
{
MessageBox.Show("Name cannot be empty");
error=true;
}
else
{
IEnumerator OperandEnum = txtName.Text.GetEnumerator();
while (OperandEnum.MoveNext())
{
char chr = (char)OperandEnum.Current;
if (!char.IsLetter(chr))
{
error=true;
MessageBox.Show("Invalid Name","Error");
txtName.Text="";
break;
}
}
}
if (error)
{
txtName.Focus();
e.Cancel=true;
}
}
}
private void txtPrice_Validating(object sender, CancelEventArgs e)
{
if (!cancelling)
{
error = false;
if (string.IsNullOrEmpty(txtPrice.Text))
{
MessageBox.Show("Price cannot be empty");
}
else
{
decimal price;
if (!Decimal.TryParse(txtPrice.Text, out price))
{
MessageBox.Show("Invalid Price");
txtPrice.Text = "";
error = true;
}
}
if (error)
{
e.Cancel = true;
}
}
}
Tuesday, 7 January 2014
Concept Of AcceptChanges() and RejectChanges()
Concept Of AcceptChanges() and RejectChanges()
ExpressionDataSet ds;
ExpressionDataSetTableAdapters.expressionTableAdapter sta;
private void AcpBtn_Click(object sender, EventArgs e)
{
try
{
ds = new ExpressionDataSet();
sta = new ExpressionDataSetTableAdapters.expressionTableAdapter();
sta.Fill(ds.expression);
DataRow dr = ds.expression.NewRow();
dr ["StudentID"] = textBox1.Text;
dr["Name"] = textBox2.Text;
dr["English"] = textBox3.Text;
dr["Chemistry"] = textBox4.Text;
dr["Math"] = textBox5.Text;
ds.expression.Rows.Add(dr);
sta.Adapter.Update(ds.expression);
ds.expression.AcceptChanges();
MessageBox.Show("Stored");
}
catch(Exception ex)
{
ds.RejectChanges();
}
}
ExpressionDataSetTableAdapters.expressionTableAdapter sta;
private void AcpBtn_Click(object sender, EventArgs e)
{
try
{
ds = new ExpressionDataSet();
sta = new ExpressionDataSetTableAdapters.expressionTableAdapter();
sta.Fill(ds.expression);
DataRow dr = ds.expression.NewRow();
dr ["StudentID"] = textBox1.Text;
dr["Name"] = textBox2.Text;
dr["English"] = textBox3.Text;
dr["Chemistry"] = textBox4.Text;
dr["Math"] = textBox5.Text;
ds.expression.Rows.Add(dr);
sta.Adapter.Update(ds.expression);
ds.expression.AcceptChanges();
MessageBox.Show("Stored");
}
catch(Exception ex)
{
ds.RejectChanges();
}
}
Wednesday, 1 January 2014
How To Show Data In Text Box Through Grid view
How To Show Data In Text Box Through Grid view
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=master;Integrated Security=True");
DataTable dt;
private void id_search_TextChanged(object sender, EventArgs e)
{
DataTable dd = new DataTable();
SqlCommand cmd = new SqlCommand("select ID,Name,Designation,Salary from Accounts where ID in ('" + id_search.Text + "')", con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
SqlDataAdapter dt = new SqlDataAdapter();
if (dr.Read())
{
dr.Close();
dt.SelectCommand = cmd;
dt.Fill(dd);
dataGridView1.DataSource = dd;
}
else
{
}
con.Close();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs a)
{
if (a.RowIndex >= 0)
{
DataGridViewRow row = this.dataGridView1.Rows[a.RowIndex];
txtid.Text = row.Cells["ID"].Value.ToString();
txtname.Text = row.Cells["Name"].Value.ToString();
txtdes.Text = row.Cells["Designation"].Value.ToString();
txtsal.Text = row.Cells["Salary"].Value.ToString();
}
}
private void LoadDatabase_btn_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("select * from Accounts", con);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
}
DataTable dt;
private void id_search_TextChanged(object sender, EventArgs e)
{
DataTable dd = new DataTable();
SqlCommand cmd = new SqlCommand("select ID,Name,Designation,Salary from Accounts where ID in ('" + id_search.Text + "')", con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
SqlDataAdapter dt = new SqlDataAdapter();
if (dr.Read())
{
dr.Close();
dt.SelectCommand = cmd;
dt.Fill(dd);
dataGridView1.DataSource = dd;
}
else
{
}
con.Close();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs a)
{
if (a.RowIndex >= 0)
{
DataGridViewRow row = this.dataGridView1.Rows[a.RowIndex];
txtid.Text = row.Cells["ID"].Value.ToString();
txtname.Text = row.Cells["Name"].Value.ToString();
txtdes.Text = row.Cells["Designation"].Value.ToString();
txtsal.Text = row.Cells["Salary"].Value.ToString();
}
}
private void LoadDatabase_btn_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("select * from Accounts", con);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
}
Boxing Example For Beginners In C#
Boxing/Un-Boxing Example For Beginners In C#
private void boxingbtn_Click(object sender, EventArgs e)
{
int a = 5;
object o = a;//boxing
a = a + a;
int b;
b = (int)o;//unboxing
b = 5 + 5;
label11.Text = a.ToString();
label12.Text = b.ToString();
// boxing
points p = new points(10,10);
object box = p;
p.x = 20;
label13.Text = ((points)box).x.ToString();
//Unboxing
object box1 = 12;
int x = (int)box1;
box1 = 12 + 12 + 12;
label15.Text = x.ToString();
// Boxing Sample
int c = 12;
object d = (object)c;
label14.Text = d.ToString();
//Unboxing Sample
c = (int) d;
this.Text = c.ToString();
}
{
int a = 5;
object o = a;//boxing
a = a + a;
int b;
b = (int)o;//unboxing
b = 5 + 5;
label11.Text = a.ToString();
label12.Text = b.ToString();
// boxing
points p = new points(10,10);
object box = p;
p.x = 20;
label13.Text = ((points)box).x.ToString();
//Unboxing
object box1 = 12;
int x = (int)box1;
box1 = 12 + 12 + 12;
label15.Text = x.ToString();
// Boxing Sample
int c = 12;
object d = (object)c;
label14.Text = d.ToString();
//Unboxing Sample
c = (int) d;
this.Text = c.ToString();
}
Lamda And Enum Example Tutorial For Beginners
Lamda And Enum Example Tutorial For Beginners
//Lamda Expression//
public delegate int calc(int la);
public delegate int calc(int la);
private void lamdabtn_Click(object sender, EventArgs e)
{
//Lamda
mob la = l => l * l * l;
label7.Text = la(6).ToString();
//---------------------------//
}
{
//Lamda
mob la = l => l * l * l;
label7.Text = la(6).ToString();
//---------------------------//
}
//Enum//
enum em { mon, tue, wed, thurs, fri = 50, sat, sun };
private void Enumbtn_Click(object sender, EventArgs e)
{
enumlabel1.Text = em.fri.ToString();
int x = (int)em.fri;
enumlabel2.Text = x.ToString();
}
Subscribe to:
Posts (Atom)