Exclusive one day event on Microsoft Technologies at Mumbai, Chennai, Bangalore, Hydarabad and Pune.
http://www.microsoft.com/india/events/webcamps/default.aspx
Saturday, April 30, 2011
Microsoft WebCamps May 5 - June 30
Thursday, April 21, 2011
Microsoft Windows Azure Camp - 30th April - 2011
Zenith Hall, UST Global, Bhavani,Technopark, Trivandrum, Kerala
Agenda
Cloud Computing and Azure Overview
Azure Architecture
Azure Management Portal
Services and Tools Needed
Create and debug Azure Application
Deploy application in Azure
Lunch Break
Moving ASP.NET application to Azure
Moving SQL Express database to Azure SQL
Windows Azure App Fabric Cache
Register
Monday, April 18, 2011
WCF RIA Services with Silverlight 4
In the next dialog select Enable WCF RIA Service.
A Silverlight Solution comprises of two project one an Asp .Net Project and another the client Silverlight project.
I am creating an Ado .Net Entity Data Model for connecting to AirLines database in the Web Project.
Run the project. Add a Domain Service Class to the Web Project.
In the Add New Domain Service Class dialog you can see all the tables selected in the Ado .Net Entity Data Model. Check Enable Editing so that it will generate CUD (Create Update Delete) code.
Again run the project so that the Domain Service class will automatically generate the proxy which you can use from Silverlight.
Now I am ready consuming the Domain Service from Silverlight.
My intention is the show the contents of Locations table inside an DataGrid. I am also filling a ComboBox with LocationNames.
using SilverlightRiaShalvin.Web;
DomainService1 context = new DomainService1();
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
dataGrid1.ItemsSource = context.Locations;
comboBox1.ItemsSource = context.Locations;
comboBox1.DisplayMemberPath = "LocationName";
comboBox1.SelectedValuePath = "Locationid";
context.Load<Location>(context.GetLocationsQuery());
}
Here I am extracting the LocationId of the selected Location.
private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
MessageBox.Show(comboBox1.SelectedValue.ToString());
}
Here the code for inserting a value to Location Table.
private void button1_Click(object sender, RoutedEventArgs e)
{
var Loc = new Location{LocationName = "Trivandrum"};
context.Locations.Add(Loc);
context.SubmitChanges();
MessageBox.Show("Record saved");
}
Silverlight Business Application Air Lines Project
Now let's take up the AirLines project.
CREATE TABLE dbo.Locations(
LocationId int IDENTITY(1,1) PRIMARY KEY NOT NULL,
LocationName varchar(20),
Latitude numeric(6, 2),
Longitude numeric(6, 2),
Description varchar(50))
GO
CREATE TABLE dbo.Flight(
FlightId int IDENTITY(1,1) NOT NULL,
FlightNo varchar(10),
FromLocationId int,
ToLocationId int,
ArrivalTime varchar(10),
DepartureTime varchar(10),
NoofBusSeats int,
NoofEcoSeats int)
GO
CREATE TABLE dbo.FlightTrans(
TransId int IDENTITY(1,1) NOT NULL,
TransDate datetime ,
UserName varchar(20) ,
FlightId int,
EcoSeats int,
BusSeats int)
GO
CREATE TABLE dbo.FlightStatus(
FlightDetailId int IDENTITY(1,1) NOT NULL,
Flightid int,
TotalSeats int,
ExecutiveSeats int,
BuisnessSeats int,
FlightDate datetime,
BookedExecutiveSeats int,
BookedBusinessSeats int)
GO
CREATE TABLE dbo.FlightRate(
FlightRateId int IDENTITY(1,1) NOT NULL,
FlightId int,
BusStdRate numeric(8, 2),
EcoStdRate numeric(8, 2))
GO
Along the way I will also demonstrate a few Visual Studio 2010 features related to Silverlight and WPF.
I am starting a new Business Applicaiton Project. WCF Ria Services will be automatically added when you select Business Application Project.
I will get a project similar to new Asp .Net Web Site Project in Visual Studion 2010. It has a good navigation structure, nice look and feel and a few HyperlinkMenus to start with.
if you want to want to learn more about about Silverlight batabinding.
To switch off the Binding of the TextBlock that holds the Application name go to properties window click on the icon next to the Text property in the dialog select Reset settings. Then type your heading.
Like wise I am changing the Content property of Hyperlink buttons to Location and Flights respectively.
I am using Silverlight Child Window in this project. I am adding a Silverlight Child Window to the project selecting Silverlight Project from the Solution Explorer. As you know two projects will be created when you start new Silverlight project, Silverlight Project and an Asp .Net project for hosting the Silverlight Project. Earlier in the blow we saw adding Entity Data Model and Domain Service Class to the Asp .Net Project.
Insert Location
Location table holds the information about a Location. This table is referenced by Flights Table.
Here is the Xaml of the frmLocations Silverlight Child Window.
<Grid x:Name="LayoutRoot" Margin="2">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<sdk:Label Height="28" HorizontalAlignment="Left" Margin="21,34,0,0" Name="label1" VerticalAlignment="Top" Width="120" Content="Location Name" />
<sdk:Label Height="28" HorizontalAlignment="Left" Margin="21,70,0,0" Name="label2" VerticalAlignment="Top" Width="120" Content="Latitude" />
<sdk:Label Height="28" HorizontalAlignment="Left" Margin="21,106,0,0" Name="label3" VerticalAlignment="Top" Width="120" Content="Longitude" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="118,26,0,0" Name="txtLocation" VerticalAlignment="Top" Width="120" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="118,62,0,0" Name="txtLatitude" VerticalAlignment="Top" Width="120" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="118,98,0,0" Name="txtLongitude" VerticalAlignment="Top" Width="120" />
<Button Content="Save" Height="23" HorizontalAlignment="Left" Margin="118,161,0,0" Name="btnSave" VerticalAlignment="Top" Width="75" Click="btnSave_Click" />
</Grid>Add Entity Data Model and Domain Data Service class as demonstrated in the first part of the blog.
using ShalvinAirlines.Web;
AirLines context = new AirLines();
private void btnSave_Click(object sender, RoutedEventArgs e)
{
decimal intLatitude = decimal.Parse(txtLatitude.Text);
decimal intLongitude = decimal.Parse(txtLongitude.Text);
var Loc = new Location { LocationName = txtLocation.Text, Latitude = intLatitude, Longitude = intLongitude };
context.Locations.Add(Loc);
context.SubmitChanges();
MessageBox.Show("Location saved");
}
Numeric data type in Sql Server will be mapped to decimal data type in .Net.Insert Flight
<Grid x:Name="LayoutRoot" Margin="2">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<sdk:Label Height="28" HorizontalAlignment="Left" Margin="72,61,0,0" Name="label1" VerticalAlignment="Top" Width="120" Content="From Location" />
<ComboBox Height="23" HorizontalAlignment="Left" Margin="181,54,0,0" Name="cboFrom" VerticalAlignment="Top" Width="120" />
<sdk:Label Content="To Location" Height="28" HorizontalAlignment="Left" Margin="72,103,0,0" Name="label2" VerticalAlignment="Top" Width="120" />
<ComboBox Height="23" HorizontalAlignment="Left" Margin="181,97,0,0" Name="cboTo" VerticalAlignment="Top" Width="120" />
<sdk:Label Height="28" HorizontalAlignment="Left" Margin="72,139,0,0" Name="label3" VerticalAlignment="Top" Width="120" Content="Arrival Time" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="181,131,0,0" Name="txtArrivalTime" VerticalAlignment="Top" Width="120" />
<sdk:Label Height="28" HorizontalAlignment="Left" Margin="72,175,0,0" Name="label4" VerticalAlignment="Top" Width="120" Content="Departure Time" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="181,167,0,0" Name="txtDepartureTime" VerticalAlignment="Top" Width="120" />
<sdk:Label Height="28" HorizontalAlignment="Left" Margin="72,211,0,0" Name="label5" VerticalAlignment="Top" Width="120" Content="No. Economy Seats" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="181,203,0,0" Name="txtNoEconomySeats" VerticalAlignment="Top" Width="120" />
<sdk:Label Content="No. Business Seats" Height="28" HorizontalAlignment="Left" Margin="72,241,0,0" Name="label6" VerticalAlignment="Top" Width="120" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="181,233,0,0" Name="txtNoBusinessSeats" VerticalAlignment="Top" Width="120" />
<Button Content="Save" Height="23" HorizontalAlignment="Left" Margin="181,277,0,0" Name="btnSave" VerticalAlignment="Top" Width="75" Click="btnSave_Click" />
<sdk:Label Height="28" HorizontalAlignment="Left" Margin="72,26,0,0" Name="label7" VerticalAlignment="Top" Width="120" Content="Flight No." />
<TextBox Height="23" HorizontalAlignment="Left" Margin="181,18,0,0" Name="txtFlightNo" VerticalAlignment="Top" Width="120" />
</Grid>using ShalvinAirlines.Web;
AirLines context = new AirLines();
private void ChildWindow_Loaded(object sender, RoutedEventArgs e)
{
cboFrom.ItemsSource = context.Locations;
cboFrom.DisplayMemberPath = "LocationName";
cboFrom.SelectedValuePath = "LocationId";
cboTo.ItemsSource = context.Locations;
cboTo.DisplayMemberPath = "LocationName";
cboTo.SelectedValuePath = "LocationId";
context.Load(context.GetLocationsQuery());
}
private void btnSave_Click(object sender, RoutedEventArgs e)
{
int intFromId = Int32.Parse(cboFrom.SelectedValue.ToString());
int intToId = Int32.Parse(cboTo.SelectedValue.ToString());
int intNoBusSeats = Int32.Parse(txtNoBusinessSeats.Text);
int intNoEcoSeats = Int32.Parse(txtNoEconomySeats.Text);
var Fl = new Flight { FlightNo = txtFlightNo.Text,
FromLocationId = intFromId,
ToLocationId = intToId,
ArrivalTime = txtArrivalTime.Text,
DepartureTime = txtDepartureTime.Text,
NoofBusSeats=intNoBusSeats,
NoofEcoSeats= intNoEcoSeats };
context.Flights.Add(Fl);
context.SubmitChanges();
MessageBox.Show("Flight inserted");
}First I filled the Combo Boxes with the LocationName and Set the SelectedValuePath to LocationId so that I an extract the LocationId of the Selected Item.Booking Module
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" Loaded="ChildWindow_Loaded">
<Grid x:Name="LayoutRoot" Margin="2">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<sdk:Label Content="Flight" Height="28" HorizontalAlignment="Left" Margin="10,10,0,0" Name="label1" VerticalAlignment="Top" Width="120" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="103,81,0,0" Name="txtEconomySeats" VerticalAlignment="Top" Width="120" />
<ComboBox Height="23" HorizontalAlignment="Left" Margin="103,10,0,0" Name="cboFlight" VerticalAlignment="Top" Width="120" />
<sdk:Label Content="Date" Height="28" HorizontalAlignment="Left" Margin="10,45,0,0" Name="label2" VerticalAlignment="Top" Width="120" />
<sdk:DatePicker Height="23" HorizontalAlignment="Left" Margin="103,45,0,0" Name="dtpDate" VerticalAlignment="Top" Width="120" />
<sdk:Label Content="Economy Seats" Height="28" HorizontalAlignment="Left" Margin="10,82,0,0" Name="label3" VerticalAlignment="Top" Width="120" />
<sdk:Label Content="Business Seats" Height="28" HorizontalAlignment="Left" Margin="10,131,0,0" Name="label4" VerticalAlignment="Top" Width="120" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="103,123,0,0" Name="txtBusSeats" VerticalAlignment="Top" Width="120" />
<Button Content="Book" Height="23" HorizontalAlignment="Left" Margin="103,188,0,0" Name="btnBook" VerticalAlignment="Top" Width="75" Click="btnBook_Click" />
</Grid>
AirLines context = new AirLines();
private void ChildWindow_Loaded(object sender, RoutedEventArgs e)
{
cboFlight.ItemsSource = context.Flights;
cboFlight.DisplayMemberPath = "FlightNo";
cboFlight.SelectedValuePath = "FlightId";
context.Load(context.GetFlightsQuery());
}
private void btnBook_Click(object sender, RoutedEventArgs e)
{
DateTime dt = DateTime.Parse(dtpDate.SelectedDate.ToString());
int intEcoSeats = Int32.Parse(txtEconomySeats.Text);
int intBusSeats = Int32.Parse(txtBusSeats.Text);
int intFlightId = Int32.Parse(cboFlight.SelectedValue.ToString());
var Book = new FlightTran { TransDate = dt, UserName = GlobalClass.UserName,
FlightId = intFlightId, EcoSeats = intEcoSeats, BusSeats = intBusSeats };
context.FlightTrans.Add(Book);
context.SubmitChanges();
MessageBox.Show("Booking completed");
}
Saturday, April 16, 2011
BarCamp Kerala 10
10th edition of BarCamp Kerala will be held at SCMS B-School at Kalamaserry on 8th May 2011.
For more details visit http://www.barcampkerala.org
Wednesday, April 13, 2011
Saturday, February 19, 2011
Razor View Engine and Visual Studio
The inspiration for this blog on Razor was the Web Camp conducted by Microsoft Evangelists Nahas Mohammed and Ramaprasanna Chellamuthu on February 18 at Kochi. We received great insight into Razor View Engine and Web Matrix.
A few of the audience were invited to the stage and it was more of an interactive Code camp.
I am using Visual Web Developer 2010, a free tool from Microsoft for developing Asp .Net Applications. All the examples will work in Visual Studio. I have already installed Asp .Net MVC 3 in my machine.
Visual Studio 2010 / Visual Web Developer 2010 comes will Intellisense and debugging support for Razor. Unlike Asp .Net Web Forms in Razor the Visual Interface is defined using HTML.
I am starting an Empty Web Site and Adding an Empty Razor Page.
@{
var strName = "";
if(IsPost)
{
strName = "Hello welcome to Razor"
}
}
<form method=post>
<p>
@strName
</p>
<input id="Submit1" type="submit" value="submit" />
</form>
Inside a block each statement should end with a semicolon. Inside html you can call the memory variable using @ symbol. There semicolon should not be present.
We are checking a form post using IsPost. On Clicking the Submit buttom a Form POST will occur after that the memory variable will be assigned the Hello message and that message will be dispayed.
Using can use Html Tab in the Toolbox to add Html tags to the form.
You can see that the auto completion feature is available.
@{
var strName = "";
if(IsPost)
{
strName = "Hello " + Request["txtName"];
}
}
<form method=post>
<p>
@strName
</p>
Name
<input Name="txtName" type="text" />
<br />
<input id="Submit1" type="submit" value="submit" />
</form>
In the above example we extracting the value of textbox using Request.@{
var sum = 0;
if(IsPost)
{
sum = Request["txtValue1"].AsInt() + Request["txtValue2"].AsInt();
}
}
<form method =post>
<p>
@sum
</p>
Value 1<input Name = "txtValue1" type="text" />
</br>
Value 2<input Name = "txtValue2" type="text" />
</br>
<input id="Submit1" type="submit" value="submit" />
</form>
AsInt() is used to convert the value to Integer.
Session
//Session.cshtml
@{
Session["Name"] = "Shalvin";
}
<form method =post>
<a href = "@Href("Welcome")">Welcome</a>
</form>
//Welcome.cshtml
@{
var strName = "Hello " + Session["Name"];
}
@strName
Href method is used to create paths to resources like Web pages.
In the first page we are defining the session variable and in the second page we extracting the value of Session variable.
Entity Framework
I am creating an Entity Data Model is shown in the figure
@{
var context = new ContactManagementModel.ContactManagementEntities();
var Grps = context.ContactGroups;
var gd = new WebGrid(Grps);
}
<html>
<body>
@gd.GetHtml();
</body>
</html>
WebGrid helper can be used to display day is a tabular manner.
@{
var context = new ContactManagementModel.ContactManagementEntities();
var strMessage = "";
if(IsPost)
{
var Grp = new ContactManagementModel.ContactGroup{GroupName = Request["txtGroupName"]};
context.AddToContactGroups(Grp);
context.SaveChanges();
strMessage = "Record Saved";
}
}
<form method = "post">
<p>
@strMessage
</p>
Group Name
<input Name = "txtGroupName" type="text" />
</br>
<input id="Submit1" type="submit" value="submit" />
</form>
Thursday, February 3, 2011
Microsoft Web Camps on February 18, Kochi
Venue : ABAD PLAZA
M.G Road, Cochin-682 035
| 09:00am - 10:00am | REGISTRATION |
| 10:00am - 10:30am | Opening Keynote - Nahas Mohammed & Ramaprasanna Chellamuthu |
| 10:30am - 11:30am | Introduction to WebMatrix - Nahas Mohammed |
| 11:30am - 12:30pm | Forms and Data Access - Nahas Mohammed |
| 12:30pm - 01:30pm | LUNCH BREAK |
| 01:30pm - 02:30pm | Helpers and Publishing - Ramaprasanna Chellamuthu |
| 02:30pm - 03:30pm | DotNetNuke on WebMatrix - Ramaprasanna Chellamuthu |
| 03:30pm - 04:00pm | Audience Q&A and Closing Note - Nahas Mohammed & Ramaprasanna Chellamuthu |
RSVP : 080-4089 7010,
+91-96636 82120
mswebcamps@end2end.in
Saturday, January 15, 2011
Asp .Net Mvc with Entity Framework




