Esempio n. 1
0
 public EmployeeForm(List <Department> departments)
 {
     InitializeComponent();
     departmentComboBox.Items.AddRange(departments.ToArray());
     departmentComboBox.SelectedIndex = 0;
     Employee = new Empoyee();
 }
Esempio n. 2
0
        public override void PrepareViewUsingArg()
        {
            _employee = _employeeRepository.GetEmpoyeeById(Arg.Id);

            SetViewTitle();
            PrepareView();
        }
Esempio n. 3
0
        public static int Save(Empoyee employee)
        {
            var a = new Empoyee
            {
                EmployeeId         = employee.EmployeeId,
                EmployeeNo         = employee.EmployeeNo,
                EmployeeIdNo       = employee.EmployeeIdNo,
                EmployeeLastName   = employee.EmployeeLastName,
                EmployeeFirstName  = employee.EmployeeFirstName,
                EmployeeMiddleName = employee.EmployeeMiddleName,
                EmployeeAddress    = employee.EmployeeAddress,
                EmployeeSex        = employee.EmployeeSex,
                EmployeePhoto      = employee.EmployeePhoto,
                EmployeeIsActive   = employee.EmployeeIsActive,
                SettingId          = employee.SettingId,
                PositionId         = employee.PositionId
            };

            using (_d = new DataRepository <Empoyee>())
            {
                if (employee.EmployeeId > 0)
                {
                    _d.Update(a);
                }
                else
                {
                    _d.Add(a);
                }

                _d.SaveChanges();
            }

            return(a.EmployeeId);
        }
Esempio n. 4
0
 /// <summary>
 /// Updates an employee with a new data
 /// </summary>
 /// <param name="employee"></param>
 public void EditEmployee(Empoyee employee)
 {
     using (TestDBEntities entities = new TestDBEntities())
     {
         entities.Entry(employee).State = EntityState.Modified;
         entities.SaveChanges();
     }
 }
Esempio n. 5
0
		/// <summary>
		/// Updates the tree structure after adding an employee
		/// </summary>
		/// <param name="employee">Added employee</param>
		public void CreateEmployee(Empoyee employee)
		{
			TreeNode departmentNode = FromID(employee.DepartmentID, company);
			TreeNode newEmployeeNode = CreateEmployeeTreeNode(employee);
			departmentNode.Nodes.Add(newEmployeeNode);
			employees = model.GetEmployees();
			departments = model.GetDepartments();
			view.ShowTreeStructure(company,newEmployeeNode);
		}
Esempio n. 6
0
		/// <summary>
		/// Creates a tree node with a full firstname and initials of an employee
		/// </summary>
		/// <param name="employee">Employee for whom the treenode is created</param>
		/// <returns>The created treenode</returns>
		private static TreeNode CreateEmployeeTreeNode(Empoyee employee)
		{
			Char patronymicDot = (employee.Patronymic != null) ? '.' : ' ';
			TreeNode newEmployeeNode = new TreeNode($"{employee.SurName} {employee.FirstName.First()}.{employee.Patronymic?.First()}{patronymicDot}");
			newEmployeeNode.Tag = employee.ID;
			newEmployeeNode.ImageIndex = 1;
			newEmployeeNode.SelectedImageIndex = 1;
			return newEmployeeNode;
		}
Esempio n. 7
0
        public static bool Delete(Empoyee empoyee)
        {
            using (_d = new DataRepository <Empoyee>())
            {
                _d.Delete(empoyee);
                _d.SaveChanges();
            }

            return(true);
        }
Esempio n. 8
0
		/// <summary>
		/// Calculates the age of an employee
		/// </summary>
		/// <param name="employee"></param>
		/// <returns>Age in years</returns>
		public int GetAge(Empoyee employee)
		{
			var today = DateTime.Today;
			var age = today.Year - employee.DateOfBirth.Year;
			if(employee.DateOfBirth.AddYears(age) > DateTime.Now)
			{
				age--;
			}
			return age;
		}
