Beispiel #1
0
        public void save(PersonBO bo)
        {
            bo.Tax = CalculateTax(bo.Salary);
            PersonDAL pdl = new PersonDAL();

            pdl.Save(bo);
        }
Beispiel #2
0
 private void btnAddPerson_Click(object sender, RoutedEventArgs e)
 {
     if (!(firstName.Text.Equals("") || lastName.Text.Equals("") || date.Text.Equals("") || cBoxClients.Text.Equals("") || cBoxPositionTypes.SelectedItem == null))
     {
         DateTime dt = new DateTime(1900, 1, 1);
         try
         {
             dt = DateTime.Parse(date.SelectedDate.ToString());
         }
         catch
         {
         }
         ClientBO       cbo = cBoxClients.SelectedItem as ClientBO;
         PositionTypeBO pTo = cBoxPositionTypes.SelectedItem as PositionTypeBO;
         PersonBO       bo  = new PersonBO(0, firstName.Text, lastName.Text, dt, cbo._id, pTo.Id);
         if (bo.Age < 16)
         {
             MessageBoxResult result = MessageBox.Show("The age of the person is less than 16, aborting add", "Warning", MessageBoxButton.OK);
             return;
         }
         bo.AddOrUpdate();
         searchBox.Text        = "";
         lvPersons.ItemsSource = _vm.Persons;
         lvPersons.UpdateLayout();
     }
     else
     {
         MessageBoxResult result = MessageBox.Show("Add a valid Date, Name, Lastname, Client", "Warning", MessageBoxButton.OK);
     }
     e.Handled = true;
 }
Beispiel #3
0
        private void btnEditPerson_Click(object sender, RoutedEventArgs e)
        {
            if (lvPersons.SelectedItem != null)
            {
                PersonBO bo = lvPersons.SelectedItem as PersonBO;
                if (bo == null)
                {
                    bo = lvPersons.Items.CurrentItem as PersonBO;
                }

                if (cBoxClients.SelectedItem != null || cBoxPositionTypes.SelectedItem != null)
                {
                    ClientBO cbo = cBoxClients.SelectedItem as ClientBO;
                    add(bo.Id, firstName.Text, lastName.Text, date.SelectedDate, cbo._id, (cBoxPositionTypes.SelectedItem as PositionTypeBO).Id);
                }
                else
                {
                    ClientBO cbo = cBoxClients.SelectionBoxItem as ClientBO;
                    add(bo.Id, firstName.Text, lastName.Text, date.SelectedDate, cbo._id, (cBoxPositionTypes.SelectedItem as PositionTypeBO).Id);
                }
                lvPersons.ItemsSource = _vm.Persons;
                searchBox.Text        = "";
                lvPersons.UpdateLayout();
                e.Handled = true;
            }
        }
Beispiel #4
0
        public void search(object sender, TextChangedEventArgs e)
        {
            if (searchBox.Text != "" && searchBox.Text.Length > 1)
            {
                string str = searchBox.Text;
                ObservableCollection <PersonBO> clts = new ObservableCollection <PersonBO>(_vm.Persons);
                int len = clts.Count;
                ObservableCollection <PersonBO> clts2 = new ObservableCollection <PersonBO>();

                for (int i = 0; i < len; i++)
                {
                    var item = clts[i];

                    if ((item.ToString().Contains(str)))
                    {
                        PersonBO a = item as PersonBO;
                        clts2.Add(a);
                    }
                }
                lvPersons.ItemsSource = clts2;
                lvPersons.UpdateLayout();
            }
            else
            {
                lvPersons.ItemsSource = _vm.Persons;
                lvPersons.UpdateLayout();
            }
            e.Handled = true;
        }
