當前位置: 首頁>>代碼示例>>C#>>正文


C# DCFIEntities.Entry方法代碼示例

本文整理匯總了C#中eSARDAL.DCFIEntities.Entry方法的典型用法代碼示例。如果您正苦於以下問題:C# DCFIEntities.Entry方法的具體用法?C# DCFIEntities.Entry怎麽用?C# DCFIEntities.Entry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eSARDAL.DCFIEntities的用法示例。


在下文中一共展示了DCFIEntities.Entry方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DismissStudent

        public Boolean DismissStudent(string studentID, ref string message)
        {
            message = "Student dismissed successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                Student studentInDB = (from s in DCEnt.Students
                                       where s.StudentId == studentID
                                       select s).FirstOrDefault();
                if (studentInDB == null)
                {
                    throw new Exception("No student with ID " + studentID);
                }

                DCEnt.Students.Remove(studentInDB);

                studentInDB.Dismissed = true;

                DCEnt.Students.Attach(studentInDB);
                DCEnt.Entry(studentInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();
                if (num != 1)
                {
                    ret = false;
                    message = "Fail to Dismiss Student.";
                }
            }
            return ret;
        }
開發者ID:dansalan,項目名稱:DCFIv3,代碼行數:30,代碼來源:StudentDAO.cs

示例2: UpdateGradeLevel

        public Boolean UpdateGradeLevel(ref GradeLevelBDO gBDO, ref string message)
        {
            message = "Grade Level updated successfully.";
            Boolean ret = true;
            using (var DCEnt = new DCFIEntities())
            {
                var gCode = gBDO.GradeLev;
                GradeLevel gInDB = (from g in DCEnt.GradeLevels
                                    where g.GradeLevel1 == gCode
                                    select g).FirstOrDefault();
                if (gInDB == null)
                {
                    throw new Exception("No Grade Level " + gBDO.GradeLev);
                }
                DCEnt.GradeLevels.Remove(gInDB);
                gInDB.GradeLevel1 = gBDO.GradeLev;
                gInDB.Description = gBDO.Description;

                DCEnt.GradeLevels.Attach(gInDB);
                DCEnt.Entry(gInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "No grade level is updated.";
                }
            }
            return ret;

        }
開發者ID:miaozhendaoren,項目名稱:DCFIv4,代碼行數:31,代碼來源:GradeLevelDAO.cs

示例3: AddLog

 public Boolean AddLog(LogBDO log)
 {
     //string message = "Log Added Successfully";
     bool ret = true;
     try
     {
         Log l = new Log();
         ConvertLogBDOToLog(log, l);
         using (var DCEnt = new DCFIEntities())
         {
             DCEnt.Logs.Add(l);
             DCEnt.Entry(l).State = System.Data.Entity.EntityState.Added;
             int num = DCEnt.SaveChanges();
              if (num < 1)
             {
                 ret = false;
                
             }
         }
     }
     catch (DbEntityValidationException dbEx)
     {
         foreach (var validationErrors in dbEx.EntityValidationErrors)
         {
             foreach (var validationError in validationErrors.ValidationErrors)
             {
                 Trace.TraceInformation("Property: {0} Error: {1}",
                                         validationError.PropertyName,
                                         validationError.ErrorMessage);
             }
         }
     }
     return ret;
 }
開發者ID:RazenRyne,項目名稱:eSAR,代碼行數:34,代碼來源:LogDAO.cs

示例4: CreateSY

        public Boolean CreateSY(ref SchoolYearBDO syBDO, ref string message)
        {
            message = "School Year Added Successfully";
            bool ret = true;

            SchoolYear u = new SchoolYear()
            {
                SY = syBDO.SY,
                CurrentSY = syBDO.CurrentSY
            };

            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.SchoolYears.Attach(u);
                DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();
                syBDO.SY = u.SY;

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of School Year failed";
                }
            }
            return ret;
        }
開發者ID:dansalan,項目名稱:DCFIv3,代碼行數:26,代碼來源:SchoolYearDAO.cs

示例5: CreateBuilding

        public Boolean CreateBuilding(ref BuildingBDO buildBDO, ref string message)
        {
            message = "Building Added Successfully";
            bool ret = true;
            try {
            Building b = new Building();
            ConvertBuildingBDOToBuilding(buildBDO,b);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Buildings.Add(b);
                DCEnt.Entry(b).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();
                buildBDO.BuildingCode = b.BuildingCode;

                if (num < 1)
                {
                    ret = false;
                    message = "Adding of Building failed";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
            }
            }
            return ret;
        }
