public ActionResult IV(int Id) { IV oIV = new IV(); try { UsuarioPV Usuario = new UsuarioPV();// Esto se remplaza por sesion de usuario. Usuario = Usuario.GetUsuario(); oIV.Responsable = Usuario.Nombre; oIV.Sector = Usuario.Sector; oIV.Subsector = Usuario.Subsector; oIV.Responsables = new List<Responsable>(); if (Id != null && Id > 0) { oIV.ID = Id; var Iniciativa = IVAdm.objIVBL.Get(Id); if (Iniciativa != null && Iniciativa.Id > 0) { oIV.Codigo = Iniciativa.Id.ToString(); // Iniciativa.Codigo; oIV.Fecha = Iniciativa.FeRegistro.Value.ToString("dd/MM/yyyy"); oIV.Hora = Iniciativa.Hora; //.FeRegistro.Value.ToString("HH:mm"); oIV.Descripcion = Iniciativa.Descripcion; oIV.Detalle = Iniciativa.DetalleIV; var lstVecino = oVecino.List(oIV.ID); if (lstVecino != null && lstVecino.Count > 0) { oIV.Responsables = (from x in lstVecino select new Responsable { ID = x.Id, Nombre = x.Nombre, ApePaterno = x.NroDoc, ApeMaterno = x.Direccion }).ToList(); } } else { return RedirectToAction("", "IniciativaVecinal"); } //Buscar Iniciativa Vecinal : } else { //return RedirectToAction("", "IniciativaVecinal"); } return View(oIV); } catch { return RedirectToAction("", "IniciativaVecinal"); } return View(); }
public JsonResult Update(IV oIV) { UsuarioPV oUusario = new UsuarioPV(); var Usuario = oUusario.GetUsuario(); PVecinal_IniciativaVecinal oIni = new PVecinal_IniciativaVecinal(); //IniciativaVecinalBL oIVBus = new IniciativaVecinalBL(); //VecinoBL oVecinoBus = new VecinoBL(); DateTime feRegistro = new DateTime(1900, 1, 1); String strhora = ""; if (!String.IsNullOrEmpty(oIV.Fecha)) { if (DateTime.TryParse(oIV.Fecha, out feRegistro)) { if (!String.IsNullOrEmpty(oIV.Hora) && oIV.Hora.Length > 4) { //"hh:mm" int hora = 0, min = 0; String xx = oIV.Hora.Substring(0, 2); String xxx = oIV.Hora.Substring(3, 2); int.TryParse(oIV.Hora.Substring(0, 2), out hora); int.TryParse(oIV.Hora.Substring(3, 2), out min); feRegistro.AddHours(hora); feRegistro.AddMinutes(min); strhora = hora + ":" + min.ToString("D2"); ; } } } oIni.Id = oIV.ID; oIni.Descripcion = (!String.IsNullOrEmpty(oIV.Descripcion)) ? oIV.Descripcion : ""; oIni.DetalleIV = (!String.IsNullOrEmpty(oIV.Detalle)) ? oIV.Detalle : ""; oIni.FeRegistro = feRegistro; oIni.IdEstado = 1;//Pendiente por defecto oIni.IdResponsable = Usuario.Id; oIni.IdDelegadoVecinal = Usuario.Id; oIni.IdSubSector = Usuario.IdSubsector; /****************************************************/ oIni.Hora = strhora; oIni.FechaNotificacion = new DateTime(1900, 1, 1); /****************************************************/ if (feRegistro > DateTime.Now) { oIV.ID = -3; var vjson = Json(oIV, JsonRequestBehavior.AllowGet); vjson.MaxJsonLength = int.MaxValue; return vjson; } oIni = IVAdm.objIVBL.Update(oIni); if (oIni.Id > 0) { //oVecinoBus.DeleteAll(oIni.Id); // --> actualizar a falso, var lstVecino = oIV.Sector.Split('|'); if (lstVecino != null && lstVecino.Length > 0) { // update all to true oVecino.DeleteAllByIV(oIni.Id); foreach (var det in lstVecino) { var datos = det.Split('#'); if (datos != null && datos.Length > 0) { String idvecino = (datos.Length >= 1) ? datos[0] : "0"; int idVe = 0; if (int.TryParse(idvecino, out idVe)) { //si existe se actualiza a true oVecino.SaveByIV(oIni.Id, idVe,true); } //String dni = (datos.Length >= 2) ? datos[2] : ""; //String nombre = (datos.Length >= 3) ? datos[3] : ""; //String direccion = (datos.Length >= 4) ? datos[4] : ""; //if (dni != "" && nombre != "") { // oVecinoBus.Save(new PVecinal_Vecino { IdTipo = oIni.Id, NroDoc = dni, Nombre = nombre, Direccion = direccion }); //} } } } } oIV.ID = oIni.Id; oIV.Codigo = oIni.Id.ToString() ;// oIni.Codigo; var vjson2 = Json(oIV, JsonRequestBehavior.AllowGet); vjson2.MaxJsonLength = int.MaxValue; return vjson2; }
public JsonResult SaveIV(IV oIV) { UsuarioPV oUusario = new UsuarioPV(); var Usuario = oUusario.GetUsuario(); PVecinal_IniciativaVecinal oIni = new PVecinal_IniciativaVecinal(); //IniciativaVecinalBL oIVBus = new IniciativaVecinalBL(); //VecinoBL oVecinoBus = new VecinoBL(); DateTime feRegistro = new DateTime(1900, 1, 1); String strHora=""; if (!String.IsNullOrEmpty(oIV.Fecha)) { if (DateTime.TryParse(oIV.Fecha, out feRegistro)) { if (!String.IsNullOrEmpty(oIV.Hora) && oIV.Hora.Length > 4) { //"hh:mm" int hora = 0, min = 0; String xx = oIV.Hora.Substring(0, 2); String xxx = oIV.Hora.Substring(3, 2); int.TryParse(oIV.Hora.Substring(0, 2), out hora); int.TryParse(oIV.Hora.Substring(3, 2), out min); strHora = hora + ":" + min.ToString("D2"); feRegistro.AddHours(hora); feRegistro.AddMinutes(min); } } } if (feRegistro > DateTime.Now) { oIV.ID = -1; var vjson = Json(oIV, JsonRequestBehavior.AllowGet); vjson.MaxJsonLength = int.MaxValue; return vjson; } oIni.Descripcion = (!String.IsNullOrEmpty(oIV.Descripcion)) ? oIV.Descripcion : ""; oIni.DetalleIV = (!String.IsNullOrEmpty(oIV.Detalle)) ? oIV.Detalle : ""; oIni.FeRegistro = feRegistro; /****************************************************/ oIni.IdEstado = 1;//Pendiente por defecto oIni.IdResponsable = Usuario.Id; oIni.IdDelegadoVecinal = Usuario.Id; oIni.IdSubSector = Usuario.IdSubsector; oIni.Hora = strHora; oIni.FechaNotificacion = new DateTime(1900,1,1); /****************************************************/ oIni =IVAdm.objIVBL.Save(oIni); if (oIni.Id > 0) { //Registro de Vecinos : //1 #0 #45096684 #CINTHIA CECILIA ANGULO MARRUJO #| //IV.SE = strVecino; var lstVecino = oIV.Sector.Split('|'); if (lstVecino != null && lstVecino.Length > 0) { foreach (var det in lstVecino) { var datos = det.Split('#'); if (datos != null && datos.Length > 0) { //String dni = (datos.Length >= 2) ? datos[2] : ""; String idvecino = (datos.Length>=1)?datos[0]:"0"; int idVe=0; if(int.TryParse(idvecino,out idVe)){ oVecino.SaveByIV(oIni.Id,idVe,false); } //String dni = (datos.Length >= 2) ? datos[2] : ""; //String nombre = (datos.Length >= 3) ? datos[3] : ""; //String direccion = (datos.Length >= 4) ? datos[4] : ""; //if (dni != "" && nombre != "") { //} } } } } oIV.ID = oIni.Id; //oIV.Codigo = oIni.Codigo; var vjson2 = Json(oIV, JsonRequestBehavior.AllowGet); vjson2.MaxJsonLength = int.MaxValue; return vjson2; }