Procesos para Pseint

May 22, 2017 | Autor: Camilo Meneses | Categoría: Lenguajes De Programacion
Share Embed


Descripción

JUEGO DE DADOS CON GRID
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace jugar
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

int filasCreadas = -1; //contador de fila

private void btnjugar_Click(object sender, EventArgs e)
{
Random aleatorio = new Random();
for (int i = 0; i y) dataGrid.Rows[filasCreadas].Cells[0].Value = "gano";

else
{
dataGrid.Rows[filasCreadas].Cells[1].Value = "gano";
}
}
}//finfor

}

}
}
BANDERA 3 COLORES
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace parcial
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Random Aleatorio = new Random();
byte ban1;
byte ban2;
byte ban3;

ban1= byte.Parse(Aleatorio.Next(1,4).ToString ());
ban2 = byte.Parse(Aleatorio.Next(1, 4).ToString());
ban3 = byte.Parse(Aleatorio.Next(1, 4).ToString());

switch (ban1)
{
case 1:
Lbl_Color1.BackColor= Color.Red;
break;

case 2:
Lbl_Color1.BackColor = Color.Blue;
break;

case 3:
Lbl_Color1.BackColor = Color.Yellow;
break;

}

switch (ban2)
{
case 1:
Lbl_Color2.BackColor = Color.Red;
break;

case 2:
Lbl_Color2.BackColor = Color.Blue;
break;

case 3:
Lbl_Color2.BackColor = Color.Yellow;
break;
}

switch (ban3)
{
case 1:
Lbl_Color3.BackColor = Color.Red;
break;

case 2:
Lbl_Color3.BackColor = Color.Blue;
break;

case 3:
Lbl_Color3.BackColor = Color.Yellow;
break;
}

//ciclo para bandera incorrecta
if (ban1 == ban2) Lbl_Resultado.Text = "Bandera Incorrecta";

else
{
if (ban2 == ban3) Lbl_Resultado.Text = "Bandera Incorrecta";
else
{
Lbl_Resultado.Text = "Bandera Correcta";
}//fin else

}//fin if


}
}
}

GUARDAR Y CARGAR GRIDDATOS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace OtrosControles_10_11_2015_
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
radioMasculino.Checked = true;
radioSoltero.Checked = true;
}
int filasAgregadas = -1;
string nombreArchivo;
string cad;
private void btnAdicion_Click(object sender, EventArgs e)
{
GridDatos.Rows.Add();//ADICIONA UNA LINEA AL DATA GRID VIEW
filasAgregadas += 1;

//NOMBRE Y APELLIDOS
GridDatos.Rows[filasAgregadas].Cells[0].Value = txtNombre.Text + " " + txtApellido.Text;

//SEXO
if (radioFemenino.Checked) GridDatos.Rows[filasAgregadas].Cells[1].Value = "F";
else GridDatos.Rows[filasAgregadas].Cells[1].Value = "M";

//ESTADO CIVIL

if (radioCasado.Checked) GridDatos.Rows[filasAgregadas].Cells[2].Value = "C";
else GridDatos.Rows[filasAgregadas].Cells[2].Value = "S";

//EDAD
GridDatos.Rows[filasAgregadas].Cells[3].Value = numericoEdad.Text;

//AFICIONES
string aficiones = "";
if (checkDeportes.Checked) aficiones += "Deportes ";
if (checkLectura.Checked) aficiones += "Lectura ";
if (checkCine.Checked) aficiones += "Cine ";
if (checkTurismo.Checked) aficiones += "Turismo ";
if (checkBaile.Checked) aficiones += "Baile ";
if (checkTv.Checked) aficiones += "Televisión ";
GridDatos.Rows[filasAgregadas].Cells[4].Value = aficiones;
//LIMPIANDO OBJETOS
txtNombre.Text = "";
txtApellido.Text = "";
radioMasculino.Checked = true;
radioSoltero.Checked = true;
numericoEdad.Text = "1";
checkLectura.Checked = false;
checkCine.Checked = false;
checkDeportes.Checked = false;
checkTurismo.Checked = false;
checkTv.Checked = false;
checkBaile.Checked = false;
}//FIN EVENTO CLICK BTN ADICIONAR DATOS

private void btnGuardar_Click(object sender, EventArgs e)//BOTON GUARDAR
{
SaveFileDialog dialogoGuardar = new SaveFileDialog();
dialogoGuardar.Title = "Guardar en Formato CSV";
dialogoGuardar.FileName = "SinNombre.csv";
dialogoGuardar.Filter = "Archivos separados por comas (*.csv)"*.csv"Todos los Archivos (*.*)"*.*";
dialogoGuardar.OverwritePrompt = true;


if (dialogoGuardar.ShowDialog() == DialogResult.OK && dialogoGuardar.FileName != "")
{
nombreArchivo = dialogoGuardar.FileName;
StreamWriter archivo = new StreamWriter(nombreArchivo);//GRABA EL ARCHIVO CARGAR EL SYSTEM.IO; en el name space
int fil, col;
for ( fil=0;fil
Lihat lebih banyak...

Comentarios

Copyright © 2017 DATOSPDF Inc.