Esempio n. 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
                });
            }
        }
Esempio n. 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();
            }
        }
        private void addData()
        {
            long      lastid;
            string    query;
            Connector db = new Connector();

            if (SubjectVM.getSubject(subjectTB.Text) == null)
            {
                query = String.Format("insert into subjects ( name, classificationID) values (" +
                                      "'{0}', {1})", subjectTB.Text,
                                      ClassificationVM.getClassification(typeCB.Text).id);
                lastid = db.addData(query);
                if (lastid != -1)
                {
                    SubjectVM.Subjects.Add(new Subject
                    {
                        id      = (int)lastid,
                        name    = subjectTB.Text,
                        classID = ClassificationVM.getClassification(typeCB.Text).id
                    });
                }
            }
            query = String.Format("insert into facultyloads (facultyId, subjectId) values (" +
                                  "{0}, {1});", CurrentUser.user.id, SubjectVM.getSubject(subjectTB.Text).id);

            lastid = db.addData(query);
            if (lastid != -1)
            {
                //Console.WriteLine(query);
                LoadsVM.specificLoads.Add(new FacultyLoads
                {
                    id        = (int)lastid,
                    facultyID = CurrentUser.user.id,
                    subjectID = SubjectVM.getSubject(subjectTB.Text).id
                });
            }
        }
        private void editData()
        {
            Connector db    = new Connector();
            string    query = String.Format("update subjects set " +
                                            "name = '{0}', classificationID = {1} where id = {2};", subjectTB.Text, ClassificationVM.getClassification(typeCB.Text).id,
                                            ((FacultyLoads)dg.SelectedItem).subjectID);

            if (db.addData(query) != -1)
            {
                SubjectVM.getSubject(((FacultyLoads)dg.SelectedItem).subjectID).name    = subjectTB.Text;
                SubjectVM.getSubject(((FacultyLoads)dg.SelectedItem).subjectID).classID = ClassificationVM.getClassification(typeCB.Text).id;
            }
            dg.Items.Refresh();
            typeCB.Items.Refresh();
            subjectTB.Items.Refresh();
        }