コード例 #1
0
        public ActionResult Delete(int id)
        {
            var usuario = db.Usuarios.Where(u => u.NombreUsuario == User.Identity.Name).FirstOrDefault().UsuarioId;

            movimiento = "Eliminando Regla";
            MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

            Regla regla = db.Reglas.Where(x => x.ReglaId == id).FirstOrDefault();

            db.Reglas.Remove(regla);
            var response = DBHelper.SaveChanges(db);

            if (response.Succeeded)
            {
                db.Database.ExecuteSqlCommand("spEliminarReglasCaracteristicas @ReglaId",
                                              new SqlParameter("@ReglaId", id));

                movimiento = "Eliminar Regla " + regla.ReglaId + " " + regla.NombreRegla;
                MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                return(Json(new { success = true, message = "REGLA ELIMINADA" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public ActionResult Delete(int id)
        {
            var usuario = db.Usuarios.Where(u => u.NombreUsuario == User.Identity.Name).FirstOrDefault().UsuarioId;

            movimiento = "Eliminando Códigos";
            MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

            db.Database.ExecuteSqlCommand(
                "spEliminarCampaña @CampañaId",
                new SqlParameter("@CampañaId", id));

            db.Database.ExecuteSqlCommand(
                "spEliminarCodigos @CampañaId",
                new SqlParameter("@CampañaId", id));

            Campaña campaña = db.Campañas.Where(x => x.CampañaId == id).FirstOrDefault();

            db.Campañas.Remove(campaña);
            var response = DBHelper.SaveChanges(db);

            if (response.Succeeded)
            {
                movimiento = "Eliminar Campaña " + campaña.CampañaId + " " + campaña.Nombre + " / " + campaña.Descripcion;
                MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                return(Json(new { success = true, message = "CAMPAÑA ELIMINADA" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #3
0
        public ActionResult DeleteCat(int id)
        {
            var usuario = db.Usuarios.Where(u => u.NombreUsuario == User.Identity.Name).FirstOrDefault().UsuarioId;

            var reglasAsignadas = db.Database.SqlQuery <spReglasAsignadas>("spGetReglasCatalogoAsignadas @ReglaCatalogoId",
                                                                           new SqlParameter("@ReglaCatalogoId", id)).ToList();

            if (reglasAsignadas.Count > 0)
            {
                return(Json(new { success = true, message = "NO SE PUEDE ELIMINAR, ASIGNADO EN REGLA" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var tiendaCaracteristica = db.TiendaCaracteristicas.Where(x => x.ReglaCatalogoId == id).ToList();

                movimiento = "Eliminando Característica " + tiendaCaracteristica[0].ReglaCatalogo.Nombre;
                MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                db.TiendaCaracteristicas.RemoveRange(tiendaCaracteristica);
                var response = DBHelper.SaveChanges(db);
                if (response.Succeeded)
                {
                    ReglaCatalogo reglaCatalogo = db.ReglasCatalogo.Where(x => x.ReglaCatalogoId == id).FirstOrDefault();
                    db.ReglasCatalogo.Remove(reglaCatalogo);
                    var response2 = DBHelper.SaveChanges(db);
                    if (response2.Succeeded)
                    {
                        var reglaCaracteristica = db.ReglasCaracteristicas.Where(x => x.ReglaCatalogoId == id).ToList();
                        db.ReglasCaracteristicas.RemoveRange(reglaCaracteristica);
                        DBHelper.SaveChanges(db);

                        //ActualizarTodo();

                        movimiento = "Característica Eliminada " + reglaCatalogo.ReglaCatalogoId + " " + reglaCatalogo.Nombre + " / " + reglaCatalogo.Categoria;
                        MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                        return(Json(new { success = true, message = "CARACTERÍSTICA ELIMINADA" }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new { success = true, message = response2.Message }, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }
コード例 #4
0
        public ActionResult AddOrEdit(Campaña campaña)
        {
            var usuario = db.Usuarios.Where(u => u.NombreUsuario == User.Identity.Name).FirstOrDefault().UsuarioId;

            if (campaña.CampañaId == 0)
            {
                movimiento = "Agregando Campaña";
                MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                campaña.Generada = "NO";
                db.Campañas.Add(campaña);
                var response = DBHelper.SaveChanges(db);
                if (response.Succeeded)
                {
                    MovementsHelper.AgregarArticulosNuevaCampaña(campaña.CampañaId);

                    movimiento = "Agregar Campaña " + campaña.CampañaId + " " + campaña.Nombre + " / " + campaña.Descripcion;
                    MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                    return(Json(new { success = true, message = "CAMPAÑA AGREGADA" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                movimiento = "Actualizando Campaña";
                MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                db.Entry(campaña).State = EntityState.Modified;
                var response = DBHelper.SaveChanges(db);
                if (response.Succeeded)
                {
                    movimiento = "Actualizar Campaña " + campaña.CampañaId + " " + campaña.Nombre + " / " + campaña.Descripcion;
                    MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                    return(Json(new { success = true, message = "CAMPAÑA ACTUALIZADA" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }
コード例 #5
0
        public ActionResult Delete(int id)
        {
            var usuario = db.Usuarios.Where(u => u.NombreUsuario == User.Identity.Name).FirstOrDefault().UsuarioId;

            Familia fam = db.Familias.Where(x => x.FamiliaId == id).FirstOrDefault();

            db.Familias.Remove(fam);
            var response = DBHelper.SaveChanges(db);

            if (response.Succeeded)
            {
                movimiento = "Eliminar Familia " + fam.FamiliaId + " " + fam.Descripcion + " / " + fam.Codigo;
                MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                return(Json(new { success = true, message = "FAMILIA ELIMINADA" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #6
0
        public ActionResult Delete(int id)
        {
            var usuario = db.Usuarios.Where(u => u.NombreUsuario == User.Identity.Name).FirstOrDefault().UsuarioId;

            ReglaCatalogo reglaCatalogo = db.ReglasCatalogo.Where(x => x.ReglaCatalogoId == id).FirstOrDefault();

            db.ReglasCatalogo.Remove(reglaCatalogo);
            var response = DBHelper.SaveChanges(db);

            if (response.Succeeded)
            {
                movimiento = "Eliminar Regla " + reglaCatalogo.ReglaCatalogoId + " " + reglaCatalogo.Nombre + " / " + reglaCatalogo.Categoria;
                MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                return(Json(new { success = true, message = "REGLA ELIMINADA" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #7
0
        public ActionResult Delete(int id)
        {
            var usuario = db.Usuarios.Where(u => u.NombreUsuario == User.Identity.Name).FirstOrDefault().UsuarioId;

            Ciudad ciudad = db.Ciudads.Where(x => x.CiudadId == id).FirstOrDefault();

            db.Ciudads.Remove(ciudad);
            var response = DBHelper.SaveChanges(db);

            if (response.Succeeded)
            {
                movimiento = "Eliminar Ciudad " + ciudad.CiudadId + " " + ciudad.Nombre + " / " + ciudad.EquityFranquicia;
                MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                return(Json(new { success = true, message = "CIUDAD ELIMINADA" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #8
0
        public ActionResult CloseCampArt(int id)
        {
            var usuario = db.Usuarios.Where(u => u.NombreUsuario == User.Identity.Name).FirstOrDefault().UsuarioId;

            movimiento = "Cerrando Campaña";
            MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

            Campaña campaña = db.Campañas.Where(x => x.CampañaId == id).FirstOrDefault();

            campaña.Generada        = "SI";
            db.Entry(campaña).State = EntityState.Modified;
            var response = DBHelper.SaveChanges(db);

            if (response.Succeeded)
            {
                var campañas = db.Campañas.Where(x => x.Generada == "NO").ToList();

                if (campañas.Count == 0)
                {
                    db.Database.ExecuteSqlCommand(
                        "spEliminarTodosArticulosTiendas");

                    db.Database.ExecuteSqlCommand(
                        "spEliminarCodigosTodos");

                    db.Database.ExecuteSqlCommand(
                        "spDesactivarMateriales");
                }

                movimiento = "Cerrar Campaña " + campaña.CampañaId + " " + campaña.Nombre + " / " + campaña.Descripcion;
                MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                return(Json(new { success = true, message = "CAMPAÑA CERRADA" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #9
0
        public ActionResult AddOrEdit(Ciudad ciudad)
        {
            var usuario = db.Usuarios.Where(u => u.NombreUsuario == User.Identity.Name).FirstOrDefault().UsuarioId;

            ciudad.EquityFranquicia = db.Regions.Where(x => x.RegionId == ciudad.RegionId).FirstOrDefault().EquityFranquicia;

            if (ciudad.CiudadId == 0)
            {
                db.Ciudads.Add(ciudad);
                var response = DBHelper.SaveChanges(db);
                if (response.Succeeded)
                {
                    movimiento = "Agregar Ciudad " + ciudad.CiudadId + " " + ciudad.Nombre + " / " + ciudad.EquityFranquicia;
                    MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                    return(Json(new { success = true, message = "CIUDAD AGREGADA" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                db.Entry(ciudad).State = EntityState.Modified;
                var response = DBHelper.SaveChanges(db);
                if (response.Succeeded)
                {
                    movimiento = "Actualizar Ciudad " + ciudad.CiudadId + " " + ciudad.Nombre + " / " + ciudad.EquityFranquicia;
                    MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                    return(Json(new { success = true, message = "CIUDAD ACTUALIZADA" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }
コード例 #10
0
        public ActionResult AddOrEdit(Familia fam)
        {
            var usuario = db.Usuarios.Where(u => u.NombreUsuario == User.Identity.Name).FirstOrDefault().UsuarioId;

            if (fam.FamiliaId == 0)
            {
                db.Familias.Add(fam);
                var response = DBHelper.SaveChanges(db);
                if (response.Succeeded)
                {
                    movimiento = "Agregar Familia " + fam.FamiliaId + " " + fam.Descripcion + " / " + fam.Codigo;
                    MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                    return(Json(new { success = true, message = "FAMILIA AGREGADA" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                db.Entry(fam).State = EntityState.Modified;
                var response = DBHelper.SaveChanges(db);
                if (response.Succeeded)
                {
                    movimiento = "Actualizar Familia " + fam.FamiliaId + " " + fam.Descripcion + " / " + fam.Codigo;
                    MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                    return(Json(new { success = true, message = "FAMILIA ACTUALIZADA" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }
コード例 #11
0
        public ActionResult AddOrEdit(ReglaCatalogo reglaCatalogo)
        {
            var usuario = db.Usuarios.Where(u => u.NombreUsuario == User.Identity.Name).FirstOrDefault().UsuarioId;

            if (reglaCatalogo.ReglaCatalogoId == 0)
            {
                db.ReglasCatalogo.Add(reglaCatalogo);
                var response = DBHelper.SaveChanges(db);
                if (response.Succeeded)
                {
                    movimiento = "Agregar Regla " + reglaCatalogo.ReglaCatalogoId + " " + reglaCatalogo.Nombre + " / " + reglaCatalogo.Categoria;
                    MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                    return(Json(new { success = true, message = "REGLA AGREGADA" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                db.Entry(reglaCatalogo).State = EntityState.Modified;
                var response = DBHelper.SaveChanges(db);
                if (response.Succeeded)
                {
                    movimiento = "Actualizar Regla " + reglaCatalogo.ReglaCatalogoId + " " + reglaCatalogo.Nombre + " / " + reglaCatalogo.Categoria;
                    MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                    return(Json(new { success = true, message = "REGLA ACTUALIZADA" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }
コード例 #12
0
        public ActionResult CodesCampArt(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var usuario = db.Usuarios.Where(u => u.NombreUsuario == User.Identity.Name).FirstOrDefault();

            movimiento = "Generando Códigos";
            MovementsHelper.MovimientosBitacora(usuario.UsuarioId, modulo, movimiento);

            if (usuario == null)
            {
                return(RedirectToAction("Index"));
            }

            var response = MovementsHelper.GenerarCodigos(id);

            if (response.Succeeded)
            {
                var campaña = db.Campañas.Where(x => x.CampañaId == id).FirstOrDefault();

                var codigosMateriales = db.Database.SqlQuery <CodigosMaterialesTotal>("spGetMaterialesCodigosCampaña @CampañaId",
                                                                                      new SqlParameter("@CampañaId", id)).ToList();

                var codigosMaterialesOrdenes = db.Database.SqlQuery <CodigosMaterialesTotalOrdenes>("spGetMaterialesOrdenes @CampañaId",
                                                                                                    new SqlParameter("@CampañaId", id)).ToList();

                var vacio = "";

                var folder = Server.MapPath("~/Content/Archivos/");

                using (StreamWriter streamWriter = new StreamWriter(folder + "Materiales" + campaña.Nombre + ".txt"))
                {
                    foreach (var codigo in codigosMateriales)
                    {
                        var linea = "INSERT INTO Articulos (Codigo, Descripcion, SistemaImpresion,MedExtendida,Sustrato,Tintas,Laminado_FV,Corte,MatPegue,InfAdicional) VALUES ('" + codigo.Codigo + "', '" + codigo.ArticuloKFC.ToUpper() + "', '" + vacio + "', '" + vacio + "', '" + vacio + "', '" + vacio + "', '" + vacio + "', '" + vacio + "', '" + vacio + "', '" + codigo.ArticuloKFC.ToUpper() + "')";
                        streamWriter.WriteLine(linea);
                    }
                }

                using (StreamWriter streamWriter = new StreamWriter(folder + "Materiales" + campaña.Nombre + ".txt", false, Encoding.GetEncoding(1252)))
                {
                    foreach (var codigo in codigosMateriales)
                    {
                        var linea = "INSERT INTO Articulos (Codigo, Descripcion, SistemaImpresion,MedExtendida,Sustrato,Tintas,Laminado_FV,Corte,MatPegue,InfAdicional) VALUES ('" + codigo.Codigo + "', '" + codigo.ArticuloKFC.ToUpper() + "', '" + vacio + "', '" + vacio + "', '" + vacio + "', '" + vacio + "', '" + vacio + "', '" + vacio + "', '" + vacio + "', '" + codigo.ArticuloKFC.ToUpper() + "')";
                        streamWriter.WriteLine(linea);
                    }
                }

                var tiendas = db.Database.SqlQuery <spTiendasActivas>("spGetRestaurantesActivos").ToList();
                var i       = 1;

                using (StreamWriter streamWriter = new StreamWriter(folder + "Tiendas" + campaña.Nombre + ".txt", false, Encoding.GetEncoding(1252)))
                {
                    foreach (var tienda in tiendas)
                    {
                        var linea = "INSERT INTO Tiendas (Id, Secuencia, Tienda, Region, Ciudad, IdCampana) VALUES (" + tienda.CCoFranquicia.ToUpper() + ", " + i + ", '" + tienda.CCoFranquicia.ToUpper() + " / " + tienda.Restaurante.ToUpper() + "', '" + tienda.Region.ToUpper() + "', '" + tienda.Ciudad.ToUpper() + "', " + Convert.ToInt32(campaña.Nombre) + ")";
                        streamWriter.WriteLine(linea);

                        i = i + 1;
                    }
                }

                using (StreamWriter streamWriter = new StreamWriter(folder + "Ordenes" + campaña.Nombre + ".txt", false, Encoding.GetEncoding(1252)))
                {
                    foreach (var codigo in codigosMaterialesOrdenes)
                    {
                        var linea = "INSERT INTO Ordenes (CAMPANA, IDTIENDA, IDARTICULO, CANTIDAD) VALUES ('" + campaña.Descripcion.ToUpper() + "', '" + codigo.CCoFranquicia.ToUpper() + "', '" + codigo.Codigo + "', " + codigo.Cantidad + ")";
                        streamWriter.WriteLine(linea);
                    }
                }

                movimiento = "Generar Códigos " + campaña.CampañaId + " " + campaña.Nombre + " / " + campaña.Descripcion;
                MovementsHelper.MovimientosBitacora(usuario.UsuarioId, modulo, movimiento);

                return(Json(new { success = true, message = "CODIGOS GENERADOS" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #13
0
        public ActionResult Caracteristicas(FormCollection fc)
        {
            var usuario = db.Usuarios.Where(u => u.NombreUsuario == User.Identity.Name).FirstOrDefault().UsuarioId;
            var id      = Session["reglaid"];

            var reglasListCurrent = db.Database.SqlQuery <spReglasCaracteristicas>("spReglasCaracteristicas @ReglaId",
                                                                                   new SqlParameter("@ReglaId", id)).OrderBy(x => x.ReglaCatalogoId).ToList();

            var textMovimiento = string.Empty;

            var reglaNombre = string.Empty;

            foreach (var item in reglasListCurrent)
            {
                reglaNombre = item.Regla;
            }

            movimiento = "Modificando Características Regla : " + reglaNombre;
            MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

            string[] reglaCaractersiticaId = fc.GetValues("ReglaCaractersiticaId");
            //string[] seleccionado = fc.GetValues("Seleccionado");
            string[] isTrue  = fc.GetValues("IsTrue");
            string[] isFalse = fc.GetValues("IsFalse");

            var selec = false;

            for (var i = 0; i < reglaCaractersiticaId.Length; i++)
            {
                ReglaCaracteristica reglaCaracteristica = db.ReglasCaracteristicas.Find(Convert.ToInt32(reglaCaractersiticaId[i]));

                //var reglaId = reglaCaracteristica.ReglaId;

                if (isTrue == null)
                {
                    selec = false;

                    reglaCaracteristica.IsTrue = selec;

                    db.Entry(reglaCaracteristica).State = EntityState.Modified;

                    db.SaveChanges();
                }
                else
                {
                    for (var j = 0; j < isTrue.Length; j++)
                    {
                        if (reglaCaractersiticaId[i] == isTrue[j])
                        {
                            selec = true;

                            reglaCaracteristica.IsTrue = selec;

                            db.Entry(reglaCaracteristica).State = EntityState.Modified;
                            db.SaveChanges();

                            break;
                        }
                        else
                        {
                            selec = false;

                            reglaCaracteristica.IsTrue = selec;

                            db.Entry(reglaCaracteristica).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                    }
                    if (!selec)
                    {
                        selec = false;

                        reglaCaracteristica.IsTrue = selec;

                        db.Entry(reglaCaracteristica).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }
                if (isFalse == null)
                {
                    selec = false;

                    reglaCaracteristica.IsFalse = selec;

                    db.Entry(reglaCaracteristica).State = EntityState.Modified;

                    db.SaveChanges();
                }
                else
                {
                    for (var j = 0; j < isFalse.Length; j++)
                    {
                        if (reglaCaractersiticaId[i] == isFalse[j])
                        {
                            selec = true;

                            reglaCaracteristica.IsFalse = selec;

                            db.Entry(reglaCaracteristica).State = EntityState.Modified;
                            db.SaveChanges();

                            break;
                        }
                        else
                        {
                            selec = false;

                            reglaCaracteristica.IsFalse = selec;

                            db.Entry(reglaCaracteristica).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                    }
                    if (!selec)
                    {
                        selec = false;

                        reglaCaracteristica.IsFalse = selec;

                        db.Entry(reglaCaracteristica).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }
            }

            var regla = db.ReglasCaracteristicas.Find(Convert.ToInt32(reglaCaractersiticaId[1]));

            var reglaId = regla.ReglaId;

            var articuloId = db.Reglas.Find(reglaId);

            var articuloKFCId = db.ArticuloKFCs.Where(x => x.ArticuloKFCId == articuloId.ArticuloKFCId).FirstOrDefault().ArticuloKFCId;

            var restauranteId = 0;

            var categoria = string.Empty;

            var campaña = db.Campañas.Where(x => x.Generada == "NO").FirstOrDefault();

            EliminarMateriales(articuloKFCId, campaña);

            MovementsHelper.AgregarMaterialesTiendaCampañaExiste(articuloKFCId, restauranteId, categoria);

            var material = db.ArticuloKFCs.Where(x => x.ArticuloKFCId == articuloId.ArticuloKFCId).FirstOrDefault();

            if (campaña != null)
            {
                var campañaId = campaña.CampañaId;

                MovementsHelper.AgregarArticuloCampañas(material, campañaId);
            }

            var reglasListActualizado = db.Database.SqlQuery <spReglasCaracteristicas>("spReglasCaracteristicas @ReglaId",
                                                                                       new SqlParameter("@ReglaId", id)).OrderBy(x => x.ReglaCatalogoId).ToList();

            textMovimiento = string.Empty;

            reglaNombre = string.Empty;

            var valorIsTrue  = string.Empty;
            var valorIsFalse = string.Empty;

            for (int i = 0; i < reglasListCurrent.Count; i++)
            {
                var caracteristica = reglasListActualizado.Where(x => x.ReglaCatalogoId == reglasListCurrent[i].ReglaCatalogoId).FirstOrDefault();

                if (caracteristica.IsFalse != reglasListCurrent[i].IsFalse || caracteristica.IsTrue != reglasListCurrent[i].IsTrue)
                {
                    if (caracteristica.IsTrue == true)
                    {
                        valorIsTrue = "ACTIVADO";
                    }
                    else
                    {
                        valorIsTrue = "DEACTIVADO";
                    }

                    if (caracteristica.IsFalse == true)
                    {
                        valorIsFalse = "ACTIVADO";
                    }
                    else
                    {
                        valorIsFalse = "DESACTIVADO";
                    }

                    textMovimiento += " " + caracteristica.Caracteristica + " SI : " + valorIsTrue + " - NO : " + valorIsFalse + " / ";
                }

                reglaNombre = caracteristica.Regla;
            }

            if (textMovimiento == string.Empty)
            {
                textMovimiento = "Sin Modificaciones";
            }

            movimiento = "Características Asignadas Regla : " + reglaNombre + " / " + textMovimiento.ToString();
            MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

            Session["reglaid"] = string.Empty;

            return(Json(new { success = true, message = "CARACTERÍSTICAS ASIGNADAS" }, JsonRequestBehavior.AllowGet));
        }
コード例 #14
0
        public ActionResult AddOrEditCat(ReglaCatalogo reglaCatalogo, FormCollection fcol)
        {
            var usuario = db.Usuarios.Where(u => u.NombreUsuario == User.Identity.Name).FirstOrDefault().UsuarioId;

            string[] fc = fcol.GetValues("FC");
            string[] fs = fcol.GetValues("FS");
            string[] il = fcol.GetValues("IL");
            string[] sb = fcol.GetValues("SB");

            var fcTipo = 0;
            var fsTipo = 0;
            var ilTipo = 0;
            var sbTipo = 0;

            if (fc != null)
            {
                fcTipo = 1;
            }

            if (fs != null)
            {
                fsTipo = 2;
            }
            if (il != null)
            {
                ilTipo = 3;
            }
            if (sb != null)
            {
                sbTipo = 4;
            }

            if (reglaCatalogo.ReglaCatalogoId == 0)
            {
                movimiento = "Agregando Característica";
                MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                if (string.IsNullOrEmpty(reglaCatalogo.Valor))
                {
                    reglaCatalogo.SiNo  = true;
                    reglaCatalogo.Valor = "SI / NO";
                }
                else
                {
                    reglaCatalogo.SiNo = false;
                }

                db.ReglasCatalogo.Add(reglaCatalogo);
                var response = DBHelper.SaveChanges(db);
                if (response.Succeeded)
                {
                    var cat = reglaCatalogo.Categoria;

                    var reglaIdTienda = reglaCatalogo.ReglaCatalogoId;

                    MovementsHelper.AgregarReglasCaracteristicas(reglaIdTienda, cat);

                    MovementsHelper.AgregarTiendasCaracteristicas(reglaIdTienda, cat, fcTipo, fsTipo, ilTipo, sbTipo, true);

                    movimiento = "Característica Agregada " + reglaIdTienda + " " + reglaCatalogo.Nombre + " / " + cat;
                    MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                    return(Json(new { success = true, message = "CARACTERÍSTICA AGREGADA" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                movimiento = "Actualizando Característica " + reglaCatalogo.Nombre;
                MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                if (string.IsNullOrEmpty(reglaCatalogo.Valor))
                {
                    reglaCatalogo.SiNo  = true;
                    reglaCatalogo.Valor = "SI / NO";
                }
                else
                {
                    reglaCatalogo.SiNo = false;
                }

                db.Entry(reglaCatalogo).State = EntityState.Modified;
                var response = DBHelper.SaveChanges(db);
                if (response.Succeeded)
                {
                    var cat = reglaCatalogo.Categoria;

                    var reglaIdTienda = reglaCatalogo.ReglaCatalogoId;

                    MovementsHelper.AgregarReglasCaracteristicas(reglaIdTienda, cat);

                    if (cat == "EQUITY")
                    {
                        cat = "FRANQUICIAS";
                    }
                    else if (cat == "FRANQUICIAS")
                    {
                        cat = "EQUITY";
                    }
                    else
                    {
                        cat = string.Empty;
                    }

                    var caracteristicasEliminar = db.Database.SqlQuery <spReglaCaracteristicasEliminar>("spGetReglasCaracteristicasAEliminar @Categoria, @ReglaCatalogoId",
                                                                                                        new SqlParameter("@Categoria", cat),
                                                                                                        new SqlParameter("@ReglaCatalogoId", reglaIdTienda)).ToList();

                    if (caracteristicasEliminar.Count > 0)
                    {
                        foreach (var caracteristicaEliminar in caracteristicasEliminar)
                        {
                            var reglaCaracteristica = db.ReglasCaracteristicas.Find(caracteristicaEliminar.ReglaCaracteristicaId);
                            db.ReglasCaracteristicas.Remove(reglaCaracteristica);
                            db.SaveChanges();
                        }
                    }

                    MovementsHelper.AgregarTiendasCaracteristicas(reglaIdTienda, cat, fcTipo, fsTipo, ilTipo, sbTipo, false);

                    movimiento = "Característica Actualizada " + reglaCatalogo.ReglaCatalogoId + " " + reglaCatalogo.Nombre + " / " + reglaCatalogo.Categoria;
                    MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                    return(Json(new { success = true, message = "CARACTERÍSTICA ACTUALIZADA" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }
コード例 #15
0
        public ActionResult AddOrEdit(Regla regla)
        {
            var usuario = db.Usuarios.Where(u => u.NombreUsuario == User.Identity.Name).FirstOrDefault().UsuarioId;

            if (regla.ReglaId == 0)
            {
                movimiento = "Agregando regla";
                MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                db.Reglas.Add(regla);
                var response = DBHelper.SaveChanges(db);
                if (response.Succeeded)
                {
                    var reglaCatalogoId = 0;

                    var reglaId = regla.ReglaId;

                    var reglasCatalogoId = db.ReglasCaracteristicas.Where(x => x.ReglaId == reglaId).FirstOrDefault();

                    if (reglasCatalogoId == null)
                    {
                        reglaCatalogoId = 0;
                    }
                    else
                    {
                        reglaCatalogoId = reglasCatalogoId.ReglaCatalogoId;
                    }
                    var cat = db.ArticuloKFCs.Where(x => x.ArticuloKFCId == regla.ArticuloKFCId).FirstOrDefault().EquityFranquicia;

                    MovementsHelper.AgregarReglasCaracteristicas(regla.ReglaId, cat, true);

                    movimiento = "Agregar Regla " + regla.ReglaId + " " + regla.NombreRegla + " / " + regla.ArticuloKFC.Descripcion;
                    MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                    return(Json(new { success = true, message = "REGLA AGREGADA" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                movimiento = "Actualizando regla";
                MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                db.Entry(regla).State = EntityState.Modified;
                var response = DBHelper.SaveChanges(db);
                if (response.Succeeded)
                {
                    var reglaId         = regla.ReglaId;
                    var reglaCatalogoId = db.ReglasCaracteristicas.Where(x => x.ReglaId == reglaId).FirstOrDefault().ReglaCatalogoId;
                    var cat             = db.ArticuloKFCs.Where(x => x.ArticuloKFCId == regla.ArticuloKFCId).FirstOrDefault().EquityFranquicia;

                    MovementsHelper.AgregarReglasCaracteristicas(reglaCatalogoId, cat);

                    movimiento = "Actualizar Regla " + regla.ReglaId + " " + regla.NombreRegla + " / " + regla.ArticuloKFC.Descripcion;
                    MovementsHelper.MovimientosBitacora(usuario, modulo, movimiento);

                    return(Json(new { success = true, message = "REGLA ACTUALIZADA" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { success = true, message = response.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }