public void insertElement(object element, USUARIO u)
        {
            if (element != null)
            {
                using (var entity = new TAE2Entities())
                {
                    UNIDAD unidad = (UNIDAD)element;

                    var validacion = (from cust in entity.UNIDADs
                                      where cust.UNIDAD1 == unidad.UNIDAD1
                                      select cust).ToList();

                    if (validacion.Count == 0)
                    {
                        unidad.UNID_UNIDAD = UNID.getNewUNID();
                        //Sync
                        unidad.IS_MODIFIED        = true;
                        unidad.LAST_MODIFIED_DATE = UNID.getNewUNID();
                        var modifiedSync = entity.SYNCs.First(p => p.UNID_SYNC == 20120101000000000);
                        modifiedSync.ACTUAL_DATE = UNID.getNewUNID();
                        entity.SaveChanges();
                        //
                        entity.UNIDADs.AddObject(unidad);
                        entity.SaveChanges();

                        UNID.Master(unidad, u, -1, "Inserción");
                    }
                }
            }
        }
        public void loadSync(object element)
        {
            if (element != null)
            {
                UNIDAD poco = (UNIDAD)element;
                using (var entity = new TAE2Entities())
                {
                    var query = (from cust in entity.UNIDADs
                                 where poco.UNID_UNIDAD == cust.UNID_UNIDAD
                                 select cust).ToList();

                    //Actualización
                    if (query.Count > 0)
                    {
                        var aux = query.First();

                        if (aux.LAST_MODIFIED_DATE < poco.LAST_MODIFIED_DATE)
                        {
                            udpateElementSync((object)poco);
                        }
                    }
                    //Inserción
                    else
                    {
                        insertElementSync((object)poco);
                    }

                    var modifiedMenu = entity.UNIDADs.First(p => p.UNID_UNIDAD == poco.UNID_UNIDAD);
                    modifiedMenu.IS_MODIFIED = false;
                    entity.SaveChanges();
                }
            }
        }
Esempio n. 3
0
 public DeleteUnidad(UNIDAD unidad)
 {
     this.UNID_UNIDAD = unidad.UNID_UNIDAD;
     this.UNIDAD1     = unidad.UNIDAD1;
     this.IS_ACTIVE   = unidad.IS_ACTIVE;
     this.IsChecked   = false;
 }
        public ActionResult Update(int ID_UNIDAD)
        {
            if (Session["Perfil"] != null)
            {
                NegocioUnidad obj = new NegocioUnidad();
                UNIDAD        aux = obj.Read().FirstOrDefault(a => a.ID_UNIDAD == ID_UNIDAD);
                ViewBag.Usuario = aux.RUT_USU;
                DataAcces.DaoCliente dc = new DataAcces.DaoCliente();
                try
                {
                    int            rut_empresa = Convert.ToInt32(Session["rutempresa"]);
                    List <USUARIO> list        = dc.ObtenerListaUsuarios(0, rut_empresa, 1);

                    ViewBag.ListaUsuarios = list;
                }
                catch (Exception ex)
                {
                    new Exception("ERROR EN METODO LISTAR" + ex.Message);
                }
                return(View("Update", aux));
            }
            else
            {
                return(View("../Mantenedor/LoginProcess"));
            }
        }
