예제 #1
0
        private void formulario_check(object sender, RoutedEventArgs e)
        {
            string nombreA    = txtNombreAlumnoFO.Text;
            string apellidoA  = txtApellidoAlumnoFO.Text;
            string edad       = txtEdadFO.Text;
            string grado      = txtGradoFO.Text;
            string municipio  = txtMunicipiFO.Text;
            string direccion  = txtDireccioFO.Text;
            string nacimiento = txtNacimientoFO.Text;
            string nombreT    = txtNombreTutorFO.Text;
            string apellidoT  = txtApellidoTutorFO.Text;
            string numero     = txtNumeroFO.Text;

            if (nombreA != "" && apellidoA != "" && edad != "" && grado != "" && municipio != "" && direccion != "" && nacimiento != "" && nombreT != "" && apellidoT != "" && numero != "")
            {
                natacadEntities dbe = new natacadEntities();
                natacadT        nt  = new natacadT();
                nt.Nombre              = txtNombreAlumnoFO.Text;
                nt.Apellidos           = txtApellidoAlumnoFO.Text;
                nt.Edad                = txtEdadFO.Text + " Años";
                nt.Grado               = txtGradoFO.Text;
                nt.Municipio           = txtMunicipiFO.Text;
                nt.Direccion           = txtDireccioFO.Text;
                nt.Fecha_de_nacimiento = Convert.ToDateTime(txtNacimientoFO.Text);
                nt.Nombre_Tutor        = txtNombreTutorFO.Text;
                nt.Apellidos_Tutor     = txtApellidoTutorFO.Text;
                nt.Celular_Tutor       = txtNumeroFO.Text;
                nt.codigo              = int.Parse("234");
                nt.cantidad            = int.Parse("1500");
                dbe.natacadT.Add(nt);
                dbe.SaveChanges();
                MessageBox.Show("El formulario ha sido completado");
                txtNombreAlumnoFO.Text   = "";
                txtApellidoAlumnoFO.Text = "";
                txtEdadFO.Text           = "";
                txtGradoFO.Text          = "";
                txtMunicipiFO.Text       = "";
                txtDireccioFO.Text       = "";
                txtNacimientoFO.Text     = "";
                txtNombreTutorFO.Text    = "";
                txtApellidoTutorFO.Text  = "";
                txtNumeroFO.Text         = "";
            }
            else
            {
                MessageBox.Show("Por favor complete el formulario");
            }
        }
예제 #2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (txtCantidad.Text != "" && txtTotal.Text != "" && txtDescripcion.Text != "")
     {
         natacadEntities dbe = new natacadEntities();
         DineroS         nt  = new DineroS();
         nt.codigo      = int.Parse("234");
         nt.cantidad    = int.Parse(txtCantidad.Text);
         nt.Descripcion = txtDescripcion.Text;
         dbe.DineroS.Add(nt);
         dbe.SaveChanges();
         MessageBox.Show("Operación realizada con éxito");
         // actualizar
         DBClass.openConnection();
         DBClass.sql             = "SELECT [cantidad], [Descripcion] FROM DineroS;";
         DBClass.cmd.CommandType = CommandType.Text;
         DBClass.cmd.CommandText = DBClass.sql;
         //
         DBClass.da = new SqlDataAdapter(DBClass.cmd);
         DBClass.dt = new DataTable();
         DBClass.da.Fill(DBClass.dt);
         myDataGridIngresos.ItemsSource = DBClass.dt.DefaultView;
         DBClass.closeConnection();
         // mostrar total de dinero
         DBClass.GetConnectionStrings();
         DBClass.openConnection();
         string        sqlSelectQuery = "SELECT Disponible FROM DineroNT";
         SqlCommand    cmd            = new SqlCommand(sqlSelectQuery, DBClass.con);
         SqlDataReader dr             = cmd.ExecuteReader();
         if (dr.Read())
         {
             txtTotal.Text = (dr["Disponible"].ToString());
         }
         DBClass.closeConnection();
         txtCantidad.Text    = "";
         txtDescripcion.Text = "";
     }
     else
     {
         MessageBox.Show("Por favor llenar todos los campos");
     }
 }