本文整理汇总了C#中SEMS.DAL.SEMSDBContext.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# SEMSDBContext.SaveChanges方法的具体用法?C# SEMSDBContext.SaveChanges怎么用?C# SEMSDBContext.SaveChanges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SEMS.DAL.SEMSDBContext
的用法示例。
在下文中一共展示了SEMSDBContext.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DelClass
/// <summary>
/// 删除班级
/// </summary>
///<returns>成功返回true</returns>
public static bool DelClass(string class_id, string class_small_id)
{
try
{
using (var db = new SEMSDBContext())
{
var toDel=db.Classes.Find(class_id,class_small_id); //所有需要级联更新删除的地方数据库里都建好了。。不用这样写,删就是了
//... on delete cascade on update cascade)...
//foreach (var temp in db.Student.Where(x => x.class_id == class_id && x.class_small_id == class_small_id))
//{
// StudentBS.DelStudent(temp.student_id);
// db.Student.Remove(temp);
//}
//foreach (var temp in db.Lk_evaluation_year_classes.Where(x => x.class_id == class_id && x.class_small_id == class_small_id))
//{
// Lk_evaluation_year_classesBS.DelLk_evaluation_year_classes(temp.evaluation_year_id, temp.class_id, temp.class_small_id);
// db.Lk_evaluation_year_classes.Remove(temp);
//}
db.Classes.Remove(toDel);
db.SaveChanges();
}
return true;
}
catch
{
return false;
}
}
示例2: AddClass
/// <summary>
/// 添加新班级
/// </summary>
///<returns>成功返回true</returns>
public static bool AddClass(Classes model)
{
try
{
using (var db = new SEMSDBContext())
{
/*var classes = new Classes()
{
class_grade = model.class_grade,
class_id = model.class_id,
class_small_id = model.class_small_id
};*/
db.Classes.Add(model);
db.SaveChanges();
}
return true;
}
catch (DbEntityValidationException e)
{
Debug.WriteLine(e.Message);
return false;
}
catch
{
return false;
}
}
示例3: AddEvaluation_entry
/// <summary>
/// 添加新测评项目
/// </summary>
/// <param name="module_id">要添加的项目</param>
/// <returns></returns>
public static bool AddEvaluation_entry(Evaluation_entry model)
{
try
{
using (var db = new SEMSDBContext())
{
db.Evaluation_entry.Add(model);
db.SaveChanges();
}
return true;
}
catch
{
return false;
}
}
示例4: AddAdministrater
/// <summary>
/// 添加管理员用户
/// </summary>
public static bool AddAdministrater(Administrater model)
{
try
{
using (var db = new SEMSDBContext())
{
db.Administrater.Add(model);
db.SaveChanges();
}
return true;
}
catch
{
return false;
}
}
示例5: AddLk_evaluation_year_classes
/// <summary>
/// 添加测评年班级链接表
/// </summary>
public static bool AddLk_evaluation_year_classes(Lk_evaluation_year_classes model)
{
try
{
using (var db = new SEMSDBContext())
{
db.Lk_evaluation_year_classes.Add(model);
db.SaveChanges();
}
return true;
}
catch
{
return false;
}
}
示例6: DelAdministrater
/// <summary>
/// 删除管理员账户
/// </summary>
public static bool DelAdministrater(string uid)
{
try
{
using (var db = new SEMSDBContext())
{
var temp = db.Administrater.Find(uid);
db.Administrater.Remove(temp);
db.SaveChanges();
}
return true;
}
catch
{
return false;
}
}
示例7: DelLk_evaluation_year_classes
/// <summary>
/// 删除测评年班级链接表
/// </summary>
public static bool DelLk_evaluation_year_classes(int evaluation_year_id, string class_id, string class_small_id)
{
try
{
using (var db = new SEMSDBContext())
{
var temp = db.Lk_evaluation_year_classes.Find(evaluation_year_id, class_id, class_small_id);
db.Lk_evaluation_year_classes.Remove(temp);
db.SaveChanges();
}
return true;
}
catch
{
return false;
}
}
示例8: AddStudent
/// <summary>
/// 添加新学生
/// </summary>
/// <param name="model">要添加的学生</param>
/// <returns>成功返回true</returns>
public static bool AddStudent(Student model)
{
try
{
using (var db = new SEMSDBContext())
{
db.Student.Add(model);
db.SaveChanges();
}
return true;
}
catch// (Exception ee)
{
//throw ee.InnerException;
return false;
}
}
示例9: DelNews
/// <summary>
/// 删除公告
/// </summary>
public static bool DelNews(int news_id)
{
try
{
using (var db = new SEMSDBContext())
{
var temp = db.News.Find(news_id);
db.News.Remove(temp);
db.SaveChanges();
}
return true;
}
catch
{
return false;
}
}
示例10: DelStudent
/// <summary>
/// 删除学生信息
/// </summary>
/// <param name="class_id">学号</param>
/// <returns>成功返回true</returns>
public static bool DelStudent(string student_id)
{
try
{
using (var db = new SEMSDBContext())
{
var temp = db.Student.Find(student_id);
db.Student.Remove(temp);
db.SaveChanges();
}
return true;
}
catch
{
return false;
}
}
示例11: AddNews
/// <summary>
/// 添加新公告
/// </summary>
public static bool AddNews(News model)
{
try
{
using (var db = new SEMSDBContext())
{
db.News.Add(model);
db.SaveChanges();
}
return true;
}
catch (Exception ee)
{
throw ee.InnerException;
//return false;
}
}
示例12: ChangePassword
/// <summary>
/// 修改管理员密码
/// </summary>
public static bool ChangePassword(string uid, string pwd,string oldPwd)
{
try
{
using (var db = new SEMSDBContext())
{
var admin = db.Administrater.FirstOrDefault(x => x.admin_id == uid);
if (admin == null) return false;
admin.admin_pwd = pwd;
db.SaveChanges();
}
return true;
}
catch
{
return false;
}
}
示例13: DelEvaluation_entry
/// <summary>
/// 删除测评项目
/// </summary>
public static bool DelEvaluation_entry(int entry_id)
{
try
{
using (var db = new SEMSDBContext())
{
var temp = db.Evaluation_entry.Find(entry_id);
//Entry_scoreBS.AllDelEntry_score(entry_id);
db.Evaluation_entry.Remove(temp);
db.SaveChanges();
}
return true;
}
catch
{
return false;
}
}
示例14: AllDelEntry_score
/// <summary>
/// 批量删除项目成绩
/// </summary>
public static bool AllDelEntry_score(int entry_id)
{
try
{
using (var db = new SEMSDBContext())
{
foreach (var temp in db.Entry_score.Where(x => x.entry_id == entry_id))
{
db.Entry_score.Remove(temp);
}
db.SaveChanges();
}
return true;
}
catch
{
return false;
}
}
示例15: AllModifyEntry_score
/// <summary>
/// 批量修改项目成绩
/// </summary>
/// <param name="entry_id">项目ID</param>
/// <param name="score">待改分数</param>
public static bool AllModifyEntry_score(int entry_id, int score)
{
try
{
using (var db = new SEMSDBContext())
{
foreach (var temp in db.Entry_score.Where(x => x.entry_id == entry_id))
{
temp.score = score;
}
db.SaveChanges();
}
return true;
}
catch
{
return false;
}
}