Beispiel #5
0
 private void btnEditContact_Click(object sender, RoutedEventArgs e)
 {
     if (lvContacts.SelectedItem != null)
     {
         PersonBO  cc      = lvPersons.SelectedItem as PersonBO;
         ContactBO contact = new ContactBO((lvContacts.SelectedItem as ContactBO).Id, contactValueBox.Text, (lvPersons.SelectedItem as PersonBO).Id, ((cBoxContactTypes.SelectedItem) as ContactTypeBO).Id);
         if (contact.Id == 1 || cBoxContactTypes.SelectedItem.Equals("Email"))
         {
             if (!IsValid(contactValueBox.Text))
             {
                 MessageBoxResult result = MessageBox.Show("The email is invalid, aborting", "Warning", MessageBoxButton.OK);
                 return;
             }
         }
         contact.AddOrUpdate();
         this._vm._contacts     = cc.Contacts;
         lvContacts.ItemsSource = _vm.Contacts;
         lvContacts.UpdateLayout();
     }
     else
     {
         MessageBoxResult result = MessageBox.Show("Select a Contact to edit first", "Warning", MessageBoxButton.OK);
     }
     e.Handled = true;
 }
Beispiel #6
0
        public static bool SendBirthdayMessage(PersonBO a)
        {
            string subject = "Happy Birthday to you.";
            string suffix;

            switch (a.Age % 10)
            {
            case 1:
                suffix = "st";
                break;

            case 2:
                suffix = "nd";
                break;

            case 3:
                suffix = "rd";
                break;

            default:
                suffix = "th";
                break;
            }
            string msg  = "Hello {1}!{0}{0}We wish you a very happy {2}{3} birthday!{0}{0}Your friends at Elibrium";
            string body = String.Format(msg, Environment.NewLine, a.Name, a.Age, suffix);

            return(SendMessage(a, subject, body));
        }
Beispiel #7
0
        private void btnDeleteContact_Click(object sender, RoutedEventArgs e)
        {
            PersonBO person   = lvPersons.SelectedItem as PersonBO;
            var      contacts = lvContacts.SelectedItems;

            if (contacts.Count > 0)
            {
                foreach (ContactBO contact in contacts)
                {
                    contact.Delete();
                }
                if (person.Contacts != null)
                {
                    this._vm._contacts = person.Contacts;
                }
                else
                {
                    this._vm.Contacts = new ObservableCollection <ContactBO>();
                }

                lvContacts.ItemsSource = _vm.Contacts;
                lvContacts.UpdateLayout();
            }
            else
            {
                MessageBoxResult result = MessageBox.Show("Select a contact to delete first", "A big fat warning", MessageBoxButton.OK);
            }
            e.Handled = true;
        }
        private void Host_LogIn_But(object sender, RoutedEventArgs e)
        {
            PersonBO temp = null;

            try // If the person dosen't exist
            {
                temp = bl.GetPersonByMail(HostUserMail.Text);
                if (HostPassword.Password == temp.Password)
                {
                    try // If the person exist but he isn't register as host
                    {
                        host = bl.GetHost(temp.Id);
                        HostInfo.DataContext          = host;
                        hostOrders                    = new ObservableCollection <OrderBO>(host.OrdersHost); // making the list request of the guest
                        hostAprrovedOrds              = new ObservableCollection <OrderBO>(host.AppovedOrdersHost);
                        AprrovedOrderList.DataContext = hostAprrovedOrds;
                        OrderList.DataContext         = hostOrders;
                        HostLogin.Visibility          = Visibility.Collapsed;
                        HostWindow.Visibility         = Visibility.Visible;
                    }
                    catch (MissingMemberException ex)
                    {
                        MessageBox.Show(ex.Message, "שגיאה", MessageBoxButton.OK, MessageBoxImage.Error);
                        AddHoset_Click(temp.Id);
                    }
                }
                HostErorrInput.Visibility = Visibility.Visible;
            }
            catch (MissingMemberException ex)
            {
                HostErorrInput.Visibility = Visibility.Visible;
            }
        }
Beispiel #9
0
        public PersonBO GetPersonByMail(string mail)
        {
            PersonBO person = null;

            try { person = PersonConvertDOToBO(dal.GetPersonByMail(mail)); }
            catch (MissingMemberException ex) { throw ex; }
            return(person);
        }
