Exemplo n.º 1
0
        /// <summary>
        /// Metoda za pomocą jakiej tworzy nowy Pracownik lub edytyje go
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static bool AddOrEditEmployee(Employee value)
        {
            if (value.EmployeeId == 0)
            {
                value.EmployeeId = context.Employees.Count() > 0 ? context.Employees.Max(x => x.EmployeeId) + 1 : 1;
                context.Employees.Add(value);
            }
            else
            {
                Employee employe = context.Employees.FirstOrDefault(x => x.EmployeeId == value.EmployeeId);
                if (employe != null)
                {

                    employe.PracownikName = value.PracownikName;
                    employe.PositionPrac = value.PositionPrac;
                    employe.AddressZam = value.AddressZam;
                    employe.ClockJob = value.ClockJob;
                    employe.InfoPrac = value.InfoPrac;
                    employe.TelNumberPracownik = value.TelNumberPracownik;
                    employe.Wiek = value.Wiek;

                }
            }
            context.SaveChanges();

            return true;
        }
Exemplo n.º 2
0
 /// <summary>
 /// 2 metody statyczne jakie obsługują serializacje
 /// </summary>
 /// <param name="employee"></param>
 /// <param name="filePath"></param>
 public static void Serialize(Employee employee, string filePath)
 {
     XmlSerializer serializer = new XmlSerializer(typeof(Employee));
     TextWriter textWriter = new StreamWriter(filePath); serializer.Serialize(textWriter, employee);
     textWriter.Close();
 }
Exemplo n.º 3
0
 public NewEmployeeForm(Employee employeeData)
 {
     this.data = employeeData;
     InitializeComponent();
     this.employeeBindingSource.DataSource = data;
 }