protected void deleteRecord(object sender, EventArgs e) { var db = new ShipmentActivityContext(); IQueryable <ShipmentActivity> query = db.ShipmentActivities; int sid = Int32.Parse(shipmentid.Value); query = query.Where(p => p.ShipmentID == sid); if (query.Count() != 0) { db.Entry(query.First()).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } }
protected void addRecord(object sender, EventArgs e) { //System.Diagnostics.Debug.WriteLine(shipname.Value); var newshipinfo = new ShipmentActivity { Shipname = shipname.Value, ShipmentSize = shipmentsize.Value, ShipmentDate = shipmentdate.Value, ShipmentLocation = shipmentlocation.Value, ShipmentStatus = shipmentstatus.Value }; var db = new ShipmentActivityContext(); db.ShipmentActivities.Add(newshipinfo); db.SaveChanges(); Response.Redirect(Request.RawUrl); }
protected void updateRecord(object sender, EventArgs e) { int sid = Int32.Parse(shipmentid.Value); var newshipinfo = new ShipmentActivity { ShipmentID = sid, Shipname = shipname.Value, ShipmentSize = shipmentsize.Value, ShipmentDate = shipmentdate.Value, ShipmentLocation = shipmentlocation.Value, ShipmentStatus = shipmentstatus.Value }; var db = new ShipmentActivityContext(); db.Entry(newshipinfo).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); Response.Redirect(Request.RawUrl); }