Ejemplo n.º 1
0
    private void ObtenerDatosAccion()
    {
        if (nIdAccion == -1)
        {
        }
        else
        {
            ACCION o = ACCION.Select(tr, nIdAccion);
            txtIdAccion.Text    = o.t383_idaccion.ToString();
            txtDesAccion.Text   = o.t383_desaccion;
            txtDescripcion.Text = o.t383_desaccionlong;
            if (o.t383_flimite.Year > 1900)
            {
                txtValLim.Text = o.t383_flimite.ToShortDateString();
            }
            //Obtengo la mayor de las fechas de vigencia de sus tareas
            if (o.t383_ffin.Year > 1900)
            {
                txtValFin.Text = o.t383_ffin.ToShortDateString();
            }
            //if (o.t383_avance > 0) txtAvance.Text = o.t383_avance.ToString();
            this.cboAvance.SelectedValue = o.t383_avance.ToString();
            this.cboAvance.Text          = o.t383_avance.ToString();

            this.txtDpto.Text   = o.t383_dpto;
            this.txtAlerta.Text = o.t383_alerta;
            this.txtObs.Text    = o.t383_obs;
        }
    }
Ejemplo n.º 2
0
    protected void btnAccDeshacerCambio_Click(object sender, EventArgs e)
    {
        int iObjetivoId = Convert.ToInt32(this.hdObjetivoId.Value);

        using (Entities c = new Entities())
        {
            try
            {
                ACCION obj = c.CONTENIDO.OfType <ACCION>().Where(o => o.CONTENIDO_ID == iObjetivoId).FirstOrDefault();

                if (obj.TIPO_CAMBIO_CONTENIDO_ID != TIPO_CAMBIO_CONTENIDO.SIN_CAMBIOS)
                {
                    obj.DeshacerCambio(c);
                    SuccessMessage         = "Los cambios pendientes del Objetivo se han cancelado.";
                    successMessage.Visible = true;
                }
                else
                {
                    ErrorMessage         = "No hay ningún cambio que deshacer.";
                    errorMessage.Visible = true;
                }
            }
            catch (Exception ex)
            {
                logger.Fatal("Error al deshacer cambios en Objetivo. Error: " + ex.Message + " " + ex.InnerException);
                Notificaciones.NotifySystemOps(ex);
                ErrorMessage         = "Error al deshacer los cambios del Objetivo.";
                errorMessage.Visible = true;
            }
        }
    }
Ejemplo n.º 3
0
 public void isEnabledAdd()
 {
     this.IsReadOnlyDescripcion = false;
     this.IsEnableSave          = true;
     this.IsEnableUpdate        = false;
     this.IsEnabledDelete       = false;
     this.IsEnableCancel        = true;
     this.accion = ACCION.NUEVO;
 }
Ejemplo n.º 4
0
 public void isEnableUpdate()
 {
     this.accion = ACCION.ACTUALIZAR;
     this.IsReadOnlyDescripcion = false;
     this.IsEnabledAdd          = false;
     this.IsEnabledDelete       = false;
     this.IsEnableUpdate        = false;
     this.IsEnableSave          = true;
     this.IsEnableCancel        = true;
 }
Ejemplo n.º 5
0
 public void isEnabledAdd()
 {
     this.IsReadOnlyName   = false;
     this.IsReadOnlyBudget = false;
     this.IsReadOnlyAdmin  = false;
     this.IsEnableSave     = true;
     this.IsEnableUpdate   = false;
     this.IsEnabledDelete  = false;
     this.IsEnableCancel   = true;
     this.accion           = ACCION.NUEVO;
 }
