예제 #1
0
        protected void reSubmit_Click(object sender, EventArgs e)
        {
            SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities();
            RequisitionDAO             rdao    = new RequisitionDAO();

            Requisition newRequisition = new Requisition();
            Requisition oldRequisition = rdao.findRequisitionByrequisitionId(reqID);

            if (oldRequisition.status != "pending")
            {
                newRequisition.staffID         = oldRequisition.staffID;
                newRequisition.deptID          = oldRequisition.deptID;
                newRequisition.requisitionDate = DateTime.Now;
                newRequisition.status          = "pending";

                context.Requisitions.Add(newRequisition);

                var oldRequisitionItemsList = oldRequisition.RequisitionItems;
                foreach (RequisitionItem item in oldRequisitionItemsList)
                {
                    RequisitionItem newItem = new RequisitionItem();
                    newItem.requisitionID  = newRequisition.requisitionID;
                    newItem.itemID         = item.itemID;
                    newItem.requisitionQty = item.requisitionQty;

                    context.RequisitionItems.Add(newItem);
                }
                context.SaveChanges();
                Response.Redirect("Emp_MyRequisition.aspx");
            }
            else
            {
                ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Warning', 'You can not resubmit a pending requisition!');</script>");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            reqID = Int32.Parse(Request.QueryString["reqID"]);
            if (!IsPostBack)
            {
                headID = (string)Session["loginID"];
                Requisition req      = reqDAO.findRequisitionByrequisitionId(reqID);
                string      reqStaff = req.DeptStaff.staffName;
                DateTime    reqDate  = req.requisitionDate;

                lblReqID.Text = Convert.ToString(reqID);
                lblDate.Text  = reqDate.ToString("dd/MM/yyyy");
                lblStaff.Text = reqStaff;
                BindData();
            }
        }