/// <summary> /// 删除养护单位 /// </summary> /// <param name="companyid"></param> /// <returns></returns> public int DeleteConserbation(int companyid) { using (Entities db = new Entities()) { yh_companys yhmodel = db.yh_companys.FirstOrDefault(a => a.companyid == companyid); if (yhmodel != null) { db.yh_companys.Remove(yhmodel); } return(db.SaveChanges()); } }
/// <summary> /// 修改养护单位 /// </summary> /// <param name="model"></param> /// <returns></returns> public int EditConserbation(YH_CompanyModel model) { using (Entities db = new Entities()) { yh_companys yhmodel = db.yh_companys.FirstOrDefault(a => a.companyid == model.companyid); if (yhmodel != null) { yhmodel.companyname = model.companyname; yhmodel.legal = model.legal; yhmodel.contact = model.contact; yhmodel.mobilephone = model.mobilephone; yhmodel.telephone = model.telephone; yhmodel.faxnumber = model.faxnumber; yhmodel.email = model.email; yhmodel.companytype = model.companytype; yhmodel.address = model.address; yhmodel.isenadle = model.isenadle; yhmodel.createuserid = model.createuserid; yhmodel.createtime = DateTime.Now; } return(db.SaveChanges()); } }
/// <summary> /// 添加养护单位 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddConserbation(YH_CompanyModel model) { using (Entities db = new Entities()) { yh_companys yhmodel = new yh_companys(); yhmodel.companyid = model.companyid; yhmodel.companyname = model.companyname; yhmodel.legal = model.legal; yhmodel.contact = model.contact; yhmodel.mobilephone = model.mobilephone; yhmodel.telephone = model.telephone; yhmodel.faxnumber = model.faxnumber; yhmodel.email = model.email; yhmodel.companytype = model.companytype; yhmodel.address = model.address; yhmodel.isenadle = 1; yhmodel.createuserid = model.createuserid; yhmodel.createtime = DateTime.Now; db.yh_companys.Add(yhmodel); db.SaveChanges(); return(yhmodel.companyid); } }