/// <summary> /// 编辑台帐登记 /// </summary> /// <param name="tztask"></param> /// <returns></returns> public int EditAccountRegister(AccountRegisterModel tzrs, List <FileUploadClass> list) { using (Entities db = new Entities()) { int count = 0; tz_registers model = db.tz_registers.Where(t => t.registerid == tzrs.registerid).FirstOrDefault(); if (model != null) { model.registerid = tzrs.registerid; model.title = tzrs.title; model.registertime = tzrs.registertime; model.remark = tzrs.remark; model.people = tzrs.people; model.address = tzrs.address; model.taskclassid = tzrs.taskclassid; model.content = tzrs.content; model.remark = tzrs.remark; model.createuserid = tzrs.createuserid; model.createtime = tzrs.createtime; model.eventid = tzrs.citizenid; // model.unitid = tzrs.unitid; model.wordname = tzrs.wordname; model.wordpath = tzrs.wordpath; foreach (var item in list) { tz_files file = new tz_files(); file.filename = item.OriginalName; file.filepath = item.OriginalPath; file.filetype = item.OriginalType; file.filesource = 2; file.sourceid = tzrs.registerid; file.filesize = item.size; db.tz_files.Add(file); } count = db.SaveChanges(); } return(count); } }
/// <summary> /// 添加台帐登记 /// </summary> /// <param name="tztask"></param> /// <returns></returns> public int AddAccountRegister(AccountRegisterModel tzrs, List <FileUploadClass> list, List <FileClass> eventList) { using (Entities db = new Entities()) { tz_registers model = new tz_registers(); model.title = tzrs.title; model.registertime = tzrs.registertime; model.remark = tzrs.remark; model.people = tzrs.people; model.address = tzrs.address; model.taskclassid = tzrs.taskclassid; model.content = tzrs.content; model.remark = tzrs.remark; model.createuserid = tzrs.createuserid; model.createtime = tzrs.createtime; model.eventid = tzrs.citizenid; model.unitid = tzrs.unitid; model.wordname = tzrs.wordname; model.wordpath = tzrs.wordpath; db.tz_registers.Add(model); db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); db.Configuration.ValidateOnSaveEnabled = true; foreach (var item in list) { tz_files file = new tz_files(); file.filename = item.OriginalName; file.filepath = item.OriginalPath; file.filetype = item.OriginalType; file.filesource = 2; file.sourceid = model.registerid; file.filesize = item.size; db.tz_files.Add(file); } db.SaveChanges(); //如果是自动处理则把事件改为1 if (tzrs.citizenid != null && eventList.Count > 0) { sm_citizenservices citizenservices = db.sm_citizenservices.Where(m => m.citizenid == tzrs.citizenid).FirstOrDefault(); citizenservices.istz = 1; foreach (var item in eventList) { tz_files file = new tz_files(); file.filename = item.OriginalName; file.filepath = item.OriginalPath; file.filetype = item.OriginalType; file.filesource = 2; file.sourceid = model.registerid; file.filesize = item.size; db.tz_files.Add(file); } db.SaveChanges(); } return(1); } }