Esempio n. 9
0
 /// <summary>
 /// Adds a new employee to the database
 /// </summary>
 /// <param name="employee"></param>
 public void AddEmployee(Empoyee employee)
 {
     using (TestDBEntities entities = new TestDBEntities())
     {
         //without getting the department from database I got an error that said I tried to create another department with the same primary keyw
         var department = entities.Department.FirstOrDefault(d => d.ID == employee.DepartmentID);
         employee.Department = department;
         entities.Empoyee.Add(employee);
         entities.SaveChanges();
     }
 }
Esempio n. 10
0
 public AddEditPresenter(CompanyPresenter parent, ICompanyModel model, ViewMode mode, Empoyee employee)
 {
     this.model              = model;
     departments             = model.GetDepartments();
     employees               = model.GetEmployees();
     this.editedEmployee     = employee;
     this.originalDepartment = employee.DepartmentID;
     this.mode               = mode;
     this.parentPresenter    = parent;
     this.editView           = new AddEditForm(this);
     editView.LoadForm(editedEmployee);
 }
Esempio n. 11
0
 public EmployeeForm(List <Department> departments, Empoyee employee) : this(departments)
 {
     Employee = employee;
     firstNameTextBox.Text            = employee.FirstName;
     surNameTextBox.Text              = employee.SurName;
     patronymicTextBox.Text           = employee.Patronymic;
     departmentComboBox.SelectedIndex = departments.IndexOf(employee.Department);
     dateOfBirthDatePicker.Value      = employee.DateOfBirth;
     docsSeriesTextBox.Text           = employee.DocSeries;
     docNumberTextBox.Text            = employee.DocNumber;
     positionTextBox.Text             = employee.Position;
 }
Esempio n. 12
0
 /// <summary>
 /// Shows the view for editing the existing employee. Sets the textboxes with employee data
 /// </summary>
 /// <param name="employee"></param>
 public void LoadForm(Empoyee employee)
 {
     this.firstNameTextBox.Text            = employee.FirstName;
     this.surNameTextBox.Text              = employee.SurName;
     this.patronymicTextBox.Text           = employee.Patronymic;
     this.positionTextBox.Text             = employee.Position;
     this.dateTextBox.Text                 = employee.DateOfBirth.ToShortDateString();
     this.docSeriesTextBox.Text            = employee.DocSeries;
     this.docNumberTextBox.Text            = employee.DocNumber;
     this.departmentCombobox.SelectedIndex = departmentCombobox.FindStringExact(presenter.GetEmployeeDepartment(employee).Name);
     this.ShowDialog();
 }
Esempio n. 13
0
 /// <summary>
 /// Updates the labels on the form to show employee data
 /// </summary>
 /// <param name="emp">The employee for which the data should be shown</param>
 public void ShowEmployeeInfo(Empoyee emp)
 {
     editButton.Enabled = true;
     ToggleEmployeeLabels(true);
     surnameLabel.Text    = emp.SurName;
     nameLabel.Text       = emp.FirstName;
     patronymicLabel.Text = emp.Patronymic;
     employeeIdLabel.Text = emp.ID.ToString();
     positionLabel.Text   = emp.Position;
     birthLabel.Text      = emp.DateOfBirth.ToShortDateString() + $" ({presenter.GetAge(emp)})";
     docSeriesLabel.Text  = emp.DocSeries;
     docNumLabel.Text     = emp.DocNumber;
 }
Esempio n. 14
0
        private void LoadDRTEnrollee(EmployeeData en)
        {
            Cursor = Cursors.WaitCursor;
            if (listBox1.Items.Count > 0)
            {
                var     eName    = en.GetFullName;
                Empoyee enrollee = EmployeeManager.Get(en.EnrolleeId);

                List <DtrData> lDTRSource01 = DTRManagement.LoadDTRViaDTRBatch(enrollee, iMonth, iStartDay, iEndDay, iYear, DTRManager.GetAll(en.EnrolleeId), eName, labelDuration.Text);
                lDTRSource.AddRange(lDTRSource01 as IEnumerable <DtrData>);
            }
            Cursor = Cursors.Default;
        }
Esempio n. 15
0
 /// <summary>
 /// Saves employee in a model
 /// </summary>
 /// <param name="employee"></param>
 public void SetEmployee(Empoyee employee)
 {
     if (mode == ViewMode.Add)
     {
         model.AddEmployee(employee);
         parentPresenter.CreateEmployee(employee);
         return;
     }
     if (mode == ViewMode.Edit)
     {
         model.EditEmployee(employee);
         parentPresenter.UpdateEmployee(employee);
         return;
     }
 }
