Exemplo n.º 1
0
        private void cmdEliminar_Click(object sender, EventArgs e)
        {
            if (dgRegistros.SelectedRows.Count > 0)
            {
                if (MessageBox.Show("Los registros seleccionados serán eliminados. ¿Desesa continuar?", "SysLab", MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    var ps = new CTRL.Persistencia();
                    ps.IniciarTransaccion();

                    int errores = 0;

                    foreach (DataGridViewRow item in dgRegistros.SelectedRows)
                    {
                        var fila = (dsSysLab.USUARIORow)((DataRowView)item.DataBoundItem).Row;

                        if (!CTRL.Administracion.Usuarios.EliminarUsuario(ps.DB, fila.ID_USUARIO))
                        {
                            errores++;
                        }
                    }

                    if (errores > 0)
                    {
                        ps.RevertirTransaccion();
                        MessageBox.Show("Los registros no pudieron ser eliminados porque "
                                        + "tienen operaciones relacionadas.", "SysLab", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                    else
                    {
                        ps.FinalizarTransaccion();

                        MessageBox.Show("Los registros fueron eliminados satisfactoriamente.",
                                        "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        frmAdminUsuarios_Load(sender, e);
                    }
                }
            }
            else
            {
                MessageBox.Show("Debe seleccionar al menos un usuario a eliminar.",
                                "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 2
0
        private void cmdEliminar_Click(object sender, EventArgs e)
        {
            if (dgRegistros.SelectedRows.Count == 0)
            {
                MessageBox.Show("Por favor, seleccione un registro.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (MessageBox.Show("Los registros seleccionados serán eliminados permanentemente. ¿Desea continuar?.", "SysLab",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    var ps = new CTRL.Persistencia();
                    ps.IniciarTransaccion();

                    int errores = 0;

                    foreach (DataGridViewRow item in dgRegistros.SelectedRows)
                    {
                        var fila = (dsSysLab.COTIZACIONRow)((DataRowView)item.DataBoundItem).Row;

                        if (!CTRL.Examenes.Cotizaciones.EliminarCotizacion(ps.DB, fila.ID_COTIZACION))
                        {
                            errores++;
                        }
                    }

                    if (errores > 0)
                    {
                        ps.RevertirTransaccion();
                        MessageBox.Show("Los registros no pudieron ser eliminados porque tienen operaciones relacionadas.",
                                        "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        ps.FinalizarTransaccion();

                        MessageBox.Show("Los registros fueron eliminados satisfactoriamente.", "SysLab", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                        frmCotizaciones_Load(sender, e);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void cmdGuardar_Click(object sender, EventArgs e)
        {
            var detalle = new List <SOLICITUD_RESULTADO_DETALLE>();

            foreach (DataGridViewRow fila in dgCampos.Rows)
            {
                if (fila.IsNewRow || fila.Index < 0)
                {
                    continue;
                }

                detalle.Add(
                    new SOLICITUD_RESULTADO_DETALLE
                {
                    ID_ANALISIS_DATO = (string)fila.Tag,
                    VALOR            = fila.Cells[5].EditedFormattedValue.ToString(),
                    COMENTARIOS      = fila.Cells[6].EditedFormattedValue.ToString()
                }
                    );
            }

            var ps = new CTRL.Persistencia();

            ps.IniciarTransaccion();

            if (CTRL.Examenes.Resultados.ProcesarResultados(ps.DB, this.ID_SOL, this.ID_ANALISIS, txtObservaciones.Text.Trim(),
                                                            detalle))
            {
                ps.FinalizarTransaccion();

                MessageBox.Show("El resultado fue procesado satisfactoriamente.", "SysLab", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Dispose();
            }
            else
            {
                ps.RevertirTransaccion();
                MessageBox.Show("El resultado no pudo ser procesado. La operación fue cancelada.", "SysLab", MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 4
0
        private void cmdSeleccionar_Click(object sender, EventArgs e)
        {
            if (dgRegistros.SelectedRows.Count > 0)
            {
                var ps = new CTRL.Persistencia();
                ps.IniciarTransaccion();

                int errores = 0;

                foreach (DataGridViewRow F in dgRegistros.SelectedRows)
                {
                    var fila = (dsSysLab.PACIENTERow)((DataRowView)F.DataBoundItem).Row;
                    if (!CTRL.Administracion.Pacientes.AsignarPaciente(ps.DB, fila.ID_PACIENTE, this._ID_SECTOR))
                    {
                        errores++;
                    }
                }

                if (errores == 0)
                {
                    ps.FinalizarTransaccion();
                    MessageBox.Show("Los pacientes se asignaron satisfactoriamente.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Dispose();
                }
                else
                {
                    ps.RevertirTransaccion();
                    MessageBox.Show("La operación no pudo ser completada.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("Por favor, seleccione un registro.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 5
0
        private void cmdGuardar_Click(object sender, EventArgs e)
        {
            ActualizarTotales();

            int no_factura = 0;

            int no_validas = (from DataGridViewRow c in dgMovs.Rows
                              where (c.Cells[0].EditedFormattedValue.ToString() == "" ||
                                     c.Cells[1].EditedFormattedValue.ToString() == "") &&
                              c.IsNewRow == false
                              select c).Count();

            if (no_validas > 0 || dgMovs.Rows.Count <= 1)
            {
                MessageBox.Show("Por favor, verifique las filas agregadas.", "SysLab",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (!int.TryParse(txtFactura.Text, out no_factura))
            {
                MessageBox.Show("Por favor, verifique el número de factura.", "SysLab",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txtPacienteID.Text == "- Ninguno -")
            {
                MessageBox.Show("Por favor, seleccione un paciente.", "SysLab",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txtDoctorID.Text == "- Ninguno -")
            {
                MessageBox.Show("Por favor, seleccione un doctor.", "SysLab",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            { //GENERANDO DETALLE
                List <SOLICITUD_DETALLE> Detalle = new List <SOLICITUD_DETALLE>();
                foreach (DataGridViewRow item in dgMovs.Rows)
                {
                    if (!item.IsNewRow)
                    {
                        SOLICITUD_DETALLE reg = new SOLICITUD_DETALLE();

                        reg.ID_ANALISIS   = long.Parse(item.Cells[0].Value.ToString());
                        reg.PRECIO        = decimal.Parse(item.Cells[2].FormattedValue.ToString());
                        reg.OBSERVACIONES = item.Cells[3].FormattedValue.ToString();
                        reg.EXENTO        = (bool)item.Cells[4].FormattedValue;

                        Detalle.Add(reg);
                    }
                }

                if (!this._EDITANDO)
                {//AGREGANDO
                    var ps = new CTRL.Persistencia();
                    ps.IniciarTransaccion();

                    if (CTRL.Examenes.Solicitudes.AgregarSolicitud(ps.DB, long.Parse(txtPacienteID.Text), long.Parse(txtDoctorID.Text),
                                                                   dtpFecha.Value, dtpRequerido.Value, int.Parse(txtFactura.Text), txtNombre.Text.Trim(), txtGiro.Text.Trim(),
                                                                   txtNIT.Text.Trim(), txtNRC.Text.Trim(), ckRetencion.Checked, ckCFiscal.Checked, this.ptjIVA, this.ptjReten,
                                                                   this.gravado, this.iva, this.subtotal, this.exento, this.retencion, this.total, Detalle)
                        )
                    {
                        ps.FinalizarTransaccion();
                        MessageBox.Show("La solicitud fue agregada satisfactoriamente.", "SysLab", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);

                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        this.Dispose();
                    }
                    else
                    {
                        ps.RevertirTransaccion();
                        MessageBox.Show("El registro no pudo ser agregado satisfactoriamente, "
                                        + "por favor verifique que la información sea correcta.", "SysLab",
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {//EDITANDO
                    var ps = new CTRL.Persistencia();
                    ps.IniciarTransaccion();

                    if (CTRL.Examenes.Solicitudes.EditarSolicitud(ps.DB, this._ID_SOLICITUD, long.Parse(txtPacienteID.Text),
                                                                  long.Parse(txtDoctorID.Text), dtpFecha.Value, dtpRequerido.Value, int.Parse(txtFactura.Text),
                                                                  txtNombre.Text.Trim(), txtGiro.Text.Trim(), txtNIT.Text.Trim(), txtNRC.Text.Trim(), ckRetencion.Checked,
                                                                  ckCFiscal.Checked, this.ptjIVA, this.ptjReten, this.gravado, this.iva, this.subtotal, this.exento,
                                                                  this.retencion, this.total, Detalle)
                        )
                    {
                        ps.FinalizarTransaccion();
                        MessageBox.Show("El registro fue procesado satisfactoriamente.", "SysLab", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        this.Dispose();
                    }
                    else
                    {
                        ps.RevertirTransaccion();
                        MessageBox.Show("El registro no pudo ser procesado satisfactoriamente, "
                                        + "por favor verifique que la información sea correcta.", "SysLab",
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void cmdGuardar_Click(object sender, EventArgs e)
        {
            this.Validate(true);

            if (txtNombre.Text.Trim() == string.Empty)
            {
                MessageBox.Show("El nombre no es válido.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (cmbFam.SelectedIndex == -1)
            {
                MessageBox.Show("Por favor, seleccione una familia existente.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                List <ANALISIS_DATO> Datos = new List <ANALISIS_DATO>();

                foreach (DataGridViewRow item in dgCampos.Rows)
                {
                    if (item.IsNewRow || item.Index < 0)
                    {
                        continue;
                    }

                    Datos.Add(
                        new ANALISIS_DATO
                    {
                        CAMPO   = item.Cells[0].EditedFormattedValue.ToString(),
                        TIPO    = Array.IndexOf(TipoDato, item.Cells[1].EditedFormattedValue.ToString()),
                        UMEDIDA = item.Cells[2].EditedFormattedValue.ToString(),
                        REF     = item.Cells[3].EditedFormattedValue.ToString(),
                        RMAX    = decimal.Parse(item.Cells[4].EditedFormattedValue.ToString()),
                        RMIN    = decimal.Parse(item.Cells[5].EditedFormattedValue.ToString())
                    });
                }


                var ps = new CTRL.Persistencia();
                ps.IniciarTransaccion();

                if (!this._EDITANDO)
                {
                    if (CTRL.Administracion.CatalogoAnalisis.AgregarAnalisis(ps.DB, (long)cmbFam.SelectedValue, txtNombre.Text.Trim(), txtDesc.Text.Trim(), nudP1.Value, nudP2.Value, nudP3.Value, Datos))
                    {
                        ps.FinalizarTransaccion();
                        MessageBox.Show("El registro fue procesado satisfactoriamente.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        this.Dispose();
                    }
                    else
                    {
                        ps.RevertirTransaccion();
                        MessageBox.Show("Ha ocurrido un error, la operación fue cancelada.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    if (CTRL.Administracion.CatalogoAnalisis.EditarAnalisis(ps.DB, this._ID_EDITAR, (long)cmbFam.SelectedValue, txtNombre.Text.Trim(), txtDesc.Text.Trim(), nudP1.Value, nudP2.Value, nudP3.Value, Datos))
                    {
                        ps.FinalizarTransaccion();
                        MessageBox.Show("El registro fue procesado satisfactoriamente.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        this.Dispose();
                    }
                    else
                    {
                        ps.RevertirTransaccion();
                        MessageBox.Show("Ha ocurrido un error, la operación fue cancelada.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
        }