public ActionResult AddProduct()
        {
            int sid = Request.Form["JobOrderId"] != null ? Request.Form["JobOrderId"].Split(',')[0].ParseInt() : 0;
            var id  = Request.Form["selProduct"].Split(':'); //  ProductId:PriceNet
            int qty = Request.Form["Quantity"].ParseInt();


            if (id.Count() > 0)
            {
                var detail = uow.Modules.JobOrder.GetDetails(sid);
                int pid    = int.Parse(id[0]);

                TblJobOrderDetail ob = uow.Modules.JobOrder.GetDetail(0);

                ob.No         = detail != null ? detail.Count + 1 : 1;
                ob.JobOrderId = sid;
                ob.ProductId  = pid;
                ob.Quantity   = qty;


                uow.Modules.JobOrder.SetDetail(ob);
                uow.SaveChanges();
            }
            return(RedirectToAction("Detail", MVCController, new { id = sid, tab = "Product", msg = "", msgType = AlertMsgType.Success }));
        }
Ejemplo n.º 2
0
 public void DeleteDetail(TblJobOrderDetail ob)
 {
     if (IsExist(ob.JobOrderId))
     {
         db.TblJobOrderDetail.Remove(ob);
     }
 }
Ejemplo n.º 3
0
        public void SetDetail(TblJobOrderDetail ob)
        {
            db.TblJobOrderDetail.Add(ob);

            /* if (ob.TransferId == 0)
             * { db.TransferDetail.Add(ob); }
             * else { db.Entry(ob).State = EntityState.Modified; }*/
        }
        //[Authorized]
        public ActionResult DetailDelete()
        {
            int qid = Request.Form["JobOrderId"].ParseInt();

            try
            {
                int Seq = Request.Form["No"].ParseInt();
                TblJobOrderDetail ob = uow.Modules.JobOrder.GetDetail(qid, Seq);
                if (ob == null)
                {
                    return(RedirectToAction("Detail", MVCController, new { id = qid, tab = "Product", msg = "ไม่พบข้อมูลที่ต้องการ", msgType = AlertMsgType.Warning }));
                }

                uow.Modules.JobOrder.DeleteDetail(ob);
                uow.SaveChanges();
                return(RedirectToAction("Detail", MVCController, new { id = qid, tab = "Product", msg = "ลบข้อมูลเรียบร้อยแล้ว", msgType = AlertMsgType.Success }));
            }
            catch (Exception ex)
            { return(RedirectToAction("Detail", MVCController, new { id = qid, tab = "Product", msg = ex.GetMessage(), msgType = AlertMsgType.Danger })); }
        }