Пример #1
0
        public async Task <IHttpActionResult> Postsocio(socio socio)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.socio.Add(socio);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (socioExists(socio.id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = socio.id }, socio));
        }
Пример #2
0
        public async Task <IHttpActionResult> Putsocio(int id, socio socio)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != socio.id)
            {
                return(BadRequest());
            }

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

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!socioExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #3
0
        public async Task <ActionResult> Edit([Bind(Include = "id,nombre,apellido,documento,celular,mail,direccion,localidad,provincia,fecha_alta,usuario_alta,observaciones,fecha_nacimiento,complejo_alta_id")] socio socio)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    socio.fecha_modificacion   = DateTime.Now;
                    socio.usuario_modificacion = User.Identity.Name;
                    db.Entry(socio).State      = EntityState.Modified;
                    await db.SaveChangesAsync();

                    TempData["MsjExito"] = "Socio Modificado Con Exito";
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    if (ex.InnerException.InnerException.Message.Contains("UNIQUE KEY"))
                    {
                        ViewBag.MsjError = "Ya existe un socio con el documento indicado";
                        cargarVieBagProvincias();
                        return(View(socio));
                    }
                }
            }
            return(View(socio));
        }
Пример #4
0
        public ActionResult Socio(socio socio, string valor)
        {
            switch (valor)
            {
            case "Buscar":
                if (socio.idsocio > 0)
                {
                    DataSet dts      = new DataSet();
                    int     intsocio = socio.idsocio;
                    dts            = ws.consultasocio(intsocio);
                    socio.tblsocio = dts.Tables[0];
                    return(View());
                }
                break;

            case "Insertar":
                ws.insertarsocio(socio.nombre, socio.direccion);
                break;

            case "Eliminar":
                int intsocio1 = socio.idsocio;
                ws.eliminarsocio(intsocio1);
                break;
            }
            return(View());
        }
Пример #5
0
        public async Task <ActionResult> PuntosCargados(int?id, string tarjeta, DateTime fechaDesde, DateTime fechaHasta)
        {
            DateTime fd = Helper.Helper.FechaHoraDesde(fechaDesde);
            DateTime fh = Helper.Helper.FechaHoraHasta(fechaHasta);

            if (id != null && id != 0)
            {
                socio soc = db.socios.Find(id);
                ViewBag.Puntos    = (int)soc.puntos_actuales;
                ViewBag.SubTitulo = "Socio: " + soc.apellido + ", " + soc.nombre + " del " + fd.ToShortDateString() + " al " + fh.ToShortDateString();
                var puntos = await(from p in db.carga_puntos
                                   where p.socio_id == id && p.fecha_alta >= fd && p.fecha_alta <= fh
                                   select p).ToListAsync();
                return(View(puntos));
            }
            else
            {
                var soc = (from ts in db.tarjeta_socio
                           join s in db.socios on ts.socio_id equals s.id
                           where ts.numero_tarjeta == tarjeta && ts.fecha_baja == null && s.fecha_baja == null
                           select s).FirstOrDefault();

                ViewBag.Puntos    = (int)soc.puntos_actuales;
                ViewBag.SubTitulo = "Socio: " + soc.apellido + ", " + soc.nombre + " del " + fd.ToShortDateString() + " al " + fh.ToShortDateString();
                var puntos = await(from p in db.carga_puntos
                                   where p.socio_id == soc.id && p.fecha_alta >= fd && p.fecha_alta <= fh
                                   select p).ToListAsync();
                return(View(puntos));
            }
        }
Пример #6
0
        public DataSet consultasocio(int id)
        {
            DataSet tabla    = new DataSet();
            socio   objsocio = new socio();

            tabla = objsocio.consultasocio(id);
            return(tabla);
        }
Пример #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            socio socio = db.socio.Find(id);

            db.socio.Remove(socio);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #8
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            socio socio = await db.socios.FindAsync(id);

            db.socios.Remove(socio);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Пример #9
0
        public ActionResult comprobarSocio(socio soc)
        {
            DataSet dts      = new DataSet();
            int     intsocio = soc.idsocio;

            dts            = ws.consultasocio(intsocio);
            socio.tblsocio = dts.Tables[0];
            return(View());
        }
