private void button1_Click(object sender, EventArgs e) { using (SampleContext db = new SampleContext()) { db.PeripheralDevices.Load(); dataGridView1.DataSource = db.PeripheralDevices.Local.ToBindingList(); dataGridView1.Columns[4].Visible = false; dataGridView1.Columns[6].Visible = false; dataGridView1.Columns[8].Visible = false; dataGridView1.Columns[10].Visible = false; } }
public WirterForm() { InitializeComponent(); Writer wr = new Writer(); SampleContext db = new SampleContext(); //foreach (Computer cm in db.Computers) // wr.DoWriteC(cm); //foreach (PeripheralDevice pd in db.PeripheralDevices) // wr.DoWriteP(pd); string path = Application.LocalUserAppDataPath; using (var dialog = new FolderBrowserDialog()) if (dialog.ShowDialog() == DialogResult.OK) { path = dialog.SelectedPath; } wr.SaveFile(path); }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Equals("")) { MessageBox.Show("Fill all fields"); } else { using (SampleContext db = new SampleContext()) { Departament departament = new Departament(); departament.DepartamentName = textBox1.Text; db.Departaments.Add(departament); db.SaveChanges(); this.Close(); } } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Equals("") || textBox2.Text.Equals("")) { MessageBox.Show("Fill all fields"); } else { using (SampleContext db = new SampleContext()) { Administrator administrator = new Administrator(); administrator.Login = textBox1.Text; administrator.Password = textBox2.Text; db.Administrators.Add(administrator); db.SaveChanges(); this.Close(); } } }
public void UpdateEmployee() { using (SampleContext db = new SampleContext()) { //db.Employees.Load(); //dataGridView3.DataSource = db.Employees.Local.ToBindingList(); //dataGridView3.Columns[4].Visible = false; //dataGridView3.Columns[6].Visible = false; var resn = from em in db.Employees join dep in db.Departaments on em.DepartamentId equals dep.DepartamentId select new { em.EmployeeID, em.fullName, em.position, dep.DepartamentName, em.ComputerId }; dataGridView3.DataSource = resn.ToList(); } }
public void UpdateEmployee() { using (SampleContext db = new SampleContext()) { var resn = from em in db.Employees join dep in db.Departaments on em.DepartamentId equals dep.DepartamentId select new { em.EmployeeID, em.fullName, em.position, dep.DepartamentName, em.ComputerId }; dataGridView3.DataSource = resn.ToList(); dataGridView3.Columns[0].HeaderText = "ID"; dataGridView3.Columns[1].HeaderText = "Full Name"; dataGridView3.Columns[2].HeaderText = "Position"; dataGridView3.Columns[3].HeaderText = "Departament"; dataGridView3.Columns[4].HeaderText = "Computer"; dataGridView3.Rows[0].Selected = true; } }
public void UpdateComp() { using (SampleContext db = new SampleContext()) { //db.Computers.Load(); //dataGridView2.DataSource = db.Computers.Local.ToBindingList(); //dataGridView2.Columns[3].Visible = false; //dataGridView2.Columns[5].Visible = false; //dataGridView2.Columns[7].Visible = false; var resn = from cmp in db.Computers join mat in db.Motherboards on cmp.MotherboardId equals mat.MotherboardId join hdd in db.HDDs on cmp.HddId equals hdd.HddId join cp in db.CPUs on cmp.CpuId equals cp.CpuId select new { cmp.ComputerId, cmp.status, mat.MotherboardName, cp.CpuName, hdd.HddName }; dataGridView2.DataSource = resn.ToList(); } }