Esempio n. 1
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);
            }
        }
Esempio n. 2
0
        public Employee saveEmployee(Employee employee)
        {
            MainFactory.getLogSvc().logAction("Save new Employee - " + employee.ID + " into console.");
            EMPLOYEE e = new EMPLOYEE {
                EMPLOYEE_ID = employee.ID,
                START_DATE = employee.StartDate,
                GROUP_MANAGER_START = employee.GroupManagerID
            };

            try {
                using (ConsoleDataContext db = (ConsoleDataContext)MainFactory.getDb("Consxole", false)) {
                    db.EMPLOYEEs.InsertOnSubmit(e);
                    db.SubmitChanges();
                    return employee;
                }
            } catch (SqlException se) {
                MainFactory.getLogSvc().logError(this.GetType().Name,
                                                 MainFactory.getCurrentMethod(),
                                                 "rs-se-01",
                                                 se.Message + "\n" + se.StackTrace);
                throw new Exception("Unable to create Employee. Please see error log for further details.");
            }
        }
Esempio n. 3
0
        private IEmployee saveUser(EMPLOYEE employee)
        {
            try {
                using (ConsoleDataContext db = (ConsoleDataContext)MainFactory.getDb("Console", false)) {
                    db.EMPLOYEEs.InsertOnSubmit(employee);
                    db.SubmitChanges();

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

                MainFactory.getLogSvc().logError(this.GetType().Name,
                                                 MainFactory.getCurrentMethod(),
                                                 "esid-su-01",
                                                 se.Message + "\n" + se.StackTrace);
            }
            throw new ArgumentException("Unable to insert employee. Please validate information and try again.");
        }
Esempio n. 4
0
 partial void DeleteEMPLOYEE(EMPLOYEE instance);
Esempio n. 5
0
 partial void UpdateEMPLOYEE(EMPLOYEE instance);
Esempio n. 6
0
 partial void InsertEMPLOYEE(EMPLOYEE instance);
Esempio n. 7
0
		private void detach_EMPLOYEEs(EMPLOYEE entity)
		{
			this.SendPropertyChanging();
			entity.GROUP_MANAGER = null;
		}