Пример #10
0
        public async Task <IHttpActionResult> Getsocio(int id)
        {
            socio socio = await db.socio.FindAsync(id);

            if (socio == null)
            {
                return(NotFound());
            }

            return(Ok(socio));
        }
Пример #11
0
 public ActionResult Edit([Bind(Include = "SocioId,Nit,Nombre,EmpresaId,Estado,CreadoPor,FechaCreacion,ModificadoPor,FechaModificacion")] socio socio)
 {
     if (ModelState.IsValid)
     {
         db.Entry(socio).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EmpresaId = new SelectList(db.empresa.Where(c => c.Estado == true).OrderBy(e => e.Nit), "EmpresaId", "Nit", socio.EmpresaId);
     return(View(socio));
 }
Пример #12
0
        // GET: socio/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            socio socio = db.socio.Find(id);

            if (socio == null)
            {
                return(HttpNotFound());
            }
            return(View(socio));
        }
Пример #13
0
        public async Task <IHttpActionResult> Deletesocio(int id)
        {
            socio socio = await db.socio.FindAsync(id);

            if (socio == null)
            {
                return(NotFound());
            }

            db.socio.Remove(socio);
            await db.SaveChangesAsync();

            return(Ok(socio));
        }
Пример #14
0
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            socio socio = await db.socios.FindAsync(id);

            if (socio == null)
            {
                return(HttpNotFound());
            }
            return(View(socio));
        }
Пример #15
0
        public ActionResult Bibliotecario(string valor)
        {
            switch (valor)
            {
            case "Comprobar Socio":
                socio soc = new socio();
                return(RedirectToAction("comprobarSocio"));

            case "Gestionar Libro":
                return(RedirectToAction("gestionarlibro"));

            case "Gestionar Préstamo":
                return(RedirectToAction("gestionarprestamo"));
            }
            return(View());
        }
Пример #16
0
        // GET: socio/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            string idDecrypted = MiUtil.desEncriptar(id);
            int    intId       = Convert.ToInt32(idDecrypted);

            socio socio = db.socio.Find(intId);

            if (socio == null)
            {
                return(HttpNotFound());
            }
            return(View(socio));
        }
Пример #17
0
        // GET: socio/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            string idDecrypted = MiUtil.desEncriptar(id);
            int    intId       = Convert.ToInt32(idDecrypted);

            socio socio = db.socio.Find(intId);

            if (socio == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EmpresaId = new SelectList(db.empresa.Where(c => c.Estado == true).OrderBy(e => e.Nit), "EmpresaId", "Nit", socio.EmpresaId);
            return(View(socio));
        }
Пример #18
0
 /// <summary>
 /// Obtiene el nombre completo de aval.
 /// </summary>
 /// <param name="id"></param>
 /// <returns>Nombre completo de aval.</returns>
 public string getAvalNombreCompleto(string id)
 {
     try
     {
         using (var db = new colinasEntities())
         {
             var query = from soc in db.socios
                         where soc.SOCIOS_ID == id
                         select soc;
             socio lista = query.First();
             return(lista.SOCIOS_PRIMER_NOMBRE + " " + lista.SOCIOS_PRIMER_APELLIDO);
         }
     }
     catch (Exception ex)
     {
         log.Fatal("Error fatal al obtener aval.", ex);
         throw;
     }
 }
Пример #19
0
        public ActionResult Create([Bind(Include = "SocioId,Nit,Nombre,EmpresaId,Estado,CreadoPor,FechaCreacion,ModificadoPor,FechaModificacion")] socio socio)
        {
            int empresaId = 0;

            if (Session["EmpresaId"] != null)
            {
                Int32.TryParse(Session["EmpresaId"].ToString(), out empresaId);
            }
            socio.EmpresaId = empresaId;
            if (ModelState.IsValid)
            {
                db.socio.Add(socio);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmpresaId = new SelectList(db.empresa.Where(c => c.Estado == true).OrderBy(e => e.Nit), "EmpresaId", "Nit", socio.EmpresaId);
            return(View(socio));
        }
Пример #20
0
 /// <summary>
 /// Obtiene información de Aval (socio)
 /// </summary>
 /// <param name="id"></param>
 /// <returns>Información de Aval (socio)</returns>
 public socio getAval(string id)
 {
     try
     {
         using (var db = new colinasEntities())
         {
             socio lista = new socio();
             var   query = from soc in db.socios
                           where soc.SOCIOS_ID == id
                           select soc;
             lista = query.First();
             return(lista);
         }
     }
     catch (Exception ex)
     {
         log.Fatal("Error fatal al obtener aval.", ex);
         throw;
     }
 }
Пример #21
0
        /// <summary>
        /// Obtiene beneficiarios de socio.
        /// </summary>
        /// <param name="SOCIOS_ID"></param>
        /// <returns>Lista de beneficiarios de socio.</returns>
        public List <beneficiario_x_socio> GetBeneficiariosDeSocio(string SOCIOS_ID = "")
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    var query = from bs in db.socios.Include("beneficiario_x_socio")
                                where string.IsNullOrEmpty(SOCIOS_ID) ? true : bs.SOCIOS_ID == SOCIOS_ID
                                select bs;

                    socio soc = query.FirstOrDefault <socio>();

                    return(soc == null ? new List <beneficiario_x_socio>() :  soc.beneficiario_x_socio.ToList <beneficiario_x_socio>());
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al obtener beneficiarios de socios.", ex);
                throw;
            }
        }