public ActionResult Index()
{
var Grp = context.ContactGroups;
return View(Grp);
}
//
// GET: /Home/Create
public ActionResult Create()
{
return View();
}
//
// POST: /Home/Create
[HttpPost]
public ActionResult Create(ContactGroup Grp)
{
if (ModelState.IsValid)
{
try
{
context.AddToContactGroups(Grp);
context.SaveChanges();
return RedirectToAction("Index");
}
catch
{
return View(Grp);
}
}
else
{
return View(Grp);
}
}
//
// GET: /Home/Edit/5
public ActionResult Edit(int id)
{
var Grp = context.ContactGroups.SingleOrDefault(x => x.GroupId == id);
return View(Grp);
}
//
// POST: /Home/Edit/5
[HttpPost]
public ActionResult Edit(int id, FormCollection collection)
{
var Grp = context.ContactGroups.SingleOrDefault(x => x.GroupId == id);
try
{
UpdateModel(Grp, collection.ToValueProvider());
context.SaveChanges();
return RedirectToAction("Index");
}
catch
{
return View();
}
}
//
// GET: /Home/Delete/5
public ActionResult Delete(int id)
{
var Grp = context.ContactGroups.SingleOrDefault(x => x.GroupId == id);
return View(Grp);
}
//
// POST: /Home/Delete/5
[HttpPost]
public ActionResult Delete(int id, FormCollection collection)
{
var Grp = context.ContactGroups.SingleOrDefault(x => x.GroupId == id);
try
{
context.DeleteObject(Grp);
context.SaveChanges();
return RedirectToAction("Index");
}
catch
{
return View();
}
}














