Esempio n. 1
0
        public static PONTOCONTROLE SelecionaPK(int pPoCodigo, string pPoTipo, DataContext MyDB = null)
        {
            DataContext db = default(DataContext);

            if ((MyDB != null))
            {
                db = MyDB;
            }
            else
            {
                db = new DataContext(MyGlobal.ConnectionString);
            }
            PONTOCONTROLE oPONTOCONTROLE = default(PONTOCONTROLE);
            var           res            = (from p in db.PONTOCONTROLEs where p.PoCodigo == pPoCodigo && p.PoTipo.Equals(pPoTipo) select p).ToList();

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

            Excluir(oPONTOCONTROLE, db);
            db.SubmitChanges();
            db.Dispose();
        }
Esempio n. 3
0
        public static void Excluir(int pPoCodigo, string pPoTipo, DataContext MyDB)
        {
            PONTOCONTROLE oPONTOCONTROLE = default(PONTOCONTROLE);
            var           res            = from p in MyDB.PONTOCONTROLEs where p.PoCodigo == pPoCodigo && p.PoTipo.Equals(pPoTipo) select p;

            if (res.Count() > 0)
            {
                oPONTOCONTROLE = res.First();
                MyDB.PONTOCONTROLEs.DeleteOnSubmit(oPONTOCONTROLE);
            }
            else
            {
                throw new Exception("Não foi possível excluir o ítem, porque o mesmo não existe na base de dados.");
            }
        }
Esempio n. 4
0
        public static void Excluir(int pPoCodigo, string pPoTipo)
        {
            DataContext   db             = new DataContext(MyGlobal.ConnectionString);
            PONTOCONTROLE oPONTOCONTROLE = default(PONTOCONTROLE);
            var           res            = from p in db.PONTOCONTROLEs where p.PoCodigo == pPoCodigo && p.PoTipo.Equals(pPoTipo) select p;

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