Exemplo n.º 1
0
 public PersonControl()
 {
     InitializeComponent();
     curPerson = new person();
     newPerson = new person();
     Check();
 }
Exemplo n.º 2
0
 public void EditLibrarian(long id, person newPerson)
 {
     librarian l = Model.FindLibrarian(id);
     if (l == null)
         throw new DBException(ErrorTypes.LibrarianNotFound);
     Model.EditLibrarian(l, newPerson);
 }
Exemplo n.º 3
0
 public librarian AddLibrarian(string user, person p)
 {
     user usr = Model.FindUser(user);
     if (usr == null)
         throw new DBException(ErrorTypes.AccountNotFound);
     return Model.AddLibrarian(usr, p);
 }
Exemplo n.º 4
0
 public void EditManager(long id, person newPerson)
 {
     manager m = Model.FindManager(id);
     if (m == null)
         throw new DBException(ErrorTypes.ManagerNotFound);
     Model.EditManager(m, newPerson);
 }
Exemplo n.º 5
0
 public void EditStudent(long id, string grName, person newPerson, DateTime dateIn, DateTime? dateOut = null)
 {
     student s = Model.FindStudent(id);
     if (s == null)
         throw new DBException(ErrorTypes.StudentNotFound);
     studentsgroup gr = Model.FindStudentGroup(grName);
     if (gr == null)
         throw new DBException(ErrorTypes.GroupNotFound);
     Model.EditStudent(s, gr, newPerson, dateIn, dateOut);
 }
Exemplo n.º 6
0
 public student AddStudent(string user, string grName, person p, DateTime dateIn, DateTime? dateOut = null)
 {
     user usr = Model.FindUser(user);
     if (usr == null)
         throw new DBException(ErrorTypes.AccountNotFound);
     studentsgroup gr = Model.FindStudentGroup(grName);
     if (gr == null)
         throw new DBException(ErrorTypes.GroupNotFound);
     return Model.AddStudent(usr, gr, p, dateIn, dateOut);
 }
Exemplo n.º 7
0
 public librarian AddLibrarian(user usr, person p)
 {
     CheckConnection();
     try
     {
         lock (locker)
         {
             EditPerson(usr.person, p.First_Name, p.Last_Name, p.Middle_Name, p.Birthday, p.H_Phone, p.M_Phone, p.Address, p.Email, p.SomeInformation, p.Photo);
             librarian l = librarian.Createlibrarian(0, usr.person.Id);
             db.librarians.AddObject(l);
             db.SaveChanges();
             return l;
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     }
 }
Exemplo n.º 8
0
 public void EditStudent(student std, studentsgroup sg, person p, DateTime dateIn, DateTime? dateOut = null)
 {
     CheckConnection();
     try
     {
         lock (locker)
         {
             EditPerson(std.person, p.First_Name, p.Last_Name, p.Middle_Name, p.Birthday, p.H_Phone, p.M_Phone, p.Address, p.Email, p.SomeInformation, p.Photo);           
             std.GroupId = sg.Id;
             std.DateIn = dateIn;
             std.DateOut = dateOut;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     }
 }
Exemplo n.º 9
0
 public ProfileViewWindow(person p)
 {
     InitializeComponent();
     this.pv.Person = p;
 }
Exemplo n.º 10
0
 void DeletePerson(person p)
 {
     CheckConnection();
     try
     {
         lock (locker)
         {
             p.IsDeleted = true;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     }
 }
Exemplo n.º 11
0
 public student AddStudent(user usr, studentsgroup sg, person p, DateTime dateIn, DateTime? dateOut = null)
 {
     CheckConnection();
     try
     {
         lock (locker)
         {
             EditPerson(usr.person, p.First_Name, p.Last_Name, p.Middle_Name, p.Birthday, p.H_Phone, p.M_Phone, p.Address, p.Email, p.SomeInformation, p.Photo);
             student std = student.Createstudent(0, usr.person.Id, sg.Id, dateIn);
             std.DateOut = dateOut;
             db.students.AddObject(std);
             db.SaveChanges();
             return std;
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     }
 }
Exemplo n.º 12
0
 void EditPerson(person p, string firstname, string lastname, string middlename, DateTime? birthday = null, string hphone = "", string mphone = "", string addr = "", string email = "", string info = "", string photo = "")
 {
     CheckConnection();
     try
     {
         lock (locker)
         {
             p.First_Name = firstname;
             p.Last_Name = lastname;
             p.Middle_Name = middlename;
             p.Birthday = birthday;
             p.H_Phone = hphone;
             p.M_Phone = mphone;
             p.Address = addr;
             p.Email = email;
             p.SomeInformation = info;
             p.Photo = photo;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     }
 }
Exemplo n.º 13
0
 public user AddUser(string login, string password)
 {
     CheckConnection();
     try
     {
         lock (locker)
         {
             person p = new person();
             db.persons.AddObject(p);
             try
             {
                 db.SaveChanges(); 
             }
             catch (Exception ex)
             {
                 db.persons.DeleteObject(p);
                 throw new DBException(ErrorTypes.UnexpectedException, ex);
             }
             user usr = user.Createuser(0, p.Id, login, password);
             db.users.AddObject(usr);
             try
             {
                 db.SaveChanges();
             }
             catch (Exception ex)
             {
                 db.users.DeleteObject(usr);
                 db.persons.DeleteObject(p);
                 db.SaveChanges();
                 throw new DBException(ErrorTypes.UnexpectedException, ex); 
             }
             return usr;
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     }
 }
Exemplo n.º 14
0
 public void EditLibrarian(librarian l, person p)
 {
     CheckConnection();
     try
     {
         lock (locker)
         {
             EditPerson(l.person, p.First_Name, p.Last_Name, p.Middle_Name, p.Birthday, p.H_Phone, p.M_Phone, p.Address, p.Email, p.SomeInformation, p.Photo);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     }
 }
Exemplo n.º 15
0
 public teacher AddTeacher(string user, person p)
 {
     user usr = Model.FindUser(user);
     if (usr == null)
         throw new DBException(ErrorTypes.AccountNotFound);
     return Model.AddTeacher(usr, p);
 }
Exemplo n.º 16
0
 /// <summary>
 /// Create a new person object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
 public static person Createperson(global::System.Int64 id, global::System.Boolean isDeleted)
 {
     person person = new person();
     person.Id = id;
     person.IsDeleted = isDeleted;
     return person;
 }
Exemplo n.º 17
0
 public void EditTeacher(long id, person newPerson)
 {
     teacher t = Model.FindTeacher(id);
     if (t == null)
         throw new DBException(ErrorTypes.ManagerNotFound);
     Model.EditTeacher(t, newPerson);
 }
Exemplo n.º 18
0
 /// <summary>
 /// Deprecated Method for adding a new object to the persons EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTopersons(person person)
 {
     base.AddObject("persons", person);
 }
Exemplo n.º 19
0
 public void SetPerson(person p)
 {
     IsEdit = true;
     curPerson = p;
     InitFields();
 }
Exemplo n.º 20
0
 public manager AddManager(user usr, person p)
 {
     CheckConnection();
     try
     {
         lock (locker)
         {
             EditPerson(usr.person, p.First_Name, p.Last_Name, p.Middle_Name, p.Birthday, p.H_Phone, p.M_Phone, p.Address, p.Email, p.SomeInformation, p.Photo);
             manager m = manager.Createmanager(0, usr.person.Id);
             db.managers.AddObject(m);
             db.SaveChanges();
             return m;
         }
     }
     catch (Exception ex)
     {
         throw new DBException(ErrorTypes.UnexpectedException, ex);
     }
 }