public Boolean actualizar(Gerencia are)
        {
            //try
            //{
            using (con = Conexion.conectar())
            {
                using (cmd = new MySqlCommand())
                {
                    cmd.CommandText = "SP_U_Tabla_Gerencia";
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Connection  = con;

                    cmd.Parameters.AddWithValue("_nombre", are.Nombre);
                    cmd.Parameters.AddWithValue("_descripcion", are.Descripcion);
                    cmd.Parameters.AddWithValue("_id_gerencia", are.Id_gerencia);

                    if (cmd.ExecuteNonQuery() > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            //}
            //catch (Exception)
            //{

            //    return false;
            //}
        }
Exemple #2
0
        public void GuardarGerencia(Gerencia entidad)
        {
            DataBaseModelContext db = new DataBaseModelContext();

            try
            {
                entidad.Descripcion = entidad.Descripcion.ToUpper();
                db.ContextOptions.ProxyCreationEnabled = _proxy;
                //TODO: Cambiar habilitado por el embebido
                entidad.Habilitado = true;
                if (entidad.Id == 0)
                {
                    db.Gerencia.AddObject(entidad);
                }
                else
                {
                    Gerencia tmpGerencia = db.Gerencia.SingleOrDefault(s => s.Id == entidad.Id);
                    if (tmpGerencia == null)
                    {
                        return;
                    }
                    tmpGerencia.Descripcion = entidad.Descripcion;
                    tmpGerencia.Habilitado  = entidad.Habilitado;
                }
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new Exception((ex.InnerException).Message);
            }
            finally
            {
                db.Dispose();
            }
        }
Exemple #3
0
        public int UpdateGerencia(Gerencia gerencia)
        {
            var result = 0;

            using (Cnx = new SqlConnection(GetCnxStringCartaDB))
            {
                var sql = "update Gerencia " +
                          "set Apoderado=@apoderado, " +
                          "NombreGerencia=@nombreGerencia, " +
                          "Activo=@activo, " +
                          "FechaIngreso = @fechaIngreso " +
                          "Abreviatura = @abreviatura " +
                          "where GerenciaId=@Id ";

                result = Cnx.ExecuteAsync(sql,
                                          new
                {
                    Id             = gerencia.GerenciaId,
                    apoderado      = gerencia.Apoderado,
                    nombreGerencia = gerencia.NombreGerencia,
                    activo         = gerencia.Activo,
                    fechaIngreso   = gerencia.FechaIngreso,
                    abreviatura    = gerencia.Abreviatura
                }).Result;
            }

            return(result);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Gerencia gerencia = db.Gerencia.Find(id);

            db.Gerencia.Remove(gerencia);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public void Altera(Guid id, Gerencia gerencia)
 {
     gerencia.IDGerencia = id;
     if (!repositorio.Atualiza(gerencia))
     {
         throw new HttpResponseException(HttpStatusCode.NotFound);
     }
 }
 public ActionResult Edit([Bind(Include = "Id,Nome,Sigla")] Gerencia gerencia)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gerencia).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(gerencia));
 }
        public Gerencia MostraByCodigo(string codigo)
        {
            Gerencia item = repositorio.MostraByCodigo(codigo);

            if (item == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            return(item);
        }
Exemple #8
0
        public void TestMethodGetGerencia3()
        {
            var gere = new Gerencia();

            var da = new GerenciaDA();

            gere = da.Get(3);

            Assert.AreEqual("GCO", gere.Abreviatura);
        }
        public ActionResult Create([Bind(Include = "Id,Nome,Sigla")] Gerencia gerencia)
        {
            if (ModelState.IsValid)
            {
                db.Gerencia.Add(gerencia);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(gerencia));
        }
        public void Apaga(string Codigo)
        {
            Gerencia item = repositorio.MostraByCodigo(Codigo);

            if (item == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            repositorio.Apaga(Codigo);
        }
Exemple #11
0
        public Gerencia Get(int id)
        {
            var result = new Gerencia();

            using (Cnx = new SqlConnection(GetCnxStringCartaDB))
            {
                var sql = "select*from Gerencia " +
                          "where GerenciaId=@Id ";

                result = Cnx.QueryAsync <Gerencia>(sql, new { Id = id }).Result.FirstOrDefault();
            }

            return(result);
        }
Exemple #12
0
 public void GuardarGerencia(Gerencia entidad)
 {
     try
     {
         using (BusinessOrganizacion negocio = new BusinessOrganizacion())
         {
             negocio.GuardarGerencia(entidad);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        // GET: Gerencias/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Gerencia gerencia = db.Gerencia.Find(id);

            if (gerencia == null)
            {
                return(HttpNotFound());
            }
            return(View(gerencia));
        }
Exemple #14
0
        public void TestMethodInsertGerencia()
        {
            var gere = new Gerencia
            {
                Apoderado      = "Alvaro Ruiz",
                Activo         = true,
                NombreGerencia = "Gerencia Comercial",
                Abreviatura    = "GCO",
                FechaIngreso   = new DateTime(2017, 1, 1)
            };

            var da = new GerenciaDA();

            Assert.AreEqual(1, da.AddGerencia(gere));
        }
        public bool validaLoginGerencia(string sUsuario, string sSenha)
        {
            bool bRetorno = false;

            if ((sUsuario.Length != 0) && (sSenha.Length != 0))
            {
                Gerencia oGerencia = new Gerencia();
                oGerencia.setUser(sUsuario);
                oGerencia.setSenha(sSenha);
                bRetorno = oGerencia.validaLoginGerencia();
            }
            else
            {
                MessageBox.Show("Por favor, informe todos os campos!!!");
            }
            return(bRetorno);
        }
        public ActionResult Modificar_Gerencia(int id, string nombre, string descripcion)
        {
            Metodo_Gerencia             mg  = new Metodo_Gerencia();
            Gerencia                    ger = new Gerencia();
            string                      message;
            SortedList <string, string> error = new SortedList <string, string>();

            if (id != 0)
            {
                if (String.IsNullOrEmpty(nombre))
                {
                    error.Add("sp_nombre", "Ingrese el nombre del Usuario");
                }
                if (String.IsNullOrEmpty(descripcion))
                {
                    error.Add("sp_descripcion", "Ingrese su Descripción");
                }

                if (error.Count == 0)
                {
                    ger.Id_gerencia = id;
                    ger.Nombre      = nombre == null ? "" : nombre;
                    ger.Descripcion = descripcion == null ? "" : descripcion;

                    if (mg.actualizar(ger))
                    {
                        message = "Se actualizaron los datos correctamente";
                    }
                    else
                    {
                        message = "No se logró actualizar lo datos";
                    }

                    return(Json(new { message = message, success = true }));
                }
                else
                {
                    message = "Ingrese los datos necesarios";
                    return(Json(new { message = message, success = false, datos = error }));
                }
            }

            return(RedirectToAction("Consultar_Gerencia"));
        }
        public IHttpActionResult Gravar(Gerencia request)
        {
            GerenciaResponse response = null;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                response = repositorio.Gravar(request);
            }
            catch (Exception)
            {
                throw;
            }


            return(Ok(response));
        }
        public ActionResult Modificar_Gerencia(int?id)
        {
            Metodo_Gerencia mg = new Metodo_Gerencia();

            if (id != null)
            {
                v_ger = mg.obtener(id);

                Info datos = new Info();
                datos.Obj_ger = v_ger;

                return(View(datos));
            }
            else
            {
                return(RedirectToAction("Consultar_Gerencia"));
            }

            //return View();
        }
        public ActionResult Registrar_Gerencia(string nombre, string descripcion)
        {
            Gerencia        ger = new Gerencia();
            Metodo_Gerencia mg  = new Metodo_Gerencia();

            string message;
            SortedList <string, string> error = new SortedList <string, string>();

            if (String.IsNullOrEmpty(nombre))
            {
                error.Add("sp_nombre", "Ingrese el nombre del Usuario");
            }

            if (String.IsNullOrEmpty(descripcion))
            {
                error.Add("sp_descripcion", "Ingrese su Descripción");
            }

            if (error.Count == 0)
            {
                ger.Nombre      = nombre == null ? "" : nombre;
                ger.Descripcion = descripcion == null ? "" : descripcion;

                if (mg.guardar(ger))
                {
                    message = "Se guardaron los datos correctamente";
                }
                else
                {
                    message = "No se Guardaron lo datos";
                }

                return(Json(new { message = message, success = true }));
            }
            else
            {
                message = "Ingrese los datos necesarios";
                return(Json(new { message = message, success = false, datos = error }));
            }
        }
Exemple #20
0
        public int AddGerencia(Gerencia gerencia)
        {
            var result = 0;

            using (Cnx = new SqlConnection(GetCnxStringCartaDB))
            {
                var sql = "insert into Gerencia " +
                          "values(@apoderado,@nombreGerencia,@activo,@fechaIngreso,@abreviatura) ";

                result = Cnx.ExecuteAsync(sql,
                                          new
                {
                    apoderado      = gerencia.Apoderado,
                    nombreGerencia = gerencia.NombreGerencia,
                    activo         = true,
                    fechaIngreso   = gerencia.FechaIngreso,
                    abreviatura    = gerencia.Abreviatura
                }).Result;
            }

            return(result);
        }
        public Gerencia obtener(int?id)
        {
            //try
            //{
            MySqlDataReader rd;
            Gerencia        ger = new Gerencia();

            using (con = Conexion.conectar())
            {
                using (cmd = new MySqlCommand())
                {
                    cmd.CommandText = "SP_O_Tabla_Gerencia";
                    //cmd.CommandText = string.Format("Select * from tbl_categoria where id_categoria='{0}'", id);
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Connection  = con;

                    cmd.Parameters.AddWithValue("_id_gerencia", id);

                    rd = cmd.ExecuteReader();

                    while (rd.Read())
                    {
                        ger.Id_gerencia = rd.GetInt32("id_gerencia");
                        ger.Nombre      = rd.GetString("nombre");
                        ger.Descripcion = rd.GetString("descripcion");
                    }

                    rd.Close();
                }
            }

            return(ger);
            //}
            //catch (Exception)
            //{
            //    return null;
            //}
        }
 public bool Atualiza(Gerencia item)
 {
     throw new NotImplementedException();
 }
 public GerenciaResponse Gravar(Gerencia item)
 {
     throw new NotImplementedException();
 }