Пример #22
0
        public async Task <ActionResult> Edit(int?id)
        {
            if (TempData["MsjError"] != null)
            {
                ViewBag.MsjError = TempData["MsjError"];
                TempData.Remove("MsjError");
            }
            cargarVieBagProvincias();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            socio socio = await db.socios.FindAsync(id);

            if (socio == null)
            {
                return(HttpNotFound());
            }
            return(View(socio));
        }
Пример #23
0
        public async Task <ActionResult> PuntosCargados(int?id, DateTime?fechaDesde, DateTime?fechaHasta)
        {
            if (id == null)
            {
                return(View());
            }
            else
            {
                if (TempData["MsjExito"] != null)
                {
                    ViewBag.MsjExito = TempData["MsjExito"];
                    TempData.Remove("MsjExito");
                }
                DateTime fd;
                DateTime fh;
                if (fechaDesde == null)
                {
                    ViewBag.NoMostrarBusquedad = "True";
                    fd = Helper.Helper.FechaHoraDesde(DateTime.Today);
                    fh = Helper.Helper.FechaHoraHasta(DateTime.Today);
                }
                else
                {
                    ViewBag.NoMostrarBusquedad = "True";
                    fd = Helper.Helper.FechaHoraDesde((DateTime)fechaDesde);
                    fh = Helper.Helper.FechaHoraHasta((DateTime)fechaHasta);
                }

                socio soc = db.socios.Find(id);
                ViewBag.Puntos    = (int)soc.puntos_actuales;
                ViewBag.SubTitulo = "Socio: " + soc.apellido + ", " + soc.nombre + " del " + fd.ToShortDateString() + " al " + fh.ToShortDateString();
                var puntos = await(from p in db.carga_puntos
                                   where p.socio_id == id && p.fecha_alta >= fd && p.fecha_alta <= fh
                                   select p).ToListAsync();
                return(View(puntos));
            }
        }
