示例#1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (id_Carpetas == 0)
            {
                using (Model.polyuprotecEntities1 db = new Model.polyuprotecEntities1())
                {
                    var oCarpeta = new Model.Carpeta();
                    oCarpeta.id_Carpetas = int.Parse(documento.Text);
                    oCarpeta.Nombre      = Nombre.Text;
                    oCarpeta.Estado      = Estado.Text;

                    db.Carpeta.Add(oCarpeta);
                    db.SaveChanges();

                    Usuario.StaticMainFrame.Content = new ListaPersonal();
                }
            }
            else
            {
                using (Model.polyuprotecEntities1 db = new Model.polyuprotecEntities1())
                {
                    var oCarpeta = db.Carpeta.Find(id_Carpetas);
                    oCarpeta.id_Carpetas = int.Parse(documento.Text);
                    oCarpeta.Nombre      = Nombre.Text;
                    oCarpeta.Estado      = Estado.Text;

                    db.Entry(oCarpeta).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    Usuario.StaticMainFrame.Content = new ListaPersonal();
                }
            }
        }
示例#2
0
        private void Button_Eliminar(object sender, RoutedEventArgs e)
        {
            int id_Carpetas = (int)((Button)sender).CommandParameter;

            using (Model.polyuprotecEntities1 db = new Model.polyuprotecEntities1())
            {
                var oCarpeta = db.Carpeta.Find(id_Carpetas);

                db.Carpeta.Remove(oCarpeta);
                db.SaveChanges();
            }

            Refresh();
        }
示例#3
0
        public FormPerson(int id_Carpetas = 0)
        {
            InitializeComponent();

            this.id_Carpetas = id_Carpetas;
            if (this.id_Carpetas != 0)
            {
                using (Model.polyuprotecEntities1 db = new Model.polyuprotecEntities1())
                {
                    var oCarpeta = db.Carpeta.Find(this.id_Carpetas);

                    documento.Text = oCarpeta.id_Carpetas.ToString();
                    Nombre.Text    = oCarpeta.Nombre;
                    Estado.Text    = oCarpeta.Estado;
                }
            }
        }
示例#4
0
        private void Refresh()
        {
            List <PersonViewModel> lst = new List <PersonViewModel>();

            using (Model.polyuprotecEntities1 db = new Model.polyuprotecEntities1())
            {
                lst = (from d in db.Carpeta
                       select new PersonViewModel
                {
                    Nombre = d.Nombre,
                    Estado = d.Estado,
                    id_Carpetas = d.id_Carpetas
                }).ToList();
            }

            DG.ItemsSource = lst;
        }