Esempio n. 16
0
		/// <summary>
		/// Decides if selected node was an employee or a department. Views different data depending on a node.
		/// </summary>
		public void SelectionResponse(TreeNode selectedNode)
		{
			if(selectedNode.Nodes.Count == 0)
			{
				Empoyee employee = employees.First(e => e.ID == (decimal)selectedNode.Tag);
				Department dep = departments.First(d => d.ID == employee.DepartmentID);
				view.ShowDepartmentInfo(dep);
				view.ShowEmployeeInfo(employee);
			}
			else
			{
				Department dep = departments.First(d => d.ID == (Guid)selectedNode.Tag);
				view.ShowDepartmentInfo(dep);
			}
		}
Esempio n. 17
0
        public void AddNewEmployee(string firstName, string surName, string patronimic,
                                   DateTime dateOfBirth, string docSeries,
                                   string docNumber, string position, Guid departmentId)
        {
            Empoyee empoyee = new Empoyee
            {
                FirstName    = firstName,
                SurName      = surName,
                Patronymic   = patronimic,
                DateOfBirth  = dateOfBirth,
                DocSeries    = docSeries,
                DocNumber    = docNumber,
                Position     = position,
                DepartmentID = departmentId
            };

            _employeeRepository.Add(empoyee);
        }
Esempio n. 18
0
        public void UpdateEmployee(int id, string firstName,
                                   string surName, string patronimic,
                                   DateTime dateOfBirth, string docSeries,
                                   string docNumber, string position,
                                   Guid departmentId)
        {
            Empoyee empoyee = _employeeRepository.FindById(id);

            empoyee.FirstName    = firstName;
            empoyee.SurName      = surName;
            empoyee.Patronymic   = patronimic;
            empoyee.DateOfBirth  = dateOfBirth;
            empoyee.DocSeries    = docSeries;
            empoyee.DocNumber    = docNumber;
            empoyee.Position     = position;
            empoyee.DepartmentID = departmentId;
            _employeeRepository.Update(empoyee);
        }
Esempio n. 19
0
 private void ackButton_Click(object sender, EventArgs e)
 {
     if (presenter.ValidateEntries(firstNameTextBox.Text, surNameTextBox.Text, positionTextBox.Text, dateTextBox.Text, departmentCombobox.Text))
     {
         Empoyee employee = new Empoyee();
         employee.FirstName    = firstNameTextBox.Text;
         employee.SurName      = surNameTextBox.Text;
         employee.Patronymic   = patronymicTextBox.Text == "" ? null : patronymicTextBox.Text;
         employee.Position     = positionTextBox.Text;
         employee.DateOfBirth  = DateTime.Parse(dateTextBox.Text);
         employee.ID           = presenter.GetEmployeeID();
         employee.DocSeries    = docSeriesTextBox.Text;
         employee.DocNumber    = docNumberTextBox.Text;
         employee.Department   = presenter.GetEmployeeDepartment(departmentCombobox.Text);
         employee.DepartmentID = employee.Department.ID;
         presenter.SetEmployee(employee);
         this.Close();
     }
 }
Esempio n. 20
0
		/// <summary>
		/// Opens another form to edit an employee
		/// </summary>
		/// <param name="selectedNode">The employee selected in a treeview.</param>
		public void OpenEditDialog(TreeNode selectedNode)
		{
			Empoyee employee = employees.First(e => e.ID == (decimal)selectedNode.Tag);
			AddEditPresenter editPresenter = new AddEditPresenter(this,model,ViewMode.Edit,employee);
		}
Esempio n. 21
0
        public void RemoveEmployee(int id)
        {
            Empoyee empoyee = _employeeRepository.FindById(id);

            _employeeRepository.Remove(empoyee);
        }
Esempio n. 22
0
        /// <summary>
        /// Returns an employee's department
        /// </summary>
        /// <param name="employee"></param>
        /// <returns></returns>
        public Department GetEmployeeDepartment(Empoyee employee)
        {
            Department result = departments.First(d => d.ID == employee.DepartmentID);

            return(result);
        }