protected void Page_Load(object sender, EventArgs e)
        {
            //Create instance of new requisition
            Requisition r = new Requisition();

            UserDAO user = new UserDAO();
            RequisitionManager rq = new RequisitionManager();
            CatalogDAO cat = new CatalogDAO();

            //set the properties of requisition object
            r.DepartmentID = user.GetDepartmentByID(1).DepartmentID;
            r.CreatedBy = user.GetUserByID(1).UserID;
            r.StatusID = rq.GetStatusByID(new Status() { StatusID = 1}).StatusID;
            r.ApprovedBy = user.GetUserByID(2).UserID;
            r.UrgencyID = rq.GetUrgencyByID(new Urgency() { UrgencyID = 1 }).UrgencyID;
            r.RequisitionForm = "test";
            r.DateRequested = DateTime.Now;
            //r.DateApproved = DateTime.Now;

            //Create a new requisitionitem for the current requisition
            RequisitionItem rqi = new RequisitionItem()
            {
                RequisitionID = r.RequisitionID,
                StationeryID = cat.GetAllStationeries().FirstOrDefault<Stationery>().StationeryID,
                QuantityRequested = 10,
                QuantityIssued = 10,
                Price = 5

            };

            //Create a new specialrequisitionitem for the current requisition
            SpecialRequisitionItem spi = new SpecialRequisitionItem()
            {
                RequisitionID = r.RequisitionID,
                SpecialStationeryID = 1,
                QuantityRequested = 10,
                QuantityIssued = 10,
                Price = 5,
                Name = "arav",
                Description = "test"

            };

            //Add Child objects of the requisition objects
            //Add requisitionitem to requisition object
            r.RequisitionItems.Add(rqi);

            //Add specialitem to requisition object
            r.SpecialRequisitionItems.Add(spi);

            //Persist requisition to database
            //EF is very intelligent. It will also persist to requistionitem and specialrequistionitem
            rq.CreateRequisition(r);

            r = rq.GetAllRequisition().Last<Requisition>();
            r.RequisitionItems.Last<RequisitionItem>().QuantityIssued = 6;

            rq.UpdateRequisition(r);

            spi = rq.GetAllSpecialRequisitionItems(r).Last<SpecialRequisitionItem>();

            rq.DeleteSpecialRequisitionItem(spi);

            //Testing databinding after creation of requisitions
            if (!IsPostBack)
            {
                GridView1.DataSource = rq.GetAllRequisitionItems(r);
                GridView1.DataBind();

                if (r != null)
                {
                    GridView2.DataSource = rq.GetAllRequisition();
                    GridView2.DataBind();
                }
            }
        }
        //Add data to session datatable
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (ddlType.Text.Trim() == "")
            {
                this.ltStock.Text = "Required";
                return;
            }

            if (txtQuantity.Text.Trim() == "")
            {
                this.ltStock.Text = "";
                this.ltQuantity.Text = "Required";
                return;
            }
            if (txtQuantity.Text.Trim() != "")
            {
                try
                {
                    int i = Convert.ToInt32(txtQuantity.Text.ToString().Trim());
                }
                catch
                {
                    this.ltQuantity.Text = "Numeric!";
                    return;
                }
            }
            if (txtReason.Text.Trim() == "")
            {
                this.ltQuantity.Text = "";
                this.ltReason.Text = "Required";
                return;
            }
            else
            {
                int stationeryID = Convert.ToInt32(this.ddlStationeryID.Text.ToString());
                int type = Convert.ToInt32(this.ddlType.Text.ToString());
                int quantity = Convert.ToInt32(this.txtQuantity.Text.ToString().Trim());
                String reason = this.txtReason.Text.Trim();

                try
                {
                    //Start Query the stationery description
                    CatalogDAO cat = new CatalogDAO();
                    String description = cat.GetStationeryByID(stationeryID).Description;
                    //End Query

                    DataRow foundRow = ((DataTable)Session["myDatatable"]).Rows.Find(stationeryID);
                    int rowNum = Convert.ToInt32(foundRow);
                    AddDataToTable(stationeryID, description, type, quantity, reason, (DataTable)Session["myDatatable"]);

                    this.GridView1.DataSource = ((DataTable)Session["myDatatable"]).DefaultView;
                    this.GridView1.DataBind();

                    this.ltStock.Text = "";
                    this.ltQuantity.Text = "";
                    this.ltDescription.Text = "";
                    this.ltReason.Text = "";
                    this.txtQuantity.Text = "";
                    this.txtReason.Text = "";
                }
                catch
                {
                    this.ltStock.Text = "";
                    this.ltQuantity.Text = "";
                    this.ltReason.Text = "";
                    this.ltDescription.Text = "Duplicate";
                }
            }
        }
 public CatalogManager()
 {
     catalogDAO = new CatalogDAO();
 }