Beispiel #1
0
        public ActionResult PrintNewTableWithLetterHead(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Lpo lpo = db.Lpoes.Find(id);

            if (lpo.LpoStatusId == 2)//revised
            {
                string message = "Sorry ,  You cant print <br/> " +
                                 " <br/> " +
                                 "Contact manaegment ";

                return(ErrorPermission(message));
            }

            ViewBag.LpoTerms = db.LpoTerms.ToList();
            var username = User.Identity.GetUserName();

            ViewBag.user = db.Users.Where(u => u.UserName == username).FirstOrDefault();
            var emp = db.EmployeeUsers.Where(eu => eu.User == username).FirstOrDefault().EmployeeId;

            ViewBag.currentEmployee = db.Employees.Find(emp);
            string   job           = "";
            DateTime currentDate   = DateTime.Now;
            int      JobBySupplier = db.Lpoes.Where(l => l.Supplier.supplierId == lpo.SupplierId &&
                                                    l.LpoDate.Month == currentDate.Month && lpo.LpoDate.Year == currentDate.Year).Count();

            job         = string.Format("{0}/{1}/job {2}", currentDate.Year, currentDate.Month, JobBySupplier);
            ViewBag.Job = job;
            return(View(lpo));
        }
Beispiel #2
0
        public JsonResult CreateJson([Bind(Include = "LpoId,code,SupplierRef,LpoDate,SupplierId,CreditTermId,SubTotal,Discount,Total,Vat,GrandTotal ")] Lpo lpo)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (lpo.LpoId != 0)
                    {
                        var old = db.Lpoes.Find(lpo.LpoId);
                        old.LpoStatusId = 2;//revised
                    }

                    lpo.StampDate = DateTime.Now;

                    // OldLPO = db.Lpoes.Find()
                    lpo.LpoStatusId = 1;//pending
                    lpo.UserCreate  = User.Identity.GetUserName();
                    db.Lpoes.Add(lpo);
                    db.SaveChanges();
                    return(Json(lpo.LpoId));
                }
                catch (Exception ex)
                {
                    String errors11 = ex.Message;

                    if (ex.InnerException != null)
                    {
                        errors11 = errors11 + ex.InnerException.Message + " \r\n ";;
                    }
                    return(Json(errors11));
                }
            }
            return(Json("Error"));
        }
Beispiel #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            Lpo lpo = db.Lpoes.Find(id);

            db.Lpoes.Remove(lpo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #4
0
 public ActionResult Edit([Bind(Include = "LpoId,code,SupplierRef,LpoDate,SupplierId,CreditTermSupplierId")] Lpo lpo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(lpo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CreditTermId = new SelectList(db.CreditTerms, "CreditTermId", "Name", lpo.CreditTermSupplierId);
     ViewBag.SupplierId   = new SelectList(db.suppliers, "supplierId", "Name", lpo.SupplierId);
     return(View(lpo));
 }
Beispiel #5
0
        // GET: Lpoes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Lpo lpo = db.Lpoes.Find(id);

            if (lpo == null)
            {
                return(HttpNotFound());
            }
            return(View(lpo));
        }
Beispiel #6
0
        public ActionResult Create([Bind(Include = "LpoId,code,SupplierRef,LpoDate,SupplierId,CreditTermId,QuotationRef")] Lpo lpo)
        {
            if (ModelState.IsValid)
            {
                lpo.StampDate = DateTime.Now;
                db.Lpoes.Add(lpo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CreditTermId = new SelectList(db.CreditTerms, "CreditTermId", "Name", lpo.CreditTermId);
            ViewBag.SupplierId   = new SelectList(db.suppliers, "supplierId", "Name", lpo.SupplierId);
            return(View(lpo));
        }
Beispiel #7
0
        // GET: Lpoes/Create
        public ActionResult Revised(int id)
        {
            //int Sequense = GetSeq();
            //ViewBag.code = generateContractCode(Sequense);
            Lpo    lpo     = db.Lpoes.Find(id);
            string code    = lpo.code;
            string newCode = code + "-Rev";

            ViewBag.code = newCode;


            ViewBag.CreditTermId = new SelectList(db.CreditTerms, "CreditTermId", "Name");
            ViewBag.SupplierId   = new SelectList(db.suppliers, "supplierId", "Name");
            return(View(lpo));
        }
Beispiel #8
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Lpo lpo = db.Lpoes.Find(id);

            if (lpo == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CreditTermId = new SelectList(db.CreditTerms, "CreditTermId", "Name", lpo.CreditTermSupplierId);
            ViewBag.SupplierId   = new SelectList(db.suppliers, "supplierId", "Name", lpo.SupplierId);
            return(View(lpo));
        }
Beispiel #9
0
        public ActionResult Revised(int id)
        {
            Lpo    lpo         = db.Lpoes.Find(id);
            string lpoBaseCode = (lpo.code.Contains("-Rev")) ? lpo.code.Substring(0, lpo.code.IndexOf("-Rev")) : lpo.code;

            string newCode = lpoBaseCode + "-Rev" + (NumberOfRevised(lpoBaseCode) + 1).ToString("000");

            ViewBag.code = newCode;


            //ViewBag.CreditTermId = new SelectList(db.CreditTermSuppliers, "CreditTermSupplierId", "Name");

            ViewBag.CreditTermSupplierId = new SelectList(db.CreditTermSuppliers, "CreditTermSupplierId", "Name", lpo.CreditTermSupplierId);
            ViewBag.SupplierId           = new SelectList(db.suppliers, "supplierId", "Name", lpo.SupplierId);
            ViewBag.LpoLocationId        = new SelectList(db.LpoLocations, "LpoLocationId", "Name", lpo.LpoLocationId);
            ViewBag.LpoNatureId          = new SelectList(db.LpoNatures, "LpoNatureId", "Name", lpo.LpoNatureId);
            ViewBag.LpoDate = DateTime.Now;

            return(View(lpo));
        }
Beispiel #10
0
        public ActionResult PrintNewTableWithLetterHead2(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Lpo lpo = db.Lpoes.Find(id);

            if (lpo.LpoStatusId == 2)//revised
            {
                string message = "Sorry ,  You cant print <br/> " +
                                 " <br/> " +
                                 "Contact manaegment ";

                return(ErrorPermission(message));
            }

            ViewBag.LpoTerms = db.LpoTerms.ToList();

            return(View(lpo));
        }