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); } } }
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); } } }
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 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); } } } }
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 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(); } } } } } }