private void BtnAceptar_Click(object sender, EventArgs e)
        {
            using (Entities db = new Entities())
            {
                if (id == null)
                {
                    nRegistro = new formulario_104();
                }

                nRegistro.periodo     = LblAño.Text;
                nRegistro.Ruc_Usuario = TxtRuc.Text;
                nRegistro.c401        = Convert.ToDouble(Lbl401.Text);
                nRegistro.c409        = Convert.ToDouble(Lbl409.Text);
                nRegistro.c411        = Convert.ToDouble(Lbl411.Text);
                nRegistro.c419        = Convert.ToDouble(Lbl419.Text);
                nRegistro.c421        = Convert.ToDouble(Lbl421.Text);
                nRegistro.c429        = Convert.ToDouble(Lbl429.Text);
                nRegistro.c499        = Convert.ToDouble(Lbl499.Text);

                nRegistro.r601 = Convert.ToDouble(Lbl601.Text);
                nRegistro.r605 = Convert.ToDouble(Lbl605.Text);
                nRegistro.r608 = Convert.ToDouble(Lbl608.Text);
                nRegistro.r609 = Convert.ToDouble(Lbl609.Text);
                nRegistro.r615 = Convert.ToDouble(Lbl615.Text);
                nRegistro.r620 = Convert.ToDouble(Lbl620.Text);
                nRegistro.r699 = Convert.ToDouble(Lbl699.Text);

                if (id == null)
                {
                    db.formulario_104.Add(nRegistro);
                }

                //db.Entry(nRegistro).State = System.Data.Entity.EntityState.Modified;

                db.SaveChanges();
                MessageBox.Show("Su formulario se registro exitosamente");
            }
        }
        private void cargarDatos(int?id)
        {
            using (Entities db = new Entities())
            {
                if (id != null)
                {
                    nRegistro = new formulario_104();
                }
                var list = from d in db.formulario_104
                           where d.Ruc_Usuario == TxtRuc.Text && d.periodo == LblAño.Text
                           select d;
                if (list.Count() > 0)
                {
                    LblAño.Text = nRegistro.periodo;
                    TxtRuc.Text = nRegistro.Ruc_Usuario;
                    Lbl401.Text = Convert.ToString(nRegistro.c401);
                    Lbl409.Text = Convert.ToString(nRegistro.c409);
                    Lbl411.Text = Convert.ToString(nRegistro.c411);
                    Lbl419.Text = Convert.ToString(nRegistro.c419);
                    Lbl421.Text = Convert.ToString(nRegistro.c421);
                    Lbl429.Text = Convert.ToString(nRegistro.c429);
                    Lbl499.Text = Convert.ToString(nRegistro.c499);

                    Lbl601.Text = Convert.ToString(nRegistro.r601);
                    Lbl605.Text = Convert.ToString(nRegistro.r605);
                    Lbl608.Text = Convert.ToString(nRegistro.r608);
                    Lbl609.Text = Convert.ToString(nRegistro.r609);
                    Lbl615.Text = Convert.ToString(nRegistro.r615);
                    Lbl620.Text = Convert.ToString(nRegistro.r620);
                    Lbl699.Text = Convert.ToString(nRegistro.r699);
                }
                else
                {
                    MessageBox.Show("Actualizar formulario");
                }
            }
        }