Esempio n. 5
0
 public CatalogUnidadModel(IDataMapper dataMapper)
 {
     this._dataMapper     = new UnidadDataMapper();
     this._unidad         = new FixupCollection <DeleteUnidad>();
     this._selectedUnidad = new UNIDAD();
     this.loadItems();
 }
 public ActionResult Update(UNIDAD dto)
 {
     if (Session["Perfil"] != null)
     {
         NegocioUnidad obj = new NegocioUnidad();
         obj.Update(dto);
         return(RedirectToAction("Read"));
     }
     else
     {
         return(View("../Mantenedor/LoginProcess"));
     }
 }
        public object getElement(object element)
        {
            object res = null;

            using (var entitie = new TAE2Entities())
            {
                UNIDAD unidad = (UNIDAD)element;
                var    query  = (from cust in entitie.UNIDADs
                                 where cust.UNID_UNIDAD == unidad.UNID_UNIDAD
                                 select cust).ToList();
                if (query.Count > 0)
                {
                    res = query;
                }
                return(res);
            }
        }
        public void insertElementSync(object element)
        {
            if (element != null)
            {
                using (var entity = new TAE2Entities())
                {
                    UNIDAD unidad = (UNIDAD)element;

                    //Sync
                    var modifiedSync = entity.SYNCs.First(p => p.UNID_SYNC == 20120101000000000);
                    modifiedSync.ACTUAL_DATE = UNID.getNewUNID();
                    entity.SaveChanges();
                    //
                    entity.UNIDADs.AddObject(unidad);
                    entity.SaveChanges();
                }
            }
        }
 public void deleteElement(object element)
 {
     if (element != null)
     {
         using (var entity = new TAE2Entities())
         {
             UNIDAD unidad         = (UNIDAD)element;
             var    modifiedUnidad = entity.UNIDADs.First(p => p.UNID_UNIDAD == unidad.UNID_UNIDAD);
             modifiedUnidad.IS_ACTIVE = false;
             //Sync
             modifiedUnidad.IS_MODIFIED        = true;
             modifiedUnidad.LAST_MODIFIED_DATE = UNID.getNewUNID();
             var modifiedSync = entity.SYNCs.First(p => p.UNID_SYNC == 20120101000000000);
             modifiedSync.ACTUAL_DATE = UNID.getNewUNID();
             entity.SaveChanges();
             //
             entity.SaveChanges();
         }
     }
 }
 public void udpateElement(object element, USUARIO u)
 {
     if (element != null)
     {
         using (var entity = new TAE2Entities())
         {
             UNIDAD unidad         = (UNIDAD)element;
             var    modifiedUnidad = entity.UNIDADs.First(p => p.UNID_UNIDAD == unidad.UNID_UNIDAD);
             modifiedUnidad.UNIDAD1 = unidad.UNIDAD1;
             //Sync
             modifiedUnidad.IS_MODIFIED        = true;
             modifiedUnidad.LAST_MODIFIED_DATE = UNID.getNewUNID();
             var modifiedSync = entity.SYNCs.First(p => p.UNID_SYNC == 20120101000000000);
             modifiedSync.ACTUAL_DATE = UNID.getNewUNID();
             entity.SaveChanges();
             //
             UNID.Master(unidad, u, -1, "Modificación");
         }
     }
 }
        public ActionResult Insert(FormCollection fc)
        {
            UNIDAD dto = new UNIDAD();

            dto.NOMBRE        = fc["NOMBRE"];
            dto.DETALLE       = fc["DETALLE"];
            dto.RUT_USU       = Convert.ToInt32(fc["RUT_USU"]);
            dto.FechaEstimada = fc["FechaEstimada"];

            if (Session["Perfil"] != null)
            {
                NegocioUnidad obj = new NegocioUnidad();
                obj.Insert(dto);
                return(RedirectToAction("Read"));
            }
            else
            {
                return(View("../Mantenedor/LoginProcess"));
            }
        }
 public ActionResult Replicar(int ID_UNIDAD)
 {
     if (Session["Perfil"] != null)
     {
         NegocioUnidad       obj = new NegocioUnidad();
         UNIDAD              aux = obj.Read().FirstOrDefault(a => a.ID_UNIDAD == ID_UNIDAD);
         DataAcces.DaoUnidad du  = new DataAcces.DaoUnidad();
         try
         {
             du.Replicar(aux.ID_UNIDAD);
         }
         catch (Exception ex)
         {
             new Exception("ERROR EN METODO LISTAR" + ex.Message);
         }
         return(RedirectToAction("Read"));
     }
     else
     {
         return(View("../Mantenedor/LoginProcess"));
     }
 }
Esempio n. 13
0
        public void guardarListaAArchivoXML_CLearAll()
        {
            XmlDocument doc  = new XmlDocument();
            XmlElement  RAIZ = doc.CreateElement("Unidades");

            doc.AppendChild(RAIZ);

            XmlElement UNIDAD;
            XmlElement IDUNIDAD;
            XmlElement IDMATERIA;
            XmlElement NUMEROUNIDAD;
            XmlElement NUMEROCALIFICACION;

            foreach (Unidad u in listaDeTodasLasUnidades)
            {
                UNIDAD = doc.CreateElement("Unidad");
                RAIZ.AppendChild(UNIDAD);

                IDUNIDAD = doc.CreateElement("idU");
                IDUNIDAD.AppendChild(doc.CreateTextNode(u.idUnidad.ToString()));
                UNIDAD.AppendChild(IDUNIDAD);

                IDMATERIA = doc.CreateElement("idM");
                IDMATERIA.AppendChild(doc.CreateTextNode(u.idMateria.ToString()));
                UNIDAD.AppendChild(IDMATERIA);

                NUMEROUNIDAD = doc.CreateElement("numU");
                NUMEROUNIDAD.AppendChild(doc.CreateTextNode(u.NumeroUnidad.ToString()));
                UNIDAD.AppendChild(NUMEROUNIDAD);

                NUMEROCALIFICACION = doc.CreateElement("calU");
                NUMEROCALIFICACION.AppendChild(doc.CreateTextNode(u.CalificacionUnidad.ToString()));
                UNIDAD.AppendChild(NUMEROCALIFICACION);
            }
            listaDeTodasLasUnidades.Clear();
            doc.Save(Server.MapPath("~/AlmacenamientoXML/UnidadesXML.xml"));
        }
        public string InsertF(UNIDAD dto)
        {
            DaoUnidad dao = new DaoUnidad();

            return(dao.InsertF(dto));
        }
        /*FUNCIONARIOS */
        public string UpdateF(UNIDAD dto)
        {
            DaoUnidad dao = new DaoUnidad();

            return(dao.UpdateF(dto));
        }