Friday, August 28, 2009

Asp .Net Mvc Resources

A list of Asp .Net Mvc Resources which I found very userful.

http://weblogs.asp.net/shijuvarghese/

ASP.NET MVC Tutorials

http://code-inside.de/blog-in/2008/11/25/howto-basics-of-aspnet-mvc-or-why-mvc/

ASP.NET MVC View Overview (C#)

DevConnections - The ASP.NET MVC Framework - Scott Hanselman

ASP.NET MVC using Visual Basic XML Literals

http://www.asp.net/learn/

ASP.NET MVC Preview 4 - Using Ajax and Ajax.Form

Free ASP.NET MVC eBook Tutorial

http://en.wikipedia.org/wiki/Model_View_Controller

http://en.wikipedia.org/wiki/Front_Controller_pattern

http://martinfowler.com/eaaCatalog/pageController.html

http://www.codeasp.net/articles/asp.net/30/aspnet-mvc-framework-tutorial

http://msdn.microsoft.com/en-us/magazine/cc337884.aspx (Old version)

Friday, August 21, 2009

WPF Windows Application, WPF Browser Application and Silverlight Clarified

WPF is Microsoft's presentation technology which is based on XAML.
WPF Windows Application in long run will act as a replacement for Windows Forms.
It runs in fuly trusted environment.


Output













WPF Browser Application
WPF Browser Application or XBAP as name suggest is browser based application. But the drawback is the that it required .net runtime present in the running machine.
It runs in partially trusted environment with limited access to system resources.














Silverlight
Silverlight is Microsoft's alternative to Flash like applications. It is based on plug in model.

Thursday, August 13, 2009

Sql Server 200 Generating Script

An Sql Script is a text file containing the database objects like like table, views, stored procedures etc.

Sql Server 2000 Enterprise Manager or Sql Server 2005/2008 Management Studio can be used for generating Sql Script.







Here is the generated script

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK__Trans__ExpenseId__7C8480AE]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)ALTER TABLE [dbo].[Trans] DROP CONSTRAINT FK__Trans__ExpenseId__7C8480AEGO


if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK__Expense__GroupId__79A81403]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)ALTER TABLE [dbo].[Expense] DROP CONSTRAINT FK__Expense__GroupId__79A81403GO


if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[spAllExpense]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)drop procedure [dbo].[spAllExpense]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Expense]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[Expense]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ExpenseGroup]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[ExpenseGroup]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Trans]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)drop table [dbo].[Trans]
GO

CREATE TABLE [dbo].[Expense] ( [ExpenseId] [int] IDENTITY (1, 1) NOT NULL , [GroupId] [int] NULL , [ExpenseName] [varchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [Description] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY]
GO

CREATE TABLE [dbo].[ExpenseGroup] ( [GroupId] [int] IDENTITY (1, 1) NOT NULL , [GroupName] [varchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NULL , [Description] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Trans] ( [TranId] [int] IDENTITY (1, 1) NOT NULL , [ExpenseId] [int] NULL , [Date] [datetime] NULL , [Amount] [numeric](8, 2) NULL , [Description] [varchar] (40) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY]GO
SET QUOTED_IDENTIFIER ON GOSET ANSI_NULLS ON
GO

create procedure spAllExpense asselect * from Expense
GOSET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON
GO

DataGridView - Extracting the Contents of Currently Selected Row

One of the common requirement is CRUD operation is extracting the contents of the currently selected row in a Grid to be updated in TextBoxes or other controls.

SqlConnection cnn;
SqlDataAdapter da;
DataSet ds = new DataSet();
private void Form1_Load(object sender, EventArgs e)
{
cnn = new SqlConnection("Integrated Security=sspi;Initial catalog=Northwind");
cnn.Open();
da = new SqlDataAdapter("select CategoryId, CategoryName, Description from Categories", cnn);
da.Fill(ds, "Cat");
dataGridView1.DataSource = ds.Tables["Cat"];
}



private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
listBox1.Items.Clear();
for (int colindex = 0; colindex < dataGridView1.Columns.Count ; colindex++)
{
listBox1.Items.Add(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[colindex].Value.ToString());
}
}




















DataGridView ComboBox Placing and Child Table Insertion



SqlConnection cnn;
SqlDataAdapter da;
DataSet ds = new DataSet();

SqlCommand cmd;
SqlDataReader dre;

DataGridViewTextBoxColumn newCol;
DataGridViewComboBoxColumn cboCol;

private void Form1_Load(object sender, EventArgs e)
{
cnn = new SqlConnection("Integrated security=sspi;INitial Catalog=ContactManagement;Data Source=.\\shalvin");
cnn.Open();

da = new SqlDataAdapter("select * from ContactGroups", cnn);
da.Fill(ds, "Grp");

CreateGridViewColumns();
}

private void CreateGridViewColumns()
{
cboCol = new DataGridViewComboBoxColumn();
cboCol.DataSource = ds.Tables["Grp"];
cboCol.DisplayMember = "GroupName";
dataGridView1.Columns.Add(cboCol);

newCol = new DataGridViewTextBoxColumn();
dataGridView1.Columns.Add(newCol);

}



private void btnSave_Click(object sender, EventArgs e)
{
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
string strGroupId = "";
DataGridViewRow row = dataGridView1.Rows[i];

string strSql;
strSql = "select GroupId from ContactGroups where GroupName= '"
+ row.Cells[0].Value.ToString() + "'";

cmd = new SqlCommand(strSql, cnn);
dre = cmd.ExecuteReader();
while(dre.Read())
strGroupId = dre["GroupId"].ToString();
dre.Close();


cmd = new SqlCommand("Insert into Contacts (GroupId, ContactName) values ('" + strGroupId + "', '" + row.Cells[1].Value.ToString() + "')", cnn);
cmd.ExecuteNonQuery();
}

MessageBox.Show("Record saved");
}