Beispiel #10
0
 public void UpdPerson(PersonBO person)
 {
     if (!IsValidMail(person.Email))
     {
         throw new FormatException("The given mail " + person.Email + " is invalid");
     }
     try { dal.UpdatePerson(PersonConvertBOToDO(person)); }
     catch (MissingMemberException ex) { throw ex; }
 }
 public Request_Detals_UserControl(GuestRequestBO request, HostBO host)
 {
     InitializeComponent();
     myRequest               = request;
     myHost                  = host;
     Person                  = bl.GetPersonById(myRequest.ClientId);
     FirstName.Text          = Person.FirstName;
     LastName.Text           = Person.LastName;
     GridRequest.DataContext = myRequest;
     initi_comboxes();
 }
Beispiel #12
0
 public Create_Order_UserControl(ObservableCollection <HostingUnitBO> hostingUnits, GuestRequestBO request)
 {
     InitializeComponent();
     myHostingUnits = hostingUnits;
     myRequest      = request;
     clientPerson   = bl.GetPersonById(myRequest.ClientId);
     GridHostingUnits.DataContext = myHostingUnits;
     worker                     = new BackgroundWorker();
     worker.DoWork             += Worker_DoWork;
     worker.RunWorkerCompleted += Worker_RunWorkerCompleted;
 }
        public void Input()
        {
            PersonBO PBO = new PersonBO();

            PBO.Name   = this.textBoxImie.Text;
            PBO.Salary = double.Parse(this.textBoxSalary.Text);

            PersonBLL pbll = new PersonBLL();

            pbll.save(PBO);
        }
Beispiel #14
0
        public List <PersonBO> Read()
        {
            //FileStream fin = new FileStream("File1.txt", FileMode.Open);
            StreamReader    sr   = new StreamReader("File1.txt");
            List <PersonBO> lpbo = new List <PersonBO>();

            while (!sr.EndOfStream)
            {
                string   data  = sr.ReadLine();
                PersonBO pbo   = new PersonBO();
                string   bufor = "";

                for (int i = 0; i < data.Length; i++)
                {
                    if (data[i] != ';')
                    {
                        pbo.Name += data[i];
                    }
                    else
                    {
                        data = data.Remove(0, i + 1);
                        break;
                    }
                }

                for (int i = 0; i < data.Length; i++)
                {
                    if (data[i] != ';')
                    {
                        bufor += data[i];
                    }
                    else
                    {
                        data       = data.Remove(0, i + 1);
                        pbo.Salary = double.Parse(bufor);
                        break;
                    }
                }


                pbo.Tax = double.Parse(data);

                lpbo.Add(pbo);
            }

            sr.Close();
            //fin.Close();

            return(lpbo);
        }
Beispiel #15
0
        PersonBO PersonConvertDOToBO(Person person)
        {
            PersonBO temp = new PersonBO();

            temp.Id          = person.Id;
            temp.IdType      = (IdTypesBO)person.IdType;
            temp.FirstName   = person.FirstName;
            temp.LastName    = person.LastName;
            temp.Email       = person.Email;
            temp.Password    = person.Password;
            temp.PhoneNomber = person.PhoneNomber;
            temp.Status      = (StatusBO)person.Status;
            return(temp);
        }
Beispiel #16
0
        Person PersonConvertBOToDO(PersonBO person)
        {
            Person temp = new Person();

            temp.Id          = person.Id;
            temp.IdType      = (IdTypes)person.IdType;
            temp.FirstName   = person.FirstName;
            temp.LastName    = person.LastName;
            temp.Email       = person.Email;
            temp.Password    = person.Password;
            temp.PhoneNomber = person.PhoneNomber;
            temp.Status      = (Status)person.Status;
            return(temp);
        }
Beispiel #17
0
 public static ObservableCollection <PersonBO> GetPersonsByClientId(int id)
 {
     using (ElibriumEntities db = new ElibriumEntities())
     {
         var Persons = db.Person.Where(x => x.ClientId == id);
         ObservableCollection <PersonBO> ccs = new ObservableCollection <PersonBO>();
         foreach (var clc in Persons)
         {
             PersonBO cc = new PersonBO(clc);
             ccs.Add(cc);
         }
         return(ccs);
     }
 }
