Esempio n. 1
0
        private void Add_Button(object sender, EventArgs e)
        {
            if (textBox2.Text.Equals(""))
            {
                MessageBox.Show("Fill all fields");
            }
            else
            {
                PeripheralDevice peripheral = new PeripheralDevice();
                peripheral.status = comboBox4.Text;
                peripheral.name   = textBox2.Text;

                var val = int.Parse(comboBox1.SelectedValue.ToString());
                peripheral.manufacturer = db.Manufacturers.Where(s => s.ManufacturerId == val).FirstOrDefault <Manufacturer>();

                var           val1 = int.Parse(comboBox2.SelectedValue.ToString());
                Project1.Type t    = db.Types.Where(s => s.TypeId == val1).FirstOrDefault <Type>();
                peripheral.TypeId = t.TypeId;

                var val2 = int.Parse(comboBox3.SelectedValue.ToString());
                peripheral.departament = db.Departaments.Where(s => s.DepartamentId == val2).FirstOrDefault <Departament>();

                var val3 = int.Parse(comboBox5.SelectedValue.ToString());
                peripheral.computer = db.Computers.Where(s => s.ComputerId == val3).FirstOrDefault <Computer>();

                db.PeripheralDevices.Add(peripheral);
                db.SaveChanges();
                this.Close();
            }
        }
Esempio n. 2
0
        private void Add_Button(object sender, EventArgs e)
        {
            Computer computer = new Computer();

            computer.status = comboBox4.Text;

            var val = int.Parse(comboBox1.SelectedValue.ToString());

            computer.motherboard = db.Motherboards.Where(
                s => s.MotherboardId == val
                ).FirstOrDefault <Motherboard>();

            var val1 = int.Parse(comboBox2.SelectedValue.ToString());

            computer.hdd = db.HDDs.Where(
                s => s.HddId == val1
                ).FirstOrDefault <HDD>();

            var val2 = int.Parse(comboBox3.SelectedValue.ToString());

            computer.cpu = db.CPUs.Where(
                s => s.CpuId == val2
                ).FirstOrDefault <CPU>();
            db.Computers.Add(computer);
            db.SaveChanges();
            this.Close();
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Manufacturer manufacturer = new Manufacturer();

            manufacturer.ManufacturerName = textBox1.Text;
            db.Manufacturers.Add(manufacturer);
            db.SaveChanges();
            this.Close();
        }
Esempio n. 4
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (SampleContext db = new SampleContext())
     {
         Departament departament = new Departament();
         departament.DepartamentName = textBox1.Text;
         db.Departaments.Add(departament);
         db.SaveChanges();
         this.Close();
     }
 }
Esempio n. 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            Type type = new Type
            {
                TypeName = textBox1.Text
            };

            db.Types.Add(type);
            db.SaveChanges();
            this.Close();
        }
Esempio n. 6
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (SampleContext db = new SampleContext())
     {
         Administrator administrator = new Administrator();
         administrator.Login    = textBox1.Text;
         administrator.Password = textBox2.Text;
         db.Administrators.Add(administrator);
         db.SaveChanges();
     }
 }
Esempio n. 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            Employee employee = new Employee();

            employee.fullName    = textBox1.Text;
            employee.position    = textBox2.Text;
            employee.departament = db.Departaments.Find(comboBox1.SelectedValue);
            employee.computer    = db.Computers.Find(comboBox2.SelectedValue);
            db.Employees.Add(employee);
            db.SaveChanges();
            this.Close();
        }
Esempio n. 8
0
        private void Delete(object sender, EventArgs e)
        {
            switch (Tabform.SelectedIndex)
            {
            case 0:
                int index = dataGridView1.SelectedRows[0].Index;
                int id    = 0;
                Int32.TryParse(dataGridView1[0, index].Value.ToString(), out id);
                PeripheralDevice player = db.PeripheralDevices.Find(id);
                db.PeripheralDevices.Remove(player);
                db.SaveChanges();
                UpdatePD();
                break;

            case 1:
                int index1 = dataGridView2.SelectedRows[0].Index;
                int id1    = 0;
                Int32.TryParse(dataGridView2[0, index1].Value.ToString(), out id1);
                Computer player1 = db.Computers.Find(id1);
                db.Computers.Remove(player1);
                db.SaveChanges();
                UpdateComp();
                break;

            case 2:
                int index2 = dataGridView3.SelectedRows[0].Index;
                int id2    = 0;
                Int32.TryParse(dataGridView3[0, index2].Value.ToString(), out id2);
                Employee player2 = db.Employees.Find(id2);
                db.Employees.Remove(player2);
                db.SaveChanges();
                UpdateEmployee();
                break;
            }
        }
Esempio n. 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            CPU cpu = new CPU();
            var val = int.Parse(comboBox1.SelectedValue.ToString());

            cpu.manufacturer = db.Manufacturers.Where(
                s => s.ManufacturerId == val
                ).FirstOrDefault <Manufacturer>();
            cpu.CpuName = textBox1.Text;
            cpu.rate    = textBox2.Text;
            db.CPUs.Add(cpu);
            db.SaveChanges();
            this.Close();
        }
Esempio n. 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            HDD hdd = new HDD();
            var val = int.Parse(comboBox1.SelectedValue.ToString());

            hdd.manufacturer = db.Manufacturers.Where(
                s => s.ManufacturerId == val
                ).FirstOrDefault <Manufacturer>();
            hdd.capacity = Convert.ToInt32(textBox1.Text);
            hdd.HddName  = textBox2.Text;
            db.HDDs.Add(hdd);
            db.SaveChanges();
            this.Close();
        }
