コード例 #1
0
 public ActionResult Edit([Bind(Include = "AllowanceID,AllowanceName,Type,Insurance,FreeTax,FreeTaxValue,AllEmployee,Value")] ALLOWANCE aLLOWANCE)
 {
     if (ModelState.IsValid)
     {
         db.Entry(aLLOWANCE).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     //ViewBag.AllowanceID = new SelectList(db.ALLOWANCEs, "AllowanceID", "AllowanceName", aLLOWANCEDETAIL.AllowanceID);
     //ViewBag.EmployeeID = new SelectList(db.EMPLOYEEs, "EmployeeID", "EmployeeName", aLLOWANCEDETAIL.EmployeeID);
     return(View(aLLOWANCE));
 }
コード例 #2
0
 //[ValidateAntiForgeryToken]
 public ActionResult DeleteConfirmed(string id)
 {
     try
     {
         ALLOWANCE aLLOWANCE = db.ALLOWANCEs.Find(id);
         db.ALLOWANCEs.Remove(aLLOWANCE);
         db.SaveChanges();
     }
     catch
     {
         return(Json(new { success = false }));
     }
     return(Json(new { success = true }));
 }
コード例 #3
0
        //public ActionResult CreateOrEdit([Bind(Include = "AllowanceID,AllowanceName,Insurance,Tax,FreeTax,Value")] ALLOWANCE aLLOWANCE)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        if (aLLOWANCE.AllowanceID == null)
        //        {
        //            //auto create allowanceID
        //            int n = 0;
        //            var allowanceList = db.ALLOWANCEs.ToList();
        //            if (allowanceList.Count > 0)
        //            {
        //                ALLOWANCE s = allowanceList.Last();
        //                n = Int32.Parse(s.AllowanceID.Substring(s.AllowanceID.Length - 3)) + 1;
        //            }

        //            string id = String.Format("{0:000}", n);
        //            aLLOWANCE.AllowanceID = "A" + id;

        //            db.ALLOWANCEs.Add(aLLOWANCE);
        //            db.SaveChanges();
        //            return RedirectToAction("Index");
        //        }
        //        else
        //        {
        //            db.Entry(aLLOWANCE).State = EntityState.Modified;
        //            db.SaveChanges();
        //            return RedirectToAction("Index");
        //        }
        //    }

        //    return View(aLLOWANCE);
        //}
        // GET: ALLOWANCEDETAILs/Edit/5
        public ActionResult Edit(string id)
        {
            Session["MainTitle"] = "Quản lý tiền lương";
            Session["SubTitle"]  = "Sửa phụ cấp, trợ cấp, thưởng";
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ALLOWANCE aLLOWANCE = db.ALLOWANCEs.Find(id);

            if (aLLOWANCE == null)
            {
                return(HttpNotFound());
            }
            //ViewBag.AllowanceID = new SelectList(db.ALLOWANCEs, "AllowanceID", "AllowanceName", aLLOWANCEDETAIL.AllowanceID);
            //ViewBag.EmployeeID = new SelectList(db.EMPLOYEEs, "EmployeeID", "EmployeeName", aLLOWANCEDETAIL.EmployeeID);
            return(View(aLLOWANCE));
        }
コード例 #4
0
 public ActionResult Create([Bind(Include = "AllowanceID,AllowanceName,Type,Insurance,FreeTax,FreeTaxValue,AllEmployee,Value")] ALLOWANCE aLLOWANCE)
 {
     if (ModelState.IsValid)
     {
         if (aLLOWANCE.AllowanceID == null)
         {
             //auto create allowanceID
             int n             = 0;
             var allowanceList = db.ALLOWANCEs.ToList();
             if (allowanceList.Count > 0)
             {
                 ALLOWANCE s = allowanceList.Last();
                 n = Int32.Parse(s.AllowanceID.Substring(s.AllowanceID.Length - 3)) + 1;
             }
             string id = String.Format("{0:000}", n);
             aLLOWANCE.AllowanceID = "A" + id;
         }
         db.ALLOWANCEs.Add(aLLOWANCE);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(aLLOWANCE));
 }