Esempio n. 1
0
        public static ACESSOPONTOCONTROLE SelecionaPK(int pAPCodigo, DataContext MyDB = null)
        {
            DataContext db = default(DataContext);

            if ((MyDB != null))
            {
                db = MyDB;
            }
            else
            {
                db = new DataContext(MyGlobal.ConnectionString);
            }
            ACESSOPONTOCONTROLE oACESSOPONTOCONTROLE = default(ACESSOPONTOCONTROLE);
            var res = (from p in db.ACESSOPONTOCONTROLEs where p.APCodigo == pAPCodigo select p).ToList();

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

            Excluir(oACESSOPONTOCONTROLE, db);
            db.SubmitChanges();
            db.Dispose();
        }
Esempio n. 3
0
        public static void Excluir(int pAPCodigo, DataContext MyDB)
        {
            ACESSOPONTOCONTROLE oACESSOPONTOCONTROLE = default(ACESSOPONTOCONTROLE);
            var res = from p in MyDB.ACESSOPONTOCONTROLEs where p.APCodigo == pAPCodigo select p;

            if (res.Count() > 0)
            {
                oACESSOPONTOCONTROLE = res.First();
                MyDB.ACESSOPONTOCONTROLEs.DeleteOnSubmit(oACESSOPONTOCONTROLE);
            }
            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 pAPCodigo)
        {
            DataContext         db = new DataContext(MyGlobal.ConnectionString);
            ACESSOPONTOCONTROLE oACESSOPONTOCONTROLE = default(ACESSOPONTOCONTROLE);
            var res = from p in db.ACESSOPONTOCONTROLEs where p.APCodigo == pAPCodigo select p;

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