This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Me And My Respected Teacher Mr Kamal Sheel Mishra

Mr. K.S. Mishra is HOD of Computer Science from SMS Varanasi where I have completed my MCA

Me And My Respected Teacher Mr Udayan Maiti

Mr. Udayan Maiti is a senior .Net Expert and has guided many professionals of multi national Companies(MNC)

Me And My Best Friend Mr Ravinder Goel

Mr. Ravinder Goel is a senior Software Engineer and now he is working Wipro Technology

Thursday 20 February 2014

How to create Tic Tack Game in Windows Application with C# .Net

How to create Tic Tack Game in Windows Application with C# .Net

Note: In this topic we will discuss about how to create Windows Games with cross and zero which is very popular and people generally play this game on paper with pen 

First we take a Windows Application with From1 and drag nine Buttons from Toolbox and create common click event for each Button as shown bellow picture…..



Code for Form1.cs ……………………..

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TicTacToeWindowsFormsApplication
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

int Count = 1;

// create click event for all  Button.................................

private void Click(object sender, EventArgs e)
{
Button b = (Button)sender;
b.Text = (Count % 2 == 0) ? "0" : "X";
b.Enabled = false;
Count++;
check();
}

private void Form1_Load(object sender, EventArgs e)
{

}

//condition for 8 logic...with row column diagonal...........................

void check()
{
if (button1.Text == button2.Text && button2.Text == button3.Text&&button1.Text!="")
{
result(button1.Text);
}
else if (button4.Text == button5.Text && button5.Text == button6.Text&&button4.Text!="")
{
result(button4.Text);
}
else if (button7.Text == button8.Text && button8.Text == button9.Text&&button7.Text!="")
{
result(button7.Text);
}
else if (button1.Text == button4.Text && button4.Text == button7.Text&&button1.Text!="")
{
result(button1.Text);
}
else if (button2.Text == button5.Text && button5.Text == button8.Text&&button2.Text!="")
{
result(button2.Text);
}
else if (button3.Text == button6.Text && button6.Text == button9.Text&&button3.Text!="")
{
result(button3.Text);
}
else if (button1.Text == button5.Text && button5.Text == button9.Text && button1.Text != "")
{
result(button1.Text);
}
else if (button3.Text == button5.Text && button5.Text == button7.Text && button3.Text != "")
{
result(button3.Text);
}
else if (Count == 10)
{
result("");
}
}

//code for  result.....................

void result(string text)
{
if (text == "0")
{
MessageBox.Show("Second Player has won the GAME!!!!!!!!");
}
else if (text == "X")
{
MessageBox.Show("First Player has won the GAME!!!!!!!!");
}
else
{
MessageBox.Show("Game Draw!!!!!");
}
if (MessageBox.Show("Are You Want To Play Again!", "Confirmation Message", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
reset();
}
else
{
this.Close();
}
}

//code for reset button.....................

void reset()
{
foreach (Button b in this.Controls)
{
b.Text = "";
b.Enabled = true;
}
Count = 1;
}
}
}
  
Result




Sunday 16 February 2014

Bind Json Result to Dropdown list in MVC4 with Country State City Concept

Bind Json Result to Dropdown list in MVC4 with Country State City Concept

--sql query....................
create database JqueryExam
use JqueryExam

--create table county,state,city in database...................
create table CountryDetails(CountryId int primary key,CountryName varchar(50) unique)

create table StateDetails(StateId int primary key,StateName varchar(50)unique,CountryId int foreign key references CountryDetails(CountryId) on delete cascade)

create table CityDetails(CityId int primary key,CityName varchar(50)unique,StateId int foreign key references StateDetails(StateId) on delete cascade)

--insert into tables........................

insert into CountryDetails values(1,'India')
insert into CountryDetails values(2,'England')

insert into StateDetails values(1,'Uttar Pradesh',1)
insert into StateDetails values(2,'Madhya Pradesh',1)

insert into CityDetails values(1,'Varanasi',1)
insert into CityDetails values(2,'Ghaziabad',1)
insert into CityDetails values(3,'Lucknow',1)
insert into CityDetails values(4,'Bhopal',2)
insert into CityDetails values(5,'Reewa',2)

Note :In this topic  this picture  is  very  helpful for you ………………….



Code for View which name is Index.cshtml………………………
@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Country State City Bind </title>
<script src="~/Scripts/jquery-1.7.1.js"></script>
<script type="text/javascript">
$(function ()
{

//******* code for state bind with countryid…………..

$("#ddlcountry").change(function () {
//debugger;
//$(this).closest('tr').remove();
var v2 = $(this).val();
$.get("Home/StateBind", { country: v2 }, function (data) {
$("#state").empty();
var v = "<option>Select</option>";
$.each(data, function (i, v1) {
v += "<option value='" + v1.Value + "'>" + v1.Text + "</option>";
});
$("#state").html(v);
});
});

//******* code for city bind with stated……………………

$("#state").change(function () {
var v2 = $(this).val();
$.get("Home/CityBind", { state: v2 }, function (data) {
$("#city").empty();
var v = "<option>Select</option>";
$.each(data, function (i, v1) {
v += "<option value='" + v1.Value + "'>" + v1.Text + "</option>";
});
$("#city").html(v);
});
});
});
</script>
</head>

<body>
<div>
<table>
<tr><td colspan="2"><font color="Red">Bind Json Result to DropDownlist in MVC4 Country State City Concept</font></td></tr>
<tr><td>Country Name</td><td>@Html.DropDownList("ddlcountry", "Select" )</td></tr>
<tr><td>State Name</td><td><select id="state"><option>Select</option></select></td></tr>
<tr><td>City Name</td><td><select id="city"><option>Select</option></select></td></tr>

</table>
</div>
</body>
</html>

Code for Controller which name is HomeController ………………………

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
//using namespace............
using MvcCountryStateCity.Models;

namespace MvcCountryStateCity.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
//create instance of  entity...........................
JqueryExamEntities mm = new JqueryExamEntities();

public ActionResult Index()
{
ViewBag.ddlcountry = CountryBind();
return View();

}

//code for bind Country Name...........................
public List<SelectListItem> CountryBind()
{
List<SelectListItem> li = new List<SelectListItem>();
foreach (var v in mm.CountryDetails)
{
li.Add(new SelectListItem { Text = v.CountryName, Value = v.CountryId.ToString() });
}

//ViewBag.ddlcountry = li;
//return View();
return li;

}

//code for bind State Name...........................
[HttpGet]
public JsonResult StateBind(string country)
{

int id = Convert.ToInt32(country);
var v = mm.StateDetails.Where(m => m.CountryId == id).Select(m => new { Text = m.StateName, Value = m.StateId });
return Json(v, JsonRequestBehavior.AllowGet);

}

//code for bind City Name...........................
[HttpGet]
public JsonResult CityBind(string state)
{

int id = Convert.ToInt32(state);
var v = mm.CityDetails.Where(m => m.StateId == id).Select(m => new { Text = m.CityName, Value = m.CityId });
return Json(v, JsonRequestBehavior.AllowGet);

}
}
}
Result: