Ejemplo n.º 1
0
        public static ROTA SelecionaPK(int pROCodigo, DataContext MyDB = null)
        {
            DataContext db = default(DataContext);

            if ((MyDB != null))
            {
                db = MyDB;
            }
            else
            {
                db = new DataContext(MyGlobal.ConnectionString);
            }
            ROTA oROTA = default(ROTA);
            var  res   = (from p in db.ROTAs where p.ROCodigo == pROCodigo select p).ToList();

            if (res.Count() > 0)
            {
                oROTA = res.First();
            }
            else
            {
                db.Dispose();
                throw new Exception("Não foi possível selecionar o ítem, porque o mesmo não existe na base de dados.");
            }
            if (MyDB == null)
            {
                db.Dispose();
            }
            return(oROTA);
        }
Ejemplo n.º 2
0
        public static void Excluir(ROTA oROTA)
        {
            DataContext db = new DataContext(MyGlobal.ConnectionString);

            Excluir(oROTA, db);
            db.SubmitChanges();
            db.Dispose();
        }
Ejemplo n.º 3
0
        public static int Incluir(ROTA oROTA)
        {
            DataContext db = new DataContext(MyGlobal.ConnectionString);

            Incluir(oROTA, db);
            db.SubmitChanges();
            db.Dispose();
            return(oROTA.ROCodigo);
        }
Ejemplo n.º 4
0
        public static void Excluir(int pROCodigo, DataContext MyDB)
        {
            ROTA oROTA = default(ROTA);
            var  res   = from p in MyDB.ROTAs where p.ROCodigo == pROCodigo select p;

            if (res.Count() > 0)
            {
                oROTA = res.First();
                MyDB.ROTAs.DeleteOnSubmit(oROTA);
            }
            else
            {
                throw new Exception("Não foi possível excluir o ítem, porque o mesmo não existe na base de dados.");
            }
        }
Ejemplo n.º 5
0
        public static void Excluir(int pROCodigo)
        {
            DataContext db    = new DataContext(MyGlobal.ConnectionString);
            ROTA        oROTA = default(ROTA);
            var         res   = from p in db.ROTAs where p.ROCodigo == pROCodigo select p;

            if (res.Count() > 0)
            {
                oROTA = res.First();
                db.ROTAs.DeleteOnSubmit(oROTA);
                db.SubmitChanges();
                db.Dispose();
            }
            else
            {
                db.Dispose();
                throw new Exception("Não foi possível excluir o ítem, porque o mesmo não existe na base de dados.");
            }
            db.Dispose();
        }
Ejemplo n.º 6
0
 public static void Excluir(ROTA oROTA, DataContext MyDb)
 {
     MyDb.ROTAs.Attach(oROTA);
     MyDb.ROTAs.DeleteOnSubmit(oROTA);
 }
Ejemplo n.º 7
0
 public static void Alterar(ROTA oROTA, DataContext MyDb)
 {
     MyDb.ROTAs.Attach(oROTA, true);
 }
Ejemplo n.º 8
0
 public static void Incluir(ROTA oROTA, DataContext MyDb)
 {
     MyDb.ROTAs.InsertOnSubmit(oROTA);
 }