当前位置: 首页>>代码示例>>C#>>正文


C# DCFIEntities.SaveChanges方法代码示例

本文整理汇总了C#中eSARDAL.DCFIEntities.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# DCFIEntities.SaveChanges方法的具体用法?C# DCFIEntities.SaveChanges怎么用?C# DCFIEntities.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eSARDAL.DCFIEntities的用法示例。


在下文中一共展示了DCFIEntities.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: AddScholarshipDiscounts

 public Boolean AddScholarshipDiscounts(List<ScholarshipDiscountBDO> discounts, int scholarshipCode, ref string message)
 {
     message = "Scholarship Discounts Added Successfully";
     Boolean ret = true;
     try {
     foreach (ScholarshipDiscountBDO d in discounts)
     {
         ScholarshipDiscount sd = new ScholarshipDiscount();
         ConvertScholarshipDiscountBDOToScholarshipDiscount(d, sd);
         using (var DCEnt = new DCFIEntities())
         {
             DCEnt.ScholarshipDiscounts.Attach(sd);
             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:dansalan,项目名称:DCFIv5,代码行数:32,代码来源:ScholarshipDAO.cs

示例13: 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

示例14: 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

示例15: 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


注:本文中的eSARDAL.DCFIEntities.SaveChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。