Exemple #1
0
        private void addData()
        {
            long      lastid;
            string    query;
            Connector db = new Connector();

            if (SeminarVM.getSeminar(seminarCB.Text) == null)
            {
                if (TypeVM.getType(typeCB.Text) == null)
                {
                    query = String.Format("insert into seminartypes (type) values (" +
                                          "'{0}');", typeCB.Text);
                    lastid = db.addData(query);
                    if (lastid != -1)
                    {
                        TypeVM.Types.Add(new Type
                        {
                            id   = (int)lastid,
                            type = typeCB.Text
                        });
                    }
                }
                query = String.Format("insert into seminars (seminarName, seminarType, classificationID, venue, date) values (" +
                                      "'{0}', {1}, {2}, '{3}', '{4}');",
                                      seminarCB.Text,
                                      TypeVM.getType(typeCB.Text).id,
                                      ClassificationVM.getClassification(classCB.Text).id,
                                      venueTB.Text, dateTB.Text);
                lastid = db.addData(query);
                if (lastid != -1)
                {
                    SeminarVM.Seminars.Add(new Seminar
                    {
                        id          = (int)lastid,
                        seminarName = seminarCB.Text,
                        typeid      = TypeVM.getType(typeCB.Text).id,
                        classId     = ClassificationVM.getClassification(classCB.Text).id,
                        venue       = venueTB.Text,
                        date        = dateTB.Text
                    });
                }
            }
            query = String.Format("insert into seminarsattendance (facultyID, seminarID) values (" +
                                  "{0}, {1});", CurrentUser.user.id,
                                  SeminarVM.getSeminar(seminarCB.Text).id);
            lastid = db.addData(query);
            if (lastid != -1)
            {
                AttendanceVM.specificAttendances.Add(new Attendance
                {
                    id        = (int)lastid,
                    facultyid = CurrentUser.user.id,
                    seminarid = SeminarVM.getSeminar(seminarCB.Text).id
                });
            }
        }
Exemple #2
0
        private void editData()
        {
            Connector db    = new Connector();
            string    query = String.Format("update seminars set " +
                                            "seminarName = '{0}', seminarType = {1}, classificationId = {2}, " +
                                            "venue = '{3}', date = '{4}' where id = {5};",
                                            seminarCB.Text, TypeVM.getType(typeCB.Text).id,
                                            ClassificationVM.getClassification(classCB.Text).id, venueTB.Text, dateTB.Text,
                                            ((Attendance)dg.SelectedItem).seminarid);

            if (db.addData(query) != -1)
            {
                SeminarVM.getSeminar(((Attendance)dg.SelectedItem).seminarid).seminarName = seminarCB.Text;
                SeminarVM.getSeminar(((Attendance)dg.SelectedItem).seminarid).typeid      = TypeVM.getType(typeCB.Text).id;
                SeminarVM.getSeminar(((Attendance)dg.SelectedItem).seminarid).classId     = ClassificationVM.getClassification(classCB.Text).id;
                SeminarVM.getSeminar(((Attendance)dg.SelectedItem).seminarid).venue       = venueTB.Text;
                SeminarVM.getSeminar(((Attendance)dg.SelectedItem).seminarid).date        = dateTB.Text;
                dg.Items.Refresh();
                classCB.Items.Refresh();
                seminarCB.Items.Refresh();
                typeCB.Items.Refresh();
            }
        }