Ejemplo n.º 1
0
        private void AddSingle(PT_Prj_Completed_Detail detail, string annexAddress, pm2Entities context)
        {
            PT_Prj_Completed_Annex annex = new PT_Prj_Completed_Annex {
                ID = Guid.NewGuid().ToString(),
                PT_Prj_Completed_Detail = detail,
                AnnexAddress            = annexAddress
            };

            context.AddToPT_Prj_Completed_Annex(annex);
        }
Ejemplo n.º 2
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();
             }
         }
     }
 }