Beispiel #1
0
        /// <summary>
        /// method for saving data to the database
        /// </summary>
        private void SaveExecute()
        {
            try
            {
                using (CompanyDBEntities context = new CompanyDBEntities())
                {
                    tblPosition newPosition = new tblPosition();

                    newPosition.PositionName        = position.PositionName;
                    newPosition.PositionDescription = position.PositionDescription;
                    newPosition.PositionID          = position.PositionID;

                    // saving data
                    context.tblPositions.Add(newPosition);
                    context.SaveChanges();

                    MessageBox.Show("The position created successfully.");

                    // logging the action
                    FileActions.FileActions.Instance.Adding(FileActions.FileActions.path, FileActions.FileActions.actions, "position", newPosition.PositionName);
                }
                addPosition.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Wrong inputs. Please try again.");
            }
        }
Beispiel #2
0
        public AddPositionViewModel(AddPosition addPosition)
        {
            view = addPosition;


            positionService = new PositionService();

            Position = new tblPosition();
        }
        public PositionsForManagerViewModel(PositionsForManager positions)
        {
            view = positions;


            positionService = new PositionService();

            Position     = new tblPosition();
            PositionList = positionService.GetPositions();
        }
Beispiel #4
0
        public tblPosition Addpos(int depid, int joblevel, string position, decimal basicpay, decimal Incometax, string exp)
        {
            var pos = new tblPosition()
            {
                DepartmentId = depid,
                JobLevel     = joblevel,
                Position     = position,
                BasicPay     = basicpay,
                IncomeTax    = Incometax,
                Experience   = exp + " Years",
            };

            return(pos);
        }
Beispiel #5
0
        public tblPosition GetPositionByName(string positionName)
        {
            try
            {
                using (MyCompanyDBEntities context = new MyCompanyDBEntities())
                {
                    tblPosition user = (from x in context.tblPositions
                                        where x.PositionName.Equals(positionName)

                                        select x).First();

                    return(user);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
                return(null);
            }
        }
Beispiel #6
0
        public void DeletePosition(int positionId)
        {
            try
            {
                using (MyCompanyDBEntities context = new MyCompanyDBEntities())
                {
                    tblPosition positionToDelete = (from u in context.tblPositions
                                                    where u.PositionID == positionId
                                                    select u).First();


                    context.tblPositions.Remove(positionToDelete);

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
            }
        }
Beispiel #7
0
        public tblPosition AddPosition(tblPosition position)
        {
            try
            {
                using (MyCompanyDBEntities context = new MyCompanyDBEntities())
                {
                    tblPosition newPositon = new tblPosition();
                    newPositon.PositionName        = position.PositionName;
                    newPositon.PositionDescription = position.PositionDescription;

                    context.tblPositions.Add(newPositon);
                    context.SaveChanges();

                    return(newPositon);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
                return(null);
            }
        }
Beispiel #8
0
 public RegistrationViewModel(Registration open)
 {
     registration = open;
     newUser      = new tblUser();
     newManager   = new tblManager();
     newEmployee  = new tblEmployee();
     //gender
     selectedGender = new tblGender();
     genderList     = Service.Service.GetGenderList();
     //sector
     selectedSector = new tblSector();
     sectorList     = Service.Service.GetSectorList();
     //marital status
     selectedMarital = new tblMarriageStatu();
     maritalList     = Service.Service.GetMaritalStatusList();
     //position
     selectedPosition = new tblPosition();
     positionList     = Service.Service.GetPositionList();
     //qualification
     selectedQualification = new tblProfessionalQualification();
     qualificationList     = Service.Service.GetQualificationList();
 }
Beispiel #9
0
        private void SaveExecute(object parameter)
        {
            try
            {
                tblPosition positionInDb = positionService.GetPositionByName(Position.PositionName);

                if (positionInDb != null)
                {
                    string str1 = string.Format("Position with this name exists\n" +
                                                "Enter another position name");
                    MessageBox.Show(str1);
                    return;
                }

                positionService.AddPosition(Position);
                string str = string.Format("You added new position");
                MessageBox.Show(str);
                view.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        /// <summary>
        /// Adds new account to tblAccount and adds an employee with the acount AccountID to database.
        /// </summary>
        /// <param name="account"></param>
        /// <param name="sector"></param>
        /// <param name="position"></param>
        /// <param name="experience"></param>
        /// <param name="qualification"></param>
        internal void AddEmployee(tblEmployee employee, tblAccount account, tblSector sector, tblPosition position, int experience)
        {
            int id = RandomManager();

            if (id != 0)
            {
                using (CompanyEntities context = new CompanyEntities())
                {
                    tblAccount newAccount = new tblAccount();
                    newAccount.FirstName       = account.FirstName;
                    newAccount.LastName        = account.LastName;
                    newAccount.JMBG            = account.JMBG;
                    newAccount.Gender          = account.Gender.ToUpper();
                    newAccount.City            = account.City;
                    newAccount.MarrigeStatusID = account.MarrigeStatusID;
                    newAccount.UserName        = account.UserName;
                    newAccount.Pass            = account.Pass;
                    context.tblAccounts.Add(newAccount);
                    context.SaveChanges();

                    tblEmployee newEmployee = new tblEmployee();
                    newEmployee.AccountID           = newAccount.AccountID;
                    newEmployee.ManagerID           = id;
                    newEmployee.SectorID            = sector.SectorID;
                    newEmployee.PositionID          = position.PositionID;
                    newEmployee.EmploymentDate      = DateTime.Now.AddYears(-experience);
                    newEmployee.QualificationsLevel = employee.QualificationsLevel;
                    context.tblEmployees.Add(newEmployee);
                    context.SaveChanges();
                    MessageBox.Show("Employee saved.");
                }
            }
            else
            {
                MessageBox.Show("You can not register any employees until there is no registered managers first.");
            }
        }
Beispiel #11
0
 public AddPositionViewModel(AddPosition open)
 {
     addPosition = open;
     position    = new tblPosition();
 }
Beispiel #12
0
 public void Add(tblPosition obj)
 {
     context.tblPositions.Add(obj);
 }