Exemple #1
0
        public Director saveDirector(int directorID)
        {
            MainFactory.getLogSvc().logAction("Save new Director - " + directorID + " into console.");
            UserMgr userMgr = new UserMgr(MainFactory.getUserSvc());
            Director director = new Director(userMgr.getUser(directorID));
            DIRECTOR d = new DIRECTOR {
                DIRECTOR_ID = director.ID,
                START_DATE = director.StartDate
            };

            try {
                using (ConsoleDataContext db = (ConsoleDataContext)MainFactory.getDb("Console", false)) {
                    db.DIRECTORs.InsertOnSubmit(d);
                    db.SubmitChanges();
                }
            } catch (SqlException se) {
                MainFactory.getLogSvc().logError(this.GetType().Name,
                                                MainFactory.getCurrentMethod(),
                                                "esid-sgm-01",
                                                se.Message + "\n" + se.StackTrace);
                throw new Exception("Unable to create Director. Please see error log for further details.");
            }
            return director;
        }
Exemple #2
0
        public IEmployee saveEmployee(IEmployee employee)
        {
            if (!employee.isValid())
                throw new ArgumentException("Please fill out all necessary information.");

            if (employee.GetType() == typeof(Director)) {
                Director d = (Director)employee;
                DIRECTOR director = new DIRECTOR {
                    DIRECTOR_ID = d.ID,
                    START_DATE = d.StartDate,
                    END_DATE = null
                };
                return saveDirector(director);
            }
            if (employee.GetType() == typeof(GroupManager)) {
                GroupManager m = (GroupManager)employee;
                GROUP_MANAGER manager = new GROUP_MANAGER {
                    MANAGER_ID = m.ID,
                    GROUP_ID = (Int16)m.GroupID,
                    DIRECTOR_ID = m.DirectorID,
                    START_DATE = m.StartDate,
                    END_DATE = null
                };
                return saveManager(manager);
            } else {
                Employee e = (Employee)employee;
                EMPLOYEE emp = new EMPLOYEE {
                    EMPLOYEE_ID = e.ID,
                    GROUP_MANAGER_START = e.GroupManagerID,
                    START_DATE = e.StartDate,
                    END_DATE = null
                };
                return saveUser(emp);
            }
        }
Exemple #3
0
        private IEmployee saveDirector(DIRECTOR director)
        {
            try {
                using (ConsoleDataContext db = (ConsoleDataContext)MainFactory.getDb("Console", false)) {
                    db.DIRECTORs.InsertOnSubmit(director);
                    db.SubmitChanges();

                    return new Director(director.DIRECTOR_ID,
                                        director.START_DATE,
                                        director.END_DATE);
                }
            } catch (SqlException se) {
                if (se.Number == 2627)  // if exception is due to primary key violation.
                    throw new ArgumentException("The director already has a new record for today. Please update that record.");

                MainFactory.getLogSvc().logError(this.GetType().Name,
                                                 MainFactory.getCurrentMethod(),
                                                 "esid-sd-01",
                                                 se.Message + "\n" + se.StackTrace);
            }
            throw new ArgumentException("Unable to insert director. Please validate information and try again.");
        }
Exemple #4
0
 partial void DeleteDIRECTOR(DIRECTOR instance);
Exemple #5
0
 partial void UpdateDIRECTOR(DIRECTOR instance);
Exemple #6
0
 partial void InsertDIRECTOR(DIRECTOR instance);