예제 #1
0
        public FormEditLector(lectors lec)
        {
            lect = lec;
            InitializeComponent();
            var group_for_list = (from g in db.lectors
                                  select g.post).Distinct();

            foreach (string it in group_for_list)
            {
                comboBox1.Items.Add(it);
            }
            textBox1.Text = lect.name_lector.ToString();
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            proverka(textBox1);
            var q = (from s in db.lectors
                     where s.post == comboBox1.SelectedItem.ToString()
                     select s.post).ToList();
            var     codde_lec = db.lectors.Max(r => r.code_lector) + 1;
            lectors lec       = new lectors {
                code_lector = codde_lec, name_lector = textBox1.Text, post = q[0].ToString()
            };

            db.lectors.Add(lec);
            db.SaveChanges();
            this.Close();
        }
예제 #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            List <lectors> query = (from lect in db.lectors
                                    select lect).ToList();

            if (dataGridView1.SelectedCells.Count == 1)
            {
                if (Application.OpenForms.Count == 2)
                {
                    lectors lect = query.First(c => c.code_lector.ToString() == dataGridView1.SelectedCells[0]
                                               .OwningRow.Cells[0].Value.ToString());
                    FormEditLector edLect = new FormEditLector(lect);
                    edLect.Owner = this;
                    edLect.Show();
                }
            }
        }