예제 #1
0
        private void DataSource_UpdatingOrInserting(object sender, EntityDataSourceChangingEventArgs e)
        {
            MetaTable childTable = ChildrenColumn.ChildTable;

            // Comments assume employee/territory for illustration, but the code is generic

            if (Mode == DataBoundControlMode.Edit)
            {
                ObjectContext.LoadProperty(e.Entity, Column.Name);
            }

            // Get the collection of territories for this employee
            dynamic entityList = Column.EntityTypeProperty.GetValue(e.Entity, null);

            // Go through all the territories (not just those for this employee)
            foreach (dynamic childEntity in childTable.GetQuery(e.Context))
            {
                // Check if the employee currently has this territory
                bool isCurrentlyInList = ListContainsEntity(childTable, entityList, childEntity);

                // Find the checkbox for this territory, which gives us the new state
                string   pkString = childTable.GetPrimaryKeyString(childEntity);
                ListItem listItem = CheckBoxList1.Items.FindByValue(pkString);
                if (listItem == null)
                {
                    continue;
                }

                // If the states differs, make the appropriate add/remove change
                if (listItem.Selected)
                {
                    if (!isCurrentlyInList)
                    {
                        entityList.Add(childEntity);
                    }
                }
                else
                {
                    if (isCurrentlyInList)
                    {
                        entityList.Remove(childEntity);
                    }
                }
            }
        }
예제 #2
0
 protected void Insert_fields(object sender, EntityDataSourceChangingEventArgs e)
 {
     YASA_PL.Standard_Files c = (YASA_PL.Standard_Files)e.Entity;
     if (c != null)
     {
         c.Date_created_modified = DateTime.Now;
         if (c.filePath != null)
         {
             c.File_extension = c.filePath.Substring(c.filePath.LastIndexOf(".") + 1).ToLower();
             //add file size information
             String             fileUrl = "~/standard_files/" + c.filePath;
             String             path    = Server.MapPath(fileUrl);
             System.IO.FileInfo fi      = null;
             fi          = new System.IO.FileInfo(path);
             c.File_size = Math.Round(Convert.ToDecimal(fi.Length / 1048576), 2);
         }
     }
 }
예제 #3
0
 protected void Insert_fields(object sender, EntityDataSourceChangingEventArgs e)
 {
     YASA_PL.Quality_Instruction_Files c = (YASA_PL.Quality_Instruction_Files)e.Entity;
     if (c != null)
     {
         c.Date_created_modified = DateTime.Now;
         if (c.filePath != null)
         {
             c.File_extension = c.filePath.Substring(c.filePath.LastIndexOf(".") + 1).ToLower();
             //add file size information
             String             fileUrl = "~/quality_instruction_files/" + c.filePath;
             String             path    = Server.MapPath(fileUrl);
             System.IO.FileInfo fi      = null;
             fi          = new System.IO.FileInfo(path);
             c.File_size = fi.Length;
         }
     }
 }
    protected void EntityDataSource1_Inserting(object sender, EntityDataSourceChangingEventArgs e)
    {
        using (PlanetWroxEntities myEntities = new PlanetWroxEntities())
        {
            int     photoAlbumId = Convert.ToInt32(Request.QueryString.Get("PhotoAlbumId"));
            Picture myPicture    = (Picture)e.Entity;
            myPicture.PhotoAlbumId = photoAlbumId;

            // upload
            FileUpload FileUpload1    = (FileUpload)ListView1.InsertItem.FindControl("FileUpload1");
            string     virtualFolder  = "~/GigPics/";
            string     physicalFolder = Server.MapPath(virtualFolder);
            string     fileName       = Guid.NewGuid().ToString();
            string     extension      = System.IO.Path.GetExtension(FileUpload1.FileName);

            FileUpload1.SaveAs(System.IO.Path.Combine(physicalFolder, fileName + extension));
            myPicture.ImageUrl = virtualFolder + fileName + extension;
        }
    }
예제 #5
0
        protected void edsUsuario_Updating(object sender, EntityDataSourceChangingEventArgs e)
        {
            SISMed.Models.Usuario u = e.Entity as SISMed.Models.Usuario;

            using (var context = new SISMedEntities(e.Context.Connection as EntityConnection))
            {
                var     antigo   = context.Pessoas.OfType <SISMed.Models.Usuario>().First(c => c.Id == u.Id);
                TextBox txbSenha = fvUsuario.FindControl("SenhaTextBox") as TextBox;

                if (string.IsNullOrWhiteSpace(txbSenha.Text))
                {
                    u.Senha = antigo.Senha;
                }
                else
                {
                    u.Senha = Password.HashPassword(u.Senha);
                }
            }
        }
