0% found this document useful (0 votes)
11 views2 pages

QLSV

nhảm

Uploaded by

ducanhhoang412
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

QLSV

nhảm

Uploaded by

ducanhhoang412
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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 QLSV
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{
var db = new QLSVEntities();
dataGridView1.DataSource = db.SINHVIENs.ToList();
}
public void xuly(int n)
{
SINHVIEN a = new SINHVIEN();
a.MA = textBox1.Text;
a.HOTEN = textBox2.Text;
a.LOP = textBox3.Text;
a.DIACHI = textBox4.Text;
var context = new QLSVEntities();
if (n == 1) { context.SINHVIENs.Add(a); }
if (n == 2) { context.Entry(a).State =
System.Data.Entity.EntityState.Deleted; }
if (n == 3) { context.Entry(a).State =
System.Data.Entity.EntityState.Modified; }
context.SaveChanges();
dataGridView1.DataSource = context.SINHVIENs.ToList();
dataGridView1.Refresh();

private void THEM_Click(object sender, EventArgs e)


{
xuly(1);
}

private void XOA_Click(object sender, EventArgs e)


{
xuly(2);
}

private void SUA_Click(object sender, EventArgs e)


{
xuly(3);
}
private void dataGridView1_CellContentClick(object sender,
DataGridViewCellEventArgs e)
{
int i = dataGridView1.CurrentRow.Index;
textBox1.Text = dataGridView1.Rows[i].Cells[0].Value.ToString();
textBox2.Text = dataGridView1.Rows[i].Cells[1].Value.ToString();
textBox3.Text = dataGridView1.Rows[i].Cells[2].Value.ToString();
textBox4.Text = dataGridView1.Rows[i].Cells[3].Value.ToString();
}
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy