public EmployeeForm(List <Department> departments) { InitializeComponent(); departmentComboBox.Items.AddRange(departments.ToArray()); departmentComboBox.SelectedIndex = 0; Employee = new Empoyee(); }
public override void PrepareViewUsingArg() { _employee = _employeeRepository.GetEmpoyeeById(Arg.Id); SetViewTitle(); PrepareView(); }
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); }
/// <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(); } }
/// <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); }
/// <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; }
public static bool Delete(Empoyee empoyee) { using (_d = new DataRepository <Empoyee>()) { _d.Delete(empoyee); _d.SaveChanges(); } return(true); }
/// <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; }
/// <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(); } }
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); }
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; }
/// <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(); }
/// <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; }
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; }
/// <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; } }
/// <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); } }
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); }
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); }
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(); } }
/// <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); }
public void RemoveEmployee(int id) { Empoyee empoyee = _employeeRepository.FindById(id); _employeeRepository.Remove(empoyee); }
/// <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); }