/// <summary> /// Método que permite insertar /// un nuevo registro en la tabla Proyecto_Entregable /// </summary> /// <param name="po_proyectoEntregable">ProyectoEntregable a insertar</param> /// <returns>Int valor del resultado de la ejecución de la sentencia</returns> public static int insertProyectoEntregable(cls_proyectoEntregable po_proyectoEntregable) { int vi_resultado; try { String vs_comando = "PA_cont_proyecto_entregableInsert"; cls_parameter[] vu_parametros = { new cls_parameter("@paramPK_proyecto", po_proyectoEntregable.pPK_Proyecto), new cls_parameter("@paramPK_entregable", po_proyectoEntregable.pPK_Entregable) }; cls_sqlDatabase.beginTransaction(); vi_resultado = cls_sqlDatabase.executeNonQuery(vs_comando, true, vu_parametros); cls_interface.insertarTransacccionBitacora(cls_constantes.INSERTAR, cls_constantes.PROYECTO_ENTREGABLE, po_proyectoEntregable.pPK_Proyecto + "/" + po_proyectoEntregable.pPK_Entregable); cls_sqlDatabase.commitTransaction(); return vi_resultado; } catch (Exception po_exception) { cls_sqlDatabase.rollbackTransaction(); throw new Exception("Ocurrió un error al insertar los entregables del proyecto.", po_exception); } }
/// <summary> /// Constructor de la clase cls_departamento. /// </summary> public cls_departamentoProyecto() { this.departamento = new cls_departamento(); this.proyecto = new cls_proyecto(); this.proyectoEntregable = new cls_proyectoEntregable(); this.departamentoList = new List<cls_departamento>(); this.proyectoEntregablesList = new List<cls_proyectoEntregable>(); }
/// <summary> /// Evento para la eliminación de un entregable asignado a un proyecto /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_removerEntregable_Click(object sender, EventArgs e) { try { for (int i = lbx_entasociados.Items.Count - 1; i >= 0; i--) { if (lbx_entasociados.Items[i].Selected == true) { cls_entregable vo_entregable = new cls_entregable(); vo_entregable.pPK_entregable = Convert.ToInt32(lbx_entasociados.Items[i].Value.ToString()); vo_entregable.pNombre = lbx_entasociados.Items[i].Text; cls_proyectoEntregable vo_proyectoEntregable = new cls_proyectoEntregable(); vo_proyectoEntregable.pEntregable = vo_entregable; //Se realiza una eliminación de todas las posibles referencias que se presenten a nivel de memoria para el entregable que se está eliminando foreach (cls_entregableComponente entComp in cls_variablesSistema.vs_proyecto.pEntregableComponenteListaMemoria) { if (entComp.pPK_Entregable == vo_entregable.pPK_entregable) { foreach (cls_componentePaquete compPaq in cls_variablesSistema.vs_proyecto.pComponentePaqueteListaMemoria) { if (compPaq.pPK_Entregable == entComp.pPK_Entregable) { foreach (cls_paqueteActividad paqAct in cls_variablesSistema.vs_proyecto.pPaqueteActividadListaMemoria) { if (paqAct.pPK_Entregable == entComp.pPK_Entregable) { cls_variablesSistema.vs_proyecto.pActividadLista.RemoveAll(searchLinQ => searchLinQ.pPK_Actividad == paqAct.pPK_Actividad); } } cls_variablesSistema.vs_proyecto.pPaqueteActividadListaMemoria.RemoveAll(searchLinQ => searchLinQ.pPK_Paquete == compPaq.pPK_Paquete); cls_variablesSistema.vs_proyecto.pPaqueteLista.RemoveAll(searchLinQ => searchLinQ.pPK_Paquete == compPaq.pPK_Paquete); } } cls_variablesSistema.vs_proyecto.pComponentePaqueteListaMemoria.RemoveAll(searchLinQ => searchLinQ.pPK_Componente == entComp.pPK_Componente); cls_variablesSistema.vs_proyecto.pComponenteLista.RemoveAll(searchLinQ => searchLinQ.pPK_componente == entComp.pPK_Componente); } } cls_variablesSistema.vs_proyecto.pEntregableComponenteListaMemoria.RemoveAll(searchLinQ => searchLinQ.pPK_Entregable == vo_entregable.pPK_entregable); cls_variablesSistema.vs_proyecto.pEntregableLista.RemoveAll(searchLinQ => searchLinQ.pPK_entregable == vo_entregable.pPK_entregable); cls_variablesSistema.vs_proyecto.pProyectoEntregableListaMemoria.RemoveAll(searchLinQ => searchLinQ.pPK_Entregable == vo_entregable.pPK_entregable); lbx_entregables.Items.Add(lbx_entasociados.Items[i]); ListItem li = lbx_entasociados.Items[i]; lbx_entasociados.Items.Remove(li); } } //Si luego de desasociar los entregables, si la lista queda vacía, no se puede proseguir hasta que no se realice al menos una asignación if (lbx_entasociados.Items.Count == 0 && cls_variablesSistema.vs_proyecto.pProyectoEntregableListaMemoria.Count == 0) { btnNxt.Enabled = false; } else { btnNxt.Enabled = true; } } catch (Exception po_exception) { String vs_error_usuario = "Ocurrió un error al intentar remover el entregable del proyecto."; this.lanzarExcepcion(po_exception, vs_error_usuario); } }
/// <summary> /// Evento para la asignación de los entregables a un proyecto específico /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_asignarEntregable_Click(object sender, EventArgs e) { try { for (int i = lbx_entregables.Items.Count - 1; i >= 0; i--) { if (lbx_entregables.Items[i].Selected == true) { cls_entregable vo_entregable = new cls_entregable(); vo_entregable.pPK_entregable = Convert.ToInt32(lbx_entregables.Items[i].Value.ToString()); vo_entregable.pNombre = lbx_entregables.Items[i].Text; cls_proyectoEntregable vo_proyectoEntregable = new cls_proyectoEntregable(); vo_proyectoEntregable.pEntregable = vo_entregable; //Si el registro no existe en memoria, se agrega if (!(cls_variablesSistema.vs_proyecto.pProyectoEntregableListaMemoria.Where(searchLinQ => searchLinQ.pPK_Entregable == vo_entregable.pPK_entregable).Count() > 0)) { cls_variablesSistema.vs_proyecto.pEntregableLista.Add(vo_entregable); cls_variablesSistema.vs_proyecto.pProyectoEntregableListaMemoria.Add(vo_proyectoEntregable); } lbx_entasociados.Items.Add(lbx_entregables.Items[i]); ListItem li = lbx_entregables.Items[i]; lbx_entregables.Items.Remove(li); } } //Si hay entregables asociados, se habilita el botón de navegación de siguiente if (lbx_entasociados.Items.Count > 0) { btnNxt.Enabled = true; } } catch (Exception po_exception) { String vs_error_usuario = "Ocurrió un error al intentar asignar el entregable al proyecto."; this.lanzarExcepcion(po_exception, vs_error_usuario); } }
/// <summary> /// Se cargan los entregables que están asociados al proyecto, ya sea por Base de Datos o por memoria /// </summary> private void cargarEntregablesPorProyecto() { DataSet vo_dataSet = new DataSet(); try { if(cls_variablesSistema.vs_proyecto.pProyectoEntregableListaMemoria.Count > 0) { //Si la variable en memoria SI posee algún valor, se va a efectuar una "Actualizacion" al proyecto cls_variablesSistema.tipoEstado = cls_constantes.EDITAR; lbx_entasociados.DataSource = cls_variablesSistema.vs_proyecto.pProyectoEntregableListaMemoria; lbx_entasociados.DataTextField = "pNombreEntregable"; lbx_entasociados.DataValueField = "pPK_Entregable"; } else { vo_dataSet = cls_gestorProyectoEntregable.selectProyectoEntregable(cls_variablesSistema.vs_proyecto); if (vo_dataSet.Tables[0].Rows.Count > 0) { //Si la variable en memoria SI posee algún valor, se va a efectuar una "Actualizacion" al proyecto cls_variablesSistema.tipoEstado = cls_constantes.EDITAR; } else { //Si la variable en memoria NO posee algún valor, se va a efectuar una "Insercion" de proyecto cls_variablesSistema.tipoEstado = cls_constantes.AGREGAR; } //Se recorren los entregables pertenecientes a un proyecto y se asignan en el listbox para los asociados foreach (DataRow row in vo_dataSet.Tables[0].Rows) { cls_entregable vo_entregable = new cls_entregable(); cls_proyectoEntregable vo_proyectoEntregable = new cls_proyectoEntregable(); vo_entregable.pPK_entregable = Convert.ToInt32(row["PK_entregable"]); vo_entregable.pNombre = Convert.ToString(row["nombre"]); vo_proyectoEntregable.pEntregable = vo_entregable; cls_variablesSistema.vs_proyecto.pEntregableLista.Add(vo_entregable); cls_variablesSistema.vs_proyecto.pProyectoEntregableListaMemoria.Add(vo_proyectoEntregable); cls_variablesSistema.vs_proyecto.pProyectoEntregableListaBaseDatos.Add(vo_proyectoEntregable); } lbx_entasociados.DataSource = vo_dataSet; lbx_entasociados.DataTextField = "nombre"; lbx_entasociados.DataValueField = "PK_entregable"; } lbx_entasociados.DataBind(); //Se elimina los entregables ya asociados de la totalidad, para evitar duplicidad en los datos por asignar if (lbx_entasociados.Items.Count > 0) { foreach (ListItem item in lbx_entasociados.Items) { lbx_entregables.Items.Remove(item); } } } catch (Exception po_exception) { throw new Exception("Ocurrió un error al cargar los entregables asociados al proyecto.", po_exception); } }