Пример #24
0
        /// <summary>
        /// Importa los datos de socios desde una hoja de Excel.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="CREADO_POR"></param>
        /// <returns>Mensaje de error de importación.</returns>
        public string SociosCargarDatos(string path, string CREADO_POR)
        {
            int x = 2;

            try
            {
                string connection = System.Configuration.ConfigurationManager.ConnectionStrings["excelConnection"].ConnectionString;

                string connectionFormatted = String.Format(connection, path);

                using (OleDbConnection oledbConnection = new OleDbConnection(connectionFormatted))
                {
                    this.excelDt = new DataTable();

                    oledbConnection.Open();

                    string strSheetname = "";

                    DataTable dtSheetNames = oledbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);

                    if (dtSheetNames.Rows.Count > 0)
                    {
                        strSheetname = dtSheetNames.Rows[0]["TABLE_NAME"].ToString();
                    }

                    string strExcelSheetSelect = System.Configuration.ConfigurationManager.AppSettings["excelSheetSelect"];

                    string excelSheetSelect = String.Format(strExcelSheetSelect, strSheetname);

                    OleDbCommand     cmd     = new OleDbCommand(excelSheetSelect, oledbConnection);
                    OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);

                    adapter.Fill(this.excelDt);
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al importar socio. Conexion Excel Fallo.", ex);
                throw;
            }

            string message = "";

            try
            {
                if (this.excelDt.Rows[1][0].ToString().Equals("Código"))
                {
                    using (var scope1 = new TransactionScope())
                    {
                        using (var db = new colinasEntities())
                        {
                            for (; x < this.excelDt.Rows.Count; x++)
                            {
                                DataRow row = this.excelDt.Rows[x];

                                socio socioImportado = new socio();
                                socioImportado.SOCIOS_ID = row[0].ToString();

                                bool validId = System.Text.RegularExpressions.Regex.IsMatch(socioImportado.SOCIOS_ID, "^[A-za-z]+[0-9]+$");

                                if (!validId)
                                {
                                    message = "Código de socio no valido";
                                    throw new Exception(message);
                                }

                                var socioQuery = from s in db.socios
                                                 where s.SOCIOS_ID == socioImportado.SOCIOS_ID
                                                 select s;

                                socio socioExistente = socioQuery.FirstOrDefault();

                                if (socioExistente != null)
                                {
                                    message = "Código de socio existente.";
                                    throw new Exception(message);
                                }

                                string letras = new string(socioImportado.SOCIOS_ID.Where(char.IsLetter).ToArray());
                                string numero = new string(socioImportado.SOCIOS_ID.Where(char.IsDigit).ToArray());


                                var codigoQuery = from c in db.codigo
                                                  where c.CODIGO_LETRA == letras
                                                  select c;

                                codigo cod = codigoQuery.FirstOrDefault();

                                if (cod != null)
                                {
                                    int codNum = 0;

                                    if (int.TryParse(numero, out codNum))
                                    {
                                        if (cod.CODIGO_NUMERO <= codNum)
                                        {
                                            cod.CODIGO_NUMERO = codNum + 1;
                                        }
                                    }
                                    else
                                    {
                                        message = "Error en código de socio. Numero invalido";
                                        throw new Exception(message);
                                    }
                                }


                                socioImportado.SOCIOS_PRIMER_NOMBRE       = row[1].ToString();
                                socioImportado.SOCIOS_SEGUNDO_NOMBRE      = row[2].ToString();
                                socioImportado.SOCIOS_PRIMER_APELLIDO     = row[3].ToString();
                                socioImportado.SOCIOS_SEGUNDO_APELLIDO    = row[4].ToString();
                                socioImportado.SOCIOS_RESIDENCIA          = row[5].ToString();
                                socioImportado.SOCIOS_ESTADO_CIVIL        = row[6].ToString();
                                socioImportado.SOCIOS_LUGAR_DE_NACIMIENTO = row[7].ToString();

                                DateTime SOCIOS_FECHA_DE_NACIMIENTO = new DateTime();
                                DateTime.TryParse(row[8].ToString(), out SOCIOS_FECHA_DE_NACIMIENTO);
                                socioImportado.SOCIOS_FECHA_DE_NACIMIENTO = SOCIOS_FECHA_DE_NACIMIENTO;

                                socioImportado.SOCIOS_NIVEL_EDUCATIVO  = row[9].ToString();
                                socioImportado.SOCIOS_PROFESION        = row[10].ToString();
                                socioImportado.SOCIOS_RTN              = row[11].ToString();
                                socioImportado.SOCIOS_TELEFONO         = row[12].ToString();
                                socioImportado.SOCIOS_IDENTIDAD        = row[13].ToString();
                                socioImportado.SOCIOS_LUGAR_DE_EMISION = row[14].ToString();

                                DateTime SOCIOS_FECHA_DE_EMISION = new DateTime();
                                DateTime.TryParse(row[15].ToString(), out SOCIOS_FECHA_DE_EMISION);
                                socioImportado.SOCIOS_FECHA_DE_EMISION = SOCIOS_FECHA_DE_EMISION;

                                socioImportado.SOCIOS_ESTATUS                  = row[16].ToString().Equals("Si") || row[16].ToString().Equals("SI") || row[16].ToString().Equals("S") || row[16].ToString().Equals("s") ? 1 : 0;
                                socioImportado.SOCIOS_APORTACION_ORD           = row[17].ToString().Equals("Si") || row[17].ToString().Equals("SI") || row[17].ToString().Equals("S") || row[17].ToString().Equals("s") ? true : false;
                                socioImportado.SOCIOS_APORTACION_EXTRAORD      = row[18].ToString().Equals("Si") || row[18].ToString().Equals("SI") || row[18].ToString().Equals("S") || row[18].ToString().Equals("s") ? true : false;
                                socioImportado.SOCIOS_APORTACION_EXTRAORD_COOP = row[19].ToString().Equals("Si") || row[19].ToString().Equals("SI") || row[19].ToString().Equals("S") || row[19].ToString().Equals("s") ? true : false;

                                int SOCIOS_APORTACION_EXTRAORD_COUNT = 0;
                                int.TryParse(row[20].ToString(), out SOCIOS_APORTACION_EXTRAORD_COUNT);
                                socioImportado.SOCIOS_APORTACION_EXTRAORD_COUNT = SOCIOS_APORTACION_EXTRAORD_COUNT;

                                socioImportado.SOCIOS_APORTACION_INTERES_S_APORTACION = row[21].ToString().Equals("Si") || row[21].ToString().Equals("SI") || row[21].ToString().Equals("S") || row[21].ToString().Equals("s") ? true : false;

                                socioImportado.socios_generales = new socio_general();
                                socioImportado.socios_generales.GENERAL_CARNET_IHCAFE           = row[22].ToString();
                                socioImportado.socios_generales.GENERAL_ORGANIZACION_SECUNDARIA = row[23].ToString();
                                socioImportado.socios_generales.GENERAL_NUMERO_CARNET           = row[24].ToString();
                                socioImportado.socios_generales.GENERAL_EMPRESA_LABORA          = row[25].ToString();
                                socioImportado.socios_generales.GENERAL_EMPRESA_CARGO           = row[26].ToString();
                                socioImportado.socios_generales.GENERAL_EMPRESA_DIRECCION       = row[27].ToString();
                                socioImportado.socios_generales.GENERAL_EMPRESA_TELEFONO        = row[28].ToString();
                                socioImportado.socios_generales.GENERAL_SEGURO = row[29].ToString();

                                DateTime GENERAL_FECHA_ACEPTACION = new DateTime();
                                DateTime.TryParse(row[30].ToString(), out GENERAL_FECHA_ACEPTACION);
                                socioImportado.socios_generales.GENERAL_FECHA_ACEPTACION = GENERAL_FECHA_ACEPTACION;

                                socioImportado.socios_produccion = new socio_produccion();
                                socioImportado.socios_produccion.PRODUCCION_UBICACION_FINCA = row[31].ToString();
                                socioImportado.socios_produccion.PRODUCCION_AREA            = row[32].ToString();
                                socioImportado.socios_produccion.PRODUCCION_VARIEDAD        = row[33].ToString();
                                socioImportado.socios_produccion.PRODUCCION_ALTURA          = row[34].ToString();
                                socioImportado.socios_produccion.PRODUCCION_DISTANCIA       = row[35].ToString();

                                int PRODUCCION_ANUAL = 0;
                                int.TryParse(row[36].ToString(), out PRODUCCION_ANUAL);
                                socioImportado.socios_produccion.PRODUCCION_ANUAL = PRODUCCION_ANUAL;

                                socioImportado.socios_produccion.PRODUCCION_BENEFICIO_PROPIO = row[37].ToString();
                                socioImportado.socios_produccion.PRODUCCION_ANALISIS_SUELO   = row[38].ToString();
                                socioImportado.socios_produccion.PRODUCCION_TIPO_INSUMOS     = row[39].ToString();

                                int PRODUCCION_MANZANAS_CULTIVADAS = 0;
                                int.TryParse(row[40].ToString(), out PRODUCCION_MANZANAS_CULTIVADAS);
                                socioImportado.socios_produccion.PRODUCCION_MANZANAS_CULTIVADAS = PRODUCCION_MANZANAS_CULTIVADAS;

                                socioImportado.CREADO_POR         = socioImportado.MODIFICADO_POR = CREADO_POR;
                                socioImportado.FECHA_CREACION     = DateTime.Today;
                                socioImportado.FECHA_MODIFICACION = socioImportado.FECHA_CREACION;

                                db.socios.AddObject(socioImportado);
                            }

                            db.SaveChanges();
                            scope1.Complete();
                        }
                        message = "Importacion realizada Exitosamente.";
                    }
                }
                else
                {
                    message = "La plantilla se encuentra en formato invalido o esta vacia.";
                }

                return(message);
            }
            catch (Exception ex)
            {
                log.Error("Error al importar socio.", ex);
                return(String.Format("Error en la linea {0}", x + 2));
            }
        }