Ejemplo n.º 6
0
        public void CreaAccion()
        {
            try
            {
                using (Entities c = new Entities())
                {
                    if (u == null)
                    {
                        Inicial();
                    }

                    if (l == null)
                    {
                        CreaLegislatura();
                    }

                    if (d == null)
                    {
                        CreaDepartamento();
                    }

                    if (o == null)
                    {
                        CreaObjetivo();
                    }

                    a = new ACCION()
                    {
                        AUTOR_CREACION           = u,
                        DEPARTAMENTO_ID          = d.DEPARTAMENTO_ID,
                        ESTADO_VALIDACION_ID     = ESTADOS_VALIDACION.PDTE_VALIDAR,
                        FECHA_CREACION           = DateTime.Now,
                        TIPO_CAMBIO_CONTENIDO_ID = TIPO_CAMBIO_CONTENIDO.ALTA,

                        SEGUIMIENTO_PDTE_VAL           = "Objetivo desde Test",
                        COSTE_ECONOMICO_PDTE_VAL       = "COSTE ECON",
                        MEDIOS_OTROS_PDTE_VAL          = "OTROS MEDIOS",
                        TEMPORALIDAD_PDTE_VAL          = "temporalidad",
                        ESTADO_SEGUIMIENTO_ID_PDTE_VAL = ESTADOS_SEGUIMIENTO.INICIADO,
                        INDICADOR_SEGUIMIENTO_PDTE_VAL = "Indicador Seg",
                        INSTRUMENTOS_ACT_PDTE_VAL      = "Inst Act",
                        RECURSOS_HUMANOS_PDTE_VAL      = "rrhh",
                        ORGANO_RESPONSABLE_PDTE_VAL    = "ORG RESP",
                        OBJETIVO = o
                    };
                    c.CONTENIDO.Add(a);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 7
0
    protected void btnEliminaAcc_Click(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(Request["__EVENTARGUMENT"]))
        {
            using (Entities c = new Entities())
            {
                try
                {
                    int    id       = Convert.ToInt32(Request["__EVENTARGUMENT"]);
                    int    iDeptoId = getDptoId();
                    ACCION acc      = c.CONTENIDO.OfType <ACCION>().SingleOrDefault(x => x.CONTENIDO_ID == id);

                    if (acc.TieneAcceso(User.Identity.GetUserId()))
                    {
                        if (acc.YaPublicado())
                        {
                            //Marcamos el cambio como eliminación
                            acc.FECHA_MODIFICACION            = DateTime.Now;
                            acc.AUTOR_MODIFICACION_USUARIO_ID = User.Identity.GetUserId().ToString();
                            acc.TIPO_CAMBIO_CONTENIDO_ID      = TIPO_CAMBIO_CONTENIDO.ELIMINADO;
                            acc.ESTADO_VALIDACION_ID          = ESTADOS_VALIDACION.PDTE_VALIDAR;

                            c.CONTENIDO.Attach(acc);
                            c.Entry(acc).State = EntityState.Modified;
                            c.SaveChanges();

                            SuccessMessage         = "Instrumento/actividad marcado para eliminación (se eliminará en la validación).";
                            successMessage.Visible = true;
                        }
                        else
                        {
                            //Si todavía no ha sido publicado lo eliminamos
                            c.CONTENIDO.Remove(acc);
                            c.SaveChanges();
                            Response.Redirect("AdminPlan?id=" + iDeptoId.ToString() + "&m=" + "Instrumento/actividad eliminado correctamente.", false);
                        }
                    }
                    else
                    {
                        logger.Info("Acceso - AdminPlan.aspx Usuario: " + User.Identity.GetUserId() + " sin permiso de modificación en Acción: " + id.ToString());
                    }
                }
                catch (Exception ex)
                {
                    ErrorMessage         = "Error al eliminar el instrumento/actividad.";
                    errorMessage.Visible = true;
                    logger.Error("ERROR: AdminPlan.aspx Error al eliminar accion " + Request["__EVENTARGUMENT"] + ". Error: " + ex.Message + " " + ex.InnerException);
                    Notificaciones.NotifySystemOps(ex);
                }
            }
        }
    }
    private string obtenerAcciones(string sIdAsunto, string sOrden, string sAscDesc)
    {
        StringBuilder sB = new StringBuilder();
        int           i = 0, nIdAsunto;
        string        sIdAccion, sI, sFecha, sIdResponsable;

        if (sIdAsunto == "")
        {
            return("error@#@Se ha intentado recoger las acciones de un asunto sin código");
        }
        nIdAsunto = int.Parse(sIdAsunto);
        sB.Append("<table id='tblDatos2' class='texto MA' style='width:600px; text-align:left;'>");
        sB.Append("<colgroup><col style='width:380px;' /><col style='width:65px;' /><col style='width:70px;' /><col style='width:85px;' /></colgroup>");
        sB.Append("<tbody>");
        SqlDataReader dr = ACCION.Catalogo(null, nIdAsunto, null, "", null, null, null, byte.Parse(sOrden), byte.Parse(sAscDesc));

        while (dr.Read())
        {
            sIdAccion      = dr["t383_idaccion"].ToString();
            sI             = i.ToString();
            sIdResponsable = dr["t382_responsable"].ToString();
            sB.Append("<tr id='" + sIdAccion + "' style='height:16px;' onclick='ms(this);' ");
            sB.Append("ondblclick=\"mDetAccion(this.id," + sIdAsunto + "," + sIdResponsable + ")\" onmouseover='TTip(event)'>");
            sB.Append("<td style='padding-left:3px;'><nobr class='NBR W370'>" + HttpUtility.HtmlEncode(dr["t383_desaccion"].ToString()) + "</nobr></td>");

            sFecha = dr["t383_flimite"].ToString();
            if (sFecha != "")
            {
                sFecha = DateTime.Parse(dr["t383_flimite"].ToString()).ToShortDateString();
            }
            sB.Append("<td>" + sFecha + "</td>");
            sB.Append("<td style='text-align:right; padding-right:10px;'>" + dr["t383_avance"].ToString() + "</td>");
            sFecha = dr["t383_ffin"].ToString();
            if (sFecha != "")
            {
                sFecha = DateTime.Parse(dr["t383_ffin"].ToString()).ToShortDateString();
            }
            sB.Append("<td>" + sFecha + "</td>");
            sB.Append("</tr>");
            i++;
        }
        dr.Close();
        dr.Dispose();
        sB.Append("</tbody>");
        sB.Append("</table>");
        strTablaHtmlAccion = sB.ToString();
        return("OK@#@" + strTablaHtmlAccion);
    }
    private string borrarAccion(string sIdAccion)
    {
        string sResul;

        try
        {
            if (sIdAccion != "")
            {
                ACCION.Delete(tr, int.Parse(sIdAccion));
            }
            sResul = "OK@#@" + sIdAccion;
        }
        catch (Exception e)
        {
            sResul = "error@#@" + e.Message;
        }
        return(sResul);
    }
Ejemplo n.º 10
0
        public async void delete()
        {
            if (this.SelectTipoEmpaque != null)
            {
                var respuesta = await Mensajes.ShowMessageAsync("Esta seguro de eliminar el registro", "Eliminar",
                                                                MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings
                {
                    AffirmativeButtonText = "Si",
                    NegativeButtonText    = "No",
                    AnimateShow           = true,
                    AnimateHide           = false
                });

                if (respuesta == MessageDialogResult.Affirmative)
                {
                    try
                    {
                        tipoEmpaque.Delete(this.SelectTipoEmpaque);
                        this.TipoEmpaques.Remove(this.SelectTipoEmpaque);
                        borrarCampos();
                        this.IsReadOnlyDescripcion = true;
                        this.accion = ACCION.NINGUNO;
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    this.SelectTipoEmpaque = null;
                    await Mensajes.ShowMessageAsync("Exito", "Registro eliminado Correctamente");
                }

                else
                {
                    await Mensajes.ShowMessageAsync("Eliminar", "No se elimino ningun registro");
                }
            }
            else
            {
                await Mensajes.ShowMessageAsync("Eliminar", "Debe seleccionar un registro");
            }
        }
Ejemplo n.º 11
0
        public void Execute(object parameter)
        {
            if (parameter.Equals("EmailProveedor"))
            {
                EmailProveedorView emailProveedor = new EmailProveedorView();
                emailProveedor.Show();
            }
            else if (parameter.Equals("TelefonoProveedor"))
            {
                TelefonoProveedorView telefonoProveedor = new TelefonoProveedorView();
                telefonoProveedor.Show();
            }
            else if (parameter.Equals("Add"))
            {
                this.IsReadOnlyNit               = false;
                this.IsReadOnlyRazonSocial       = false;
                this.IsReadOnlyDireccion         = false;
                this.IsReadOnlyPaginaWeb         = false;
                this.IsReadOnlyContactoPrincipal = false;
                this.accion            = ACCION.NUEVO;
                this.IsEnabledAdd      = false;
                this.IsEnabledCancel   = true;
                this.IsEnabledDelete   = false;
                this.IsEnabledSave     = true;
                this.IsEnabledUpdate   = false;
                this.nit               = "";
                this.razonSocial       = "";
                this.direccion         = "";
                this.paginaWeb         = "";
                this.contactoPrincipal = "";
            }
            else if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    Proveedores nuevo = new Proveedores();
                    nuevo.nit               = this.nit;
                    nuevo.razonSocial       = this.razonSocial;
                    nuevo.direccion         = this.direccion;
                    nuevo.paginaWeb         = this.paginaWeb;
                    nuevo.contactoPrincipal = this.contactoPrincipal;
                    db.Proveedores.Add(nuevo);
                    db.SaveChanges();
                    this.Proveedores.Add(nuevo);
                    MessageBox.Show("Registro almacenado correctamente");
                    this.IsReadOnlyNit               = true;
                    this.IsReadOnlyRazonSocial       = true;
                    this.IsReadOnlyDireccion         = true;
                    this.IsReadOnlyPaginaWeb         = true;
                    this.IsReadOnlyContactoPrincipal = true;
                    this.IsEnabledAdd      = true;
                    this.IsEnabledCancel   = true;
                    this.IsEnabledDelete   = true;
                    this.IsEnabledSave     = true;
                    this.IsEnabledUpdate   = true;
                    this.nit               = "";
                    this.razonSocial       = "";
                    this.direccion         = "";
                    this.paginaWeb         = "";
                    this.contactoPrincipal = "";
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        int posicion          = this.Proveedores.IndexOf(this.SelectProveedores);
                        var updateProveedores = this.db.Proveedores.Find(this.SelectProveedores.codigoProveedor);
                        updateProveedores.nit                  = this.nit;
                        updateProveedores.razonSocial          = this.razonSocial;
                        updateProveedores.direccion            = this.direccion;
                        updateProveedores.paginaWeb            = this.paginaWeb;
                        updateProveedores.contactoPrincipal    = this.contactoPrincipal;
                        this.db.Entry(updateProveedores).State = System.Data.Entity.EntityState.Modified;
                        this.db.SaveChanges();
                        this.Proveedores.RemoveAt(posicion);
                        this.Proveedores.Insert(posicion, updateProveedores);
                        MessageBox.Show("Registro actualizado");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SelectProveedores != null)
                {
                    var respuesta = MessageBox.Show("¿Está seguro de eliminar el registro?", "Eliminar", MessageBoxButton.YesNo);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.Proveedores.Remove(this.SelectProveedores);
                            db.SaveChanges();
                            this.Proveedores.Remove(this.SelectProveedores);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("Registro eliminado correctamente");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else if (parameter.Equals("Update"))
            {
                this.accion                      = ACCION.ACTUALIZAR;
                this.IsReadOnlyNit               = false;
                this.IsReadOnlyRazonSocial       = false;
                this.IsReadOnlyDireccion         = false;
                this.IsReadOnlyPaginaWeb         = false;
                this.IsReadOnlyContactoPrincipal = false;
            }
            else if (parameter.Equals("Cancel"))
            {
                this.IsReadOnlyNit               = true;
                this.IsReadOnlyRazonSocial       = true;
                this.IsReadOnlyDireccion         = true;
                this.IsReadOnlyPaginaWeb         = true;
                this.IsReadOnlyContactoPrincipal = true;
                this.IsEnabledAdd      = true;
                this.IsEnabledCancel   = true;
                this.IsEnabledDelete   = true;
                this.IsEnabledSave     = true;
                this.IsEnabledUpdate   = true;
                this.nit               = "";
                this.razonSocial       = "";
                this.direccion         = "";
                this.paginaWeb         = "";
                this.contactoPrincipal = "";
            }
        }
        public void Execute(object parameter)        //ejecuta evento
        {
            if (parameter.Equals("Agregar"))
            {
                this.IsReadOnlyDescripcion = false;
                this.accion             = ACCION.NUEVO;
                this.IsEnableAgregar    = false;
                this.IsEnableEliminar   = false;
                this.IsEnableActualizar = false;
                this.IsEnableCancelar   = true;
                this.IsEnableGuardar    = true;
            }
            if (parameter.Equals("Guardar"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    Categoria nuevo = new Categoria();
                    nuevo.Descripcion = this.Descripcion;
                    db.Categorias.Add(nuevo);
                    db.SaveChanges();
                    this.Categorias.Add(nuevo);
                    MessageBox.Show("Registro Almacenado");
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        int posicion        = this.Categorias.IndexOf(this.SelectCategoria);
                        var updateCategoria = this.db.Categorias.Find(this.SelectCategoria.CodigoCategoria);
                        updateCategoria.Descripcion          = this.Descripcion;
                        this.db.Entry(updateCategoria).State = EntityState.Modified;
                        this.db.SaveChanges();
                        this.Categorias.RemoveAt(posicion);
                        this.Categorias.Insert(posicion, updateCategoria);
                        MessageBox.Show("Registro Actualizado!!!");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
                this.IsEnableAgregar       = true;
                this.IsEnableEliminar      = true;
                this.IsEnableActualizar    = true;
                this.IsEnableCancelar      = false;
                this.IsEnableGuardar       = false;
                this.IsReadOnlyDescripcion = true;
            }

            else if (parameter.Equals("Actualizar"))
            {
                this.accion = ACCION.ACTUALIZAR;
                this.IsReadOnlyDescripcion = false;
                this.IsEnableAgregar       = false;
                this.IsEnableEliminar      = false;
                this.IsEnableActualizar    = false;
                this.IsEnableCancelar      = true;
                this.IsEnableGuardar       = true;
            }
            else if (parameter.Equals("Eliminar"))
            {
                if (this.SelectCategoria != null)
                {
                    var respuesta = MessageBox.Show("Esta seguro de eliminar el registo?", "Eliminar", MessageBoxButton.YesNo);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.Categorias.Remove(this.SelectCategoria);
                            db.SaveChanges();
                            this.Categorias.Remove(this.SelectCategoria);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }

                        MessageBox.Show("Registro eliminado correctamente!!");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else if (parameter.Equals("Cancelar"))
            {
                this.IsEnableAgregar        = true;
                this.IsEnableEliminar       = true;
                this.IsEnableActualizar     = true;
                this.IsEnableCancelar       = false;
                this.IsEnableGuardar        = false;
                this._IsReadOnlyDescripcion = true;
            }
        }
        public void Execute(object parameter)
        {
            if (parameter.Equals("Add"))
            {
                this.IsReadOnlyEmail = false;
                this.IsReadOnlyNit   = false;
                this.accion          = ACCION.NUEVO;
                this.IsEnabledAdd    = false;
                this.IsEnabledCancel = true;
                this.IsEnabledDelete = false;
                this.IsEnabledSave   = true;
                this.IsEnabledUpdate = false;
                this.email           = "";
                this.nit             = "";
            }
            else if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    EmailCliente nuevo = new EmailCliente();
                    nuevo.email = this.email;
                    nuevo.nit   = this.nit;
                    db.EmailClientes.Add(nuevo);
                    db.SaveChanges();
                    this.EmailClientes.Add(nuevo);
                    MessageBox.Show("Registro almacenado correctamente");
                    this.IsReadOnlyEmail = true;
                    this.IsReadOnlyNit   = true;
                    this.IsEnabledAdd    = true;
                    this.IsEnabledCancel = true;
                    this.IsEnabledDelete = true;
                    this.IsEnabledSave   = true;
                    this.IsEnabledUpdate = true;
                    this.email           = "";
                    this.nit             = "";
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        int posicion    = this.EmailClientes.IndexOf(this.SelectEmailCliente);
                        var updateEmail = this.db.EmailClientes.Find(this.SelectEmailCliente.codigoEmail);
                        updateEmail.email = this.email;
                        updateEmail.nit   = this.nit;
                        this.db.Entry(updateEmail).State = System.Data.Entity.EntityState.Modified;
                        this.db.SaveChanges();
                        this.EmailClientes.RemoveAt(posicion);
                        this.EmailClientes.Insert(posicion, updateEmail);
                        MessageBox.Show("Registro actualizado");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SelectEmailCliente != null)
                {
                    var respuesta = MessageBox.Show("¿Está seguro de eliminar el registro?", "Eliminar", MessageBoxButton.YesNo);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.EmailClientes.Remove(this.SelectEmailCliente);
                            db.SaveChanges();
                            this.EmailClientes.Remove(this.SelectEmailCliente);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("Registro eliminado correctamente");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else if (parameter.Equals("Update"))
            {
                this.accion          = ACCION.ACTUALIZAR;
                this.IsReadOnlyNit   = false;
                this.IsReadOnlyEmail = false;
            }
            else if (parameter.Equals("Cancel"))
            {
                this.IsReadOnlyNit   = true;
                this.IsReadOnlyEmail = true;
                this.IsEnabledAdd    = true;
                this.IsEnabledCancel = true;
                this.IsEnabledDelete = true;
                this.IsEnabledSave   = true;
                this.IsEnabledUpdate = true;
                this.nit             = "";
                this.email           = "";
            }
        }
        public void Execute(object parameter)
        {
            if (parameter.Equals("Add"))
            {
                this.IsReadOnlyCodigoCategoria = false;
                this.IsReadOnlyCodigoEmpaque   = false;
                this.IsReadOnlyDescripcion     = false;
                this.IsReadOnlyPrecioUnitario  = false;
                this.IsReadOnlyPrecioPorDocena = false;
                this.IsReadOnlyPrecioPorMayor  = false;
                this.IsReadOnlyExistencia      = false;
                this.IsReadOnlyImagen          = false;
                this.accion = ACCION.NUEVO;
            }
            if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    Producto nuevo = new Producto();
                    nuevo.CodigoCategoria = Convert.ToInt16(this.CodigoCategoria);
                    nuevo.CodigoEmpaque   = Convert.ToInt16(this.CodigoEmpaque);
                    nuevo.Descripcion     = this.Descripcion;
                    nuevo.PrecioUnitario  = Convert.ToDecimal(this.PrecioUnitario);
                    nuevo.PrecioPorDocena = Convert.ToDecimal(this.PrecioPorDocena);
                    nuevo.PrecioPorMayor  = Convert.ToDecimal(this.PrecioUnitario);
                    nuevo.Existencia      = Convert.ToInt32(this.Existencia);
                    nuevo.Imagen          = this.Imagen;
                    db.Productos.Add(nuevo);
                    db.SaveChanges();
                    this.Productos.Add(nuevo);
                    MessageBox.Show("Registro Almacenado");
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        int posicion       = this.Productos.IndexOf(this.SeleccionarProducto);
                        var updateProducto = this.db.Productos.Find(this.SeleccionarProducto.CodigoProducto);
                        updateProducto.CodigoCategoria      = Convert.ToInt16(this.CodigoCategoria);
                        updateProducto.CodigoEmpaque        = Convert.ToInt16(this.CodigoEmpaque);
                        updateProducto.Descripcion          = this.Descripcion;
                        updateProducto.PrecioUnitario       = Convert.ToDecimal(this.PrecioUnitario);
                        updateProducto.PrecioPorDocena      = Convert.ToDecimal(this.PrecioPorDocena);
                        updateProducto.PrecioPorMayor       = Convert.ToDecimal(this.PrecioUnitario);
                        updateProducto.Existencia           = Convert.ToInt32(this.Existencia);
                        updateProducto.Imagen               = this.Imagen;
                        this.db.Entry(updateProducto).State = EntityState.Modified;
                        this.db.SaveChanges();
                        this.Productos.RemoveAt(posicion);
                        this.Productos.Insert(posicion, updateProducto);
                        MessageBox.Show("Registro Actualizado!!!");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SeleccionarProducto != null)
                {
                    var respuesta = MessageBox.Show("Esta seguro de eliminar el registro?", "Eliminar", MessageBoxButton.YesNo);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.Productos.Remove(this.SeleccionarProducto);
                            db.SaveChanges();
                            this.Productos.Remove(this.SeleccionarProducto);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("Registro eliminado correctamente!!!");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
        public void Execute(object parameter)
        {
            if (parameter.Equals("Add"))
            {
                this.IsReadOnlyIdCompra       = false;
                this.IsReadOnlyCodigoProducto = false;
                this.IsReadOnlyCantidad       = false;
                this.IsReadOnlyPrecio         = false;
                this.accion = ACCION.NUEVO;
            }
            if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:

                    DetalleCompra nuevo = new DetalleCompra();
                    nuevo.IdCompra       = Convert.ToInt32(this.IdCompra);
                    nuevo.CodigoProducto = Convert.ToInt32(this.CodigoProducto);
                    nuevo.Cantidad       = Convert.ToInt16(this.Cantidad);
                    nuevo.Precio         = Convert.ToDecimal(this.Precio);
                    db.DetalleCompras.Add(nuevo);
                    db.SaveChanges();
                    this.DetalleCompras.Add(nuevo);
                    MessageBox.Show("Registro Almacenado");
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        int posicion            = this.DetalleCompras.IndexOf(this.SeleccionarDetalleCompra);
                        var updateDetalleCompra = this.db.DetalleCompras.Find(this.SeleccionarDetalleCompra.IdDetalle);
                        updateDetalleCompra.IdCompra             = Convert.ToInt16(this.IdCompra);
                        updateDetalleCompra.CodigoProducto       = Convert.ToInt16(this.CodigoProducto);
                        updateDetalleCompra.Cantidad             = Convert.ToInt16(this.Cantidad);
                        updateDetalleCompra.Precio               = Convert.ToDecimal(this.Precio);
                        this.db.Entry(updateDetalleCompra).State = EntityState.Modified;
                        this.db.SaveChanges();
                        this.DetalleCompras.RemoveAt(posicion);
                        this.DetalleCompras.Insert(posicion, updateDetalleCompra);
                        MessageBox.Show("Registro Actualizado!!!");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SeleccionarDetalleCompra != null)
                {
                    var respuesta = MessageBox.Show("Esta seguro de eliminar el registro?", "Eliminar", MessageBoxButton.YesNo);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.DetalleCompras.Remove(this.SeleccionarDetalleCompra);
                            db.SaveChanges();
                            this.DetalleCompras.Remove(this.SeleccionarDetalleCompra);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("Registro eliminado correctamente!!!");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Ejemplo n.º 16
0
        public async void Execute(object control)
        {
            if (control.Equals("Nuevo"))
            {
                LimpiarCampos();
                ActivarControles();
                this._accion = ACCION.NUEVO;
            }
            else if (control.Equals("Eliminar"))
            {
                if (Elemento != null)
                {
                    MessageDialogResult resultado = await this._dialogCoordinator.ShowMessageAsync(
                        this,
                        "Eliminar Profesor",
                        "Esta seguro de eliminar el registro?",
                        MessageDialogStyle.AffirmativeAndNegative);

                    if (resultado == MessageDialogResult.Affirmative)
                    {
                        try
                        {
                            _db.Clases.Remove(Elemento);
                            _db.SaveChanges();
                            this.ListaClases.Remove(Elemento);
                            LimpiarCampos();
                        }
                        catch (Exception ex)
                        {
                            await this._dialogCoordinator.ShowMessageAsync(
                                this,
                                "Eliminar Clase",
                                ex.Message);
                        }
                    }
                }
                else
                {
                    await this._dialogCoordinator.ShowMessageAsync(
                        this,
                        "Eliminar Clase",
                        "Debe seleccionar un elemento");
                }
            }
            else if (control.Equals("Guardar"))
            {
                switch (this._accion)
                {
                case ACCION.NINGUNO:
                    break;

                case ACCION.NUEVO:
                    try
                    {
                        var registro = new Clase
                        {
                            Nombre         = this.Nombre,
                            FechaCreacion  = this.FechaCreacion,
                            HoraInicio     = this.HoraInicio,
                            HoraFin        = this.HoraFin,
                            FechaInicio    = this.FechaInicio,
                            FechaFinal     = this.FechaFinal,
                            Salon          = this.SalonSeleccionado,
                            GrupoAcademico = this.GrupoAcademicoSeleccionado,
                            Profesor       = this.ProfesorSeleccionado,
                            Curso          = this.CursoSeleccionado
                        };

                        _db.Clases.Add(registro);
                        _db.SaveChanges();
                        this.ListaClases.Add(registro);
                    }
                    catch (Exception ex)
                    {
                        await this._dialogCoordinator.ShowMessageAsync(
                            this,
                            "Guardar Clase",
                            ex.Message);
                    }
                    finally
                    {
                        DesactivarControles();
                        this._accion = ACCION.NINGUNO;
                    }
                    break;

                case ACCION.GUARDAR:
                    try
                    {
                        int posicion = ListaClases.IndexOf(Elemento);
                        var registro = _db.Clases.Find(Elemento.ClaseId);

                        if (registro != null)
                        {
                            registro.Nombre           = this.Nombre;
                            registro.FechaCreacion    = this.FechaCreacion;
                            registro.HoraInicio       = this.HoraInicio;
                            registro.HoraFin          = this.HoraFin;
                            registro.FechaInicio      = this.FechaInicio;
                            registro.FechaFinal       = this.FechaFinal;
                            registro.Salon            = this.SalonSeleccionado;
                            registro.GrupoAcademico   = this.GrupoAcademicoSeleccionado;
                            registro.Profesor         = this.ProfesorSeleccionado;
                            registro.Curso            = this.CursoSeleccionado;
                            _db.Entry(registro).State = EntityState.Modified;
                            _db.SaveChanges();
                            ListaClases.RemoveAt(posicion);
                            ListaClases.Insert(posicion, registro);
                        }
                    }
                    catch (Exception ex)
                    {
                        await this._dialogCoordinator.ShowMessageAsync(
                            this,
                            "Editar Clase",
                            ex.Message);
                    }
                    finally
                    {
                        DesactivarControles();
                        this._accion = ACCION.NINGUNO;
                    }
                    break;

                default:
                    break;
                }
            }
            else if (control.Equals("Editar"))
            {
                if (Elemento != null)
                {
                    ActivarControles();
                    this._accion = ACCION.GUARDAR;
                }
                else
                {
                    await this._dialogCoordinator.ShowMessageAsync(
                        this,
                        "Editar Clase",
                        "Debe seleccionar un elemento");
                }
            }
            else if (control.Equals("Cancelar"))
            {
                DesactivarControles();
                this._accion = ACCION.NINGUNO;
            }
        }
Ejemplo n.º 17
0
        public void Execute(object parameter)
        {
            if (parameter.Equals("Add"))
            {
                this.IsReadOnlyCodigoCategoria = false;
                this.IsReadOnlyTipoEmpaque     = false;
                this.IsReadOnlyDescripcion     = false;
                this.IsReadOnlyExistencia      = false;
                this.IsReadOnlyImagen          = false;
                this.IsReadOnlyPrecioPorDocena = false;
                this.IsReadOnlyPrecioPorMayor  = false;
                this.IsReadOnlyPrecioUnitario  = false;
                this.accion          = ACCION.NUEVO;
                this.IsEnabledAdd    = false;
                this.IsEnabledCancel = true;
                this.IsEnabledDelete = false;
                this.IsEnabledSave   = true;
                this.IsEnabledUpdate = false;
                this.descripcion     = "";
                this.precioUnitario  = 0;
                this.precioPorMayor  = 0;
                this.precioPorDocena = 0;
                this.existencia      = 0;
                this.imagen          = "";
            }
            else if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    Productos nuevo = new Productos();
                    nuevo.codigoCategoria = this.codigoCategoria;
                    nuevo.codigoEmpaque   = this.codigoEmpaque;
                    nuevo.descripcion     = this.descripcion;
                    nuevo.precioUnitario  = this.precioUnitario;
                    nuevo.precioPorMayor  = this.precioPorMayor;
                    nuevo.precioPorDocena = this.precioPorDocena;
                    nuevo.existencia      = this.existencia;
                    nuevo.imagen          = this.imagen;
                    db.Productos.Add(nuevo);
                    db.SaveChanges();
                    this.Productos.Add(nuevo);
                    MessageBox.Show("Registro almacenado correctamente", "Exito", MessageBoxButton.OK, MessageBoxImage.None);
                    this.IsReadOnlyCodigoCategoria = true;
                    this.IsReadOnlyTipoEmpaque     = true;
                    this.IsReadOnlyPrecioUnitario  = true;
                    this.IsReadOnlyPrecioPorMayor  = true;
                    this.IsReadOnlyPrecioPorDocena = true;
                    this.IsReadOnlyDescripcion     = true;
                    this.IsReadOnlyExistencia      = true;
                    this.IsReadOnlyImagen          = true;
                    this.descripcion     = "";
                    this.imagen          = "";
                    this.precioPorDocena = 0;
                    this.precioPorMayor  = 0;
                    this.precioUnitario  = 0;
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        int posicion        = this.Productos.IndexOf(this.SelectProductos);
                        var updateProductos = this.db.Productos.Find(this.SelectProductos.codigoProducto);
                        updateProductos.codigoCategoria      = this.codigoCategoria;
                        updateProductos.codigoEmpaque        = this.codigoEmpaque;
                        updateProductos.descripcion          = this.descripcion;
                        updateProductos.precioPorDocena      = this.precioPorDocena;
                        updateProductos.precioPorMayor       = this.precioPorMayor;
                        updateProductos.precioUnitario       = this.precioUnitario;
                        updateProductos.existencia           = this.existencia;
                        updateProductos.imagen               = this.imagen;
                        this.db.Entry(updateProductos).State = System.Data.Entity.EntityState.Modified;
                        this.db.SaveChanges();
                        this.Productos.RemoveAt(posicion);
                        this.Productos.Insert(posicion, updateProductos);
                        MessageBox.Show("Registro actualizado correctamente");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SelectProductos != null)
                {
                    var respuesta = MessageBox.Show("¿Está seguro de eliminar el registro?", "Eliminar", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.Productos.Remove(this.SelectProductos);
                            db.SaveChanges();
                            this.Productos.Remove(this.SelectProductos);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("Registro eliminado correctamente");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                }
            }
            else if (parameter.Equals("Update"))
            {
                this.accion = ACCION.ACTUALIZAR;
                this.IsReadOnlyCodigoCategoria = false;
                this.IsReadOnlyDescripcion     = false;
                this.IsReadOnlyExistencia      = false;
                this.IsReadOnlyImagen          = false;
                this.IsReadOnlyPrecioPorDocena = false;
                this.IsReadOnlyPrecioPorMayor  = false;
                this.IsReadOnlyPrecioUnitario  = false;
                this.IsReadOnlyTipoEmpaque     = false;
            }
            else if (parameter.Equals("Cancel"))
            {
                this.IsReadOnlyCodigoCategoria = true;
                this.IsReadOnlyDescripcion     = true;
                this.IsReadOnlyExistencia      = true;
                this.IsReadOnlyImagen          = true;
                this.IsReadOnlyPrecioPorDocena = true;
                this.IsReadOnlyPrecioPorMayor  = true;
                this.IsReadOnlyPrecioUnitario  = true;
                this.IsReadOnlyTipoEmpaque     = true;
            }
        }
Ejemplo n.º 18
0
        public void Execute(object parameter)
        {
            if (parameter.Equals("EmailClientes"))
            {
                EmailClientesView email = new EmailClientesView();
                email.Show();
            }
            else if (parameter.Equals("TelefonoClientes"))
            {
                TelefonoClientesView telefono = new TelefonoClientesView();
                telefono.Show();
            }
            else if (parameter.Equals("Add"))
            {
                this.IsReadOnlyNit       = false;
                this.IsReadOnlyDPI       = false;
                this.IsReadOnlyNombre    = false;
                this.IsReadOnlyDireccion = false;
                this.accion          = ACCION.NUEVO;
                this.IsEnabledAdd    = false;
                this.IsEnabledCancel = true;
                this.IsEnabledDelete = false;
                this.IsEnabledSave   = true;
                this.IsEnabledUpdate = false;
                this.nit             = "";
                this.dpi             = "";
                this.nombre          = "";
                this.direccion       = "";
            }
            else if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    Clientes nuevo = new Clientes();
                    nuevo.nit       = this.nit;
                    nuevo.DPI       = this.dpi;
                    nuevo.nombre    = this.nombre;
                    nuevo.direccion = this.direccion;
                    db.Clientes.Add(nuevo);
                    db.SaveChanges();
                    this.Clientes.Add(nuevo);
                    MessageBox.Show("Registro almacenado correctamente");
                    this.IsReadOnlyNit       = true;
                    this.IsReadOnlyDPI       = true;
                    this.IsReadOnlyNombre    = true;
                    this.IsReadOnlyDireccion = true;
                    this.IsEnabledAdd        = true;
                    this.IsEnabledCancel     = true;
                    this.IsEnabledDelete     = true;
                    this.IsEnabledSave       = true;
                    this.IsEnabledUpdate     = true;
                    this.nit       = "";
                    this.dpi       = "";
                    this.nombre    = "";
                    this.direccion = "";
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        if (SelectCliente != null)
                        {
                            int posicion       = this.Clientes.IndexOf(this.SelectCliente);
                            var updateClientes = this.db.Clientes.Find(this.SelectCliente.nit);
                            updateClientes.nit                  = this.nit;
                            updateClientes.DPI                  = this.dpi;
                            updateClientes.nombre               = this.nombre;
                            updateClientes.direccion            = this.direccion;
                            this.db.Entry(updateClientes).State = System.Data.Entity.EntityState.Modified;
                            this.db.SaveChanges();
                            this.Clientes.RemoveAt(posicion);
                            this.Clientes.Insert(posicion, updateClientes);
                            MessageBox.Show("Registro actualizado");
                        }
                        else
                        {
                            MessageBox.Show("Debe seleccionar un dato para poder actualizar");
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SelectCliente != null)
                {
                    var respuesta = MessageBox.Show("¿Está seguro de eliminar el registro?", "Eliminar", MessageBoxButton.YesNo);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.Clientes.Remove(this.SelectCliente);
                            db.SaveChanges();
                            this.Clientes.Remove(this.SelectCliente);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("Registro eliminado correctamente");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else if (parameter.Equals("Update"))
            {
                this.accion              = ACCION.ACTUALIZAR;
                this.IsReadOnlyNit       = false;
                this.IsReadOnlyDPI       = false;
                this.IsReadOnlyNombre    = false;
                this.IsReadOnlyDireccion = false;
            }
            else if (parameter.Equals("Cancel"))
            {
                this.IsReadOnlyNit       = true;
                this.IsReadOnlyDPI       = true;
                this.IsReadOnlyNombre    = true;
                this.IsReadOnlyDireccion = true;
                this.IsEnabledAdd        = true;
                this.IsEnabledCancel     = true;
                this.IsEnabledDelete     = true;
                this.IsEnabledSave       = true;
                this.IsEnabledUpdate     = true;
                this.nit       = "";
                this.dpi       = "";
                this.nombre    = "";
                this.direccion = "";
            }
        }
        public void Execute(object parameter)
        {
            if (parameter.Equals("Add"))
            {
                this.IsReadOnlyCodigoProducto = false;
                this.IsReadOnlyFecha          = false;
                this.IsReadOnlyTipoRegistro   = false;
                this.IsReadOnlyPrecio         = false;
                this.IsReadOnlyEntradas       = false;
                this.IsReadOnlySalidas        = false;
                this.accion = ACCION.NUEVO;
            }
            if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    Inventario nuevo = new Inventario();
                    nuevo.CodigoProducto = Convert.ToInt16(this.CodigoProducto);
                    nuevo.Fecha          = DateTime.Now;
                    nuevo.TipoRegistro   = this.TipoRegistro;
                    nuevo.Precio         = Convert.ToDecimal(this.Precio);
                    nuevo.Entradas       = Convert.ToInt16(this.Entradas);
                    nuevo.Salidas        = Convert.ToInt16(this.Salidas);
                    db.Inventarios.Add(nuevo);
                    db.SaveChanges();
                    this.Inventarios.Add(nuevo);
                    MessageBox.Show("Registro Almacenado");
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        int posicion         = this.Inventarios.IndexOf(this.SeleccionarInventario);
                        var updateInventario = this.db.Inventarios.Find(this.SeleccionarInventario.CodigoInventario);
                        updateInventario.CodigoProducto       = Convert.ToInt16(this.CodigoProducto);
                        updateInventario.Fecha                = Convert.ToDateTime(this.Fecha);
                        updateInventario.TipoRegistro         = this.TipoRegistro;
                        updateInventario.Precio               = Convert.ToDecimal(this.Precio);
                        updateInventario.Entradas             = Convert.ToInt16(this.Entradas);
                        updateInventario.Salidas              = Convert.ToInt16(this.Salidas);
                        this.db.Entry(updateInventario).State = EntityState.Modified;
                        this.db.SaveChanges();
                        this.Inventarios.RemoveAt(posicion);
                        this.Inventarios.Insert(posicion, updateInventario);
                        MessageBox.Show("Registro Actualizado!!!");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SeleccionarInventario != null)
                {
                    var respuesta = MessageBox.Show("Esta seguro de eliminar el registro?", "Eliminar", MessageBoxButton.YesNo);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.Inventarios.Remove(this.SeleccionarInventario);
                            db.SaveChanges();
                            this.Inventarios.Remove(this.SeleccionarInventario);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("Registro eliminado correctamente!!!");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Ejemplo n.º 20
0
        public async void Execute(object control)
        {
            if (control.Equals("Nuevo"))
            {
                LimpiarCampos();
                ActivarControles();
                this._accion = ACCION.NUEVO;
            }
            else if (control.Equals("Eliminar"))
            {
                if (Elemento != null)
                {
                    MessageDialogResult resultado = await this._dialogCoordinator.ShowMessageAsync(
                        this,
                        "Eliminar Puesto",
                        "Esta seguro de eliminar el registro?",
                        MessageDialogStyle.AffirmativeAndNegative);

                    if (resultado == MessageDialogResult.Affirmative)
                    {
                        try
                        {
                            _db.Puestos.Remove(Elemento);
                            _db.SaveChanges();
                            this.ListaPuestos.Remove(Elemento);
                            LimpiarCampos();
                        }
                        catch (Exception ex)
                        {
                            await this._dialogCoordinator.ShowMessageAsync(
                                this,
                                "Eliminar Puesto",
                                ex.Message);
                        }
                    }
                }
                else
                {
                    await this._dialogCoordinator.ShowMessageAsync(
                        this,
                        "Eliminar Puesto",
                        "Debe seleccionar un elemento");
                }
            }
            else if (control.Equals("Guardar"))
            {
                switch (this._accion)
                {
                case ACCION.NINGUNO:
                    break;

                case ACCION.NUEVO:
                    try
                    {
                        var registro = new Puesto
                        {
                            Descripcion = this.Descripcion
                        };

                        _db.Puestos.Add(registro);
                        _db.SaveChanges();
                        this.ListaPuestos.Add(registro);
                    }
                    catch (Exception ex)
                    {
                        await this._dialogCoordinator.ShowMessageAsync(
                            this,
                            "Guardar Puesto",
                            ex.Message);
                    }
                    finally
                    {
                        DesactivarControles();
                        this._accion = ACCION.NINGUNO;
                    }
                    break;

                case ACCION.GUARDAR:
                    try
                    {
                        int posicion = ListaPuestos.IndexOf(Elemento);
                        var registro = _db.Puestos.Find(Elemento.PuestoId);

                        if (registro != null)
                        {
                            registro.Descripcion      = this.Descripcion;
                            _db.Entry(registro).State = EntityState.Modified;
                            _db.SaveChanges();
                            ListaPuestos.RemoveAt(posicion);
                            ListaPuestos.Insert(posicion, registro);
                        }
                    }
                    catch (Exception ex)
                    {
                        await this._dialogCoordinator.ShowMessageAsync(
                            this,
                            "Editar Puesto",
                            ex.Message);
                    }
                    finally
                    {
                        DesactivarControles();
                        this._accion = ACCION.NINGUNO;
                    }
                    break;

                default:
                    break;
                }
            }
            else if (control.Equals("Editar"))
            {
                if (Elemento != null)
                {
                    ActivarControles();
                    this._accion = ACCION.GUARDAR;
                }
                else
                {
                    await this._dialogCoordinator.ShowMessageAsync(
                        this,
                        "Editar Puesto",
                        "Debe seleccionar un elemento");
                }
            }
        }
Ejemplo n.º 21
0
        public void Execute(object parameter)
        {
            if (parameter.Equals("Add"))
            {
                this.IsReadOnlyNumero          = false;
                this.IsReadOnlyDescripcion     = false;
                this.IsReadOnlyCodigoProveedor = false;
                this.accion = ACCION.NUEVO;
            }
            if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    TelefonoProveedor nuevo = new TelefonoProveedor();
                    nuevo.Numero          = this.Numero;
                    nuevo.Descripcion     = this.Descripcion;
                    nuevo.CodigoProveedor = Convert.ToInt16(this.CodigoProveedor);
                    db.TelefonoProveedores.Add(nuevo);
                    db.SaveChanges();
                    this.TelefonoProveedores.Add(nuevo);
                    MessageBox.Show("Registro Almacenado");
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        int posicion = this.TelefonoProveedores.IndexOf(this.SeleccionarTelefonoProveedor);
                        var updateTelefonoProveedor = this.db.TelefonoProveedores.Find(this.SeleccionarTelefonoProveedor.CodigoTelefono);
                        updateTelefonoProveedor.Numero               = this.Numero;
                        updateTelefonoProveedor.Descripcion          = this.Descripcion;
                        updateTelefonoProveedor.CodigoProveedor      = Convert.ToInt16(this.CodigoProveedor);
                        this.db.Entry(updateTelefonoProveedor).State = EntityState.Modified;
                        this.db.SaveChanges();
                        this.TelefonoProveedores.RemoveAt(posicion);
                        this.TelefonoProveedores.Insert(posicion, updateTelefonoProveedor);
                        MessageBox.Show("Registro Actualizado!!!");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SeleccionarTelefonoProveedor != null)
                {
                    var respuesta = MessageBox.Show("Esta seguro de eliminar el registro?", "Eliminar", MessageBoxButton.YesNo);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.TelefonoProveedores.Remove(this.SeleccionarTelefonoProveedor);
                            db.SaveChanges();
                            this.TelefonoProveedores.Remove(this.SeleccionarTelefonoProveedor);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("Registro eliminado correctamente!!!");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Ejemplo n.º 22
0
        public async void Execute(object parametro)
        {
            if (parametro.Equals("Nuevo"))
            {
                this._accion = ACCION.NUEVO;
                this.ElementoSeleccionado = new Alumno();
                this.IsNuevo             = false;
                this.IsEliminar          = false;
                this.IsModificar         = false;
                this.IsGuardar           = true;
                this.IsCancelar          = true;
                this.IsReadOnlyCarne     = false;
                this.IsReadOnlyApellidos = false;
                this.IsReadOnlyNombres   = false;
                this.IsFechaNacimiento   = true;
            }
            else if (parametro.Equals("Modificar"))
            {
                if (this.ElementoSeleccionado != null)
                {
                    this._accion             = ACCION.MODIFICAR;
                    this.IsNuevo             = false;
                    this.IsEliminar          = false;
                    this.IsModificar         = false;
                    this.IsGuardar           = true;
                    this.IsCancelar          = true;
                    this.IsReadOnlyApellidos = false;
                    this.IsReadOnlyNombres   = false;
                    this.IsFechaNacimiento   = true;
                    this.Posicion            = this.ListaAlumno.IndexOf(this.ElementoSeleccionado);
                    this.Update                 = new Alumno();
                    this.Update.AlumnoId        = this.ElementoSeleccionado.AlumnoId;
                    this.Update.Carne           = this.ElementoSeleccionado.Carne;
                    this.Update.Apellidos       = this.ElementoSeleccionado.Apellidos;
                    this.Update.Nombres         = this.ElementoSeleccionado.Nombres;
                    this.Update.FechaNacimiento = this.ElementoSeleccionado.FechaNacimiento;
                }
                else
                {
                    await this.dialogCoordinator.ShowMessageAsync(this, "Alumno",
                                                                  "Debe seleccionar un elemento");
                }
            }
            else if (parametro.Equals("Guardar"))
            {
                switch (this._accion)
                {
                case ACCION.NUEVO:
                    try
                    {
                        Religion r = this.dbContext.Religiones.Find(1);        // Select * from Religiones where ReligionId = 1
                        this.ElementoSeleccionado.Religion = r;
                        this.dbContext.Alumnos.Add(this.ElementoSeleccionado); // insert into Alumno values(...)
                        this.dbContext.SaveChanges();
                        this.ListaAlumno.Add(this.ElementoSeleccionado);
                        await this.dialogCoordinator.ShowMessageAsync(this, "Alumno",
                                                                      "Datos actualizados!!!");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;

                case ACCION.MODIFICAR:
                    if (this.ElementoSeleccionado != null)
                    {
                        this.dbContext.Entry(this.ElementoSeleccionado).State = EntityState.Modified;
                        this.dbContext.SaveChanges();
                        await this.dialogCoordinator.ShowMessageAsync(this, "Alumno",
                                                                      "Datos actualizados!!!");

                        this.IsNuevo     = true;
                        this.IsEliminar  = true;
                        this.IsModificar = true;
                        this.IsGuardar   = false;
                        this.IsCancelar  = false;
                    }
                    else
                    {
                        await this.dialogCoordinator.ShowMessageAsync(this, "Alumno",
                                                                      "Debe seleccionar un elemento");
                    }
                    break;
                }
            }
            else if (parametro.Equals("Cancelar"))
            {
                if (this._accion == ACCION.MODIFICAR)
                {
                    this.ListaAlumno.RemoveAt(this.Posicion);
                    ListaAlumno.Insert(this.Posicion, this.Update);
                }
                this.IsNuevo             = true;
                this.IsEliminar          = true;
                this.IsModificar         = true;
                this.IsGuardar           = false;
                this.IsCancelar          = false;
                this.IsReadOnlyApellidos = true;
                this.IsReadOnlyNombres   = true;
                this.IsFechaNacimiento   = false;
            }
            else if (parametro.Equals("Eliminar"))
            {
                if (this.ElementoSeleccionado != null)
                {
                    MessageDialogResult resultado = await this.dialogCoordinator.ShowMessageAsync(this,
                                                                                                  "Eliminar Alumno",
                                                                                                  "Esta seguro de eliminar el registro?",
                                                                                                  MessageDialogStyle.AffirmativeAndNegative);

                    if (resultado == MessageDialogResult.Affirmative)
                    {
                        this.dbContext.Remove(this.ElementoSeleccionado);
                        this.dbContext.SaveChanges();
                        this.ListaAlumno.Remove(this.ElementoSeleccionado);
                        await this.dialogCoordinator.ShowMessageAsync(this, "Alumno",
                                                                      "Registro eliminado");
                    }
                }
                else
                {
                    await this.dialogCoordinator.ShowMessageAsync(this, "Alumno",
                                                                  "Debe seleccionar un elemento");
                }
            }
        }
Ejemplo n.º 23
0
        public void Execute(object parameter)
        {
            if (parameter.Equals("Add"))
            {
                this.IsReadOnlyNit               = false;
                this.IsReadOnlyRazonSocial       = false;
                this.IsReadOnlyDireccion         = false;
                this.IsReadOnlyPaginaWeb         = false;
                this.IsReadOnlyContactoPrincipal = false;
                this.accion = ACCION.NUEVO;
            }
            if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    Proveedor nuevo = new Proveedor();
                    nuevo.Nit               = this.Nit;
                    nuevo.RazonSocial       = this.RazonSocial;
                    nuevo.Direccion         = this.Direccion;
                    nuevo.PaginaWeb         = this.PaginaWeb;
                    nuevo.ContactoPrincipal = this.ContactoPrincipal;
                    db.Proveedores.Add(nuevo);
                    db.SaveChanges();
                    this.Proveedores.Add(nuevo);
                    MessageBox.Show("Registro Almacenado");
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        int posicion        = this.Proveedores.IndexOf(this.SeleccionarProveedor);
                        var updateProveedor = this.db.Proveedores.Find(this.SeleccionarProveedor.CodigoProveedor);
                        updateProveedor.Nit                  = this.Nit;
                        updateProveedor.RazonSocial          = this.RazonSocial;
                        updateProveedor.PaginaWeb            = this.PaginaWeb;
                        updateProveedor.ContactoPrincipal    = this.ContactoPrincipal;
                        this.db.Entry(updateProveedor).State = EntityState.Modified;
                        this.db.SaveChanges();
                        this.Proveedores.RemoveAt(posicion);
                        this.Proveedores.Insert(posicion, updateProveedor);
                        MessageBox.Show("Registro Actualizado!!!");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SeleccionarProveedor != null)
                {
                    var respuesta = MessageBox.Show("Esta seguro de eliminar el registro?", "Eliminar", MessageBoxButton.YesNo);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.Proveedores.Remove(this.SeleccionarProveedor);
                            db.SaveChanges();
                            this.Proveedores.Remove(this.SeleccionarProveedor);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("Registro eliminado correctamente!!!");
                    }
                }

                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Ejemplo n.º 24
0
    protected string Grabar(string strDatosTarea, string slIntegrantes, string sTareas)
    {
        string   sResul = "", sAccionBD, sIdRecurso, sCad, sTipoLinea, sCodTarea, oRec, sIdResponsable = "";
        int      iCodAccion, iCodAsunto = -1;
        byte     iAvance;
        DateTime?dFfp = null;
        DateTime?dFLi = null;
        bool     bNotificable = false, bEnviarAlerta = false, bAlta = false;

        try
        {
            oConn = Conexion.Abrir();
            tr    = Conexion.AbrirTransaccionSerializable(oConn);
        }
        catch (Exception ex)
        {
            sResul = "Error@#@" + Errores.mostrarError("Error al abrir la conexión", ex);
            return(sResul);
        }
        try
        {
            #region Datos accion
            string[] aDatosTarea = Regex.Split(strDatosTarea, "##");
            // 0 -> id accion (si -1 es un alta)
            // 1 -> avance
            // 2 -> descripcion corta
            // 3 -> descripcion larga
            // 4 -> departamento
            // 5 -> f/fin
            // 6 -> f/limite
            // 7 -> alerta
            // 8 -> observaciones
            // 9 -> asunto
            // 10 -> des asunto
            // 11 -> num PE
            // 12 -> des PE
            // 13 -> enviar alerta (S/N)
            // 14 -> Id responsable del asunto
            //if (aDatosTarea[13] == "S") bEnviarAlerta = true;
            bEnviarAlerta = true;
            if (aDatosTarea[0] == "")
            {
                iCodAccion = -1;
            }
            else
            {
                iCodAccion = int.Parse(aDatosTarea[0]);
            }
            iCodAsunto = int.Parse(aDatosTarea[9]);
            if (aDatosTarea[1] == "")
            {
                iAvance = 0;
            }
            else
            {
                iAvance = byte.Parse(aDatosTarea[1]);
            }
            if (aDatosTarea[5] != "")
            {
                dFfp = DateTime.Parse(aDatosTarea[5]);
            }
            if (aDatosTarea[6] != "")
            {
                dFLi = DateTime.Parse(aDatosTarea[6]);
            }

            if (iCodAccion == -1)
            {
                bAlta = true;
            }
            if (bAlta)
            {
                DateTime dtNow = System.DateTime.Now;
                iCodAccion = ACCION.Insert(tr, dtNow, iCodAsunto, Utilidades.unescape(aDatosTarea[7]),
                                           iAvance, Utilidades.unescape(aDatosTarea[2]),
                                           Utilidades.unescape(aDatosTarea[3]),
                                           Utilidades.unescape(aDatosTarea[4]),
                                           dFfp, dFLi, Utilidades.unescape(aDatosTarea[8]));
            }
            else
            {
                ACCION.Update(tr, Utilidades.unescape(aDatosTarea[7]),
                              iAvance,
                              Utilidades.unescape(aDatosTarea[2]),
                              Utilidades.unescape(aDatosTarea[3]),
                              Utilidades.unescape(aDatosTarea[4]),
                              dFfp, dFLi, iCodAccion,
                              Utilidades.unescape(aDatosTarea[8]));
            }
            #endregion
            #region Datos integrantes
            //OfiTec.BorrarIntegrantes(iCodCR);
            if (slIntegrantes == "")
            {//Tenemos lista vacía. No hacemos nada
            }
            else
            {//Con la cadena generamos una lista y la recorremos para grabar cada elemento
                string[] aPersonas = Regex.Split(slIntegrantes, @"///");

                for (int i = 0; i < aPersonas.Length - 1; i++)
                {
                    if (aPersonas[i] != "")
                    {
                        string[] aIntegrante = Regex.Split(aPersonas[i], @"##");
                        sAccionBD  = aIntegrante[0];
                        sIdRecurso = aIntegrante[1];
                        if (aIntegrante[2] == "1")
                        {
                            bNotificable = true;
                        }
                        else
                        {
                            bNotificable = false;
                        }

                        oRec  = iCodAccion.ToString() + "##" + sIdRecurso + "##";
                        oRec += Utilidades.unescape(aDatosTarea[2]) + "##";                           //descripcion corta
                        oRec += aDatosTarea[11] + "##" + Utilidades.unescape(aDatosTarea[12]) + "##"; //cod y des PE
                        oRec += aDatosTarea[9] + "##" + Utilidades.unescape(aDatosTarea[10]) + "##";  //cod y des Asunto
                        oRec += dFLi.ToString() + "##" + dFfp.ToString() + "##";

                        switch (sAccionBD)
                        {
                        case "I":
                            ACCIONRECURSOS.Insert(tr, int.Parse(sIdRecurso), iCodAccion, bNotificable);
                            //if (bNotificable) EnviarCorreoRecurso("I", oRec);
                            break;

                        case "D":
                            //delete
                            ACCIONRECURSOS.Delete(tr, iCodAccion, int.Parse(sIdRecurso));
                            //if (bNotificable) EnviarCorreoRecurso("D", oRec);
                            break;

                        case "U":
                            //update
                            ACCIONRECURSOS.Update(tr, int.Parse(sIdRecurso), iCodAccion, bNotificable);
                            //if (bNotificable) EnviarCorreoRecurso("U", oRec);
                            break;
                        }
                    }
                }//for
            }
            #endregion
            #region tareas
            //Grabamos las tareas asociadas a la acción
            if (sTareas != "")
            {
                string[] aTareas = Regex.Split(sTareas, @"##");

                for (int i = 0; i < aTareas.Length - 1; i++)
                {
                    sCad       = aTareas[i];
                    sTipoLinea = sCad.Substring(0, 1);
                    sCodTarea  = quitaPuntos(sCad.Substring(1));
                    if (sTipoLinea == "D")
                    {//Borrar accion-tarea
                        ACCIONTAREAS.Delete(tr, iCodAccion, int.Parse(sCodTarea));
                    }
                    else
                    {
                        if (sTipoLinea == "I")
                        {//Insertar accion-tarea
                            ACCIONTAREAS.Insert(tr, int.Parse(sCodTarea), iCodAccion);
                        }
                    }
                }
            }
            #endregion
            #region Enviar correos
            if (bEnviarAlerta)
            {
                oRec  = iCodAccion.ToString() + "##";
                oRec += Utilidades.unescape(aDatosTarea[2]) + "##";                           //descripcion corta
                oRec += aDatosTarea[11] + "##" + Utilidades.unescape(aDatosTarea[12]) + "##"; //cod y des PE
                oRec += aDatosTarea[9] + "##" + Utilidades.unescape(aDatosTarea[10]) + "##";  //cod y des Asunto
                oRec += dFLi.ToString() + "##" + dFfp.ToString() + "##";
                oRec += aDatosTarea[1] + "##";                                                //avance
                oRec += Utilidades.unescape(aDatosTarea[3]) + "##";                           //descripcion larga accion
                oRec += Utilidades.unescape(aDatosTarea[8]) + "##";                           //observaciones
                oRec += Utilidades.unescape(aDatosTarea[4]) + "##";                           //Dpto

                if (bAlta)
                {
                    sCad = "I";
                }
                else
                {
                    sCad = "U";
                }

                //if (aDatosTarea.Length > 14)
                //    sIdResponsable = aDatosTarea[14];
                //if (sIdResponsable == "")
                sIdResponsable = SUPER.Capa_Negocio.ASUNTO.GetResponsable(iCodAsunto);

                EnviarCorreoAlerta(sCad, oRec, Utilidades.unescape(aDatosTarea[7]), slIntegrantes, sIdResponsable, bAlta);
            }
            #endregion
            Conexion.CommitTransaccion(tr);
            //sResul = "OK@#@" + DateTime.Now.ToString() + "@#@" + Session["UsuarioActual"].ToString() + "@#@" + Session["APELLIDO1"].ToString() + " " + Session["APELLIDO2"].ToString() + ", " + Session["NOMBRE"].ToString();
            sResul = "OK@#@" + iCodAccion.ToString();
        }
        catch (Exception ex)
        {
            Conexion.CerrarTransaccion(tr);
            sResul = "Error@#@" + Errores.mostrarError("Error al grabar los datos de la acción", ex);
        }
        finally
        {
            Conexion.Cerrar(oConn);
        }
        return(sResul);
    }
Ejemplo n.º 25
0
        public async void Execute(object control)
        {
            if (control.Equals("Nuevo"))
            {
                LimpiarCampos();
                ActivarControles();
                this._accion = ACCION.NUEVO;
            }
            else if (control.Equals("Eliminar"))
            {
                if (Elemento != null)
                {
                    MessageDialogResult resultado = await this._dialogCoordinator.ShowMessageAsync(
                        this,
                        "Eliminar Alumno",
                        "Esta seguro de eliminar el registro?",
                        MessageDialogStyle.AffirmativeAndNegative);

                    if (resultado == MessageDialogResult.Affirmative)
                    {
                        try
                        {
                            _db.Alumnos.Remove(Elemento);
                            _db.SaveChanges();
                            this.ListaAlumnos.Remove(Elemento);
                            LimpiarCampos();
                        }
                        catch (Exception ex)
                        {
                            await this._dialogCoordinator.ShowMessageAsync(
                                this,
                                "Eliminar Alumno",
                                ex.Message);
                        }
                    }
                }
                else
                {
                    await this._dialogCoordinator.ShowMessageAsync(
                        this,
                        "Eliminar Alumno",
                        "Debe seleccionar un elemento");
                }
            }
            else if (control.Equals("Guardar"))
            {
                switch (this._accion)
                {
                case ACCION.NINGUNO:
                    break;

                case ACCION.NUEVO:
                    try
                    {
                        var registro = new Alumno
                        {
                            Carne           = this.Carne,
                            Apellidos       = this.Apellidos,
                            Nombres         = this.Nombres,
                            FechaNacimiento = this.FechaNacimiento,
                            Carrera         = this.CarreraSeleccionada
                        };

                        _db.Alumnos.Add(registro);
                        _db.SaveChanges();
                        this.ListaAlumnos.Add(registro);
                    }
                    catch (Exception ex)
                    {
                        await this._dialogCoordinator.ShowMessageAsync(
                            this,
                            "Guardar Alumno",
                            ex.Message);
                    }
                    finally
                    {
                        DesactivarControles();
                        this._accion = ACCION.NINGUNO;
                    }
                    break;

                case ACCION.GUARDAR:
                    try
                    {
                        int posicion = ListaAlumnos.IndexOf(Elemento);
                        var registro = _db.Alumnos.Find(Elemento.AlumnoId);

                        if (registro != null)
                        {
                            registro.Apellidos        = this.Apellidos;
                            registro.Nombres          = this.Nombres;
                            registro.FechaNacimiento  = this.FechaNacimiento;
                            registro.Carrera          = this.CarreraSeleccionada;
                            _db.Entry(registro).State = EntityState.Modified;
                            _db.SaveChanges();
                            ListaAlumnos.RemoveAt(posicion);
                            ListaAlumnos.Insert(posicion, registro);
                        }
                    }
                    catch (Exception ex)
                    {
                        await this._dialogCoordinator.ShowMessageAsync(
                            this,
                            "Editar Alumno",
                            ex.Message);
                    }
                    finally
                    {
                        DesactivarControles();
                        this._accion = ACCION.NINGUNO;
                    }
                    break;

                default:
                    break;
                }
            }
            else if (control.Equals("Editar"))
            {
                if (Elemento != null)
                {
                    ActivarControles();
                    this.IsReadOnlyCarne = true;
                    this._accion         = ACCION.GUARDAR;
                }
                else
                {
                    await this._dialogCoordinator.ShowMessageAsync(
                        this,
                        "Editar Alumno",
                        "Debe seleccionar un elemento");
                }
            }
            else if (control.Equals("Cancelar"))
            {
                DesactivarControles();
                this._accion = ACCION.NINGUNO;
            }
        }
Ejemplo n.º 26
0
        public void Execute(object parameter)
        {
            if (parameter.Equals("Add"))
            {
                /*MessageBox.Show("Agregar Departamento");*/
                this.IsReadOnlyName   = false;
                this.IsReadOnlyBudget = false;
                this.IsReadOnlyAdmin  = false;
                this.accion           = ACCION.NUEVO;
                this.IsEnabledAdd     = false;
                this.IsEnabledDelete  = false;
                this.IsEnabledUpdate  = false;
                this.IsEnabledSave    = true;
                this.IsEnabledCancel  = true;
            }
            if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    Department nuevo = new Department();
                    nuevo.Name          = this.Name;
                    nuevo.Budget        = Convert.ToDecimal(this.Budget);
                    nuevo.Administrator = Convert.ToInt16(this.Admin);
                    nuevo.StartDate     = DateTime.Now;
                    db.Departments.Add(nuevo);
                    db.SaveChanges();
                    this.Departments.Add(nuevo);
                    MessageBox.Show("Registro Almacenado");
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        int posicion         = this.Departments.IndexOf(this.SelectDepartment);              //Devuelve la posición del objeto, para que no solo se refleje el cambio en la BD sino también en la vista
                        var updateDepartment = this.db.Departments.Find(this.SelectDepartment.DepartmentID); //OBJETO PERSISTENTE "Significa que la información de la vista tiene q modificarse también en la BD"
                        updateDepartment.Name                 = this.Name;
                        updateDepartment.Budget               = Convert.ToDecimal(this.Budget);
                        updateDepartment.Administrator        = Convert.ToInt16(this.Admin);
                        this.db.Entry(updateDepartment).State = EntityState.Modified;
                        this.db.SaveChanges();
                        this.Departments.RemoveAt(posicion);
                        this.Departments.Insert(posicion, updateDepartment);
                        MessageBox.Show("¡Registro actualizado!");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
            }
            else if (parameter.Equals("Update"))
            {
                this.accion           = ACCION.ACTUALIZAR;
                this.IsReadOnlyName   = false;
                this.IsReadOnlyBudget = false;
                this.IsReadOnlyAdmin  = false;
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SelectDepartment != null)
                {
                    var respuesta = MessageBox.Show("¿Está seguro de eliminar el registro?", "Eliminar", MessageBoxButton.YesNo);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.Departments.Remove(this.SelectDepartment);
                            db.SaveChanges();
                            this.Departments.Remove(this.SelectDepartment);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("¡Registro eliminado correctamente!");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                /* Name = this.SelectDepartment.Name;
                 * Budget = this.SelectDepartment.Budget.ToString("0.00");
                 * Admin = this.SelectDepartment.Administrator.ToString();*/
            }
        }
Ejemplo n.º 27
0
    protected void btnAddAcc_Click(object sender, EventArgs e)
    {
        if (ModelState.IsValid)
        {
            if ((!String.IsNullOrEmpty(this.txtInstrumentosAct.Text)) && (!String.IsNullOrEmpty(this.txtOrganoResponsable.Text)) &&
                (!String.IsNullOrEmpty(this.txtSeguimiento.Text)) && (!String.IsNullOrEmpty(this.txtRecursosHumanos.Text)) &&
                (!String.IsNullOrEmpty(this.txtCosteEconomico.Text)) &&
                (!String.IsNullOrEmpty(this.txtTemporalidad.Text)) && (!String.IsNullOrEmpty(this.txtIndSeguimiento.Text)) &&
                (this.ddlPorcentajeAvance.SelectedItem.Value != "-1"))
            //(this.ddlEstadoSeguimiento.SelectedItem.Value != "-1"))
            {
                int iDeptoId = getDptoId();
                using (Entities c = new Entities())
                {
                    try
                    {
                        ACCION obj = new ACCION
                        {
                            AUTOR_CREACION_USUARIO_ID = User.Identity.GetUserId().ToString(),
                            DEPARTAMENTO_ID           = iDeptoId,
                            ESTADO_VALIDACION_ID      = ESTADOS_VALIDACION.PDTE_VALIDAR,
                            FECHA_CREACION            = DateTime.Now,
                            TIPO_CAMBIO_CONTENIDO_ID  = TIPO_CAMBIO_CONTENIDO.ALTA,
                            VISIBLE = false,
                            SEGUIMIENTO_PDTE_VAL           = txtSeguimiento.Text.Trim(),
                            RECURSOS_HUMANOS_PDTE_VAL      = txtRecursosHumanos.Text.Trim(),
                            COSTE_ECONOMICO_PDTE_VAL       = txtCosteEconomico.Text.Trim(),
                            INSTRUMENTOS_ACT_PDTE_VAL      = txtInstrumentosAct.Text.Trim(),
                            MEDIOS_OTROS_PDTE_VAL          = txtMediosOtros.Text.Trim(),
                            TEMPORALIDAD_PDTE_VAL          = txtTemporalidad.Text.Trim(),
                            INDICADOR_SEGUIMIENTO_PDTE_VAL = txtIndSeguimiento.Text.Trim(),
                            //ESTADO_SEGUIMIENTO_ID_PDTE_VAL = Convert.ToInt32(this.ddlEstadoSeguimiento.SelectedItem.Value),
                            PORCENTAJE_AVANCE_PDTE_VAL  = Convert.ToByte(this.ddlPorcentajeAvance.SelectedItem.Value),
                            ORGANO_RESPONSABLE_PDTE_VAL = txtOrganoResponsable.Text.Trim(),
                            OBJETIVO_CONTENIDO_ID       = Convert.ToInt32(this.hdObjetivoId.Value),
                            OBSERVACIONES = txtAccObservaciones.Text.Trim()
                        };

                        c.CONTENIDO.Add(obj);

                        c.SaveChanges();
                        SuccessMessage         = "Instrumento/actividad guardado correctamente.";
                        successMessage.Visible = true;
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Error al crear nuevo instrumento/actividad (AdminPlan.aspx). Error: " + ex.Message + " " + ex.InnerException);
                        Notificaciones.NotifySystemOps(ex);
                        ErrorMessage         = "Error al crear nueva acción.";
                        errorMessage.Visible = true;
                    }
                }
            }
            else
            {
                ErrorMessage         = "Se deben rellenar los campos del formulario.";
                errorMessage.Visible = true;
            }
        }
        else
        {
            ErrorMessage         = "Se deben rellenar los campos del formulario.";
            errorMessage.Visible = true;
        }
    }
Ejemplo n.º 28
0
        public void Execute(object parameter)
        {
            if (parameter.Equals("Add"))
            {
                this.IsReadOnlyName   = false;
                this.IsReadOnlyBudget = false;
                this.IsReadOnlyAdmin  = false;
                this.accion           = ACCION.NUEVO;
                this.IsEnableAdd      = false;
                this.IsEnableDelete   = false;
                this.IsEnableUpdate   = false;
                this.IsEnableSave     = true;
                this.IsEnableCancel   = true;
            }
            if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    Department nuevo = new Department();
                    nuevo.Name          = this.Name;
                    nuevo.Budget        = Convert.ToDecimal(this.Budget);
                    nuevo.Administrator = Convert.ToInt16(this.Admin);
                    nuevo.StartDate     = DateTime.Now;
                    db.Departments.Add(nuevo);
                    db.SaveChanges();
                    this.Departments.Add(nuevo);
                    MessageBox.Show("Registro almacenado");
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        int posicion         = this.Departments.IndexOf(this.SelectDepartment);
                        var updateDepartment = this.db.Departments.Find(this.SelectDepartment.DepartmentID);
                        updateDepartment.Name                 = this.Name;
                        updateDepartment.Budget               = Convert.ToDecimal(this.Budget);
                        updateDepartment.Administrator        = Convert.ToInt16(this.Admin);
                        this.db.Entry(updateDepartment).State = EntityState.Modified;
                        this.db.SaveChanges();
                        this.Departments.RemoveAt(posicion);
                        this.Departments.Insert(posicion, updateDepartment);
                        MessageBox.Show("Registro actualizado!!!");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
                this.IsEnableAdd      = true;
                this.IsEnableDelete   = true;
                this.IsEnableUpdate   = true;
                this.IsEnableSave     = false;
                this.IsEnableCancel   = false;
                this.IsReadOnlyName   = true;
                this.IsReadOnlyBudget = true;
                this.IsReadOnlyAdmin  = true;
            }

            else if (parameter.Equals("Update"))
            {
                this.accion           = ACCION.ACTUALIZAR;
                this.IsReadOnlyName   = false;
                this.IsReadOnlyBudget = false;
                this.IsReadOnlyAdmin  = false;
                this.IsEnableAdd      = false;
                this.IsEnableDelete   = false;
                this.IsEnableUpdate   = false;
                this.IsEnableSave     = true;
                this.IsEnableCancel   = true;
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SelectDepartment != null)
                {
                    var respuesta = MessageBox.Show("Esta seguro de elminar el registro?", "Eliminar", MessageBoxButton.YesNo);

                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.Departments.Remove(this.SelectDepartment);
                            db.SaveChanges();
                            this.Departments.Remove(this.SelectDepartment);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("Registro eliminado correctamente!!!");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else if (parameter.Equals("Cancel"))
            {
                this.IsEnableAdd      = true;
                this.IsEnableDelete   = true;
                this.IsEnableUpdate   = true;
                this.IsEnableSave     = false;
                this.IsEnableCancel   = false;
                this.IsReadOnlyName   = true;
                this.IsReadOnlyBudget = true;
                this.IsReadOnlyAdmin  = true;
            }
        }
Ejemplo n.º 29
0
        public void Execute(object parameter)
        {
            if (parameter.Equals("Add"))
            {
                this.IsReadOnlyEmail = false;
                this.IsReadOnlyNit   = false;
                this.accion          = ACCION.NUEVO;
            }
            if (parameter.Equals("Save"))
            {
                switch (this.accion)
                {
                case ACCION.NUEVO:
                    EmailCliente nuevo = new EmailCliente();
                    nuevo.Email = this.Email;
                    nuevo.Nit   = this.Nit;
                    db.EmailClientes.Add(nuevo);
                    db.SaveChanges();
                    this.EmailClientes.Add(nuevo);
                    MessageBox.Show("Registro Almcenado");
                    break;

                case ACCION.ACTUALIZAR:
                    try
                    {
                        int posicion           = this.EmailClientes.IndexOf(this.SeleccionarEmailCliente);
                        var updateEmailCliente = this.db.EmailClientes.Find(this.SeleccionarEmailCliente.CodigoEmail);
                        updateEmailCliente.Email = this.Email;
                        updateEmailCliente.Nit   = this.Nit;
                        this.db.Entry(updateEmailCliente).State = EntityState.Modified;
                        this.db.SaveChanges();
                        this.EmailClientes.RemoveAt(posicion);
                        this.EmailClientes.Insert(posicion, updateEmailCliente);
                        MessageBox.Show("Registro Actualizado!!!");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;
                }
            }
            else if (parameter.Equals("Delete"))
            {
                if (this.SeleccionarEmailCliente != null)
                {
                    var respuesta = MessageBox.Show("Esta seguro de eliminar el registro?", "Eliminar", MessageBoxButton.YesNo);
                    if (respuesta == MessageBoxResult.Yes)
                    {
                        try
                        {
                            db.EmailClientes.Remove(this.SeleccionarEmailCliente);
                            db.SaveChanges();
                            this.EmailClientes.Remove(this.SeleccionarEmailCliente);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message);
                        }
                        MessageBox.Show("Registro eliminado correctamente!!!");
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar un registro", "Eliminar", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Ejemplo n.º 30
0
    /// <summary>
    /// Actualiza Objetivo
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnActualizaAcc_Click(object sender, EventArgs e)
    {
        if (ModelState.IsValid)
        {
            int iObjetivoId = Convert.ToInt32(this.hdObjetivoId.Value);
            using (Entities c = new Entities())
            {
                try
                {
                    ACCION obj = c.CONTENIDO.OfType <ACCION>().Where(o => o.CONTENIDO_ID == iObjetivoId).FirstOrDefault();

                    bool bHayCambios = false;

                    if (String.IsNullOrEmpty(obj.INSTRUMENTOS_ACT_PDTE_VAL))
                    {
                        bHayCambios = true;
                    }
                    else if (
                        obj.INSTRUMENTOS_ACT_PDTE_VAL.Trim() != this.txtInstrumentosAct.Text.Trim() ||
                        obj.SEGUIMIENTO_PDTE_VAL.Trim() != this.txtSeguimiento.Text.Trim() ||
                        obj.RECURSOS_HUMANOS_PDTE_VAL.Trim() != this.txtRecursosHumanos.Text.Trim() ||
                        obj.COSTE_ECONOMICO_PDTE_VAL.Trim() != this.txtCosteEconomico.Text.Trim() ||
                        obj.INDICADOR_SEGUIMIENTO_PDTE_VAL.Trim() != this.txtIndSeguimiento.Text.Trim() ||
                        obj.TEMPORALIDAD_PDTE_VAL.Trim() != this.txtTemporalidad.Text.Trim() ||
                        obj.INDICADOR_SEGUIMIENTO_PDTE_VAL.Trim() != this.txtIndSeguimiento.Text.Trim() ||
                        //obj.ESTADO_SEGUIMIENTO_ID_PDTE_VAL.ToString() != this.ddlEstadoSeguimiento.SelectedItem.Value ||
                        obj.PORCENTAJE_AVANCE_PDTE_VAL.ToString() != this.ddlPorcentajeAvance.SelectedItem.Value ||
                        obj.ORGANO_RESPONSABLE_PDTE_VAL.Trim() != this.txtOrganoResponsable.Text.Trim()
                        )
                    {
                        bHayCambios = true;
                    }
                    else if (!String.IsNullOrEmpty(obj.MEDIOS_OTROS_PDTE_VAL))
                    {
                        if (obj.MEDIOS_OTROS_PDTE_VAL.Trim() != this.txtMediosOtros.Text.Trim())
                        {
                            bHayCambios = true;
                        }
                    }
                    else if (!String.IsNullOrEmpty(this.txtMediosOtros.Text.Trim()))
                    {
                        bHayCambios = true;
                    }

                    if (bHayCambios)
                    {
                        if (obj.YaPublicado())
                        {
                            obj.FECHA_MODIFICACION            = DateTime.Now;
                            obj.AUTOR_MODIFICACION_USUARIO_ID = User.Identity.GetUserId().ToString();
                            obj.TIPO_CAMBIO_CONTENIDO_ID      = TIPO_CAMBIO_CONTENIDO.MODIFICACION;
                        }
                        else
                        {
                            //Si todavía no ha sido publicado lo trataremos como un alta
                            obj.FECHA_CREACION            = DateTime.Now;
                            obj.AUTOR_CREACION_USUARIO_ID = User.Identity.GetUserId().ToString();
                            obj.TIPO_CAMBIO_CONTENIDO_ID  = TIPO_CAMBIO_CONTENIDO.ALTA;
                        }

                        obj.INSTRUMENTOS_ACT_PDTE_VAL      = this.txtInstrumentosAct.Text.Trim();
                        obj.SEGUIMIENTO_PDTE_VAL           = this.txtSeguimiento.Text.Trim();
                        obj.RECURSOS_HUMANOS_PDTE_VAL      = this.txtRecursosHumanos.Text.Trim();
                        obj.COSTE_ECONOMICO_PDTE_VAL       = this.txtCosteEconomico.Text.Trim();
                        obj.INDICADOR_SEGUIMIENTO_PDTE_VAL = this.txtIndSeguimiento.Text.Trim();
                        obj.MEDIOS_OTROS_PDTE_VAL          = this.txtMediosOtros.Text.Trim();
                        obj.TEMPORALIDAD_PDTE_VAL          = this.txtTemporalidad.Text.Trim();
                        obj.INDICADOR_SEGUIMIENTO_PDTE_VAL = this.txtIndSeguimiento.Text.Trim();
                        //if (this.ddlEstadoSeguimiento.SelectedItem.Value != "-1")
                        //    obj.ESTADO_SEGUIMIENTO_ID_PDTE_VAL = Convert.ToInt32(this.ddlEstadoSeguimiento.SelectedItem.Value);
                        if (this.ddlPorcentajeAvance.SelectedItem.Value != "-1")
                        {
                            obj.PORCENTAJE_AVANCE_PDTE_VAL = Convert.ToByte(this.ddlPorcentajeAvance.SelectedItem.Value);
                        }
                        obj.ORGANO_RESPONSABLE_PDTE_VAL = this.txtOrganoResponsable.Text.Trim();
                        obj.OBSERVACIONES        = this.txtAccObservaciones.Text.Trim();
                        obj.ESTADO_VALIDACION_ID = ESTADOS_VALIDACION.PDTE_VALIDAR;

                        c.CONTENIDO.Attach(obj);
                        c.Entry(obj).State = EntityState.Modified;
                        c.SaveChanges();

                        SuccessMessage         = "Instrumento/actividad actualizado correctamente.";
                        successMessage.Visible = true;
                    }
                    else
                    {
                        //no marcamos como cambio si actualizan observaciones
                        obj.OBSERVACIONES = this.txtAccObservaciones.Text.Trim();
                        c.CONTENIDO.Attach(obj);
                        c.Entry(obj).State = EntityState.Modified;
                        c.SaveChanges();
                        SuccessMessage         = "Instrumento/actividad actualizado correctamente.";
                        successMessage.Visible = true;
                    }
                }
                catch (Exception ex)
                {
                    logger.Fatal("Error al actualizar Instrumento/actividad (AdminPlan.aspx). Error: " + ex.Message + " " + ex.InnerException);
                    Notificaciones.NotifySystemOps(ex);
                    ErrorMessage         = "Error al actualizar nuevo Instrumento/actividad.";
                    errorMessage.Visible = true;
                }
            }
        }
        else
        {
            ErrorMessage         = "Se deben rellenar los campos del formulario.";
            errorMessage.Visible = true;
        }
    }