Beispiel #1
0
 private void Update(string prjId, string prjCompletedId, List <string> annexAddress)
 {
     if (annexAddress != null)
     {
         using (pm2Entities entities = new pm2Entities())
         {
             string detailId = new CompletedAnnex().GetDetailId(prjId, prjCompletedId);
             if (detailId != "")
             {
                 List <string> list = this.GetAnnex(detailId);
                 using (List <string> .Enumerator enumerator = list.GetEnumerator())
                 {
                     string address;
                     while (enumerator.MoveNext())
                     {
                         address = enumerator.Current;
                         if (!annexAddress.Contains(address))
                         {
                             PT_Prj_Completed_Annex entity = (from m in entities.PT_Prj_Completed_Annex
                                                              where (m.PT_Prj_Completed_Detail.ID == detailId) && (m.AnnexAddress == address)
                                                              select m).FirstOrDefault <PT_Prj_Completed_Annex>();
                             if (entity != null)
                             {
                                 entities.DeleteObject(entity);
                             }
                         }
                     }
                 }
                 PT_Prj_Completed_Detail detail = (from m in entities.PT_Prj_Completed_Detail
                                                   where m.ID == detailId
                                                   select m).FirstOrDefault <PT_Prj_Completed_Detail>();
                 if (detail != null)
                 {
                     CompletedAnnex annex2 = new CompletedAnnex();
                     foreach (string str in annexAddress)
                     {
                         if (!list.Contains(str))
                         {
                             annex2.AddSingle(detail, str, entities);
                         }
                     }
                 }
                 entities.SaveChanges();
             }
         }
     }
 }
Beispiel #2
0
 private void Add(string prjId, string prjCompletedId, List <string> annexAddress)
 {
     if (annexAddress != null)
     {
         using (pm2Entities entities = new pm2Entities())
         {
             Guid prjGuid = new Guid(prjId);
             PT_Prj_Completed_Detail detail = (from m in entities.PT_Prj_Completed_Detail
                                               where (m.PrjGuid == prjGuid) && (m.PT_Prj_Completed.ID == prjCompletedId)
                                               select m).FirstOrDefault <PT_Prj_Completed_Detail>();
             if (detail != null)
             {
                 CompletedAnnex annex = new CompletedAnnex();
                 foreach (string str in annexAddress)
                 {
                     annex.AddSingle(detail, str, entities);
                 }
                 entities.SaveChanges();
             }
         }
     }
 }