예제 #6
0
 protected void Insert_fields(object sender, EntityDataSourceChangingEventArgs e)
 {
     YASA_PL.CNC_Program_Files c = (YASA_PL.CNC_Program_Files)e.Entity;
     if (c != null)
     {
         c.Date_created_modified = DateTime.Now;
         c.UserId = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
         if (c.filePath != null)
         {
             c.File_extension = c.filePath.Substring(c.filePath.LastIndexOf(".") + 1).ToLower();
             //add file size information
             String             fileUrl = "~/cnc_program/" + c.filePath;
             String             path    = Server.MapPath(fileUrl);
             System.IO.FileInfo fi      = null;
             fi          = new System.IO.FileInfo(path);
             c.File_size = fi.Length;
         }
     }
 }
예제 #7
0
 protected void Insert_fields(object sender, EntityDataSourceChangingEventArgs e)
 {
     YASA_PL.Standard_Files c = (YASA_PL.Standard_Files)e.Entity;
     if (c != null)
     {
         c.Date_created_modified = DateTime.Now;
         if (c.filePath != null)
         {
             c.File_extension = c.filePath.Substring(c.filePath.LastIndexOf(".") + 1).ToLower();
             //add file size information
             String             fileUrl = "~/standard_files/" + c.filePath;
             String             path    = Server.MapPath(fileUrl);
             System.IO.FileInfo fi      = null;
             fi          = new System.IO.FileInfo(path);
             c.File_size = Math.Round(Convert.ToDecimal(fi.Length / 1048576), 2);
         }
         Session["Record_Info"] = "Edycja pliku zakończona prawidłowo";
         redirectlink           = "~/StandardSet/Details.aspx?Id=" + c.StandardId;
     }
 }
예제 #8
0
 protected void Insert_fields(object sender, EntityDataSourceChangingEventArgs e)
 {
     YASA_PL.Fixture_Document_File c = (YASA_PL.Fixture_Document_File)e.Entity;
     if (c != null)
     {
         c.Date_created_modified = DateTime.Now;
         if (c.filePath != null)
         {
             c.File_extension = c.filePath.Substring(c.filePath.LastIndexOf(".") + 1).ToLower();
             //add file size information
             String             fileUrl = "~/fixture_files/" + c.filePath;
             String             path    = Server.MapPath(fileUrl);
             System.IO.FileInfo fi      = null;
             fi          = new System.IO.FileInfo(path);
             c.File_size = fi.Length;
         }
         Session["Record_Info"] = "Edycja pliku zakończona poprawnie";
         redirectlink           = "~/FixtureSet/Details.aspx?Id=" + c.FixtureId;
     }
 }
예제 #9
0
 protected void EntityDataSource3_Inserting(object sender, EntityDataSourceChangingEventArgs e)
 {
     //// Nueva entidad alums_asigs
     //var nuevo = e.Entity as alum_asig;
     //nuevo.id_alumno = Convert.ToInt32(DropDownList1.SelectedValue);
     //nuevo.id_asignatura = Convert.ToInt32(DropDownList2.SelectedValue);
     //nuevo.nota = 0.0F;
     //// Establecer las relaciones con idAlum e idAsig
     //int idAlum = Convert.ToInt32(DropDownList1.SelectedValue);
     //int idAsig = Convert.ToInt32(DropDownList2.SelectedValue);
     //// Establecer referencias
     //object alum;
     //e.Context.TryGetObjectByKey(new System.Data.EntityKey(
     //    "bd_notasAlumnosEntities.alumnos", "id_alumno", idAlum), out alum);
     //nuevo.alumno = (alumno)alum;
     //object asig;
     //e.Context.TryGetObjectByKey(new System.Data.EntityKey(
     //    "bd_notasAlumnosEntities.asignaturas", "id_asignatura", idAsig), out asig);
     //nuevo.asignatura = (asignatura)asig;
 }
예제 #10
0
        protected void edsMovPorCuenta_Updating(object sender, EntityDataSourceChangingEventArgs e)
        {
            e.Cancel = true;
            var entidad   = (DMovCtaxBco)e.Entity;
            var entidadBD = SrvLista.DMovCtaxBco(entidad.IdMovCtaxBco);

            e.Context.SaveChanges();

            if (entidad.nImporte != entidadBD.nImporte || entidad.dFecOpe != entidadBD.dFecOpe)
            {//-------------------si cambia la fecha, utilizo la fecha menor (mas cerca al saldo inicial)
                //al cambiar la fecha, debo actualizar todos los saldos afectados a partir de la fecha menor
                var compararFechas = DateTime.Compare(entidadBD.dFecOpe.Value, entidad.dFecOpe.Value);
                var fechaOpeMenor  = (compararFechas < 0) ? entidadBD.dFecOpe : entidad.dFecOpe; //0 > date1 es menor, 0 = iguales, 0 < date2 es menor
                //PD la fechaIng siempre sera desde la BD porque el entitydatasource me muestra null


                var     ultiMovi     = SrvLista.UltimoMovimientoPorFecha(entidadBD.IdCtaxBco, entidadBD.IdMovCtaxBco, fechaOpeMenor);
                decimal?saldoInicial = (ultiMovi == null) ? 0 : ultiMovi.nSalFin;  //si no hay ultimovi entonces empezara de 0
                SrvLista.ActualizarUltimosSaldos(entidadBD.IdCtaxBco, entidadBD.IdMovCtaxBco, fechaOpeMenor, saldoInicial);
            }
        }
