Пример #1
0
 public int AddStudent(Student obj)
 {
     try
     {
         using (CosmosContext ctx = new CosmosContext())
         {
             ctx.Students.Add(obj);
             ctx.SaveChanges();
             return obj.Id;
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Пример #2
0
        public AddStudent()
        {
            InitializeComponent();
            student = new Student();
            guardians = new List<Guardian>();
            studentId = 0;
            List<Class> dbClasses = new ClassDAC().GetAllClasses();

            dbClasses.Insert(0, new Class() { Id = 0, Name = "Select" });

            classComboBox.DataSource = dbClasses;
            classComboBox.DisplayMember = "Name";
            classComboBox.ValueMember = "Id";

            List<ClassSection> sectionsByClass = new List<ClassSection>();

            sectionsByClass.Insert(0, new ClassSection() { Id = 0, Name = "Select" });
            sectionsComboBox.DataSource = sectionsByClass;
            sectionsComboBox.DisplayMember = "Name";
            sectionsComboBox.ValueMember = "Id";

            sectionsByClass.Insert(1, new ClassSection() { Id = 1, Name = "Male" });
            sectionsByClass.Insert(2, new ClassSection() { Id = 2, Name = "Female" });
            genderComboBox.DataSource = sectionsByClass;
            genderComboBox.DisplayMember = "Name";
            genderComboBox.ValueMember = "Id";


            List<ClassSection> religions = new List<ClassSection>();

            religions.Insert(0, new ClassSection() { Id = 0, Name = "Select" });
            religions.Insert(1, new ClassSection() { Id = 1, Name = "Islam" });
            religions.Insert(2, new ClassSection() { Id = 2, Name = "Christian" });
            religions.Insert(3, new ClassSection() { Id = 3, Name = "Hindus" });
            religions.Insert(4, new ClassSection() { Id = 4, Name = "Sikh" });
            religionComboBox.DataSource = religions;
            religionComboBox.DisplayMember = "Name";
            religionComboBox.ValueMember = "Id";

            addNewGuardianBtn.Visible = false;
            addExistingGuardianBtn.Visible = false;

        }