コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Select_Instructor_Result ins = ent.Select_Instructor(instructorID).First();
            int     deptID = int.Parse(ins.Department_ID.ToString());
            Student std    = new Student();

            if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "")
            {
                std.Fname   = textBox2.Text;
                std.Lname   = textBox1.Text;
                std.Address = textBox3.Text;
                std.DoB     = Convert.ToDateTime(textBox4.Text);
                std.DeptId  = deptID;
                ent.Students.Add(std);
                MessageBox.Show("ADDED");
                ent.SaveChanges();
                loadStudentData();
            }
            else
            {
                MessageBox.Show("PLEASE ENTER FULL DATA");
            }

            //ent.Insert_Student()
        }
コード例 #2
0
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dataGridView1.CurrentCell.ColumnIndex > 0)
     {
         this.dataGridView1.CurrentCell.Selected = false;
     }
     else
     {
         int insID = int.Parse(dataGridView1.SelectedCells[0].Value.ToString());
         Select_Instructor_Result myins = ent.Select_Instructor(insID).First();
         var myInsDept = ent.Departments.Find(myins.Department_ID);
         comboBox1.Text = myInsDept.DeptName;
         comboBox2.Text = myins.Instructor_ID.ToString();
         textBox2.Text  = myins.Instructor_name;
     }
 }