Пример #25
0
        public async Task <ActionResult> Create([Bind(Include = "id,nombre,apellido,documento,celular,mail,direccion,localidad,provincia,observaciones,NroTarjeta,fecha_nacimiento")] socio socio)
        {
            if (ModelState.IsValid)
            {
                if (db.socios.Any(ss => ss.documento == socio.documento))
                {
                    TempData["MsjError"] = "Ya existe un socio con el documento indicado";
                    return(RedirectToAction("Create"));
                }
                try
                {
                    socio.complejo_alta_id = IdComplejoIdentity;

                    var t = db.tarjeta_socio.FirstOrDefault(ts => ts.numero_tarjeta == socio.NroTarjeta.Trim());
                    if (t != null)
                    {
                        if (t.socio_id != null)
                        {
                            TempData["MsjError"] = "La tarjeta esta asociada a otro socio";
                            return(RedirectToAction("Create"));
                        }
                        else if (!t.activada)
                        {
                            TempData["MsjError"] = "La tarjeta se encuentra inactiva";
                            return(RedirectToAction("Create"));
                        }
                        else
                        {
                            using (var dbTransaction = db.Database.BeginTransaction())
                            {
                                try
                                {
                                    socio.fecha_alta           = DateTime.Now;
                                    socio.fecha_modificacion   = DateTime.Now;
                                    socio.usuario_alta         = User.Identity.Name;
                                    socio.usuario_modificacion = User.Identity.Name;
                                    db.socios.Add(socio);
                                    await db.SaveChangesAsync();

                                    t.activada             = true;
                                    t.fecha_modificacion   = DateTime.Now;
                                    t.modo_activacion      = Helper.Helper.ModosActivacionTarjeta.UsuarioInterno.ToString();
                                    t.usuario_modificacion = User.Identity.Name;
                                    t.socio_id             = socio.id;
                                    db.Entry(t).State      = EntityState.Modified;
                                    db.Configuration.ValidateOnSaveEnabled = false;
                                    await db.SaveChangesAsync();

                                    dbTransaction.Commit();
                                }
                                catch (Exception)
                                {
                                    dbTransaction.Rollback();
                                    throw;
                                }
                            }
                        }
                    }
                    else
                    {
                        using (var dbTransaction = db.Database.BeginTransaction())
                        {
                            try
                            {
                                socio.fecha_alta           = DateTime.Now;
                                socio.fecha_modificacion   = DateTime.Now;
                                socio.usuario_alta         = User.Identity.Name;
                                socio.usuario_modificacion = User.Identity.Name;
                                if (!String.IsNullOrEmpty(socio.NroTarjeta))
                                {
                                    t                      = new tarjeta_socio();
                                    t.activada             = true;
                                    t.fecha_alta           = DateTime.Now;
                                    t.fecha_modificacion   = DateTime.Now;
                                    t.modo_activacion      = Helper.Helper.ModosActivacionTarjeta.UsuarioInterno.ToString();
                                    t.numero_tarjeta       = socio.NroTarjeta;
                                    t.usuario_alta         = User.Identity.Name;
                                    t.usuario_modificacion = User.Identity.Name;
                                    t.socio                = socio;
                                    db.tarjeta_socio.Add(t);
                                    await db.SaveChangesAsync();
                                }
                                else
                                {
                                    db.socios.Add(socio);
                                    await db.SaveChangesAsync();
                                }
                                dbTransaction.Commit();
                            }
                            catch (Exception ex)
                            {
                                dbTransaction.Rollback();
                                throw;
                            }
                        }
                    }
                    TempData["MsjExito"] = "Socio Agregado Con Exito";
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    TempData["MsjError"] = ex.Message;
                    return(RedirectToAction("Create"));
                }
            }

            return(View(socio));
        }
Пример #26
0
        public void insertarsocio(string nombre, string direccion)
        {
            socio objsocio = new socio();

            objsocio.insertarsocio(nombre, direccion, 1);
        }
Пример #27
0
        public void eliminarsocio(int id)
        {
            socio objsocio = new socio();

            objsocio.borrarsocio(id);
        }