開發者ID:dansalan,項目名稱:DCFIv5,代碼行數:35,代碼來源:BuildingDAO.cs

示例6: CreateTrait

        public Boolean CreateTrait(ref TraitBDO tBDO, ref string message)
        {
            message = "Trait Added Successfully";
            bool ret = true;

            Trait t = new Trait();
            try {
            ConvertTraitBDOToTrait(tBDO, t);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Traits.Attach(t);
                DCEnt.Entry(t).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Trait failed";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
                }
            }
            return ret;
        }
開發者ID:dansalan,項目名稱:DCFIv5,代碼行數:35,代碼來源:TraitDAO.cs

示例7: ActivateUser

        public Boolean ActivateUser(int userId, ref string message)
        {
            message = "User Activated successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                User userInDB = (from u in DCEnt.Users
                                 where u.UserId == userId
                                 select u).FirstOrDefault();

                if (userInDB == null)
                {
                    throw new Exception("No user with ID " + userId);
                }

                DCEnt.Users.Remove(userInDB);

                userInDB.Deactivated = false;

                DCEnt.Users.Attach(userInDB);
                DCEnt.Entry(userInDB).State = System.Data.Entity.EntityState.Modified;
                int num = DCEnt.SaveChanges();
                if (num != 1)
                {
                    ret = false;
                    message = "Activation Failed.";
                }
            }
            return ret;
        }
開發者ID:dansalan,項目名稱:DCFIv3,代碼行數:31,代碼來源:UserDAO.cs

示例8: AddScholarshipDiscount

        public Boolean AddScholarshipDiscount(ScholarshipDiscountBDO discount,int scholarshipCode, ref string message)
        {
            message = "Scholarship Discount Added Successfully";
            Boolean ret = true;

            ScholarshipDiscount sd = new ScholarshipDiscount();
            try {
            ConvertScholarshipDiscountBDOToScholarshipDiscount(discount, sd);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.ScholarshipDiscounts.Add(sd);
                DCEnt.Entry(sd).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Scholarship Discount failed";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
            }
            }
                return ret;
        }
開發者ID:dansalan,項目名稱:DCFIv5,代碼行數:35,代碼來源:ScholarshipDAO.cs

示例9: CreateFee

        public Boolean CreateFee(ref FeeBDO fBDO, ref string message)
        {
            message = "Fee Added Successfully";
            bool ret = true;

            Fee f = new Fee();
            try {
            ConvertFeeBDOToFee(fBDO, f);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Fees.Attach(f);
                DCEnt.Entry(f).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Fee failed";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
            }
            }
            return ret;
        }
開發者ID:dansalan,項目名稱:DCFIv5,代碼行數:35,代碼來源:FeeDAO.cs

示例10: CreateCurriculum

        public Boolean CreateCurriculum(ref CurriculumBDO cbdo, ref string message)
        {
            message = "Curriculum Added Successfully";
            bool ret = true;
            Curriculum cur = new Curriculum();
            try {
                ConvertCurriculumBDOToCurriculum(cbdo, cur);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.Curriculums.Add(cur);
                DCEnt.Entry(cur).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                    if (num == 0)
                    {
                        ret = false;
                        message = "Adding of Curriculum failed";
                    }
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
            }
            }
            return ret;
        }
開發者ID:dansalan,項目名稱:DCFIv5,代碼行數:34,代碼來源:CurriculumDAO.cs

示例11: CreateGradeSection

        public Boolean CreateGradeSection(ref GradeSectionBDO gsBDO, ref string message)
        {
            message = "Grade Section Added Successfully";
            bool ret = true;

            GradeSection gs = new GradeSection();
            try{
            ConvertGradeSectionBDOToGradeSection(gsBDO, gs);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.GradeSections.Attach(gs);
                DCEnt.Entry(gs).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num != 1)
                {
                    ret = false;
                    message = "Adding of Grade Section failed";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
                }
            }
            return ret;
        }
開發者ID:dansalan,項目名稱:DCFIv5,代碼行數:35,代碼來源:GradeSectionDAO.cs

