Ejemplo n.º 1
0
		private void RefreshGrid()
		{
			using (var logic = new NomenclaturesLogic())
			{
				this.grGridView.ItemsSource = logic.NM_PositionTypes.GetAll();
			}
		}
Ejemplo n.º 2
0
		private void btnSave_Click(object sender, RoutedEventArgs e)
		{
			using (var logic = new NomenclaturesLogic())
			{
				if (ambulance.id_ambulance == 0)
				{
					logic.GR_Ambulances.Add(ambulance);
				}
				else
				{
					logic.GR_Ambulances.Update(ambulance);
				}

				try
				{
					logic.Save();
					this.Close();
				}
				catch (ZoraException ex)
				{
					MessageBox.Show(ex.Result.ErrorCodeMessage);
				}
				catch(Exception ex)
				{
					MessageBox.Show(ex.Message);
				}
			}
		}
		private void btnSave_Click(object sender, RoutedEventArgs e)
		{
			using (var logic = new NomenclaturesLogic())
			{
				if (this.globalPosition.id_globalPosition == 0)
				{
					logic.HR_GlobalPositions.Add(this.globalPosition);
				}
				else
				{
					logic.HR_GlobalPositions.Update(this.globalPosition);
				}

				try
				{
					logic.Save();
					this.Close();
				}
				catch (ZoraException ex)
				{
					MessageBox.Show(ex.Result.ErrorCodeMessage);
				}
				catch(Exception ex)
				{
					MessageBox.Show(ex.Message);
				}
			}
		}
Ejemplo n.º 4
0
		private void btnImportGlobalPositions_Click(object sender, RoutedEventArgs e)
		{
			OpenFileDialog opf = new OpenFileDialog();

			if (opf.ShowDialog().Value == true)
			{
				Excel.Worksheet xlsheet;
				Excel.Workbook xlwkbook;

				xlwkbook = (Excel.Workbook)System.Runtime.InteropServices.Marshal.BindToMoniker(opf.FileName);
				xlsheet = (Excel.Worksheet)xlwkbook.ActiveSheet;

				Excel.Range oRng;

				for (int i = 2; i < 48; i++)
				{
					HR_GlobalPositions pos = new HR_GlobalPositions();
					//name
					string gstr;
					oRng = (Excel.Range)xlsheet.Cells[i, 1];
					try
					{
						gstr = oRng.get_Value(Missing.Value).ToString();
					}
					catch (System.NullReferenceException)
					{
						continue;
					}
					if (gstr == "")
					{
						continue;
					}
					pos.Name = gstr;


					oRng = (Excel.Range)xlsheet.Cells[i, 6];
					try
					{
						gstr = oRng.get_Value(Missing.Value).ToString();
					}
					catch (System.NullReferenceException)
					{
						continue;
					}
					if (gstr == "")
					{
						continue;
					}
					pos.id_positionType = int.Parse(gstr);
					pos.IsActive = true;
					pos.ActiveFrom = DateTime.Now;

					using (var logic = new NomenclaturesLogic())
					{
						logic.HR_GlobalPositions.Add(pos);
						logic.Save();
					}
				}
			}
		}
		private void MenuItemUp_Click(object sender, RoutedEventArgs e)
		{
			if (this.RadViewSource.SelectedItem != null)
			{
				var item = this.RadViewSource.SelectedItem as RadTreeViewItem;
				var tag = item.Tag as StructureTreeViewModel;

				using (var logic = new NomenclaturesLogic())
				{
					try
					{
						if (logic.MoveTreeNodeUp(tag.id_department))
						{
							this.RefreshTree();
						}
					}
					catch (ZoraException ex)
					{
						MessageBox.Show(ex.Result.ErrorCodeMessage);
					}
					catch (Exception ex)
					{
						MessageBox.Show(ex.Message);
					}
				}


			}
		}
		private void RefreshGrid()
		{
			using (var logic = new NomenclaturesLogic())
			{
				var lstGlobalPositions = logic.GetGlobalPositions(this.chkShowInactive.IsChecked == false);
				this.grGridView.ItemsSource = lstGlobalPositions;
			}
		}
Ejemplo n.º 7
0
		private void RefreshDataSource()
		{
			using (var logic = new NomenclaturesLogic())
			{
				this.lstAmbulances = logic.GetAmbulances(this.chkShowInactive.IsChecked == false);
				this.grGridView.ItemsSource = lstAmbulances;
			}
		}
		private void PopulateTreeNodes(int p, RadTreeViewItem parent, NomenclaturesLogic logic)
		{
			var lstItems = logic.GetTreeNodes(false, p);
			foreach (var item in lstItems)
			{
				RadTreeViewItem it = new RadTreeViewItem();
				it.Tag = item;
				it.Header = item.DepartmentName;
				parent.Items.Add(it);
				this.PopulateTreeNodes(item.id_department, it, logic);
			}
		}
		private void PopulateTreeRoot(RadTreeView Tree)
		{
			using (var logic = new NomenclaturesLogic())
			{
				var rootItems = logic.GetTreeNodes(true, 0);
				foreach (var item in rootItems)
				{
					RadTreeViewItem it = new RadTreeViewItem();
					it.Tag = item;
					it.Header = item.DepartmentName;
					Tree.Items.Add(it);
					this.PopulateTreeNodes(item.id_department, it, logic);
				}
			}
		}