Related Blog
Windows Forms ListView
Filling Windows Forms ListView with DataTable

Wednesday, August 12, 2009

Hotel California tabs

Tabs


Bm
e:----------------------------------------------------
B: ----------------------3--5--7--7h8p7--5/7---
G:---4--4h5p3h4--5------------------------------
D:---------------------------------------------------
A:--------------------------------------------------
E:--------------------------------------------------
.......B..B...C A#B.. C.. D.E..F#. F# G.F#.E.F#

A
e:----------------------------------------
B:----------------------------------------
G:---------7-6--------------------------
D:----7-9---------7h9-7--------------
A:--------------9----------9\7--5/7--
E:----------------------------------------
......A.B..D.C#.F#A.B.A.F#E..D.E

..Em
e:-----------0-------0-------0-------0-
B:---------0-------0-------0-------0---
G:-------0-------2-------4-------7-----
D:-----2-------4-------5-------9-------
A:-------------------------------------
E:-------------------------------------
.......e.G.B.E.f#a.B.E.g.b.B.E.b.d.B.E

e:-----7p0-----10p0-----7p0-----10p0-----7p0-----10p0-
B:---8---------8--------8---------8---------8---------8----------
G:-9---------9--------9---------9--------9---------9------------
D:--------------------------------------------------------------
A:--------------------------------------------------------------
E:--------------------------------------------------------------
...e.G.B.E.e.G.B..E.e.G.B.E.e.G.B.E...e.G.B.E...e.G.B.E.

e:-----7p0-----10p0-----7-6-7-9-10-9-10-12/14-14~~~~~-
B:---8--------8---------8------------------------------------
G:-9--------9---------9--------------------------------------
D:-----------------------------------------------------------
A:-----------------------------------------------------------
E:-----------------------------------------------------------
........................BA#.B.C#D..C#.D.E.F#.F#

Electric

Guitar Fretboard



Tuesday, August 11, 2009

Seminar on Windows 7, Windows Server 2008 R2 and Microsoft Exchange 2010

Yesterday (August 11 th) there was a seminar on Seminar on Windows 7, Windows Server 2008 R2 and Microsoft Exchange 2010 at The Gateway Hotel, Marine Drive Kochi.
The seminar was highly informative though there was lack of proper promotion for the event. So I missed technology enthsiasts like Praseed Pai, Mathew K J and Biju Alapatt. Thanks to Plaito Williams for informing me about the event.
All the participants received the Windows 7 DVD which expires on June 2010.

Julius Caesar

Recently I started watching the film Julius Caesar (2002) which further triggered my interest in the Father of Classical Cryptography.
The film gave much greater insight into the Roman political situation of the era. The film starts with the tyranny of Sulla and the flight of Julius Caesar with the help of Pompei. His return to Roma after the death of Sulla. Julius Caesar helping Pompei in amassing the legions for crushing Pirates.

Julius Caesar along with Marcus Licinius Crassus and Pompei was part of the First Triumverate.
Historians doesn't consider Brutus as a villain as his intention behind assasination of Caesar was restoration of Roman Republic.

Roman Emperors of Julio Claudian Dynasty
Augustus Causar (27 BC - 14 AD)
Tiberius Caesar (14 - 37)
Caligula (37 - 41)
Claudius (41 - 54)
Nero (54 - 68)

Saturday, August 8, 2009

Field Area Ratio

Field Area Ration referes to the built up area that is possible in a piece of land. Cent which is the Indian standard measure of land is 435.59 square feet of land.
FAR 2 Means it is possible only to have 435.59 * 2 area of built up area in a cent of land.