Sunday, November 29, 2009

Popup in asp.net 2.0

in default.aspx.cs page
protected void btnPopup_Click(object sender, EventArgs e)
{
string sFeature = "dialogWidth: 400px; dialogHeight: 250px;";
string sUrl = "Popup.aspx?Info=No Shipping Information";
Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowPopup", "");
}


in popup.aspx.cs page

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
lblPopInfo.Text = Request.QueryString["Info"].ToString();
}
}

Monday, November 23, 2009

Add Requisition

public void AddRequisition(GridView grid)
{
myReq = (Requisition)Session["MyRequisition"];
rc = new RequisitionController();

for (int i = 0; i < grid.Rows.Count; i++)
{
CheckBox chk = (CheckBox)grid.Rows[i].FindControl("CheckBox1");
TextBox txtQty = (TextBox)grid.Rows[i].Cells[2].Controls[1];

string q = txtQty.Text;


if ((chk != null) && (chk.Checked == true))
{
if (q != "")
{
if (ValidateInputQty(q))
{
int qty = int.Parse(q.ToString());
String reqItemCode = grid.Rows[i].Cells[0].Text;
String strDescription = grid.Rows[i].Cells[1].Text;
try
{
rc.addRequest(qty, reqItemCode, strDescription, myReq);
Label2.Text = "You have selected the following items:";
displayButtons(true);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}


}
else
{
Label2.Text = "Quantity should be number.";
}
}
else
{
Label2.Text = "Please enter quantity.";
}
}
else if ((q != ""))
{
if (ValidateInputQty(q) != true)
{ Label2.Text = "Quantity should be number, and please select."; }
else
{ Label2.Text = "Please select."; }
}
}

}

gridview codings

protected void btnRemove_Click(object sender, EventArgs e)
{
Requisition myReq3 = (Requisition)Session["MyRequisition"];
for (int i = 0; i < gridDetails.Rows.Count; i++)
{
CheckBox chk2 = (CheckBox)gridDetails.Rows[i].FindControl("CheckBox1");
if (chk2 != null && chk2.Checked == true)
{
string reqItem = gridDetails.Rows[i].Cells[0].Text;
if (myReq3 != null)
{
try
{
myReq3.DeleteItem(reqItem);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}

Sunday, November 22, 2009

Thursday, November 19, 2009

Get Primary key on Row Command (GridView)

http://weblogs.asp.net/aghausman/archive/2009/01/08/get-primary-key-on-row-command-gridview.aspx

Thursday, November 12, 2009

Checking validity of Singapore IC Number

It is based on modulus 11 using the 7 digits in the NRIC number. Using Di to denote the digit where i is the placing in the 7 digits, we have

x = 2 * D1 + 7 * D2 + 6 * D3 + 5 * D4 + 4 * D5 + 3 * D6 + 2 * D7

To get y, which is the check digit, we have

y = 11 - ( x mod 11 )

Where y is represented by: 1 = A, 2 = B, 3 = C, 4 = D, 5 = E, 6 = F, 7 = G, 8 = H, 9 = I, 10 = Z and 11 = J

The above information is obtained from one of the NUS lab exercise.

Validate Your NUS Undergraduate Matric Number

Let the six-digit number be denoted d1d2d3d4d5d6
Compute the weighted sum (2 × d2) + (6 × d3) + (2 × d4) + (4 × d5) + d6
(we ignore the digit d1 as undergraduates for this decade would have it as 0 )
Divide the result in step 1 by 13 and obtain its remainder.
Subtract the remainder from 13.
Locate the check-letter using the table below:
Result from step 3 Check-Letter
1 M
2 B
3 N
4 A
5 R
6 E
7 U
8 H
9 W
10 J
11 X
12 L
13 Y

Copied from the following link:
http://www.comp.nus.edu.sg/~cs1101cl/labs_sem1_0405/lab1/part2/matric.html

displaying gridview row index number

http://forums.asp.net/p/992655/1292995.aspx

http://bytes.com/topic/asp-net/answers/339667-how-find-column-index-name-asp-net-datagrid

http://www.asp.net/learn/data-access/tutorial-28-vb.aspx

至少還有你 (林億蓮&杜克)

shayne ward - breathless (lyrics)

Wednesday, November 4, 2009

What are the main differences between Access and SQL Server?

http://sqlserver2000.databases.aspfaq.com/what-are-the-main-differences-between-access-and-sql-server.html