示例12: CreateLearningArea

        public Boolean CreateLearningArea(ref LearningAreaBDO laBDO, ref string message)
        {
            message = "Learning Area Added Successfully";
            bool ret = true;

            LearningArea la = new LearningArea();
            try {
            ConvertLearningAreaBDOToLearningArea(laBDO, la);
            using (var DCEnt = new DCFIEntities())
            {
                DCEnt.LearningAreas.Add(la);
                DCEnt.Entry(la).State = System.Data.Entity.EntityState.Added;
                int num = DCEnt.SaveChanges();

                if (num == 0)
                {
                    ret = false;
                    message = "Adding of Learning Area failed";
                }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
                }
            }
            return ret;
        }
開發者ID:dansalan,項目名稱:DCFIv5,代碼行數:35,代碼來源:LearningAreaDAO.cs

示例13: CreateUser

        public Boolean CreateUser(ref UserBDO userBDO, ref string message)
        {
            message = "User Added Successfully";
            bool ret = true;

             UserType ut = new UserType()
                {
                    UserType1 = userBDO.UserType.UsersType,
                    UserTypeCode = userBDO.UserType.UserTypeCode
                };
             User u = new User()
                {

                    UserName = userBDO.UserName,
                    Password = userBDO.Password,
                    LastName = userBDO.LastName,
                    FirstName = userBDO.FirstName,
                    MiddleName = userBDO.MiddleName,
                    UserTypeCode = userBDO.UserType.UserTypeCode,
                    UserType = ut
                };

              using (var DCEnt = new DCFIEntities()) {
                    DCEnt.Users.Attach(u);
                    DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added;
                    int num = DCEnt.SaveChanges();
                    userBDO.UserId = u.UserId;

                    if (num != 1) {
                        ret = false;
                        message = "Adding of User failed";
                    }
            }
            return ret;
        }
開發者ID:dansalan,項目名稱:DCFIv3,代碼行數:35,代碼來源:UserDAO.cs

示例14: DeleteSY

        public Boolean DeleteSY(string schoolyear, ref string message)
        {
            message = "SY " + schoolyear + " Deleted successfully.";
            Boolean ret = true;

            using (var DCEnt = new DCFIEntities())
            {
                SchoolYear SYInDB = (from u in DCEnt.SchoolYears
                                 where u.SY == schoolyear
                                 select u).FirstOrDefault();

                if (SYInDB == null)
                {
                    throw new Exception("No SY " + schoolyear + " existed");
                }

                DCEnt.SchoolYears.Remove(SYInDB);
                DCEnt.Entry(SYInDB).State = System.Data.Entity.EntityState.Deleted;
                int num = DCEnt.SaveChanges();
                if (num != 1)
                {
                    ret = false;
                    message = "Deletion of SY Failed.";
                }
            }
            return ret;
        }
開發者ID:dansalan,項目名稱:DCFIv3,代碼行數:27,代碼來源:SchoolYearDAO.cs

示例15: CreateUser

        public Boolean CreateUser(ref UserBDO userBDO, ref string message)
        {
            message = "User Added Successfully";
            bool ret = true;

             UserType ut = new UserType()
                {
                    UserType1 = userBDO.UserType.UsersType,
                    UserTypeCode = userBDO.UserType.UserTypeCode
                };
             User u = new User()
                {

                    UserName = userBDO.UserName,
                    Password = userBDO.Password,
                    LastName = userBDO.LastName,
                    FirstName = userBDO.FirstName,
                    MiddleName = userBDO.MiddleName,
                    UserTypeCode = userBDO.UserType.UserTypeCode,
                    UserType = ut
                };
            try {
              using (var DCEnt = new DCFIEntities()) {
                    DCEnt.Users.Attach(u);
                    DCEnt.Entry(u).State = System.Data.Entity.EntityState.Added;
                    int num = DCEnt.SaveChanges();
                    userBDO.UserId = u.UserId;

                    if (num != 1) {
                        ret = false;
                        message = "Adding of User failed";
                    }
            }
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}",
                                                validationError.PropertyName,
                                                validationError.ErrorMessage);
                    }
                }
            }
            return ret;
        }
開發者ID:dansalan,項目名稱:DCFIv5,代碼行數:48,代碼來源:UserDAO.cs


注:本文中的eSARDAL.DCFIEntities.Entry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。