Esempio n. 1
0
 private void mCDP(string COD_CON)
 {
     CDP_CONTRATOS ep_cdp;
     foreach (vEP_CDP_DTO dto in oDto.l_EP_CDP)
     {
         if (!dto.ES_NUEVO && dto.ES_ANULAR)
         {
             ep_cdp = cto.CDP_CONTRATOS.Where(t => t.NRO_CDP == dto.NRO_CDP).FirstOrDefault();
             if (ep_cdp != null)
             {
                 ctx.Entry(ep_cdp).State = EntityState.Deleted;
             }
         }
         if (dto.ES_NUEVO && !dto.ES_ANULAR)
         {
             ep_cdp = new CDP_CONTRATOS();
             ep_cdp.NRO_CDP = dto.NRO_CDP;
             ep_cdp.FEC_CDP = dto.FEC_CDP;
             ep_cdp.VAL_CDP = dto.VAL_CDP;
             ep_cdp.VIG_FUT = dto.VIG_FUT;
             ep_cdp.COD_CON = COD_CON;
             cto.CDP_CONTRATOS.Add(ep_cdp);
             mRubrosCDPs(dto.EP_RUBROS_CDP, COD_CON);
         }
         if (!dto.ES_NUEVO && !dto.ES_ANULAR) //MODIFICAR
         {
             ep_cdp = cto.CDP_CONTRATOS.Where(t => t.NRO_CDP == dto.NRO_CDP).FirstOrDefault();
             if (ep_cdp != null)
             {
                 ep_cdp.NRO_CDP = dto.NRO_CDP;
                 ep_cdp.FEC_CDP = dto.FEC_CDP;
                 ep_cdp.VAL_CDP = dto.VAL_CDP;
                 ep_cdp.COD_CON = COD_CON;
                 ep_cdp.VIG_FUT = dto.VIG_FUT;
                 //ep_cdp.USAP_MOD = oDto.USAP_ELA_EP;
                 ctx.Entry(ep_cdp).State = EntityState.Modified;
                 
             }
         }
     }
 }
Esempio n. 2
0
        private void mCDP()
        {
            List<CDP_CONTRATOS> lCDPsOld = ctx.CDP_CONTRATOS.Where(t => t.COD_CON == cto.COD_CON).ToList();
            foreach (CDP_CONTRATOS item in lCDPsOld)
            {
                bool ban = true;
                foreach (vEP_CDP_DTO item2 in oDto.l_EP_CDP)
                {
                    if (item.NRO_CDP == item2.NRO_CDP) ban = false;
                }
                if (ban)
                {
                    List<C_RUBROS_CDP> lRubrosEliminar = ctx.C_RUBROS_CDP.Where(t => t.COD_CON == cto.COD_CON && t.NRO_CDP == item.NRO_CDP).ToList();
                    foreach (C_RUBROS_CDP item3 in lRubrosEliminar)
                    {
                        ctx.C_RUBROS_CDP.Remove(item3);
                        ctx.SaveChanges();
                    }
                    ctx.CDP_CONTRATOS.Remove(item);
                }
            }

            CDP_CONTRATOS ep_cdp;
            foreach (vEP_CDP_DTO dto in oDto.l_EP_CDP)
            {
                if (!dto.ES_NUEVO && dto.ES_ANULAR)
                {
                    ep_cdp = cto.CDP_CONTRATOS.Where(t => t.NRO_CDP == dto.NRO_CDP).FirstOrDefault();
                    if (ep_cdp != null)
                    {
                        ctx.Entry(ep_cdp).State = EntityState.Deleted;
                    }
                }
                if (dto.ES_NUEVO && !dto.ES_ANULAR)
                {
                    ep_cdp = new CDP_CONTRATOS();
                    ep_cdp.NRO_CDP = dto.NRO_CDP;
                    ep_cdp.FEC_CDP = dto.FEC_CDP;
                    ep_cdp.VAL_CDP = dto.VAL_CDP;
                    ep_cdp.VIG_FUT = dto.VIG_FUT;
                    cto.CDP_CONTRATOS.Add(ep_cdp);
                    mRubrosCDPs(dto.EP_RUBROS_CDP, cto.COD_CON);
                }
                if (!dto.ES_NUEVO && !dto.ES_ANULAR) //MODIFICAR
                {
                    ep_cdp = cto.CDP_CONTRATOS.Where(t => t.NRO_CDP == dto.NRO_CDP).FirstOrDefault();
                    if (ep_cdp != null)
                    {
                        ep_cdp.NRO_CDP = dto.NRO_CDP;
                        ep_cdp.FEC_CDP = dto.FEC_CDP;
                        ep_cdp.VAL_CDP = dto.VAL_CDP;
                        ep_cdp.VIG_FUT = dto.VIG_FUT;
                        //ep_cdp.USAP_MOD = oDto.USAP_ELA_EP;
                        ctx.Entry(ep_cdp).State = EntityState.Modified;

                    }
                }
            }
        }
Esempio n. 3
0
 private void mCDP(string COD_CON)
 {
     CDP_CONTRATOS ep_cdp;
     foreach (vEP_CDP_DTO dto in oDto.l_EP_CDP)
     {
         ep_cdp = new CDP_CONTRATOS();
         ep_cdp.NRO_CDP = dto.NRO_CDP;
         ep_cdp.FEC_CDP = dto.FEC_CDP;
         ep_cdp.VAL_CDP = dto.VAL_CDP;
         ep_cdp.COD_CON = COD_CON;
         //ep_cdp.VIG_FUT = dto.VIG_FUT;
         ctx.CDP_CONTRATOS.Add(ep_cdp);
         mRubrosCDPs(dto.EP_RUBROS_CDP, COD_CON);
     }
 }