Ejemplo n.º 10
0
		private void Window_Loaded(object sender, RoutedEventArgs e)
		{
			using (var logic = new NomenclaturesLogic())
			{
				if (this.id_ambulance == 0)
				{
					this.ambulance = new GR_Ambulances();
					this.ambulance.IsActive = true;
				}
				else
				{
					this.ambulance = logic.GR_Ambulances.GetById(this.id_ambulance);
				}
			}
			this.DataContext = ambulance;
		}
Ejemplo n.º 11
0
		private void btnSave_Click(object sender, RoutedEventArgs e)
		{			
			using (var logic = new NomenclaturesLogic())
			{
				if (this.id_departmentParent == 0)
				{					
					this.department.Level = 1;
				}
				else
				{
					int level;					
					level = logic.GetTreeLevel(this.id_departmentParent);
					this.department.Level = level + 1;
				}
				if (this.department.id_department == 0)
				{
					logic.UN_Departments.Add(this.department);
				}
				else
				{
					logic.UN_Departments.Update(this.department);					
				}

				try
				{					
					logic.Save();
					if (this.id_departmentParent == 0)
					{
						this.department.id_departmentParent = this.department.id_department;
						this.department.TreeOrder = this.department.id_department;
						logic.Save();
					}
					else if (this.department.TreeOrder == 0)
					{
						this.department.id_departmentParent = this.id_departmentParent;
						this.department.TreeOrder = this.department.id_department;
						logic.Save();
					}
					this.Close();
				}
				catch (ZoraException ex)
				{
					MessageBox.Show(ex.Result.ErrorCodeMessage);
				}
			}
		}
Ejemplo n.º 12
0
		private void Window_Loaded(object sender, RoutedEventArgs e)
		{
			using (var logic = new NomenclaturesLogic())
			{
				if (this.id_department == 0)
				{
					this.department = new UN_Departments();
					this.department.IsActive = true;
					this.department.ActiveFrom = DateTime.Now;
				}
				else
				{
					this.department = logic.UN_Departments.GetById(this.id_department);
				}
			}
			this.DataContext = this.department;
		}
Ejemplo n.º 13
0
		private void Window_Loaded(object sender, RoutedEventArgs e)
		{
			using (var logic = new NomenclaturesLogic())
			{				
				if (this.id_globalPosition == 0)
				{
					this.globalPosition = new HR_GlobalPositions();
					this.globalPosition.IsActive = true;
					this.globalPosition.ActiveFrom = DateTime.Now;
				}
				else
				{
					this.globalPosition = logic.HR_GlobalPositions.GetById(this.id_globalPosition);
				}

				using (var comboBoxLogic = new ComboBoxLogic())
				{
					this.cmbPositionTypes.ItemsSource = comboBoxLogic.ReadPositionTypes(this.globalPosition.id_globalPosition);
				}
				this.DataContext = this.globalPosition;
			}
		}
		private void btnDelete_Click(object sender, RoutedEventArgs e)
		{
			//Excel.Worksheet xlsheet;
			//Excel.Workbook xlwkbook;
			//var excelApp = new Excel.Application(); // Initialize a new Excel reader. Must be integrated with an Excel interface object.

			//xlwkbook = excelApp.Workbooks.Add(1);
			//xlsheet = (Excel.Worksheet)xlwkbook.Sheets[1];

			//var list = new List<string>();
			//list.Add("Alpha");

			//list.Add("Bravo");

			//list.Add("Charlie");

			//list.Add("Delta");

			//list.Add("Echo");
			//var flatList = string.Join(",", list.ToArray());
			//var cell = (Excel.Range)xlsheet.Cells[2, 2];
			//cell.Validation.Delete();
			//cell.Validation.Add(
			//Excel.XlDVType.xlValidateList,
			//Excel.XlDVAlertStyle.xlValidAlertStop,
			//Excel.XlFormatConditionOperator.xlBetween,
			//flatList,
			//Type.Missing);
			//cell.Validation.IgnoreBlank = true;
			//cell.Validation.InCellDropdown = true;

			//excelApp.Visible = true;
			using (var logic = new NomenclaturesLogic())
			{
				if (this.grGridView.SelectedItem != null)
				{
					var item = this.grGridView.SelectedItem as HR_GlobalPositions;

					try
					{
						logic.HR_GlobalPositions.Delete(item);
						logic.Save();
					}
					catch (ZoraException ex)
					{
						MessageBox.Show(ex.Result.ErrorCodeMessage);
					}
					catch (Exception ex)
					{
						MessageBox.Show(ex.Message);
					}
				}
			}
		}
