//
        // GET: /PurchaseRequestHeader/Create
        public ActionResult Create()
        {
            var model = new PurchaseRequestHeader();

            model.GetSelectListRequestorID = GetSelectListRequestorID();
            model.GetSelectListPriority    = GetSelectListPriority();
            return(View(model));
        }
        public PurchaseRequestHeader Add(PurchaseRequestHeader PRH, string userid)
        {
            var sqlQuery = @"INSERT INTO PURCHASEREQUESTHEADER (PURCHASEREQUESTDATE, REQUESTORID, PRIORITY, REMARKS, STATUS, COMPANYSITE, INPUTBY, INPUTDATE, UPDATEBY, UPDATEDATE) VALUES
                           ('" + PRH.PURCHASEREQUESTDATE + "', '" + PRH.REQUESTORID + "', '" + PRH.PRIORITY + "', '" + PRH.REMARKS + "', '" + PRH.STATUS + "', '" + PRH.COMPANYSITE + @"', " + Convert.ToInt32(userid) + ", '" + DateTime.Now + @"', " + Convert.ToInt32(userid) + ", '" + DateTime.Now + @"'); " + "SELECT CAST(SCOPE_IDENTITY() as int)";
            var SID      = _db.Query <int>(sqlQuery, PRH).Single();

            PRH.SID = SID;
            AddDocumentNo(SID);
            return(PRH);
        }
 public ActionResult Create(PurchaseRequestHeader PurchaseRequestHeader)
 {
     if (ModelState.IsValid)
     {
         PurchaseRequestHeader.COMPANYSITE = int.Parse(Session["companysite"].ToString());
         PRH.Add(PurchaseRequestHeader, Session["userid"].ToString());
         TempData["successmessage"] = "Saved successfully";
         return(RedirectToAction("Create"));
     }
     else
     {
         PurchaseRequestHeader.GetSelectListRequestorID = GetSelectListRequestorID();
         PurchaseRequestHeader.GetSelectListPriority    = GetSelectListPriority();
         return(View(PurchaseRequestHeader));
     }
 }
        public PurchaseRequestHeader Update(PurchaseRequestHeader PRH)
        {
            var sqlQuery =
                "UPDATE PURCHASEREQUESTHEADER " +
                "SET IDPURCHASEREQUEST    = '" + PRH.IDPURCHASEREQUEST + "', " +
                "    PURCHASEREQUESTDATE  = '" + PRH.PURCHASEREQUESTDATE + "', " +
                "    REQUESTORID   = '" + PRH.REQUESTORID + "', " +
                "    PRIORITY   = '" + PRH.PRIORITY + "', " +
                "    REMARKS   = '" + PRH.REMARKS + "', " +
                "    STATUS   = '" + PRH.STATUS + "', " +
                "    COMPANYSITE   = '" + PRH.COMPANYSITE + "', " +
                "    UPDATEBY      = '" + Convert.ToInt32(PRH.UPDATEBY) + "', " +
                "    UPDATEDATE    = '" + PRH.UPDATEDATE + "' " +
                "WHERE SID = " + PRH.SID + "";

            this._db.Execute(sqlQuery, PRH);
            return(PRH);
        }
 public ActionResult Edit(PurchaseRequestHeader PurchaseRequestHeader, int id)
 {
     if (ModelState.IsValid)
     {
         PurchaseRequestHeader.SID         = id;
         PurchaseRequestHeader.COMPANYSITE = int.Parse(Session["companysite"].ToString());
         PurchaseRequestHeader.UPDATEBY    = int.Parse(Session["userid"].ToString());
         PurchaseRequestHeader.UPDATEDATE  = DateTime.Now;
         PRH.Update(PurchaseRequestHeader);
         return(RedirectToAction("Index", PRH.GetAllByCompanySite(int.Parse(Session["companysite"].ToString()))));
         //return View("Index", PRH.GetAllByCompanySite(int.Parse(Session["companysite"].ToString())));
     }
     else
     {
         PurchaseRequestHeader.GetSelectListRequestorID = GetSelectListRequestorID(PurchaseRequestHeader.REQUESTORID);
         PurchaseRequestHeader.GetSelectListPriority    = GetSelectListPriority(PurchaseRequestHeader.PRIORITY);
         return(View(PurchaseRequestHeader));
     }
 }
        public ActionResult CreateAndAddPurchaseRequestDetails(PurchaseRequestHeader PurchaseRequestHeader)
        {
            if (ModelState.IsValid)
            {
                PurchaseRequestHeader.COMPANYSITE = int.Parse(Session["companysite"].ToString());
                PurchaseRequestHeader blo = PRH.Add(PurchaseRequestHeader, Session["userid"].ToString());
                var model = PRH.Find(blo.SID);
                Session["SID_PURCHASEREQUESTHEADER"] = blo.SID;
                model.GetSelectListRequestorID       = GetSelectListRequestorID(model.REQUESTORID);
                model.GetSelectListPriority          = GetSelectListPriority(model.PRIORITY);

                return(RedirectToAction("Edit", new { id = blo.SID }));
                //return View("Edit", model);
            }
            else
            {
                PurchaseRequestHeader.GetSelectListRequestorID = GetSelectListRequestorID();
                PurchaseRequestHeader.GetSelectListPriority    = GetSelectListPriority();
                return(View(PurchaseRequestHeader));
            }
        }