Exemplo n.º 1
0
        public static LOTACAOROTA SelecionaPK(int pLRCodigo, DataContext MyDB = null)
        {
            DataContext db = default(DataContext);

            if ((MyDB != null))
            {
                db = MyDB;
            }
            else
            {
                db = new DataContext(MyGlobal.ConnectionString);
            }
            LOTACAOROTA oLOTACAOROTA = default(LOTACAOROTA);
            var         res          = (from p in db.LOTACAOROTAs where p.LRCodigo == pLRCodigo select p).ToList();

            if (res.Count() > 0)
            {
                oLOTACAOROTA = 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(oLOTACAOROTA);
        }
Exemplo n.º 2
0
        public static void Excluir(LOTACAOROTA oLOTACAOROTA)
        {
            DataContext db = new DataContext(MyGlobal.ConnectionString);

            Excluir(oLOTACAOROTA, db);
            db.SubmitChanges();
            db.Dispose();
        }
Exemplo n.º 3
0
        public static void Excluir(int pLRCodigo, DataContext MyDB)
        {
            LOTACAOROTA oLOTACAOROTA = default(LOTACAOROTA);
            var         res          = from p in MyDB.LOTACAOROTAs where p.LRCodigo == pLRCodigo select p;

            if (res.Count() > 0)
            {
                oLOTACAOROTA = res.First();
                MyDB.LOTACAOROTAs.DeleteOnSubmit(oLOTACAOROTA);
            }
            else
            {
                throw new Exception("Não foi possível excluir o ítem, porque o mesmo não existe na base de dados.");
            }
        }
Exemplo n.º 4
0
        public static void Excluir(int pLRCodigo)
        {
            DataContext db           = new DataContext(MyGlobal.ConnectionString);
            LOTACAOROTA oLOTACAOROTA = default(LOTACAOROTA);
            var         res          = from p in db.LOTACAOROTAs where p.LRCodigo == pLRCodigo select p;

            if (res.Count() > 0)
            {
                oLOTACAOROTA = res.First();
                db.LOTACAOROTAs.DeleteOnSubmit(oLOTACAOROTA);
                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();
        }
Exemplo n.º 5
0
 public static void Excluir(LOTACAOROTA oLOTACAOROTA, DataContext MyDb)
 {
     MyDb.LOTACAOROTAs.Attach(oLOTACAOROTA);
     MyDb.LOTACAOROTAs.DeleteOnSubmit(oLOTACAOROTA);
 }
Exemplo n.º 6
0
 public static void Alterar(LOTACAOROTA oLOTACAOROTA, DataContext MyDb)
 {
     MyDb.LOTACAOROTAs.Attach(oLOTACAOROTA, true);
 }
Exemplo n.º 7
0
 public static void Incluir(LOTACAOROTA oLOTACAOROTA, DataContext MyDb)
 {
     MyDb.LOTACAOROTAs.InsertOnSubmit(oLOTACAOROTA);
 }