Beispiel #18
0
        private void add(int id, string firstName, string lastName, DateTime?db, int cId, int pId)
        {
            DateTime dt = new DateTime(1900, 1, 1);

            try
            {
                dt = DateTime.Parse(db.ToString());
            }
            catch
            {
            }
            PersonBO bo = new PersonBO(id, firstName, lastName, dt, cId, pId);

            bo.AddOrUpdate();
        }
Beispiel #19
0
 private void lvPersons_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (lvPersons.SelectedItem != null)
     {
         PersonBO a = lvPersons.SelectedItem as PersonBO;
         firstName.Text         = a.FirstName;
         lastName.Text          = a.LastName;
         date.Text              = a.DBO;
         cBoxClients.Text       = a.Client.Name.ToString();
         this._vm._contacts     = a.Contacts;
         lvContacts.ItemsSource = _vm.Contacts;
         cBoxPositionTypes.Text = a.PositionType.Name.ToString();
     }
     e.Handled = true;
 }
Beispiel #20
0
 public void AddPerson(PersonBO person)
 {
     if (!IsValidTZ(person.Id))
     {
         new InvalidOperationException("The given Id is invalid");
     }
     if (!dal.ChaeckPersonMail(person.Email))
     {
         try { dal.AddPerson(PersonConvertBOToDO(person)); }
         catch (DuplicateKeyException ex) { throw ex; }
     }
     else
     {
         throw new DuplicateKeyException(person.Email, "The mail alredy is in the system by a othrer user\n");
     }
 }
Beispiel #21
0
 public static ObservableCollection <PersonBO> GetAllPersons()
 {
     using (ElibriumEntities db = new ElibriumEntities())
     {
         ObservableCollection <PersonBO> ccs = new ObservableCollection <PersonBO>();
         if (db.Person.Count() > 0)
         {
             var Persons = db.Person.ToList();
             foreach (var clc in Persons)
             {
                 PersonBO cc = new PersonBO(clc);
                 ccs.Add(cc);
             }
         }
         return(ccs);
     }
 }
Beispiel #22
0
 public static ObservableCollection <PersonBO> GetPersonsWithBirthdays()
 {
     using (ElibriumEntities db = new ElibriumEntities())
     {
         ObservableCollection <PersonBO> ccs = new ObservableCollection <PersonBO>();
         if (db.Person.Count() > 0)
         {
             var Persons = db.Person.Where(x => x.DBO.Day == DateTime.Now.Day && x.DBO.Month == DateTime.Now.Month).ToList();
             foreach (var clc in Persons)
             {
                 PersonBO cc = new PersonBO(clc);
                 ccs.Add(cc);
             }
         }
         return(ccs);
     }
 }
Beispiel #23
0
        public static bool SendMessage(PersonBO a, string subject, string body)
        {
            string      to      = a.Email.Value;
            string      from    = "*****@*****.**";
            MailMessage message = new System.Net.Mail.MailMessage(from, to, subject, body);

            try
            {
                client.Send(message);
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception caught in SendMessage(): {0}",
                                  ex.ToString());
                return(false);
            }
        }
Beispiel #24
0
        public void Input()
        {
            Console.Write("Enter Name: ");
            string name = Console.ReadLine();


            Console.Write("Enter Salry: ");
            double salary = double.Parse(Console.ReadLine());

            PersonBO PBO = new PersonBO();

            PBO.Name   = name;
            PBO.Salary = salary;

            PersonBLL pbll = new PersonBLL();

            pbll.save(PBO);
        }
Beispiel #25
0
 private void btnAddContact_Click(object sender, RoutedEventArgs e)
 {
     if (_vm.ContactTypes.Count > 0)
     {
         if (!contactValueBox.Text.Equals(""))
         {
             PersonBO      a           = lvPersons.SelectedItem as PersonBO;
             ContactTypeBO contactType = cBoxContactTypes.SelectedItem as ContactTypeBO;
             if (a != null)
             {
                 ContactBO cbo = new ContactBO(contactValueBox.Text, (lvPersons.SelectedItem as PersonBO).Id, (cBoxContactTypes.SelectedItem as ContactTypeBO).Id);
                 if (contactType.Name.Equals("Email"))
                 {
                     if (!IsValid(contactValueBox.Text))
                     {
                         MessageBoxResult result = MessageBox.Show("The email is invalid, aborting", "Warning", MessageBoxButton.OK);
                         return;
                     }
                 }
                 cbo.AddOrUpdate();
                 this._vm._contacts     = a.Contacts;
                 lvContacts.ItemsSource = _vm.Contacts;
                 lvContacts.UpdateLayout();
             }
             else
             {
                 MessageBox.Show("Select a Person first, to whom you want to add the contact", "A big fat warning", MessageBoxButton.OK);
             }
         }
         else
         {
             MessageBox.Show("Contact value can not be empty", "Warning", MessageBoxButton.OK);
         }
     }
     else
     {
         MessageBox.Show("Add atleast one contact type first", "Warning", MessageBoxButton.OK);
     }
     e.Handled = true;
 }
Beispiel #26
0
        public void Save(PersonBO bo)
        {
            FileStream fout;

            if (File.Exists("File1.txt"))
            {
                fout = new FileStream("File1.txt", FileMode.Open);
            }
            else
            {
                fout = new FileStream("File1.txt", FileMode.Create);
            }

            StreamWriter sw = new StreamWriter(fout);

            string data = bo.Name + ";" + bo.Salary + ";" + bo.Tax;

            sw.WriteLine(data);

            sw.Close();
            fout.Close();
        }
        private void clientListManager_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            PersonBO          client        = (PersonBO)clientListManager.SelectedItem;
            UserControlSingUp clientDetalse = new UserControlSingUp();

            clientDetalse.Email.Text           = client.Email;
            clientDetalse.Email.IsEnabled      = false;
            clientDetalse.FirstName.Text       = client.FirstName;
            clientDetalse.FirstName.IsEnabled  = false;
            clientDetalse.LastName.Text        = client.LastName;
            clientDetalse.LastName.IsEnabled   = false;
            clientDetalse.Phone.Text           = client.PhoneNomber;
            clientDetalse.Phone.IsEnabled      = false;
            clientDetalse.Password.Visibility  = Visibility.Collapsed;
            clientDetalse.PassIcon.Visibility  = Visibility.Collapsed;
            clientDetalse.Id.Text              = client.Id;
            clientDetalse.Id.IsEnabled         = false;
            clientDetalse.IDType.SelectedItem  = client.IdType;
            clientDetalse.IDType.IsEnabled     = false;
            clientDetalse.CreateBut.Visibility = Visibility.Collapsed;
            clientDetalse.CloseBut.Content     = "סגור";
            MaterialDesignThemes.Wpf.DialogHost.Show(clientDetalse, "ManagerDialog");
        }
        private void LogIn_But(object sender, RoutedEventArgs e)
        {
            PersonBO temp = null;

            try
            {
                temp = bl.GetPersonByMail(UserMail.Text);
                if (Password.Password == temp.Password)
                {
                    client = bl.GetClient(temp.Id);
                    ClientInfo.DataContext = client;
                    requests = new ObservableCollection <GuestRequestBO>(client.ClientRequests); // making the list request of the guest
                    ListRequest.DataContext = requests;
                    clientLogin.Visibility  = Visibility.Collapsed;
                    clientWindow.Visibility = Visibility.Visible;
                }
                ErorrInput.Visibility = Visibility.Visible;
            }
            catch (MissingMemberException ex)
            {
                ErorrInput.Visibility = Visibility.Visible;
            }
        }
 public PessoaController(IConfiguration cfg) : base(cfg)
 {
     bo = new PersonBO(this.ConnectionString());
 }
Beispiel #30
0
        public static bool SendOffer(PersonBO a, string body, string subject)
        {
            string actualBody = String.Format("Hello " + a.Name + ",{0}{0}We at Elibrium have an wonderful offer for you, the details are below{0}{0}" + body + "{0}{0}Elibrium© " + DateTime.Now.Year, Environment.NewLine);

            return(SendMessage(a, subject, actualBody));
        }