public int ProximoCodigoIndividual(DIdentInstrumento Ident_Instrumento)
        {
            DataTable     DtResultado = new DataTable();
            SqlConnection SlqCon      = new SqlConnection();

            try
            {
                string sp = "SpIdent_InstrumentoProximoCodigoIndividual";

                SlqCon.ConnectionString = Conexion.Cn;
                SqlCommand SqlCmd = new SqlCommand(sp, SlqCon);

                SlqCon.Open();
                SqlCmd.CommandType = CommandType.StoredProcedure;
                SqlCmd.Parameters.AddWithValue("@ID_INSTRUMENTO", Ident_Instrumento.Id_instrumento);

                SqlDataAdapter SqlDat = new SqlDataAdapter(SqlCmd);
                SqlDat.Fill(DtResultado);
            }
            catch
            {
                DtResultado = null;
            }
            finally
            {
                if (SlqCon.State == ConnectionState.Open)
                {
                    SlqCon.Close();
                }
            }
            return(Convert.ToInt32(DtResultado.Rows[0][0]));
        }
        public string Eliminar(DIdentInstrumento Ident_Instrumento)
        {
            string        rpta   = "";
            SqlConnection SlqCon = new SqlConnection();

            try
            {
                string sp = "SpIdent_InstrumentoEliminar";

                SlqCon.ConnectionString = Conexion.Cn;
                SqlCommand SqlCmd = new SqlCommand(sp, SlqCon);
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SlqCon.Open();

                SqlCmd.Parameters.AddWithValue("@ID", Ident_Instrumento.Id);

                rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "NO se Elimino el Registro";

                return(rpta);
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
            }
            finally
            {
                if (SlqCon.State == ConnectionState.Open)
                {
                    SlqCon.Close();
                }
            }

            return(rpta);
        }
        public DataTable Buscar(DIdentInstrumento Ident_Instrumento)
        {
            DataTable     DtResultado = new DataTable();
            SqlConnection SlqCon      = new SqlConnection();

            try
            {
                string sp = "SpIdent_InstrumentoObtener";

                SlqCon.ConnectionString = Conexion.Cn;
                SqlCommand SqlCmd = new SqlCommand(sp, SlqCon);

                SlqCon.Open();
                SqlCmd.CommandType = CommandType.StoredProcedure;
                SqlCmd.Parameters.AddWithValue("@ID_INSTRUMENTO", Ident_Instrumento.Id_instrumento);
                SqlCmd.Parameters.AddWithValue("@ID_INDIVUAL", Ident_Instrumento.Id_indivual);

                SqlDataAdapter SqlDat = new SqlDataAdapter(SqlCmd);
                SqlDat.Fill(DtResultado);
            }
            catch
            {
                DtResultado = null;
            }
            finally
            {
                if (SlqCon.State == ConnectionState.Open)
                {
                    SlqCon.Close();
                }
            }
            return(DtResultado);
        }
        public string Actualizar(DIdentInstrumento Ident_Instrumento)
        {
            string        rpta   = "";
            SqlConnection SlqCon = new SqlConnection();

            try
            {
                string sp = "SpIdent_InstrumentoActualizar";

                SlqCon.ConnectionString = Conexion.Cn;
                SqlCommand SqlCmd = new SqlCommand(sp, SlqCon);
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SlqCon.Open();

                SqlCmd.Parameters.AddWithValue("@ID", Ident_Instrumento.Id);
                SqlCmd.Parameters.AddWithValue("@ID_INSTRUMENTO", Ident_Instrumento.Id_instrumento);
                SqlCmd.Parameters.AddWithValue("@ID_INDIVUAL", Ident_Instrumento.Id_indivual);
                SqlCmd.Parameters.AddWithValue("@CALIB_NUM", Ident_Instrumento.Calib_Num);
                SqlCmd.Parameters.AddWithValue("@ULTIMA_CALIB", Ident_Instrumento.Ultima_Calib);
                SqlCmd.Parameters.AddWithValue("@INGRESO", Ident_Instrumento.Ingreso);
                SqlCmd.Parameters.AddWithValue("@ESTADO", Ident_Instrumento.Estado);
                SqlCmd.Parameters.AddWithValue("@PROX_CALIB", Ident_Instrumento.Prox_Calib);
                SqlCmd.Parameters.AddWithValue("@COD_TRAB", Ident_Instrumento.Cod_Trab);
                SqlCmd.Parameters.AddWithValue("@NOM_TRAB", Ident_Instrumento.Nom_Trab);
                SqlCmd.Parameters.AddWithValue("@CERTIFICADO", Ident_Instrumento.Certificado);
                SqlCmd.Parameters.AddWithValue("@MARCA", Ident_Instrumento.Marca);

                rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "NO se Modifico el Registro";
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
            }
            finally
            {
                if (SlqCon.State == ConnectionState.Open)
                {
                    SlqCon.Close();
                }
            }

            return(rpta);
        }