private void FillAvailableEmployees() { AvailableEmployeesLB.Items.Clear(); StaffEmployeeLogic employeesLogic = new StaffEmployeeLogic(manager); StaffEmployeePositionsLogic employeePositionsLogic = new StaffEmployeePositionsLogic(manager); //List<StaffEmployee> employees = employeesLogic.GetAll().Select(a => new { a.ID, a.LastName + " " + a.FirstName + " " + a.MiddleName}); AvailableEmployeesLB.ValueMember = "ID"; AvailableEmployeesLB.DisplayMember = "Name"; int structureObjectId = Convert.ToInt32(StructureObjectsCB.SelectedValue); //BindingList<Helpers.ItemIntValue> structureObjects = structureObjectsLogic.GetStructureObjectsHierarchy(false, structureObjectId); List <StaffEmployee> filteredEmloyees = employeePositionsLogic.GetByPositionID(Convert.ToInt32(PositionsCB.SelectedValue)).Select(a => a.StaffEmployee).ToList(); var employees = employeesLogic.GetAll().Where(a => filteredEmloyees.Contains(a)).Select(a => new { a.ID, Name = a.LastName + " " + a.FirstName + " " + a.MiddleName }); foreach (var employee in employees) { ItemIntValue item = new ItemIntValue(); item.ID = employee.ID; item.Name = employee.Name; AvailableEmployeesLB.Items.Add(item); } }
/// <summary> /// Заповнення таблиці працівників для відображення /// </summary> private void FillGrid() { manager = new ContextManager(); DataGV.Rows.Clear(); StaffEmployeeLogic employees = new StaffEmployeeLogic(manager); DataGV.AutoGenerateColumns = false; int enterpriseId; int?StructureObjectId = null; if (StructureObjectsCB.SelectedIndex > 0) { StructureObjectId = Convert.ToInt32(StructureObjectsCB.SelectedValue); } BindingSource bs = new BindingSource(); StaffEmployeePositionsLogic employeePositions = new StaffEmployeePositionsLogic(manager); //bs.DataSource = employees.GetAll(enterpriseId); if (StructureObjectId != null) { bs.DataSource = employeePositions.GetAll(StructureObjectId); } else { bs.DataSource = employees.GetAll(); } DataGV.DataSource = bs; DataGV.Update(); DataGV.Refresh(); }
private void FillInfo() { if (DataGV.SelectedRows.Count > 0) { StaffEmployeePositionsLogic employeePositionsLogic = new StaffEmployeePositionsLogic(manager); StaffEmployeeLogic employeeLogic = new StaffEmployeeLogic(manager); SecurityUserRolesLogic userRoles = new SecurityUserRolesLogic(manager); int employeeId = Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value); PositionsLB.DataSource = employeePositionsLogic.GetPositionsByEmployeeID(employeeId).ToList(); PositionsLB.DisplayMember = "Name"; PositionsLB.ValueMember = "ID"; PositionsLB.Update(); StaffEmployee employee = employeeLogic.Get(employeeId); if (employee.UserID != null) { int userId = Convert.ToInt32(employee.UserID); RolesLB.DataSource = userRoles.GetAll(userId).Select(a => a.SecurityRole).ToList(); RolesLB.DisplayMember = "Name"; RolesLB.ValueMember = "ID"; RolesLB.Update(); } } }
private void SaveBt_Click(object sender, EventArgs e) { ContextManager manager = new ContextManager(); StaffEmployeePositionsLogic employeePositions = new StaffEmployeePositionsLogic(manager); DateTime?endDate = null; int? StructureObjectId = null; if (StructureObjectsCB.SelectedIndex > 0) { StructureObjectId = Convert.ToInt32(((Item)(StructureObjectsCB.SelectedItem)).ID); } if (EndDateDTP.Format == DateTimePickerFormat.Custom) { endDate = null; } else { endDate = EndDateDTP.Value; } if (mode == "new") { employeePositions.Create(employeeId, Convert.ToInt32(PositionsCB.SelectedValue), StartDateDTP.Value, endDate, ActiveCB.Checked, StructureObjectId); } if (mode == "edit") { employeePositions.Update(Convert.ToInt32(id), Convert.ToInt32(PositionsCB.SelectedValue), StartDateDTP.Value, endDate, ActiveCB.Checked, StructureObjectId); } manager.Save(); this.Close(); }
private void DeleteSB_Click(object sender, EventArgs e) { StaffEmployeePositionsLogic employeePositions = new StaffEmployeePositionsLogic(manager); employeePositions.Delete(Convert.ToInt32(DataGV.SelectedRows[0].Cells["ID"].Value)); manager.Save(); Fill(); }
private void Fill() { StaffEmployeePositionsLogic positions = new StaffEmployeePositionsLogic(manager); DataGV.AutoGenerateColumns = false; DataGV.DataSource = positions.GetByEmployeeID(employeeId).Select(a => new { a.ID, Name = a.StaffPosition.Name, a.StartDate, a.EndDate, a.Active }).ToList(); StaffEmployeeLogic employees = new StaffEmployeeLogic(manager); StaffEmployee employee = employees.Get(employeeId); EmployeeL.Text = employee.LastName + " " + employee.FirstName + " " + employee.MiddleName; DataGV.Update(); }
/// <summary> /// Заповнення таблиці працівників для відображення /// </summary> private void FillGrid() { manager = new ContextManager(); DataGV.Rows.Clear(); StaffEmployeeLogic employees = new StaffEmployeeLogic(manager); DataGV.AutoGenerateColumns = false; int enterpriseId; int? StructureObjectId = null; if(StructureObjectsCB.SelectedIndex > 0) StructureObjectId = Convert.ToInt32(StructureObjectsCB.SelectedValue); BindingSource bs = new BindingSource(); StaffEmployeePositionsLogic employeePositions = new StaffEmployeePositionsLogic(manager); //bs.DataSource = employees.GetAll(enterpriseId); if (StructureObjectId != null) bs.DataSource = employeePositions.GetAll(StructureObjectId); else bs.DataSource = employees.GetAll(); DataGV.DataSource = bs; DataGV.Update(); DataGV.Refresh(); }
private void FillAvailableEmployees() { AvailableEmployeesLB.Items.Clear(); StaffEmployeeLogic employeesLogic = new StaffEmployeeLogic(manager); StaffEmployeePositionsLogic employeePositionsLogic = new StaffEmployeePositionsLogic(manager); //List<StaffEmployee> employees = employeesLogic.GetAll().Select(a => new { a.ID, a.LastName + " " + a.FirstName + " " + a.MiddleName}); AvailableEmployeesLB.ValueMember = "ID"; AvailableEmployeesLB.DisplayMember = "Name"; int structureObjectId = Convert.ToInt32(StructureObjectsCB.SelectedValue); //BindingList<Helpers.ItemIntValue> structureObjects = structureObjectsLogic.GetStructureObjectsHierarchy(false, structureObjectId); List<StaffEmployee> filteredEmloyees = employeePositionsLogic.GetByPositionID(Convert.ToInt32(PositionsCB.SelectedValue)).Select(a => a.StaffEmployee).ToList(); var employees = employeesLogic.GetAll().Where(a => filteredEmloyees.Contains(a)).Select(a => new { a.ID, Name = a.LastName + " " + a.FirstName + " " + a.MiddleName }); foreach(var employee in employees) { ItemIntValue item = new ItemIntValue(); item.ID = employee.ID; item.Name = employee.Name; AvailableEmployeesLB.Items.Add(item); } }
private void Fill() { StaffEmployeePositionsLogic employeePositions = new StaffEmployeePositionsLogic(manager); //StaffStructureObjectsLogic StructureObjects = new StaffStructureObjectsLogic(manager); StaffEmployeePosition employeePosition = employeePositions.Get(Convert.ToInt32(id)); StaffPositionsLogic positions = new StaffPositionsLogic(manager); StaffEmployeeLogic employees = new StaffEmployeeLogic(manager); StaffEmployee employee = employees.Get(employeeId); EmployeeL.Text = employee.LastName + " "+ employee.FirstName + " " + employee.MiddleName; PositionsCB.DataSource = positions.GetAll(); PositionsCB.DisplayMember = "Name"; PositionsCB.ValueMember = "ID"; PositionsCB.Update(); //заповнюємо поле відділу StaffStructureObjectsLogic StructureObjects = new StaffStructureObjectsLogic(manager); int objectId = Convert.ToInt32(employee.StructureObjectID); List<Item> list = new List<Item>(); Item defaultItem = new Item(); defaultItem.ID = ""; defaultItem.Name = " - всі відділи - "; list.Add(defaultItem); foreach (var a in StructureObjects.GetHeirarchyView()) { Item i = new Item(); i.ID = a.ID.ToString(); i.Name = a.Name; list.Add(i); } StructureObjectsCB.DisplayMember = "Name"; StructureObjectsCB.ValueMember = "ID"; StructureObjectsCB.DataSource = list; if (mode == "new") { //очищаємо поле EndDate //set the format to custom EndDateDTP.Format = DateTimePickerFormat.Custom; // set custom format to empty EndDateDTP.CustomFormat = " "; ActiveCB.Checked = true; } if (mode == "edit") { StartDateDTP.Value = employeePosition.StartDate; if (employeePosition.EndDate != null) { EndDateDTP.Value = Convert.ToDateTime(employeePosition.EndDate); } else { //очищаємо поле EndDate //set the format to custom EndDateDTP.Format = DateTimePickerFormat.Custom; // set custom format to empty EndDateDTP.CustomFormat = " "; } PositionsCB.SelectedItem = positions.GetAll().Where(a => a.ID == employeePosition.PositionID).FirstOrDefault(); ActiveCB.Checked = employeePosition.Active; if (employeePosition.StructureObjectID != null) { int n = 0; foreach (Item i in StructureObjectsCB.Items) { if (i.ID == employeePosition.StructureObjectID.ToString()) StructureObjectsCB.SelectedIndex = n; n++; } } } }
private void SaveBt_Click(object sender, EventArgs e) { ContextManager manager = new ContextManager(); StaffEmployeePositionsLogic employeePositions = new StaffEmployeePositionsLogic(manager); DateTime? endDate = null; int? StructureObjectId= null; if (StructureObjectsCB.SelectedIndex > 0) { StructureObjectId = Convert.ToInt32(((Item)(StructureObjectsCB.SelectedItem)).ID); } if(EndDateDTP.Format == DateTimePickerFormat.Custom) { endDate = null; } else { endDate = EndDateDTP.Value; } if (mode == "new") { employeePositions.Create(employeeId, Convert.ToInt32(PositionsCB.SelectedValue), StartDateDTP.Value, endDate, ActiveCB.Checked, StructureObjectId); } if (mode == "edit") { employeePositions.Update(Convert.ToInt32(id), Convert.ToInt32(PositionsCB.SelectedValue), StartDateDTP.Value, endDate, ActiveCB.Checked, StructureObjectId); } manager.Save(); this.Close(); }
private void Fill() { StaffEmployeePositionsLogic employeePositions = new StaffEmployeePositionsLogic(manager); //StaffStructureObjectsLogic StructureObjects = new StaffStructureObjectsLogic(manager); StaffEmployeePosition employeePosition = employeePositions.Get(Convert.ToInt32(id)); StaffPositionsLogic positions = new StaffPositionsLogic(manager); StaffEmployeeLogic employees = new StaffEmployeeLogic(manager); StaffEmployee employee = employees.Get(employeeId); EmployeeL.Text = employee.LastName + " " + employee.FirstName + " " + employee.MiddleName; PositionsCB.DataSource = positions.GetAll(); PositionsCB.DisplayMember = "Name"; PositionsCB.ValueMember = "ID"; PositionsCB.Update(); //заповнюємо поле відділу StaffStructureObjectsLogic StructureObjects = new StaffStructureObjectsLogic(manager); int objectId = Convert.ToInt32(employee.StructureObjectID); List <Item> list = new List <Item>(); Item defaultItem = new Item(); defaultItem.ID = ""; defaultItem.Name = " - всі відділи - "; list.Add(defaultItem); foreach (var a in StructureObjects.GetHeirarchyView()) { Item i = new Item(); i.ID = a.ID.ToString(); i.Name = a.Name; list.Add(i); } StructureObjectsCB.DisplayMember = "Name"; StructureObjectsCB.ValueMember = "ID"; StructureObjectsCB.DataSource = list; if (mode == "new") { //очищаємо поле EndDate //set the format to custom EndDateDTP.Format = DateTimePickerFormat.Custom; // set custom format to empty EndDateDTP.CustomFormat = " "; ActiveCB.Checked = true; } if (mode == "edit") { StartDateDTP.Value = employeePosition.StartDate; if (employeePosition.EndDate != null) { EndDateDTP.Value = Convert.ToDateTime(employeePosition.EndDate); } else { //очищаємо поле EndDate //set the format to custom EndDateDTP.Format = DateTimePickerFormat.Custom; // set custom format to empty EndDateDTP.CustomFormat = " "; } PositionsCB.SelectedItem = positions.GetAll().Where(a => a.ID == employeePosition.PositionID).FirstOrDefault(); ActiveCB.Checked = employeePosition.Active; if (employeePosition.StructureObjectID != null) { int n = 0; foreach (Item i in StructureObjectsCB.Items) { if (i.ID == employeePosition.StructureObjectID.ToString()) { StructureObjectsCB.SelectedIndex = n; } n++; } } } }