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."; }
}
}

}

No comments: