Ejemplo n.º 1
0
        public IHttpActionResult PuttblRoad(int id, tblRoad tblRoad)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tblRoad.BIA_No)
            {
                return(BadRequest());
            }

            db.Entry(tblRoad).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tblRoadExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public ActionResult update(int BIA_No, string Road_Name, string Miles, int Type_Id)
        {
            tblRoad table = new tblRoad();

            using (var db = new RoadsEntities())
            {
                table = db.tblRoads.First(em => em.BIA_No == BIA_No);
            }
            if (table != null)
            {
                table.Road_Name = Road_Name;
                table.Type_Id   = Type_Id;
                table.Miles     = Convert.ToDouble(Miles);
            }
            using (var dc = new RoadsEntities())
            {
                dc.Entry(table).State = EntityState.Modified;
                dc.SaveChanges();
            }


            ModelState.Clear();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public ActionResult EditingInline_Update([DataSourceRequest] DataSourceRequest request, TranViewModel tran)
        {
            RoadsEntities db = new RoadsEntities();
            var           t  = db.tblTransactions.Where(tr => tr.AutoNumber.Equals(tran.AutoNumber)).FirstOrDefault();

            t.Hours     = tran.Hours;
            t.Lease_Chg = tran.Lease_Chg;
            db.SaveChanges();
            return(Json(new[] { tran }.ToDataSourceResult(request, ModelState)));
        }
Ejemplo n.º 4
0
        public ActionResult create(RoadViewModel tbl)
        {
            RoadsEntities db = new RoadsEntities();
            tblRoad       tb = new tblRoad();

            tb.BIA_No    = Convert.ToInt32(tbl.BIA_No);
            tb.Road_Name = tbl.Road_Name;
            tb.Miles     = tbl.Miles;
            tb.Type_Id   = tbl.Type_Id;
            db.tblRoads.Add(tb);
            db.SaveChanges();
            ModelState.Clear();

            return(Index());
        }
Ejemplo n.º 5
0
 public ActionResult AddTransaction(TranViewModel tvm)
 {
     using (RoadsEntities db = new RoadsEntities())
     {
         tblTransaction tt = new tblTransaction();
         tt.Trans_Date    = tvm.Trans_Date;
         tt.Emp_No        = tvm.Emp_no;
         tt.Mach_No       = tvm.Mach_No;
         tt.BIA_No        = tvm.BIA_No;
         tt.Activity_Code = tvm.Activity_Code;
         tt.Hours         = tvm.Hours;
         tt.Lease_Chg     = tvm.Lease_Chg;
         db.tblTransactions.Add(tt);
         db.SaveChanges();
         ModelState.Clear();
     }
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 6
0
        public ActionResult AddMachine(tblMach mac)
        {
            RoadsEntities dbCxt = new RoadsEntities();

            //if (dbCxt.tblMaches.Select(m => m.Mach_No == mac.Mach_No) != null)
            //{
            //    ModelState.AddModelError("", "Cannot add duplicate Machine Code.");
            //}
            //else
            //{
            using (RoadsEntities db = new RoadsEntities())
            {
                db.tblMaches.Add(mac);
                db.SaveChanges();
                ModelState.Clear();
            }
            //}
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 7
0
        public ActionResult Update(int Mach_No, string Mach_Desc, double Lease_Rate, int Owner_Num, bool Active)
        {
            tblMach tblmach;

            using (db = new RoadsEntities())
            {
                tblmach = db.tblMaches.First(m => m.Mach_No == Mach_No);
            }
            if (tblmach != null)
            {
                tblmach.Mach_Desc  = Mach_Desc;
                tblmach.Lease_Rate = Lease_Rate;
                tblmach.Owner_Num  = Owner_Num;
                tblmach.Active     = Active;
            }
            using (var dbCtx = new RoadsEntities())
            {
                dbCtx.Entry(tblmach).State = System.Data.Entity.EntityState.Modified;
                dbCtx.SaveChanges();
            }
            ModelState.Clear();
            return(RedirectToAction("Index"));
        }