Exemple #1
0
        public GroupManager saveGroupManager(int groupID, int managerID, int directorID)
        {
            MainFactory.getLogSvc().logAction("Save new GroupManager - " + managerID + " into console.");
            GROUP_MANAGER gm = new GROUP_MANAGER {
                GROUP_ID = (short)groupID,
                MANAGER_ID = managerID,
                DIRECTOR_ID = directorID,
                START_DATE = DateTime.Today
            };
            UserMgr userMgr = new UserMgr(MainFactory.getUserSvc());
            GroupManager groupManager;

            try {
                using (ConsoleDataContext db = (ConsoleDataContext)MainFactory.getDb("Console", false)) {
                    db.GROUP_MANAGERs.InsertOnSubmit(gm);
                    db.SubmitChanges();
                    groupManager = new GroupManager(userMgr.getUser(managerID),
                                                    gm.DIRECTOR_ID,
                                                    gm.START_DATE,
                                                    gm.END_DATE,
                                                    gm.GROUP_ID,
                                                    gm.GROUP_MANAGER_START,
                                                    getGroupName(gm.GROUP_ID));
                }
            } 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 Group Manager. Please see error log for further details.");
            }
            return groupManager;
        }
Exemple #2
0
        private IEmployee saveManager(GROUP_MANAGER manager)
        {
            try {
                using (ConsoleDataContext db = (ConsoleDataContext)MainFactory.getDb("Console", false)) {
                    db.GROUP_MANAGERs.InsertOnSubmit(manager);
                    db.SubmitChanges();

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

                MainFactory.getLogSvc().logError(this.GetType().Name,
                                                 MainFactory.getCurrentMethod(),
                                                 "esid-sm-01",
                                                 se.Message + "\n" + se.StackTrace);
            }
            throw new ArgumentException("Unable to insert manager. Please validate information and try again.");
        }
Exemple #3
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 #4
0
		private void detach_GROUP_MANAGERs(GROUP_MANAGER entity)
		{
			this.SendPropertyChanging();
			entity.GROUP_lkp = null;
		}
Exemple #5
0
 partial void DeleteGROUP_MANAGER(GROUP_MANAGER instance);
Exemple #6
0
 partial void UpdateGROUP_MANAGER(GROUP_MANAGER instance);
Exemple #7
0
 partial void InsertGROUP_MANAGER(GROUP_MANAGER instance);
Exemple #8
0
		private void attach_GROUP_MANAGERs(GROUP_MANAGER entity)
		{
			this.SendPropertyChanging();
			entity.DIRECTOR = this;
		}