Ejemplo n.º 1
0
        /// <summary>
        /// Add a new designation
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public bool UpdateDetails(string code, Gender gender,
                                  string firstName, string middleName, string lastName,
                                  DateTime joiningDate,
                                  Department department, Designation designation,
                                  EmployeeType type)
        {
            lock (BusinessEntity.m_sDS)
            {
                bool success = false;

                if (!string.IsNullOrEmpty(code) &&
                    !string.IsNullOrEmpty(firstName) &&
                    department != null && designation != null && type != null)
                {
                    // These are optional
                    lastName                 = string.IsNullOrEmpty(lastName) ? "" : lastName;
                    middleName               = string.IsNullOrEmpty(middleName) ? "" : middleName;
                    m_dataRow.Code           = code;
                    m_dataRow.Gender         = Gender.Female == gender;
                    m_dataRow.FirstName      = firstName;
                    m_dataRow.MiddleName     = middleName;
                    m_dataRow.LastName       = lastName;
                    m_dataRow.JoiningDate    = joiningDate;
                    m_dataRow.DepartmentID   = department.ID;
                    m_dataRow.DesignationID  = designation.ID;
                    m_dataRow.EmployeeTypeID = type.ID;

                    // For now we shall not expose this feature
                    m_dataRow.SetManagerIDNull();
                    m_dataRow.SetLeavingDateNull();
                    m_dataRow.SetPreviousIDNull();

                    try
                    {
                        success = 1 == Employee.m_sTA.Update(m_dataRow);
                        m_type  = type;
                    }
                    catch { }

                    if (!success)
                    {
                        m_dataRow.RejectChanges();
                    }
                }

                return(success);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add a new designation
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public bool AddEmployee(string code, Gender gender,
                                string firstName, string middleName, string lastName,
                                DateTime joiningDate,
                                Department department, Designation designation,
                                EmployeeType type)
        {
            lock (BusinessEntity.m_sDS)
            {
                bool success = false;

                if (!string.IsNullOrEmpty(code) &&
                    !string.IsNullOrEmpty(firstName) &&
                    department != null && designation != null && type != null)
                {
                    // These are optional
                    lastName   = string.IsNullOrEmpty(lastName) ? "" : lastName;
                    middleName = string.IsNullOrEmpty(middleName) ? "" : middleName;

                    var dataRow = m_sDS.Employees.AddEmployeesRow(code, gender == Gender.Female,
                                                                  firstName, middleName, lastName,
                                                                  joiningDate, default(DateTime), null, type.m_dataRow,
                                                                  null, m_dataRow, department.m_dataRow, designation.m_dataRow);

                    // For now we shall not expose this feature
                    dataRow.SetManagerIDNull();
                    dataRow.SetLeavingDateNull();
                    dataRow.SetPreviousIDNull();

                    try
                    {
                        success = 1 == Employee.m_sTA.Update(dataRow);
                    }
                    catch { }

                    if (success)
                    {
                        m_employees.Add(new Employee(this, dataRow));
                    }
                    else
                    {
                        m_sDS.Employees.RemoveEmployeesRow(dataRow);
                    }
                }

                return(success);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Remove
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static bool Remove(EmployeeType employeeType)
        {
            lock (BusinessEntity.m_sDS)
            {
                bool success = false;

                if (employeeType != null)
                {
                    try
                    {
                        success = (m_sTA.DeleteByID(employeeType.ID) == 1);
                    }
                    catch { }

                    if (success)
                    {
                        m_sEmployeeTypes.Remove(employeeType);
                        BusinessEntity.m_sDS.EmployeeTypes.RemoveEmployeeTypesRow(employeeType.m_dataRow);
                    }
                }

                return(success);
            }
        }