close

Enter

Log in using OpenID

DataGridView

embedDownload
DataGridView
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
System.IO;
namespace _30102014
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string resim;
private void resim_sec_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);
resim = openFileDialog1.FileName;
}
private void kaydet_Click(object sender, EventArgs e)
{
StreamWriter dosya =
File.AppendText(Application.StartupPath+"\\ogrenciler.txt");
dosya.Write(textBox1.Text+"-");
dosya.Write(textBox2.Text+"-");
dosya.Write(comboBox1.Text+"-");
double vize = Convert.ToDouble(textBox3.Text);
double final = Convert.ToDouble(textBox4.Text);
double ortalama = vize * 0.4 + final * 0.6;
dosya.Write(textBox3.Text+"-");
dosya.Write(textBox4.Text+"-");
dosya.Write(ortalama.ToString()+"-");
dosya.WriteLine(resim);
dosya.Close();
//System.Diagnostics.Process.Start(Application.StartupPath +
"\\ogrenciler.txt");
listele();
}
public void listele()
{
dataGridView1.Rows.Clear();
StreamReader dosya = File.OpenText(Application.StartupPath +
"\\ogrenciler.txt");
string oku = dosya.ReadLine();
while (oku!=null)
{
string[] parca = oku.Split('-');
dataGridView1.Rows.Add(parca[0], parca[1], parca[2], parca[3],
parca[4], parca[5], Image.FromFile(parca[6]));
oku = dosya.ReadLine();
}
dosya.Close();
boya();
}
private void Form1_Load(object sender, EventArgs e)
{
listele();
}
public void boya()
{
for (int i = 0; i <= dataGridView1.Rows.Count-1; i++)
{
if (Convert.ToDouble(dataGridView1.Rows[i].Cells[5].Value)>=50)
{
dataGridView1.Rows[i].Cells[5].Style.BackColor = Color.Blue;
}
else
{
dataGridView1.Rows[i].Cells[5].Style.BackColor = Color.Red;
}
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
dataGridView1.Rows.Clear();
StreamReader dosya = File.OpenText(Application.StartupPath +
"\\ogrenciler.txt");
string oku = dosya.ReadLine();
while (oku != null)
{
string[] parca = oku.Split('-');
if(textBox1.Text==parca[0].Substring(0,textBox1.TextLength))
{
dataGridView1.Rows.Add(parca[0], parca[1], parca[2], parca[3],
parca[4], parca[5], Image.FromFile(parca[6]));
}
oku = dosya.ReadLine();
}
dosya.Close();
boya();
}
private void çıkışToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
Author
Document
Category
Uncategorized
Views
0
File Size
264 KB
Tags
1/--pages
Report inappropriate content