Esempio n. 11
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text.Equals(""))
     {
         MessageBox.Show("Fill all fields");
     }
     else
     {
         Manufacturer manufacturer = new Manufacturer();
         manufacturer.ManufacturerName = textBox1.Text;
         db.Manufacturers.Add(manufacturer);
         db.SaveChanges();
         this.Close();
     }
 }
Esempio n. 12
0
        private void button1_Click(object sender, EventArgs e)
        {
            Motherboard motherboard = new Motherboard();

            motherboard.MotherboardName = textBox1.Text;

            var val = int.Parse(comboBox1.SelectedValue.ToString());

            motherboard.manufacturer = db.Manufacturers.Where(
                s => s.ManufacturerId == val
                ).FirstOrDefault <Manufacturer>();

            db.Motherboards.Add(motherboard);
            db.SaveChanges();
            this.Close();
        }
Esempio n. 13
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text.Equals(""))
     {
         MessageBox.Show("Fill all fields");
     }
     else
     {
         Type type = new Type
         {
             TypeName = textBox1.Text
         };
         db.Types.Add(type);
         db.SaveChanges();
         this.Close();
     }
 }
Esempio n. 14
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text.Equals("") || textBox2.Text.Equals(""))
     {
         MessageBox.Show("Fill all fields");
     }
     else
     {
         Employee employee = new Employee();
         employee.fullName    = textBox1.Text;
         employee.position    = textBox2.Text;
         employee.departament = db.Departaments.Find(comboBox1.SelectedValue);
         employee.computer    = db.Computers.Find(comboBox2.SelectedValue);
         db.Employees.Add(employee);
         db.SaveChanges();
         this.Close();
     }
 }
Esempio n. 15
0
 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();
         }
     }
 }
Esempio n. 16
0
 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();
         }
     }
 }
Esempio n. 17
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text.Equals("") || textBox2.Text.Equals(""))
     {
         MessageBox.Show("Fill all fields");
     }
     else
     {
         CPU cpu = new CPU();
         var val = int.Parse(comboBox1.SelectedValue.ToString());
         cpu.manufacturer = db.Manufacturers.Where(
             s => s.ManufacturerId == val
             ).FirstOrDefault <Manufacturer>();
         cpu.CpuName = textBox1.Text;
         cpu.rate    = textBox2.Text;
         db.CPUs.Add(cpu);
         db.SaveChanges();
         this.Close();
     }
 }
Esempio n. 18
0
        private void Delete(object sender, EventArgs e)
        {
            switch (Tabform.SelectedIndex)
            {
            case 0:
                int  num  = 0;
                int  id   = 0;
                bool scan = true;
                for (int i = 0; i < dataGridView1.RowCount; i++)
                {
                    if (dataGridView1.Rows[i].Selected == true)
                    {
                        Int32.TryParse(dataGridView1[0, i].Value.ToString(), out id);
                        PeripheralDevice player = db.PeripheralDevices.Find(id);
                        db.PeripheralDevices.Remove(player);
                        num++;
                        scan = false;
                    }
                }
                db.SaveChanges();
                UpdatePD();
                if (scan == true)
                {
                    MessageBox.Show("Надо выбрать строку полностью");
                }
                if (scan == false)
                {
                    MessageBox.Show("Удалено:" + num);
                }
                break;

            case 1:
                num = 0;
                int id1 = 0;
                scan = true;
                int sel = 0;
                for (int i = 0; i < dataGridView2.RowCount; i++)
                {
                    if (dataGridView2.Rows[i].Selected == true)
                    {
                        sel++;
                        Int32.TryParse(dataGridView2[0, i].Value.ToString(), out id1);
                        Computer player1 = db.Computers.Find(id1);
                        if (db.Employees.Where(s => s.ComputerId == player1.ComputerId).FirstOrDefault <Employee>() != null || db.PeripheralDevices.Where(s => s.ComputerId == player1.ComputerId).FirstOrDefault <PeripheralDevice>() != null)
                        {
                            scan = false;
                        }
                    }
                }
                if (sel == 0)
                {
                    MessageBox.Show("Надо выбрать строку полностью");
                }
                else if (scan == false)
                {
                    MessageBox.Show("К этому компьютеру уже назначен пользователь или периферия");
                }
                else if (scan == true)
                {
                    for (int i = 0; i < dataGridView2.RowCount; i++)
                    {
                        if (dataGridView2.Rows[i].Selected == true)
                        {
                            Int32.TryParse(dataGridView2[0, i].Value.ToString(), out id1);
                            Computer player1 = db.Computers.Find(id1);
                            db.Computers.Remove(player1); num++;
                        }
                    }

                    db.SaveChanges();
                    UpdateComp();
                    MessageBox.Show("Удалено:" + num);
                }
                break;

            case 2:
                num  = 0;
                scan = true;
                int id2 = 0;
                for (int i = 0; i < dataGridView3.RowCount; i++)
                {
                    if (dataGridView3.Rows[i].Selected == true)
                    {
                        Int32.TryParse(dataGridView3[0, i].Value.ToString(), out id2);
                        Employee player2 = db.Employees.Find(id2);
                        db.Employees.Remove(player2);
                        num++;
                        scan = false;
                    }
                }
                db.SaveChanges();
                UpdateEmployee();
                if (scan == true)
                {
                    MessageBox.Show("Надо выбрать строку полностью");
                }
                if (scan == false)
                {
                    MessageBox.Show("Удалено:" + num);
                }
                break;
            }
        }