Beispiel #1
0
        void registroConvenio_Closed(object sender, EventArgs e)
        {
            RegistroConvenioPlanoSaude registro = (RegistroConvenioPlanoSaude)sender;
            AdministracaoContext       context  = (AdministracaoContext)convenioPlanoSaudeSetDomainDataSource.DomainContext;

            if (registro.DialogResult == true && registro.novoConvenio != null)
            {
                context.ConvenioPlanoSaudeSets.Add(registro.novoConvenio);
                convenioPlanoSaudeSetDomainDataSource.SubmitChanges();
                dfrConvenio.CurrentItem = registro.novoConvenio;

                ConvenioPlanoSaudeSet convenio = (ConvenioPlanoSaudeSet)registro.novoConvenio;
                ConvenioServicoSet    desconto = null;

                AdministracaoContext             administracaoContext  = new AdministracaoContext();
                LoadOperation <ServicoMedicoSet> loadOpServicosMedicos = administracaoContext.Load <ServicoMedicoSet>(administracaoContext.GetServicoMedicoSetQuery());
                loadOpServicosMedicos.Completed += (s2, e2) =>
                {
                    foreach (ServicoMedicoSet servico in ((LoadOperation)s2).Entities)
                    {
                        desconto = new ConvenioServicoSet();
                        desconto.ConvenioPlanoSaude_codigo = convenio.codigo;
                        desconto.ServicoMedicoSet_codigo   = servico.codigo;
                        desconto.porcentagem_desconto      = 0;

                        context.ConvenioServicoSets.Add(desconto);
                    }
                    convenioPlanoSaudeSetDomainDataSource.SubmitChanges();
                };
            }
        }
 public void DeleteConvenioServicoSet(ConvenioServicoSet convenioServicoSet)
 {
     if ((convenioServicoSet.EntityState == EntityState.Detached))
     {
         this.ObjectContext.ConvenioServicoSet.Attach(convenioServicoSet);
     }
     this.ObjectContext.ConvenioServicoSet.DeleteObject(convenioServicoSet);
 }
 public void InsertConvenioServicoSet(ConvenioServicoSet convenioServicoSet)
 {
     if ((convenioServicoSet.EntityState != EntityState.Detached))
     {
         this.ObjectContext.ObjectStateManager.ChangeObjectState(convenioServicoSet, EntityState.Added);
     }
     else
     {
         this.ObjectContext.ConvenioServicoSet.AddObject(convenioServicoSet);
     }
 }
Beispiel #4
0
        private void dgrDescontosServicos_RowEditEnded(object sender, DataGridRowEditEndedEventArgs e)
        {
            AdministracaoContext  administracaoContext    = new AdministracaoContext();
            ConvenioPlanoSaudeSet convenioSelecionado     = (ConvenioPlanoSaudeSet)convenioPlanoSaudeSetDataGrid.SelectedItem;
            DescontoServico       descontoServicoAlterado = (DescontoServico)((DataGrid)sender).SelectedItem;

            LoadOperation <ConvenioServicoSet> loadOp = administracaoContext.Load <ConvenioServicoSet>(administracaoContext.GetConvenioServicoSet_IdQuery(descontoServicoAlterado.Id));

            loadOp.Completed += (s3, e3) =>
            {
                ConvenioServicoSet descontoServico = administracaoContext.ConvenioServicoSets.Where <ConvenioServicoSet>(desc => desc.id == descontoServicoAlterado.Id).Single <ConvenioServicoSet>();
                descontoServico.porcentagem_desconto = descontoServicoAlterado.Desconto;
                administracaoContext.SubmitChanges();
            };
        }
 public void UpdateConvenioServicoSet(ConvenioServicoSet currentConvenioServicoSet)
 {
     this.ObjectContext.ConvenioServicoSet.AttachAsModified(currentConvenioServicoSet, this.ChangeSet.GetOriginal(currentConvenioServicoSet));
 }