public async Task <IActionResult> Edit(int id, [Bind("PlantillaID,ModeloNegocioID,Fecha,Visible")] Plantilla plantilla) { if (id != plantilla.PlantillaID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(plantilla); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PlantillaExists(plantilla.PlantillaID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ModeloNegocioID"] = new SelectList(_context.ModeloNegocio, "ModeloNegocioID", "ModeloNegocioID", plantilla.ModeloNegocioID); return(View(plantilla)); }
public async Task <ActionResult> Crear([FromBody] CrearViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var fechaHora = DateTime.Now; Plantilla plantilla = new Plantilla { nombre = model.nombre, correo = model.correo, idEstatus = 1, fechaRegistro = fechaHora }; _context.Plantillas.Add(plantilla); try { await _context.SaveChangesAsync(); } catch (Exception ex) { return(BadRequest()); } return(Ok()); }
public IHttpActionResult PutPlantilla(int id, Plantilla plantilla) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != plantilla.PlantillaID) { return(BadRequest()); } db.Entry(plantilla).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PlantillaExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void Lstprofesores_ItemSelected(object sender, SelectedItemChangedEventArgs e) { Plantilla profesor = (Plantilla)e.SelectedItem; ProfesoresViewModel viewModel = (ProfesoresViewModel)this.BindingContext; viewModel.ProfesorSeleccionado = profesor; }
public IHttpActionResult PutPlantilla(int id, Plantilla plantilla) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != plantilla.PlantillaID) { return BadRequest(); } db.Entry(plantilla).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PlantillaExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
// GET: Plantillas/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Plantilla plantilla = db.Plantillas.Find(id); if (plantilla == null) { return(HttpNotFound()); } ViewBag.Id_Fabricante = new SelectList(db.Fabricantes, "Id_Fabricante", "Nombre", plantilla.Id_Fabricante); var funcIds = ( from pf in db.Plantilla_Funcion where pf.id_Plantilla.Equals(plantilla.id_Plantilla) select pf.id_Funcion ).ToList(); var allfunc = db.Funciones.ToList().OrderBy(c => c.Descripcion); ViewBag.Funciones = new MultiSelectList(allfunc, "Id_Esquema", "Descripcion", funcIds); return(View(plantilla)); }
public void PlantillaGrabar(string id, string descripcion, string texto, string idTipo) { Plantilla plantilla; int _id = id.ConvertirInt(); if (_id == -1) { plantilla = new Plantilla(); } else { plantilla = this.PlantillaObtener(_id); } plantilla.Descripcion = descripcion == null ? string.Empty : descripcion; plantilla.Texto = texto; plantilla.Vigente = true; plantilla.TipoPlantilla = idTipo == null ? null : ObtenerObjeto <TipoPlantilla>(idTipo.ConvertirInt()); plantilla.Validar(); RepositoryGenerico <Plantilla> repository = new RepositoryGenerico <Plantilla>(); repository.Actualizar(plantilla); }
public IHttpActionResult PutPlantilla(long id, Plantilla Plantilla) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != Plantilla.Id) { return(BadRequest()); } try { this.PlantillasService.PutPlantilla(Plantilla); } catch (DbUpdateConcurrencyException) { if (this.PlantillasService.GetPlantilla(id) == null) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
protected void DeletePlanilla() { long idPlanilla = Convert.ToInt64(ViewState["idsel"]); Plantilla _ItemPlanilla = (from c in Contexto.Plantilla where c.IdPlantilla == idPlanilla select c).FirstOrDefault(); if (_ItemPlanilla != null) { try { List <RolesPlanilla> roles = _ItemPlanilla.RolesPlanilla.ToList(); foreach (var item in roles) { Contexto.DeleteObject(item); } Contexto.DeleteObject(_ItemPlanilla); Contexto.SaveChanges(); this.RadGrid1.Rebind(); } catch (Exception e) { ScriptManager.RegisterStartupScript(updpnlGrilla, typeof(UpdatePanel), "Error Grabacion", "alert(" + e.Message + ")", true); } } }
private void BindControles(TreeNode node) { Plantilla obj = null; if (node != null) { obj = uow.PlantillaBusinessLogic.GetByID(Utilerias.StrToInt(node.Value)); txtClave.Text = obj.Clave; txtDescripcion.Text = obj.Descripcion; ddlEjercicio.SelectedValue = obj.EjercicioId.ToString(); txtOrden.Value = obj.Orden.ToString(); _IDPlantilla.Value = obj.Id.ToString(); _rutaNodoSeleccionado.Value = node.ValuePath; treePlantilla.FindNode(node.ValuePath).Select(); } else { txtClave.Text = string.Empty; txtDescripcion.Text = string.Empty; if (ddlEjercicio.Items.Count > 0) { ddlEjercicio.SelectedIndex = 0; } txtOrden.Value = string.Empty; _IDPlantilla.Value = string.Empty; _rutaNodoSeleccionado.Value = string.Empty; } }
protected void btnAccept_Click(object sender, ImageClickEventArgs e) { try { if (!DataOk()) { return; } if (newRecord) { plantilla = new Plantilla(); } UnloadData(plantilla); if (newRecord) { ctx.Add(plantilla); } ctx.SaveChanges(); if (newRecord) { RadAjaxManager1.ResponseScripts.Add(String.Format("closeWindowRefreshGrid('{0}', 'new');", caller)); } else { RadAjaxManager1.ResponseScripts.Add(String.Format("closeWindowRefreshGrid('{0}', 'edit');", caller)); } } catch (Exception ex) { ControlDeError(ex); } }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Plantilla plantilla = db.Plantillas.Find(id); var fabricante = db.Plantillas.Include(p => p.Fabricante).FirstOrDefault().Fabricante.Nombre; if (plantilla == null) { return(HttpNotFound()); } var f = ( from pl in db.Plantillas join pf in db.Plantilla_Funcion on pl.id_Plantilla equals pf.id_Plantilla join fun in db.Funciones on pf.id_Funcion equals fun.Id_Esquema where pl.id_Plantilla == id select fun.Descripcion ).ToList(); ViewBag.Fabricante = fabricante; ViewBag.Funciones = f; return(View(plantilla)); }
public string PlantillaObtenerTexto(string descripcion) { RepositoryGenerico <Plantilla> repository = new RepositoryGenerico <Plantilla>(); Plantilla plantilla = repository.Obtener("Descripcion", descripcion); return((plantilla != null) ? plantilla.Texto : string.Empty); }
private void BindControles(Plantilla obj) { txtClave.Text = obj.Clave; txtDescripcion.Text = obj.Descripcion; ddlEjercicio.SelectedValue = obj.EjercicioId.ToString(); txtOrden.Value = obj.Orden.ToString(); }
public List <Plantilla> Listar() { var plantillas = new List <Plantilla>(); try { using (var conexion = new SqlConnection(ConfigurationManager.ConnectionStrings["roffusdb"].ToString())) { conexion.Open(); var query = new SqlCommand("SELECT t.CodPlantilla,t.Diseño,t.Ancho, t.Largo, t.Alto FROM Plantilla t", conexion); using (var dr = query.ExecuteReader()) { while (dr.Read()) { var plantilla = new Plantilla(); plantilla.CodPlantilla = Convert.ToInt32(dr["CodPlantilla"]); plantilla.Diseño = dr["Diseño"].ToString(); plantilla.Ancho = Convert.ToDouble(dr["Ancho"]); plantilla.Largo = Convert.ToDouble(dr["Largo"]); plantilla.Alto = Convert.ToDouble(dr["Alto"]); plantillas.Add(plantilla); } } } } catch (Exception ex) { throw; } return(plantillas); }
public static ClientResponse Preview(int plantilla) { ClientResponse response; try { using (PlantillaDAO dbPlanilla = new PlantillaDAO()) { response = dbPlanilla.getPlantillaXId(plantilla); } Plantilla objetoplantilla = Newtonsoft.Json.JsonConvert.DeserializeObject <Plantilla>(response.DataJson); string body = string.Empty; using (StreamReader reader = new StreamReader(objetoplantilla.ruta_plantilla_html)) { body = reader.ReadToEnd(); } response.ViewResult = body; } catch (Exception exception) { throw exception; } return(response); }
public bool Actualizar(Plantilla t) { bool rpta = false; try { using (var conexion = new SqlConnection(ConfigurationManager.ConnectionStrings["roffusdb"].ToString())) { conexion.Open(); var query = new SqlCommand("UPDATE Plantilla SET Ancho=@Ancho, Largo=@Largo, Alto=@Alto,Diseño=@Diseño WHERE CodPlantilla=@CodPlantilla", conexion); query.Parameters.AddWithValue("@CodPlantilla", t.CodPlantilla); query.Parameters.AddWithValue("@Diseño", t.Diseño); query.Parameters.AddWithValue("@Ancho", t.Ancho); query.Parameters.AddWithValue("@Largo", t.Largo); query.Parameters.AddWithValue("@Alto", t.Alto); query.ExecuteNonQuery(); rpta = true; } } catch (Exception ex) { throw; } return(rpta); }
public bool Insertar(Plantilla t) { bool rpta = false; try { using (var conexion = new SqlConnection(ConfigurationManager.ConnectionStrings["roffusdb"].ToString())) { conexion.Open(); var query = new SqlCommand("INSERT INTO Plantilla VALUES(@Ancho, @Largo, @Alto,@Diseño)", conexion); query.Parameters.AddWithValue("@Diseño", t.Diseño); query.Parameters.AddWithValue("@Ancho", t.Ancho); query.Parameters.AddWithValue("@Largo", t.Largo); query.Parameters.AddWithValue("@Alto", t.Alto); query.ExecuteNonQuery(); rpta = true; } } catch (Exception ex) { throw; } return(rpta); }
protected void btnPlantilla_Click(object sender, ImageClickEventArgs e) { try { Dictionary <string, object> parameters = new System.Collections.Generic.Dictionary <string, object>(); List <string> L = new List <string>(); L.Add("Clave Invernadero"); L.Add("Año Plantación"); L.Add("Semana Plantación"); L.Add("Interplanting"); L.Add("Número De Corte"); L.Add("Semana De Corte"); L.Add("Año De Corte"); L.Add("Libras"); Plantilla P = new Plantilla(Response, "Libras Planeadas"); P.CrearTabla(L, 40000, 1, 1, "Libras Planeadas", "tbl_LibrasPlaneadas", "Libras Planeadas"); P.ProtegerArchivo(); P.GuardarPlantilla(); } catch (Exception ex) { log.Error(ex.ToString()); } }
protected override void presentarData(Plantilla dato) { EmpresaDAO datoEmpresa = (EmpresaDAO)dato; campo.Text = datoEmpresa.Factura.NombreEmpresa; direccion.Text = datoEmpresa.Factura.DireccionEmpresa; }
protected void Unnamed1_Click(object sender, ImageClickEventArgs e) { if (ddlPlanta.SelectedIndex == 0) { popUpMessageControl1.setAndShowInfoMessage("Seleccione la planta", Common.MESSAGE_TYPE.Error); return; } try { Dictionary <string, object> prm = new Dictionary <string, object>(); prm.Add("@idFarm", ddlPlanta.SelectedValue); DataSet ds = DataAccess.executeStoreProcedureDataSet("spr_GET_ddlInvernaderos", prm); prm.Clear(); DataTable dt = DataAccess.executeStoreProcedureDataTable("spr_GET_ActivosEquipoBoquilla", prm); dt.TableName = "Boquillas"; ds.Tables.Add(dt); prm.Add("@idFarm", ddlPlanta.SelectedValue); DataTable dt2 = DataAccess.executeStoreProcedureDataTable("spr_GET_Plantilla", prm); dt2.TableName = "Volumenes"; ds.Tables.Add(dt2); Plantilla c = new Plantilla("Inverndaderos", ds, this.Response); } catch (Exception x) { Log.Error(x); popUpMessageControl1.setAndShowInfoMessage(x.Message, Common.MESSAGE_TYPE.Error); } }
public ClientResponse UpdatePantilla(Plantilla objeto) { try { XElement root = new XElement("ROOT"); foreach (Plantilla_Detalle detalle in objeto.list_plantilla_detalle) { XElement address = new XElement("Detalle", new XElement("NombreArchivoImagen", detalle.NombreArchivoImagen), new XElement("ruta_imagen", detalle.ruta_imagen), new XElement("ruta_site_imagen", detalle.ruta_site_imagen) ); root.Add(address); } string xml = root.ToString(); using (conexion = new SqlConnection(ConexionDAO.cnx)) { using (comando = new SqlCommand("usp_upd_planilla", conexion)) { comando.Parameters.AddWithValue("@id", objeto.id); comando.Parameters.AddWithValue("@xml", xml); comando.Parameters.AddWithValue("@fl_parrafo", objeto.fl_parrafo); comando.Parameters.AddWithValue("@descripcion", objeto.descripcion); comando.Parameters.AddWithValue("@NombreArchivoHtml", objeto.NombreArchivoHtml == null ? "" : objeto.NombreArchivoHtml); comando.Parameters.AddWithValue("@ruta_plantilla_html", objeto.ruta_plantilla_html == null ? "": objeto.ruta_plantilla_html); comando.Parameters.Add("@Ind", SqlDbType.Int).Direction = ParameterDirection.Output; comando.Parameters.Add("@Mensaje", SqlDbType.VarChar, 200).Direction = ParameterDirection.Output; comando.CommandType = CommandType.StoredProcedure; conexion.Open(); comando.ExecuteNonQuery(); int ind = Convert.ToInt32(comando.Parameters["@Ind"].Value); string mensaje = Convert.ToString(comando.Parameters["@Mensaje"].Value); if (ind > 0) { clientResponse.Mensaje = mensaje; clientResponse.Status = "Ok"; } else { clientResponse.Mensaje = mensaje; clientResponse.Status = "ERROR"; } } } } catch (Exception ex) { clientResponse.Mensaje = ex.Message; clientResponse.Status = "ERROR"; } finally { conexion.Close(); conexion.Dispose(); comando.Dispose(); } return(clientResponse); }
private void MenuItemClicked(object sender, EventArgs e) { if (sender.GetType() == typeof(ToolStripMenuItem)) { string NombreFormulario = ((ToolStripItem)sender).Tag.ToString(); Object ObjFrm; Type tipo = Ensamblado.GetType(Ensamblado.GetName().Name + "." + NombreFormulario); if (tipo == null) { if (sender.ToString().Trim() == "EGESAC S.A.") { Clases.Usuario.EmpresaLogeada.EmpresaIngresada = "EGES"; this.Text = "Clínica Santa Catalina: " + "[EGESAC S.A.]"; foreach (ToolStripMenuItem menu in this.MenuPpal.Items) { if (menu.Text.Trim() == "Empresa") { RecorreMenuHijos(menu.DropDownItems, "EGES"); } } return; } else { if (sender.ToString().Trim() == "RSC S.A.") { Clases.Usuario.EmpresaLogeada.EmpresaIngresada = "RSC"; this.Text = "Clínica Santa Catalina: " + "[RSC S.A.]"; foreach (ToolStripMenuItem menu in this.MenuPpal.Items) { if (menu.Text.Trim() == "Empresa") { RecorreMenuHijos(menu.DropDownItems, "RSC"); } } return; } } MessageBox.Show("No se encontró el formulario", "Error de ubicación", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (!this.FormularioEstaAbierto(NombreFormulario)) { ObjFrm = Activator.CreateInstance(tipo); Plantilla Formulario = (Plantilla)ObjFrm; Formulario.Id_Perfil = id_Perfil; Formulario.MdiParent = this; Formulario.Tag = ((ToolStripItem)sender).Name.ToString();//le envio el numero de Id de Menu para recuperar con este valor los permisos de este menu Formulario.Top = 5; Formulario.Show(); } } } }
public PlantillaDAO() { list_plantilla = new List <Plantilla>(); entidad = null; reader = null; clientResponse = new ClientResponse(); clientResponse.Status = "OK"; }
public EnvioCorreoPlantillaDAO() { list_envioplantilla = new List <EnvioCorreoPlantilla>(); entidad = null; reader = null; clientResponse = new ClientResponse(); clientResponse.Status = "OK"; }
public ActionResult DeleteConfirmed(int id) { Plantilla plantilla = db.Plantillas.Find(id); db.Plantillas.Remove(plantilla); db.SaveChanges(); return(RedirectToAction("Index")); }
public Solicitud ObtenerSolicitud(string pcodsolicitud) { Solicitud oSolicitud = new Solicitud(); Plantilla oPlantilla = new Plantilla(); //oPlantilla.lceldas = new List<Celda>(); oPlantilla.lcomponentes = new List <Componente>(); oPlantilla.lespecialidades = new List <Especialidad>(); oPlantilla.lservicios = new List <Servicio>(); oPlantilla.ltipocomponentes = new List <TipoComponente>(); DataSet tb = new DataSet(); using (var helper = new SqlHelper()) { helper.Connect(); var sql = "usp_Solicitud_ConsultaInfoPlantilla"; SqlDataAdapter sq = new SqlDataAdapter(); List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("@cod_solicitud", pcodsolicitud)); SqlCommand cmd = helper.CreateCommand(sql, CommandType.StoredProcedure, parameters.ToArray()); sq.SelectCommand = cmd; sq.Fill(tb, "Table1"); } DataTable dt = tb.Tables[0]; DataTable dt1 = tb.Tables[1]; DataTable dt2 = tb.Tables[2]; DataTable dt3 = tb.Tables[3]; DataTable dt4 = tb.Tables[4]; foreach (DataRow row in dt.Rows) { oSolicitud.codigo = row["codigosolicitud"].ToString(); oSolicitud.entaller = row["entaller"].ToString(); oSolicitud.cliente = row["cliente"].ToString(); oSolicitud.equipo = row["equipo"].ToString(); } foreach (DataRow row in dt1.Rows) { oPlantilla.lservicios.Add(new Servicio(int.Parse(row["idservicio"].ToString()), row["servicio"].ToString(), decimal.Parse(row["cantidad"].ToString()), decimal.Parse(row["costohora"].ToString()), 0)); } foreach (DataRow row in dt2.Rows) { oPlantilla.lespecialidades.Add(new Especialidad(int.Parse(row["idEspecialidad"].ToString()), row["especialidad"].ToString(), decimal.Parse(row["cantidad"].ToString()), 0, 0)); } foreach (DataRow row in dt3.Rows) { oPlantilla.lcomponentes.Add(new Componente(int.Parse(row["id"].ToString()), row["componente"].ToString(), decimal.Parse(row["cantidad"].ToString()) , row["codigo"].ToString(), row["tipocomponente"].ToString(), decimal.Parse(row["costosoles"].ToString()), row["moneda"].ToString(), 0, 0, int.Parse(row["idComponenteTipo"].ToString()))); } foreach (DataRow row in dt4.Rows) { oPlantilla.ltipocomponentes.Add(new TipoComponente(int.Parse(row["id"].ToString()), row["tipocomponente"].ToString(), decimal.Parse(row["cantidad"].ToString()), decimal.Parse(row["obtenido"].ToString()))); } oSolicitud.requerimientos_basicos = oPlantilla; return(oSolicitud); }
protected void btnExport_Click(object sender, EventArgs e) { if (!DatosOk()) { return; } int id_instalacion = -1; if (instalacion != null) { id_instalacion = instalacion.InstalacionId; } string directorio = MapPath("/") + "\\Repo"; string nombreFichero = String.Format("ACT{0:0000000}_{1:0000}.pdf", id_instalacion, usuario.UsuarioId); string fichero = String.Format("{0}\\{1}", directorio, nombreFichero); ReportProcessor reportProcessor = new ReportProcessor(); RenderingResult renderingResult = null; string nombre = ""; switch (informe) { case "RptActa": Plantilla plantilla = CntLainsaSci.GetPlantilla(1, ctx); // la primera plantilla es la de acta. string numeroAutorizado = ConfigurationManager.AppSettings["NumeroAutorizado"]; string contenido = String.Format(plantilla.Contenido, numeroAutorizado, tecnicoResponsable.Nombre, actaNumero, fechaActa); ReportBook reportBook = new ReportBook(); RptCartaActa rptCartaActa = new RptCartaActa(contenido); reportBook.Reports.Add(rptCartaActa); if (instalacion != null) { RptInformeActa rptInformeActa = new RptInformeActa(instalacion, observaciones, actaNumero, fechaActa, tecnicoResponsable.Nombre, ctx); reportBook.Reports.Add(rptInformeActa); } else { RptInformeActaEmpresa rptInformeActaEmpresa = new RptInformeActaEmpresa(emp, observaciones, actaNumero, fechaActa, tecnicoResponsable.Nombre, ctx); reportBook.Reports.Add(rptInformeActaEmpresa); } renderingResult = reportProcessor.RenderReport("PDF", reportBook, null); break; } FileStream fs = new FileStream(fichero, FileMode.Create); fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length); fs.Close(); // abrir como documento sobre el repositorio nombre = txtActaNumero.Text + "_" + DateTime.Now.ToShortDateString(); string url = String.Format("DocumentoView.aspx?FileName={0}&InstalacionId={1}&Nombre={2}&EmpresaId={3}", nombreFichero, id_instalacion, nombre, emp.EmpresaId); string jCommand = String.Format("parent.openOutSide('{0}', 'DocumentoView');", url); RadAjaxManager1.ResponseScripts.Add(jCommand); //string url = String.Format("VisorInforme.aspx?Informe=RptInformeActaEmpresas&prueba=arg&emp={0}",emp.EmpresaId); //string jCommand = String.Format("parent.openOutSide('{0}','{1}');", url, "VisorInforme"); //RadAjaxManager1.ResponseScripts.Add(jCommand); }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { string Errores = string.Empty; Errores += ddl_Planta.SelectedValue.Equals("0") ? "Es necesario elegir una planta.<br/>" : string.Empty; Errores += Regex.IsMatch(txt_Semanas.Text, @"^\d+$") ? ((Decimal.Parse(txt_Semanas.Text) > 0 && Decimal.Parse(txt_Semanas.Text) <= 255) ? string.Empty : "La plantilla no se puede generar debido a que se excede el limite de columnas disponibles.") : "Es necesario un numero entero positivo para especificar las semanas.<br/>"; if (Errores.Equals(string.Empty)) { Plantilla P = new Plantilla(this.Response, "Abejorros_"); try { Decimal semanas = Decimal.Parse(txt_Semanas.Text); List <string> Semanas = new List <string>(); Semanas.Add("Semanas"); for (int i = 1; i < semanas + 1; i++) { Semanas.Add(i.ToString()); } /*var dt = da.executeStoreProcedureDataTable("spr_EtapasObtenerPorPlantaActividad", new Dictionary<string, object>() { * {"@idPlanta", ddl_Planta.SelectedValue}, * {"@idioma", getIdioma()} * });*/ List <string> Etapas = new List <string>(); DataTable dtq = new DataTable(); /*foreach (DataRow tr in dt.Rows) * { * Etapas.Add(string.Format("{0}-{1}", tr["NombreCorto"], tr["NombreEtapa"])); * }*/ Etapas.Add("Colmenas"); Errores += Etapas.Count > 0 ? "No se detectaron etapas para la planta elegida" : string.Empty; P.CrearTabla(Semanas, Etapas, 1, 5, "Directriz Abejorros", "tbl_DirectrizAbejorro", "Directriz Abejorros"); DataTable dtPlanta = new DataTable(); dtPlanta.Columns.Add("Planta"); var dr = dtPlanta.NewRow(); dr["Planta"] = ddl_Planta.SelectedItem.Text; dtPlanta.Rows.Add(dr); P.CrearTabla(dtPlanta, 1, 0, "Generales", "tbl_Generales", "Directriz Abejorros"); P.ProtegerArchivo(ConfigurationManager.AppSettings["ContrasenaDeArchivos"].ToString()); P.GuardarPlantilla(); } catch (Exception x) { P.evitarDescargaDeArchivo(); popUpMessage.setAndShowInfoMessage(x.Message.ToString(), Comun.MESSAGE_TYPE.Error); log.Error(x); } } else { popUpMessage.setAndShowInfoMessage(Errores, Comun.MESSAGE_TYPE.Error); return; } }
public Result <Plantilla> ClonarPlantilla(Plantilla data) { var cl = GetCollection <Plantilla> (); if (cl.FindOne(Query <Plantilla> .EQ(e => e.Id, data.Id)) == default(Plantilla)) { throw new Exception("No Exite plantilla con Id:'{0}'".Fmt(data.Id)); } var clGuias = GetCollection <Guia> (); var guias = clGuias.Find(Query <Guia> .EQ(e => e.IdPlantilla, data.Id)).ToList(); var clCapitulos = GetCollection <Capitulo> (); var capitulos = clCapitulos.Find(Query <Capitulo> .EQ(e => e.IdPlantilla, data.Id)).ToList(); var capIds = capitulos.ConvertAll(e => e.Id); var clPreguntas = GetCollection <Pregunta> (); var preguntas = clPreguntas.Find(Query <Pregunta> .In(e => e.IdCapitulo, capIds)).ToList(); data.Id = string.Empty; var wcr = cl.Insert(data); var gIds = new List <string> (); guias.ForEach(g => { gIds.Add(g.Id); g.IdPlantilla = data.Id; g.Id = string.Empty; }); clGuias.InsertBatch(guias); capitulos.ForEach(c => { c.Id = string.Empty; c.IdPlantilla = data.Id; }); clCapitulos.InsertBatch(capitulos); preguntas.ForEach(p => { var ic = capIds.FindIndex(i => i == p.IdCapitulo); p.IdCapitulo = capitulos[ic].Id; var ng = new List <string>(); p.IdGuias.ForEach(x => { var ig = gIds.FindIndex(i => i == x); ng.Add(guias[ig].Id); }); p.IdGuias = ng; p.Id = string.Empty; }); clPreguntas.InsertBatch(preguntas); return(Store.CreateResult(data, wcr)); }
//Comentario de ejemplo protected void Page_Load(object sender, EventArgs e) { uow = new UnitOfWork(Session["IdUser"].ToString()); if (!IsPostBack) { string M = string.Empty; int idPOADetalle = Request.QueryString["pd"] != null?Utilerias.StrToInt(Request.QueryString["pd"].ToString()) : 0; int idObra = Request.QueryString["ob"] != null?Utilerias.StrToInt(Request.QueryString["ob"].ToString()) : 0; //Se recupera el id del objeto OBRA int ordenPlantilla = Utilerias.StrToInt(Request.QueryString["o"].ToString()); //Se recupera el orden de la plantilla que sera evaluada BindControlesObra(idObra, idPOADetalle); //Se bindean los datos del poadetalle, se pasa como argumento el ID, recuperado de la sesion Plantilla plantilla = uow.PlantillaBusinessLogic.Get(p => p.Orden == ordenPlantilla).FirstOrDefault(); idPOADetalle = Utilerias.StrToInt(_IDPOADetalle.Value); //DEPENDIENDO DE DONDE SE HAYA LLAMADO LA EVALUACION, SE COLOCA EL POADETALLEID POAPlantilla poaPlantilla = uow.POAPlantillaBusinessLogic.Get(pp => pp.PlantillaId == plantilla.Id && pp.POADetalleId == idPOADetalle).FirstOrDefault(); //Se recupera POAPlantilla if (poaPlantilla == null) //Si no existe ningun objeto con la plantilla creada, entonces se procede a clonar la plantilla { M = CopiarPlantilla(plantilla.Id); } else { M = CrearPreguntasInexistentes(poaPlantilla.Id); //Se obtienen todas aquellas preguntas que se pudieron haber creado en las plantillas despues de HABER creado la clonada de plantillas, } //Si hubo errores if (!M.Equals(string.Empty)) { lblMsgImportarPlantilla.Text = M; lblMsgImportarPlantilla.ForeColor = System.Drawing.Color.Red; divMsgImportarPlantilla.Style.Add("display", "block"); return; } //Se carga la informacion de la plantilla clonada BindArbol(treePOAPlantilla); //Se bindea el arbol de las plantillas que se seleccionaron, las que se van a usar if (treePOAPlantilla.Nodes.Count > 0) //Si existen plantillas cargadas, se bindea el grid de preguntas para la primera plantilla { BindGrid(Utilerias.StrToInt(treePOAPlantilla.Nodes[0].Value)); _IDPlantilla.Value = treePOAPlantilla.Nodes[0].Value; treePOAPlantilla.Nodes[0].Selected = true; } _SoloChecks.Value = "true"; //Hidden que indica cuando solo se van a guardar las respuetas de las preguntas (NO, SI, NO APLICA) } //Evento que se ejecuta en JAVASCRIPT para evitar que se 'RESCROLLEE' el arbol al seleccionar un NODO y no se pierda el nodo seleccionado ClientScript.RegisterStartupScript(this.GetType(), "script", "SetSelectedTreeNodeVisible('<%= TreeViewName.ClientID %>_SelectedNode')", true); }
public IHttpActionResult PostPlantilla(Plantilla plantilla) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Plantillas.Add(plantilla); db.SaveChanges(); Plantilla newPlantilla = plantilla; return Ok(newPlantilla); //return CreatedAtRoute("DefaultApi", new { id = plantilla.PlantillaID }, plantilla); }