Example #1
0
        private void btmguardar_Click(object sender, EventArgs e)
        {
            if (validar())
            {
                string sql = "";
                if (nuevo == true)
                {
                    Partituras Pa = new Partituras();
                    Pa.pNombre_cancion = txtnombre.Text;
                    if (rbtno.Checked)
                    {
                        Pa.pCapotrasto = 0;
                    }
                    else
                    if (rbtsi.Checked)
                    {
                        Pa.pCapotrasto = 1;
                    }
                    Pa.pPosicion_capo = Convert.ToInt32(txtcapo.Text);
                    Pa.pLetra1        = txtpartitura.Text;
                    Pa.pLetra2        = txtpartitura2.Text;
                    Pa.pId_genero     = Convert.ToInt32(cbogenero.SelectedValue);
                    Pa.pId_autor      = Convert.ToInt32(cboautor.SelectedValue);
                    sql = "Insert into Partituras Values('" + Pa.pNombre_cancion.Replace("'", "''") + "'," + Pa.pCapotrasto + "," + Pa.pPosicion_capo +
                          ",'" + Pa.pLetra1.Replace("'", "''") + "','" + Pa.pLetra2.Replace("'", "''") + "'," + Pa.pId_genero + "," + Pa.pId_autor + ")";

                    nuevo = false;
                }
                else
                {
                    int i = lstpartitura.SelectedIndex;
                    vp[i].pNombre_cancion = txtnombre.Text;
                    if (rbtno.Checked)
                    {
                        vp[i].pCapotrasto = 0;
                    }
                    else
                    if (rbtsi.Checked)
                    {
                        vp[i].pCapotrasto = 1;
                    }
                    vp[i].pPosicion_capo = Convert.ToInt32(txtcapo.Text);
                    vp[i].pLetra1        = txtpartitura.Text;
                    vp[i].pLetra2        = txtpartitura2.Text;
                    vp[i].pId_genero     = Convert.ToInt32(cbogenero.SelectedValue);
                    vp[i].pId_autor      = Convert.ToInt32(cboautor.SelectedValue);
                    sql = "Update Partituras set nombre_cancion='" + vp[i].pNombre_cancion.Replace("'", "''") + "',capotrasto=" + vp[i].pCapotrasto + ",posicion_capo=" +
                          vp[i].pPosicion_capo + ",letra1='" + vp[i].pLetra1.Replace("'", "''") + "',letra2='" + vp[i].pLetra2.Replace("'", "''") + "',id_genero=" + vp[i].pId_genero + ",id_autor=" + vp[i].pId_autor +
                          " where id_partitura=" + vp[i].pId_partitura;
                }
                datos.actualizarDB(sql);
                Habilitar(true);
                cargarLista("Partituras", "order by 2");
                Limpiar();
                lstpartitura.Enabled = true;
            }
        }
Example #2
0
        private void cargarLista(string sql)
        {
            int c = 0;

            datos.LeerTabla2(sql);
            while (datos.pLector.Read())
            {
                Partituras P = new Partituras();
                if (!datos.pLector.IsDBNull(0))
                {
                    P.pId_partitura = datos.pLector.GetInt32(0);
                }
                if (!datos.pLector.IsDBNull(1))
                {
                    P.pNombre_cancion = datos.pLector.GetString(1);
                }
                if (!datos.pLector.IsDBNull(2))
                {
                    P.pCapotrasto = datos.pLector.GetInt32(2);
                }
                P.pCapotrasto = datos.pLector.GetInt32(2);
                P.pCapotrasto = datos.pLector.GetInt32(2);
                if (!datos.pLector.IsDBNull(3))
                {
                    P.pPosicion_capo = datos.pLector.GetInt32(3);
                }
                if (!datos.pLector.IsDBNull(4))
                {
                    P.pLetra1 = datos.pLector.GetString(4);
                }
                if (!datos.pLector.IsDBNull(5))
                {
                    P.pLetra2 = datos.pLector.GetString(5);
                }
                if (!datos.pLector.IsDBNull(6))
                {
                    P.pId_genero = datos.pLector.GetInt32(6);
                }
                if (!datos.pLector.IsDBNull(7))
                {
                    P.pId_autor = datos.pLector.GetInt32(7);
                }
                vp[c] = P;
                c++;
            }
            datos.pLector.Close();
            datos.desconectar();
            lstpartitura.Items.Clear();
            for (int i = 0; i < c; i++)
            {
                lstpartitura.Items.Add(vp[i].toString());
            }
            lstpartitura.SelectedIndex = -1;
        }