Example #1
0
        private void cmdGuardar_Click(object sender, EventArgs e)
        {
            if (txtNombres.Text.Length < 3 || txtApellidos.Text.Length < 3)
            {
                MessageBox.Show("Los nombres y los apellidos deben tener una longitud mínima "
                                + "de 3 caracteres.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txtContra.Text.Length < 8 || txtIdentificador.Text.Length < 8)
            {
                MessageBox.Show("El identificador y la contraseña deben tener una longitud mínima"
                                + "de 8 caraceres.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                var ps = new CTRL.Persistencia();
                ps.IniciarTransaccion();

                if (!this._EDITANDO) // AGREGANDO
                {
                    if (CTRL.Administracion.Usuarios.AgregarUsuario(ps.DB, txtContra.Text.Trim(),
                                                                    txtTelefono.Text.Trim(), txtIdentificador.Text.Trim(), txtNombres.Text.Trim(),
                                                                    txtCorreo.Text.Trim(), txtApellidos.Text.Trim(), cbTipo.Text))
                    {
                        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("La operación no pudo ser completada.", "SysLab",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else // EDITANDO
                {
                    if (CTRL.Administracion.Usuarios.EditarUsuario(ps.DB, _ID_EDITANDO,
                                                                   (txtContra.Text.Trim() == "(Sin Cambios)") ? "" : txtContra.Text.Trim(),
                                                                   txtTelefono.Text.Trim(), txtNombres.Text.Trim(),
                                                                   txtCorreo.Text.Trim(), txtApellidos.Text.Trim(), cbTipo.Text))
                    {
                        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("La operación no pudo ser completada.", "SysLab",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
        }
Example #2
0
        private void cmdGuardar_Click(object sender, EventArgs e)
        {
            if (txtNombres.Text.Trim() == string.Empty)
            {
                MessageBox.Show("El nombre no es válido.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                var ps = new CTRL.Persistencia();
                ps.IniciarTransaccion();

                if (!this._EDITANDO)
                {
                    if (CTRL.Administracion.Empresas.AgregarEmpresa(ps.DB, txtNombres.Text.Trim(), txtGiro.Text.Trim(),
                                                                    txtDireccion.Text.Trim(), txtMunicipio.Text.Trim(), txtDepartamento.Text.Trim(), txtNIT.Text.Trim(), txtNRC.Text.Trim(),
                                                                    ckGranContribuyente.Checked, ckCredito.Checked, (int)nudDiasCredito.Value, txtCorreo.Text.Trim(),
                                                                    txtContactoNombre.Text.Trim(), txtContactoNIT.Text.Trim(), txtContactoCorreo.Text.Trim(),
                                                                    txtContactoTelefono.Text.Trim()))
                    {
                        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("La operación no pudo ser completada.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    if (CTRL.Administracion.Empresas.EditarEmpresa(ps.DB, this._ID_EDITAR, txtNombres.Text.Trim(), txtGiro.Text.Trim(),
                                                                   txtDireccion.Text.Trim(), txtMunicipio.Text.Trim(), txtDepartamento.Text.Trim(), txtNIT.Text.Trim(), txtNRC.Text.Trim(),
                                                                   ckGranContribuyente.Checked, ckCredito.Checked, (int)nudDiasCredito.Value, txtCorreo.Text.Trim(),
                                                                   txtContactoNombre.Text.Trim(), txtContactoNIT.Text.Trim(), txtContactoCorreo.Text.Trim(),
                                                                   txtContactoTelefono.Text.Trim()))
                    {
                        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("La operación no pudo ser completada.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
        }
Example #3
0
        private void cmdGuardar_Click(object sender, EventArgs e)
        {
            if (txtNombres.Text.Trim() == string.Empty)
            {
                MessageBox.Show("El nombre no es válido.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                var ps = new CTRL.Persistencia();
                ps.IniciarTransaccion();

                if (!this._EDITANDO)
                {
                    if (CTRL.Administracion.Doctores.AgregarDoctores(ps.DB, txtNombres.Text.Trim(), txtDireccion.Text.Trim(),
                                                                     txtTelefono.Text.Trim(), txtNIT.Text.Trim(), txtDUI.Text.Trim(), txtCorreo.Text.Trim(),
                                                                     txtClinicaNombre.Text.Trim(), txtClinicaTelefono.Text.Trim()))
                    {
                        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("La operación no pudo ser completada.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    if (CTRL.Administracion.Doctores.EditarDoctores(ps.DB, this._ID_EDITAR, txtNombres.Text.Trim(), txtDireccion.Text.Trim(),
                                                                    txtTelefono.Text.Trim(), txtNIT.Text.Trim(), txtDUI.Text.Trim(), txtCorreo.Text.Trim(),
                                                                    txtClinicaNombre.Text.Trim(), txtClinicaTelefono.Text.Trim()))
                    {
                        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("La operación no pudo ser completada.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
        }
Example #4
0
        private void btDesasignar_Click(object sender, EventArgs e)
        {
            if (dgRegistros.SelectedRows.Count > 0)
            {
                var ps = new CTRL.Persistencia();
                ps.IniciarTransaccion();

                foreach (DataGridViewRow F in dgRegistros.SelectedRows)
                {
                    var fila = (dsSysLab.PACIENTERow)((DataRowView)F.DataBoundItem).Row;
                    if (CTRL.Administracion.Pacientes.AsignarPaciente(ps.DB, fila.ID_PACIENTE, null))
                    {
                        ps.FinalizarTransaccion();
                        MessageBox.Show("Los pacientes se asignaron satisfactoriamente.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.pACIENTETableAdapter.Fill(this.dsSysLab.PACIENTE);
                    }
                    else
                    {
                        ps.RevertirTransaccion();
                        MessageBox.Show("La operación no pudo ser completada.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
            else
            {
                MessageBox.Show("Debe seleccionar al menos un paciente a desasignar", "SysLab",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #5
0
 private void cmdEliminar_Click(object sender, EventArgs e)
 {
     if (dgRegistros.SelectedRows.Count != 0)
     {
         var ps = new CTRL.Persistencia();
         ps.IniciarTransaccion();
         int errores = 0;
         foreach (DataGridViewRow item in dgRegistros.SelectedRows)
         {
             var fila = (dsSysLab.PACIENTERow)((DataRowView)item.DataBoundItem).Row;
             if (!CTRL.Administracion.Pacientes.EliminarPaciente(ps.DB, fila.ID_PACIENTE))
             {
                 errores++;
             }
         }
         if (errores > 0)
         {
             ps.RevertirTransaccion();
         }
         else
         {
             ps.FinalizarTransaccion();
             frmPacientes_Load(sender, e);
         }
     }
 }
Example #6
0
        private void cmdGuardar_Click(object sender, EventArgs e)
        {
            if (txtNombres.Text.Trim() == string.Empty)
            {
                MessageBox.Show("El nombre de la familia no es válido.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                var ps = new CTRL.Persistencia();
                ps.IniciarTransaccion();

                if (!this._EDITANDO)
                {
                    if (CTRL.Administracion.Clasificaciones.AgregarFamilia(ps.DB, this._ID__CATEG, txtNombres.Text.Trim(), txtDesc.Text.Trim()))
                    {
                        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.Clasificaciones.EditarFamilia(ps.DB, this._ID_EDITAR, txtNombres.Text.Trim(), txtDesc.Text.Trim()))
                    {
                        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);
                    }
                }
            }
        }
Example #7
0
        private void cmdGuardar_Click(object sender, EventArgs e)
        {
            if (cbDoctor.SelectedIndex < 0)
            {
                MessageBox.Show("Debe seleccionar un doctor.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                var ps = new CTRL.Persistencia();
                ps.IniciarTransaccion();

                if (!this._EDITANDO)
                {
                    if (CTRL.Administracion.Talonarios.AgregarTalonario(ps.DB, (long)cbDoctor.SelectedValue,
                                                                        dtpFecha.Value, (int)nudCantidad.Value))
                    {
                        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("La operación no pudo ser completada.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    if (CTRL.Administracion.Talonarios.EditarTalonario(ps.DB, this._ID_EDITAR, (long)cbDoctor.SelectedValue,
                                                                       (int)nudCantidad.Value, dtpFecha.Value))
                    {
                        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("La operación no pudo ser completada.", "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
        }
Example #8
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);
            }
        }
Example #9
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);
                    }
                }
            }
        }
Example #10
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);
            }
        }
Example #11
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);
            }
        }
Example #12
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);
                    }
                }
            }
        }
Example #13
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);
                    }
                }
            }
        }