예제 #11
0
        protected void edsMudarSenha_Updating(object sender, EntityDataSourceChangingEventArgs e)
        {
            SISMed.Models.Usuario novo = e.Entity as SISMed.Models.Usuario;

            using (var context = new SISMedEntities(e.Context.Connection as EntityConnection))
            {
                var     antigo        = context.Pessoas.OfType <SISMed.Models.Usuario>().First(c => c.Id == novo.Id);
                TextBox txbSenhaAtual = fvMudarSenha.FindControl("txbSenhaAtual") as TextBox;

                if (antigo.Senha == Password.HashPassword(txbSenhaAtual.Text))
                {
                    novo.Senha = Password.HashPassword(novo.Senha);
                    Response.Redirect("./Default.aspx?successPassword=U2VuaGEgYWx0ZXJhZGEgY29tIHN1Y2Vzc28u");
                }
                else
                {
                    Response.Redirect("./Default.aspx?errorPassword=QSBzZW5oYSBhdHVhbCBlc3TDoSBpbmNvcnJldGEu");
                    e.Cancel = true;
                }
            }
        }
예제 #12
0
        protected void CountriesDataSource_Deleting(object sender, EntityDataSourceChangingEventArgs e)
        {
            var editedCountry = (Data.Country)e.Entity;

            using (var context = new Data.WorldEntities())
            {
                var editedCountryInDB = context.Countries
                                        .Include("Towns").FirstOrDefault(c => c.Id == editedCountry.Id);

                if (editedCountryInDB == null)
                {
                    return;
                }

                context.Towns.RemoveRange(editedCountryInDB.Towns);
                editedCountryInDB.Languages.Clear();


                context.SaveChanges();
            }
        }
예제 #13
0
        void DataSource_UpdatingOrInserting(object sender, EntityDataSourceChangingEventArgs e)
        {
            MetaTable childTable = ChildrenColumn.ChildTable;

            if (Mode == DataBoundControlMode.Edit)
            {
                ObjectContext.LoadProperty(e.Entity, Column.Name);
            }

            dynamic entityCollection = Column.EntityTypeProperty.GetValue(e.Entity, null);

            foreach (dynamic childEntity in childTable.GetQuery(e.Context))
            {
                var isCurrentlyInList = ListContainsEntity(childTable, entityCollection, childEntity);

                string   pkString = childTable.GetPrimaryKeyString(childEntity);
                ListItem listItem = CheckBoxList1.Items.FindByValue(pkString);
                if (listItem == null)
                {
                    continue;
                }

                if (listItem.Selected)
                {
                    if (!isCurrentlyInList)
                    {
                        entityCollection.Add(childEntity);
                    }
                }
                else
                {
                    if (isCurrentlyInList)
                    {
                        entityCollection.Remove(childEntity);
                    }
                }
            }
        }
예제 #14
0
 protected void edsUsuario_Inserting(object sender, EntityDataSourceChangingEventArgs e)
 {
     SISMed.Models.Usuario u = e.Entity as SISMed.Models.Usuario;
     u.Senha = Password.HashPassword(u.Senha);
 }
예제 #15
0
        protected void edsConsulta_Inserting(object sender, EntityDataSourceChangingEventArgs e)
        {
            Consulta c = e.Entity as Consulta;

            c.DataHora = DateTime.Now;
        }
        protected void PaymentDataSource_Inserting(object sender, EntityDataSourceChangingEventArgs e)
        {
            var newPmnt = (BAGA.Payment)e.Entity;

            newPmnt.ReservationID = Convert.ToInt32(ListBox1.SelectedValue);
        }
예제 #17
0
 protected void TownsDataSource_Deleting(object sender, EntityDataSourceChangingEventArgs e)
 {
 }
예제 #18
0
    protected void EntityDataSource1_Inserting(object sender, EntityDataSourceChangingEventArgs e)
    {
        TPhotoAlbum myPhotoAlbum = (TPhotoAlbum)e.Entity;

        myPhotoAlbum.strUserName = User.Identity.Name;
    }
예제 #19
0
        protected void dsUsers_Deleting(object sender, EntityDataSourceChangingEventArgs e)
        {
            var it = e.Entity as DA.Users;

            BL.UserBL.RemoveUserRelationships(it.UserId);
        }
예제 #20
0
 protected void EntityDataSource1_Updating(object sender, EntityDataSourceChangingEventArgs e)
 {
 }
예제 #21
0
        protected void edsSolicitacoes_Inserting(object sender, EntityDataSourceChangingEventArgs e)
        {
            Solicitacao s = e.Entity as Solicitacao;

            s.DataHora = DateTime.Now;
        }