/// <summary> /// 编辑台帐 /// </summary> /// <param name="tztask"></param> /// <returns></returns> public int EditAccountTask(AccountTaskModel tztask, List <FileUploadClass> list) { using (Entities db = new Entities()) { int count = 0; tz_tztasks model = db.tz_tztasks.Where(t => t.taskid == tztask.taskid).FirstOrDefault(); if (model != null) { model.endtime = tztask.endtime; model.remark = tztask.remark; model.starttime = tztask.starttime; model.taskname = tztask.taskname; model.taskyear = tztask.taskyear; model.tz_type = tztask.tz_type; // model.tz_json = tztask.tz_json; // model.sszd = tztask.sszd; // IQueryable<tz_taskclasses> iqueryable = db.tz_taskclasses.Where(t => t.taskid == tztask.taskid); //foreach (tz_taskclasses item in iqueryable) //{ // db.tz_taskclasses.Remove(item); //} //foreach (var item in list_tzclass) //{ // tz_taskclasses tz = new tz_taskclasses(); // tz.classid = item.classid; // tz.sszd = item.sszd; // tz.status = item.status; // tz.tasktime = item.tasktime; // tz.taskid = model.taskid; // db.tz_taskclasses.Add(tz); //} 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 = 1; file.sourceid = tztask.taskid; file.filesize = item.size; db.tz_files.Add(file); } count = db.SaveChanges(); } return(count); } }
/// <summary> /// 添加台帐任务 /// </summary> /// <param name="tztask"></param> /// <returns></returns> public int AddAccountTask(AccountTaskModel tztask, List <FileUploadClass> list, List <tz_taskclasses> list_tzclass) { using (Entities db = new Entities()) { tz_tztasks model = new tz_tztasks(); model.createtime = tztask.createtime; model.createuserid = tztask.createuserid; model.endtime = tztask.endtime; model.remark = tztask.remark; model.starttime = tztask.starttime; model.taskname = tztask.taskname; model.taskyear = tztask.taskyear; model.tz_type = tztask.tz_type; model.tz_json = tztask.tz_json; model.sszd = tztask.sszd; model.ssrw = tztask.ssrw; db.tz_tztasks.Add(model); db.SaveChanges(); foreach (var item in list_tzclass) { tz_taskclasses tz = new tz_taskclasses(); tz.classid = item.classid; tz.sszd = item.sszd; tz.status = item.status; tz.tasktime = item.tasktime; tz.taskid = model.taskid; db.tz_taskclasses.Add(tz); } 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 = 1; file.sourceid = model.taskid; file.filesize = item.size; db.tz_files.Add(file); } db.SaveChanges(); return(1); } }