Ejemplo n.º 15
0
		private void btnImportPersonsAndPositions_Click(object sender, RoutedEventArgs e)
		{
			OpenFileDialog opf = new OpenFileDialog();

			if (opf.ShowDialog().Value == true)
			{
				Excel.Worksheet xlsheet;
				Excel.Workbook xlwkbook;

				xlwkbook = (Excel.Workbook)System.Runtime.InteropServices.Marshal.BindToMoniker(opf.FileName);
				xlsheet = (Excel.Worksheet)xlwkbook.ActiveSheet;

				Excel.Range oRng;

				int id_currentDepartment = 0;
				int id_parentDepartment = 0;


				for (int i = 1; i < 12; i++)
				{
					using (var logic = new NomenclaturesLogic())
					{
						string gstr;
						if (id_currentDepartment == 0)
						{
							gstr = this.GetRangeValue(i, 1, xlsheet);
							if (gstr == "")
							{
								continue;
							}
							if (gstr == "1000")
							{

								gstr = this.GetRangeValue(i, 2, xlsheet);
								
								id_currentDepartment = logic.GetDepartmentByName(gstr).id_department;
								id_parentDepartment = id_currentDepartment;
								continue;
	                        }
							else if(gstr == "999")
							{
								gstr = this.GetRangeValue(i, 2, xlsheet);
								id_currentDepartment = logic.GetDepartmentShiftByName(gstr, id_currentDepartment).id_department;
								continue;
							}
						}
						else
						{
							
							gstr = this.GetRangeValue(i, 1, xlsheet);
							if (gstr == "")
							{
								continue;
							}
							#region parse department
							if (gstr == "1000")
							{
								gstr = this.GetRangeValue(i, 2, xlsheet);
								id_currentDepartment = logic.GetDepartmentByName(gstr).id_department;
								id_parentDepartment = id_currentDepartment;
								continue;
							}
							else if (gstr == "999")
							{
								gstr = this.GetRangeValue(i, 2, xlsheet);
								id_currentDepartment = logic.GetDepartmentShiftByName(gstr, id_parentDepartment).id_department;
								continue;
							}
							#endregion
							else
							{
								gstr = this.GetRangeValue(i, 2, xlsheet);

								
								HR_StructurePositions spos = null;

								UN_Persons per = new UN_Persons();
								HR_Contracts con = new HR_Contracts();
								HR_Assignments ass = new HR_Assignments();

								spos = logic.FindStructurePositionByName(gstr, id_currentDepartment);
								if(spos == null)
								{
									spos = new HR_StructurePositions();
									spos.id_globalPosition = logic.GetGlobalPositionByName(gstr).id_globalPosition;
									spos.id_department = id_currentDepartment;
									spos.IsActive = true;
									spos.ActiveFrom = DateTime.Now;
									spos.StaffCount = 1;
									logic.HR_StructurePositions.Add(spos);
								}

								gstr = this.GetRangeValue(i, 3, xlsheet);
								per.Name = gstr;

								con.UN_Persons = per;

								ass.HR_StructurePositions = spos;
								ass.AdditionalHolidays = 0;
								ass.NumberHolidays = 20;
								ass.HR_Contracts = con;
								ass.IsActive = true;
								ass.IsAdditionalAssignment = false;								

								logic.UN_Persons.Add(per);
								
								logic.HR_Contracts.Add(con);
								logic.HR_Assignments.Add(ass);

								logic.Save();

								spos.Order = spos.id_structurePosition;
								logic.Save();

							}
						}						
					}
				}
			}
		}
		private void GridMenuItemDown_Click(object sender, RoutedEventArgs e)
		{
			if (this.grGridView.SelectedItem != null)
			{
				var item = this.grGridView.SelectedItem as StructurePositionViewModel;
				using (var logic = new NomenclaturesLogic())
				{
					try
					{
						if (logic.MoveStructurePositionDown(item.id_structurePosition) == true)
						{
							this.LoadPositions();
						}
					}
					catch (ZoraException ex)
					{
						MessageBox.Show(ex.Result.ErrorCodeMessage);
					}
					catch (Exception ex)
					{
						MessageBox.Show(ex.Message);
					}
				}
			}
		}
		private void btnDeletePosition_Click(object sender, RoutedEventArgs e)
		{
			if (this.grGridView.SelectedItem != null)
			{
				var item = this.grGridView.SelectedItem as StructurePositionViewModel;
				using (var logic = new NomenclaturesLogic())
				{
					try
					{
						var it = logic.HR_StructurePositions.GetById(item.id_structurePosition);
						logic.HR_StructurePositions.Delete(it);
						logic.Save();
						this.LoadPositions();
					}
					catch (ZoraException ex)
					{
						MessageBox.Show(ex.Result.ErrorCodeMessage);
					}
					catch (Exception ex)
					{
						MessageBox.Show(ex.Message);
					}
				}
			}
		}
		private void LoadPositions()
		{
			using (var logic = new NomenclaturesLogic())
			{
				this.grGridView.ItemsSource = logic.GetStructurePositions(this.id_selectedDepartment, this.chkShowInactive.IsChecked != true);
			}
		}