OrdersUntilDate(int days)
- {
- return myDAL.ReturenAllOrders(x => NumOfDays(x.CreateDate) == days).ToList(); ;
- }
-
- ///
- /// Average Orders per client
- ///
- ///
- public double averageOrdersPerClient()
- {
- double sum = 0;
- foreach (var guestRequest in GuestRequestBy())
- {
- sum += OrdersPerClient(guestRequest);
- }
- return sum;
- }
-
- ///
- /// Average Orders per hosting unit
- ///
- ///
- public double averageOrdersPerHostingUnit()
- {
- double sum = 0;
- foreach (var hostingUnit in HustingUnitsBy())
- {
- sum += OrdersPerUnit(hostingUnit);
- }
- return sum;
- }
-
- #endregion Order
-
- #region Date
-
- ///
- /// Is date available
- ///
- public bool IsDateAvailable(DateTime start, DateTime end, int unitKey)
- {
-
- HostingUnit x = GetHostingUnit(unitKey);
- start.AddDays(1);
- for (DateTime i = start; i < end; i.AddDays(1))
- {
- if(x.Diary.FindIndex((z) => z == i) != -1 )
- {
- return false;
- }
- }
-
- return true;
-
- }
-
- ///
- /// Check if end day later than the start date
- ///
- public bool IsDateCorrect(DateTime start, DateTime end)
- {
- if (end > start)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- ///
- /// Return number of days from date until now
- ///
- public int NumOfDays(DateTime date)
- {
- return (int)(DateTime.Now - date).TotalDays;
- }
-
- ///
- /// Return number of days between 2 Date Times OBJ
- ///
- public int NumOfDays(DateTime firstDate, DateTime SecondDate)
- {
- return (int)(SecondDate - firstDate).TotalDays;
- }
-
- #endregion Date
-
- ///
- /// BootingUp the progrem.
- /// 1) Receive bank data from the web
- /// 2)
- ///
- public void bootingUp()
- {
- try{
- GetBankInfoFromTheWeb();
- } catch (Exception ex){
- // throw new Exception("Can't get bank info from the web " + ex);
- MessageBox.Show("Can't get bank info from the web\n "+ex );
- }
-
- }
-
-
-
-
- ///
- /// Sending Email to client
- ///
- public void SendMail(Order order)
- {
- MailMessage mail = new MailMessage();
- mail.To.Add(GuestRequestBy(x => x.GuestRequestKey == order.GuestRequestKey).First().MailAddress);
- mail.From = new MailAddress(GetHostingUnit(order.HostingUnitKey).Owner.MailAddress);
- mail.Subject = "Resort offeras as you request";
- mail.Body = "You'r request:
"+
- GuestRequestBy(x => x.GuestRequestKey == order.GuestRequestKey).First().ToString()+
- "------------------
"+
- "Our offer is:
"+
- GetHostingUnit(order.HostingUnitKey).ToString()+
- "Please notify us with return mail to this address:
"+
- GetHostingUnit(order.HostingUnitKey).Owner.MailAddress;
- mail.IsBodyHtml = true;
-
- SmtpClient smtp = new SmtpClient();
- smtp.Host = "smtp.gmail.com";
- smtp.Credentials = new System.Net.NetworkCredential("ipewzner@g.jct.ac.il", "Reptor17");
- smtp.EnableSsl = true;
-
- try
- {
- smtp.Send(mail);
- }
- catch (Exception ex)
- {
- throw new Exception("Email error " + ex);
- }
-
-
- }
-
- ///
- /// Send email with new password
- ///
- ///
- public void SendMailWithNewPassword(Host host)
- {
- // Manager manager = new Manager();
- // manager.MailAddress = "dotnetproject2020@gmail.com";
- var rand = new Random();
- int password = rand.Next(10000000,99999999);
- host.PasswordKey = KeyForPassword(password);
-
- MailMessage mail = new MailMessage();
- mail.To.Add(host.MailAddress);
- // mail.From = new MailAddress("ipewzner@g.jct.ac.il");
- mail.From = new MailAddress(" dotnetproject2020 @gmail.com");
-
- mail.Subject = "New password - do not replay!";
- mail.Body = "You'r new password is: "+ password +
- "Please change your password after the next login
"+
- "You can change your password in the Host updata section
";
- mail.IsBodyHtml = true;
-
- SmtpClient smtp = new SmtpClient();
- smtp.Host = "smtp.gmail.com";
- smtp.Credentials = new System.Net.NetworkCredential("dotnetproject2020@gmail.com", "kuku4ever");
- smtp.EnableSsl = true;
-
- try
- {
- smtp.Send(mail);
- }
- catch (Exception ex)
- {
- throw new Exception("Email error " + ex);
- }
-
- }
-
- ///
- /// Checke if password is curect
- ///
- ///
- ///
- ///
- public bool CheckePassword(double key,int password)
- {
- return Math.Sin( password )*Math.Sqrt(password)==key;
- }
-
- ///
- /// Make key for password
- ///
- ///
- ///
- public double KeyForPassword(int password)
- {
- return Math.Sin(password) * Math.Sqrt(password);
- }
-
- ///
- /// Creates Offers by area and available dates
- ///
- public void CreateOffer(GuestRequest req)
- {
- List hostingUnits = UintsAvailable(req.EntryDate, NumOfDays(req.EntryDate, req.EntryDate));
- foreach (var item in hostingUnits)
- {
- Offer y = new Offer();
-
- foreach (var guest in GuestRequestBy((x => x.Area == item.Area)))
- {
- y.GuestKey = guest.GuestRequestKey;
- y.UnitKey = item.HostingUnitKey;
- }
-
- if (y != null)
- Offer.ListOfOffers.Add(y);
- }
-
- }
-
- public bool IsAccountCharged(Host host)
- {
- //HOW TO CHECK IF ACCOUNT CHARGED??
- throw new NotImplementedException();
- }
-
- ///
- /// GetBankInfoFromTheWeb
- ///
- public void GetBankInfoFromTheWeb()
- {
- //C:\Users\ipewz\Documents\GitHub\Mini_project_Windows_system
- //const string xmlLocalPath = @"atm.xml";
- const string xmlLocalPath = @"C:\Users\ipewz\Documents\GitHub\Mini_project_Windows_system\ATM.xml";
- WebClient wc = new WebClient();
- try
- {
- string xmlServerPath =
- @"http://www.boi.org.il/he/BankingSupervision/BanksAndBranchLocations/Lists/BoiBankBranchesDocs/atm.xml";
- wc.DownloadFile(xmlServerPath, xmlLocalPath);
- }
- catch (Exception)
- {
- string xmlServerPath = @"http://www.jct.ac.il/~coshri/atm.xml";
- wc.DownloadFile(xmlServerPath, xmlLocalPath);
- }
- finally
- {
- wc.Dispose();
- }
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using BE;
+using System.Reflection;
+
+using DAL;
+using System.Net.Mail;
+using System.Net;
+using System.Windows;
+using System.Threading;
+
+namespace BL
+{
+ public class MyBl : IBL
+ {
+ DalXML myDAL = new DalXML();
+
+ ///
+ /// Add Guest Request
+ ///
+ public bool AddGuestRequest(GuestRequest req)
+ {
+
+ if (myDAL.ReturnGuestRequestList((x) => x.GuestRequestKey == req.GuestRequestKey).ToList().Count == 0)
+ {
+ myDAL.addGuestRequest(req);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+
+ ///
+ /// Add Hosting Unit
+ ///
+ public void AddHostingUnit(HostingUnit unit)
+ {
+ if (myDAL.ReturnHostingUnitList((x) => x.HostingUnitKey == unit.HostingUnitKey).ToList().Count == 0)
+ {
+ myDAL.addHostingUnit(unit);
+ }
+ else
+ {
+ throw new Exception("This Hosting unit exist already!");
+ }
+
+ }
+
+ ///
+ /// create a new order
+ ///
+ public bool AddOrder(Order neworder)
+ {
+
+ //Order order = instance.ReturenAllOrders((x)=> x.OrderKey == neworder.OrderKey).First();
+ //if (order.Status == OrderStatus.CloseByClient || order.Status == OrderStatus.CloseByClientTimeOut)
+ //{
+ // return false;
+ //}
+ //else
+ //{
+ myDAL.addOrder(neworder);
+ //}
+ return true;
+ }
+
+ ///
+ /// Close the order and handle the Implications
+ ///
+ public void CloseOrder(Order order)
+ {
+ if (order.Status == OrderStatus.CloseByClient)
+ {
+ //TODO:
+ //close status for changes
+
+ HostingUnit x = GetHostingUnit(Convert.ToInt32(order.HostingUnitKey));
+ GuestRequest y = GetGusetRequest(Convert.ToInt32(order.GuestRequestKey));
+ for (DateTime i = y.EntryDate; i <= y.ReleaseDate; i.AddDays(1))
+ {
+ x.Diary.Add(i);
+ }
+
+
+ //TODO add Commision
+ //To Where??
+
+ //Change client STATUS
+ y.Status = ClientStatus.CloseByApp;
+
+ }
+ }
+
+ public void RemoveHost(Host host)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Is date available
+ ///
+ public bool IsDateAvailable(DateTime start, DateTime end, int unitKey)
+ {
+
+ HostingUnit x = GetHostingUnit(unitKey);
+ start.AddDays(1);
+ for (DateTime i = start; i < end; i.AddDays(1))
+ {
+ if (x.Diary.FindIndex((z) => z == i) != -1)
+ {
+ return false;
+ }
+ }
+
+ return true;
+
+ }
+
+ ///
+ /// Check if end day later than the start date
+ ///
+ public bool IsDateCorrect(DateTime start, DateTime end)
+ {
+ return(end > start)? true:false;
+ }
+
+ public void UpdateHost(Host host)
+ {
+ throw new NotImplementedException();
+ }
+
+ ///
+ /// Return number of days from date until now
+ ///
+ public int NumOfDays(DateTime date)
+ {
+ return (int)(DateTime.Now - date).TotalDays;
+ }
+
+ ///
+ /// Return number of days between 2 Date Times OBJ
+ ///
+ public int NumOfDays(DateTime firstDate, DateTime SecondDate)
+ {
+ return (int)(SecondDate - firstDate).TotalDays;
+ }
+
+ ///
+ /// Sending Email to client
+ ///
+ //public void SendMail(Order order)
+ //{
+ // if (order.Status == OrderStatus.MailSent)
+ // {
+ // Console.WriteLine(
+ // $"You order:\n" +
+ // $"Create Date: {order.CreateDate}\n" +
+ // $"Order Date: {order.OrderDate}\n" +
+ // $"Hosting Unit Key: {order.HostingUnitKey}\n"
+ // );
+ // }
+ //}
+
+ ///
+ /// Return number of orders that sent to client
+ ///
+ public int OrdersPerClient(GuestRequest req)
+ {
+ int counter = 0;
+ foreach (var item in myDAL.ReturenAllOrders())
+ {
+ if (item.GuestRequestKey == req.GuestRequestKey)
+ {
+ if (item.Status == OrderStatus.MailSent)
+ counter++;
+ }
+ }
+ return counter;
+ }
+
+ ///
+ /// Return number of orders that seccessfully close
+ ///
+ public int OrdersPerUnit(HostingUnit unit)
+ {
+ int counter = 0;
+ foreach (var item in myDAL.ReturenAllOrders())
+ {
+ if (item.HostingUnitKey == unit.HostingUnitKey)
+ {
+ if (item.Status == OrderStatus.CloseByClient)
+ counter++;
+ }
+ }
+ return counter;
+ }
+
+ ///
+ /// Check if Unit can be remove
+ ///
+ public void UnitRemove(int unitKey)
+ {
+ foreach (var item in myDAL.ReturenAllOrders())
+ {
+ if ((item.HostingUnitKey == unitKey) && (item.Status == OrderStatus.UntreatedYet))
+ {
+ throw new Exception("Can't delete this unit, whan some order still open!");
+ }
+ }
+ HostingUnit hostingUnit = GetHostingUnit(Convert.ToInt32(unitKey));
+ try
+ {
+ myDAL.DeleteHostingUnit(hostingUnit);
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("" + ex);
+ }
+ }
+
+ ///
+ /// Update Unit
+ ///
+ ///
+ public void UpdateUnit(HostingUnit hostingUnit)
+ {
+ try
+ {
+ UnitRemove(hostingUnit.HostingUnitKey);
+ AddHostingUnit(hostingUnit);
+ MessageBox.Show($"Hosting unit: {hostingUnit.HostingUnitName} updated Seccessfuly!");
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"Error during Update {hostingUnit.HostingUnitName} please try again later! " + ex);
+ }
+ }
+
+
+
+ ///
+ /// Return all units available in given date range
+ ///
+ public List UintsAvailable(DateTime start, int numOfDays)
+ {
+ List listOfUnits = new List();
+
+ DateTime end = start.AddDays(numOfDays);
+ var x = myDAL.ReturnHostingUnitList(null);
+ foreach (var item in x)
+ {
+
+ if (IsDateAvailable(start, end, item.HostingUnitKey))
+ {
+ listOfUnits.Add(item);
+ }
+
+ }
+
+ return listOfUnits;
+ }
+
+ ///
+ /// Add new Host
+ ///
+ public bool AddHost(Host host)
+ {
+ if (myDAL.returnHostList((x) => x.HostKey == host.HostKey).ToList().Count == 0)
+ {
+ myDAL.addHost(host);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+
+
+
+ }
+
+ ///
+ /// Return Guest Request By any requirment
+ ///
+ public IEnumerable GuestRequestBy(Func predicate = null)
+ {
+ if (predicate == null)
+ return myDAL.getAllGuestRequests().AsEnumerable();
+ return myDAL.getAllGuestRequests().Where(predicate);
+ }
+
+ ///
+ /// Return Husting uinits By any requirment
+ ///
+ public IEnumerable HustingUnitsBy(Func predicate = null)
+ {
+ return myDAL.ReturnHostingUnitList(predicate);
+ }
+
+
+ ///
+ /// Creates Offers by area and available dates
+ ///
+ public void CreateOffer(GuestRequest req)
+ {
+ List hostingUnits = UintsAvailable(req.EntryDate, NumOfDays(req.EntryDate, req.EntryDate));
+ foreach (var item in hostingUnits)
+ {
+ Offer y = new Offer();
+
+ foreach (var guest in GuestRequestBy((x => x.Area == item.Area)))
+ {
+ y.GuestKey = guest.GuestRequestKey;
+ y.UnitKey = item.HostingUnitKey;
+ }
+
+ if (y != null)
+ Offer.ListOfOffers.Add(y);
+ }
+
+ }
+
+ ///
+ /// Return all Orders that created X dayes before
+ ///
+ public List OrdersUntilDate(int days)
+ {
+ return myDAL.ReturenAllOrders(x => NumOfDays(x.CreateDate) == days).ToList(); ;
+ }
+
+ #region ///// Helpers /////
+
+ ///
+ /// Find Guset Request by ID
+ ///
+ ///
+ ///
+ GuestRequest GetGusetRequest(int key)
+ {
+ return (myDAL.ReturnGuestRequestList(x => x.GuestRequestKey == key)).First();
+ }
+
+ ///
+ /// Find Hosting Unit by key
+ ///
+ ///
+ ///
+ public HostingUnit GetHostingUnit(int key)
+ {
+ return (myDAL.ReturnHostingUnitList(x => x.HostingUnitKey == key)).First();
+ }
+
+ #endregion
+
+ #region ///// NOT IMPLAMENTED /////
+
+ public bool IsAccountCharged(Host host)
+ {
+ //HOW TO CHECK IF ACCOUNT CHARGED??
+ throw new NotImplementedException();
+ }
+
+ #endregion
+
+ #region ///// Gruping /////
+
+ ///
+ /// Order Guest Request By Location
+ ///
+ ///
+ public IEnumerable> GuestRequestOrderBy_Location()
+ {
+ IEnumerable> result =
+ from gr in myDAL.ReturnGuestRequestList()
+ group gr by gr.Area;
+ return result;
+ }
+
+ ///
+ /// Order Guest Request By Number Of Vacationers
+ ///
+ ///
+ public IEnumerable> GuestRequest_OrderBy_NumberOfVacationers()
+ {
+ IEnumerable> result =
+ from gr in myDAL.ReturnGuestRequestList()
+ group gr by (gr.Adults + gr.Children);
+ return result;
+ }
+
+ ///
+ /// Order Hosts By Number Of Hosting Unit
+ ///
+ ///
+ //public IEnumerable> Hosts_OrderBy_NumberOfHostingUnit()
+ //{
+ // IEnumerable> result =
+ // from hosts in myDAL.returnHostList()
+ // group hosts by NumOfHostingUnitsInHost(hosts);
+ // return result;
+ //}
+
+ ///
+ /// Order Hosting Unit By Location
+ ///
+ ///
+ public IEnumerable> HostingUnit_OrderBy_Location()
+ {
+ IEnumerable> result =
+ from hu in myDAL.ReturnHostingUnitList()
+ group hu by hu.Area;
+ return result;
+ }
+
+ ///
+ /// Return the number Of Hosting Units In Host
+ ///
+ ///
+ ///
+ public int NumOfHostingUnitsInHost(Host host)
+ {
+ int sum = 0;
+ foreach (var hu in myDAL.ReturnHostingUnitList())
+ {
+ if (hu.Owner.HostKey == host.HostKey)
+ sum++;
+ }
+ return sum;
+ }
+
+ #endregion
+
+
+ public Dictionary GuestRequestPerArea()
+ {
+ return new Dictionary
+ {
+ { Area.Center , GuestRequestBy().Count(p => p.Area == Area.Center) },
+ { Area.Jerusalem , GuestRequestBy().Count(p => p.Area == Area.Jerusalem) },
+ { Area.North , GuestRequestBy().Count(p => p.Area == Area.North) } ,
+ { Area.South , GuestRequestBy().Count(p => p.Area == Area.South) }
+ };
+ }
+ public Dictionary GuestRequestPerRquirement(Requirements requirements)
+ {
+ return new Dictionary
+ {
+ { "Pool" , GuestRequestBy().Count(p => p.Pool == requirements) },
+ { "Jacuzzi" , GuestRequestBy().Count(p => p.Jacuzzi == requirements) },
+ { "Garden" , GuestRequestBy().Count(p => p.Garden == requirements) },
+ { "ChildrensAttractions" , GuestRequestBy().Count(p => p.ChildrensAttractions == requirements) },
+ { "SpredBads" , GuestRequestBy().Count(p => p.SpredBads == requirements) },
+ { "AirCondsner" , GuestRequestBy().Count(p => p.AirCondsner == requirements) },
+ { "frisider" , GuestRequestBy().Count(p => p.frisider == requirements) },
+ { "SingogNaerBy" , GuestRequestBy().Count(p => p.SingogNaerBy == requirements) },
+ { "NaerPublicTrensportion" , GuestRequestBy().Count(p => p.NaerPublicTrensportion==requirements) }
+ };
+ }
+
+
+ ///
+ /// Get Orders by predicate
+ ///
+ ///
+ ///
+ public IEnumerable GetOrders(Func predicate = null)
+ {
+ if (predicate == null)
+ return myDAL.ReturenAllOrders().AsEnumerable();
+ return myDAL.ReturenAllOrders().Where(predicate);
+ }
+
+ ///
+ /// return list of all the husting uint key for spasific host
+ ///
+ ///
+ ///
+ public IEnumerable GetHostingUnitsKeysList(int hostKey)
+ {
+ List result = new List();
+
+ foreach (var hostingUnit in myDAL.ReturnHostingUnitList(x => x.Owner.HostKey == hostKey))
+ { result.Add(hostingUnit.HostingUnitKey); }
+ return result;
+ }
+
+ ///
+ /// Return host list
+ ///
+ ///
+ public IEnumerable GetHosts()
+ {
+ //return myDAL.returnHostList();
+ return myDAL.getAllHosts();
+ }
+
+ //need to replace the one in idal with this
+ public void UpdateOrder(Order order)
+ {
+ try
+ {
+ myDAL.updateOrder(order);
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Can't update order" + ex);
+ }
+ }
+
+
+ /*
+ public IEnumerable GetGuestRequestKeysList(IEnumerable list,PropertyInfo propertyInfo)
+ {
+ List result = new List();
+
+ foreach (var i in list)
+ { result.Add(i.GuestRequestKey); }
+ { result.Add(i.g; }
+ return result;
+ }
+ */
+
+
+
+ ///
+ /// Gruping Order Hosts By Number Of Hosting Unit
+ ///
+ ///
+ public IEnumerable> Hosts_OrderBy_NumberOfHostingUnit()
+ {
+ IEnumerable> result =
+ from hosts in myDAL.returnHostList()
+ group hosts by NumOfHostingUnitsInHost(hosts);
+ return result;
+ }
+
+
+
+ ///
+ /// Number of Hosting Unit per area
+ ///
+ /// Dictionary
+ public Dictionary HostingUnitPerArea()
+ {
+ return new Dictionary
+ {
+ { Area.Center , HustingUnitsBy().Count(p => p.Area == Area.Center) },
+ { Area.Jerusalem , HustingUnitsBy().Count(p => p.Area == Area.Jerusalem) },
+ { Area.North , HustingUnitsBy().Count(p => p.Area == Area.North) } ,
+ { Area.South , HustingUnitsBy().Count(p => p.Area == Area.South) }
+ };
+ }
+
+
+
+
+
+
+
+
+ ///
+ /// Average Orders per hosting unit
+ ///
+ ///
+ public double averageOrdersPerHostingUnit()
+ {
+ double sum = 0;
+ foreach (var hostingUnit in HustingUnitsBy())
+ {
+ sum += OrdersPerUnit(hostingUnit);
+ }
+ return sum;
+ }
+
+
+ ///
+ /// BootingUp the progrem.
+ /// 1) Receive bank data from the web
+ /// 2)
+ ///
+ public void bootingUp()
+ {
+ try
+ {
+ Thread thread = new Thread(GetBankInfoFromTheWeb);
+ thread.Start();
+ }
+ catch (Exception ex)
+ {
+ // throw new Exception("Can't get bank info from the web " + ex);
+ MessageBox.Show("Can't get bank info from the web\n " + ex);
+ }
+
+ if(NewDay())
+ {
+ try
+ {
+ Thread thread = new Thread(RefreshDatabase);
+ thread.Start();
+ }
+ catch (Exception ex)
+ {
+ // throw new Exception("Can't get bank info from the web " + ex);
+ MessageBox.Show("Fail to refresh the database! \n " + ex);
+ }
+ }
+
+ }
+
+ private void RefreshDatabase() { }
+ private bool NewDay() { return true; }
+
+ ///
+ /// Sending Email to client
+ ///
+ public void SendMail(Order order)
+ {
+ MailMessage mail = new MailMessage();
+ mail.To.Add(GuestRequestBy(x => x.GuestRequestKey == order.GuestRequestKey).First().MailAddress);
+ mail.From = new MailAddress(GetHostingUnit(order.HostingUnitKey).Owner.MailAddress);
+ mail.Subject = "Resort offeras as you request";
+ mail.Body = "You'r request:
" +
+ GuestRequestBy(x => x.GuestRequestKey == order.GuestRequestKey).First().ToString() +
+ "------------------
" +
+ "Our offer is:
" +
+ GetHostingUnit(order.HostingUnitKey).ToString() +
+ "Please notify us with return mail to this address:
" +
+ GetHostingUnit(order.HostingUnitKey).Owner.MailAddress;
+ mail.IsBodyHtml = true;
+
+ SmtpClient smtp = new SmtpClient();
+ smtp.Host = "smtp.gmail.com";
+ smtp.Credentials = new System.Net.NetworkCredential("ipewzner@g.jct.ac.il", "Reptor17");
+ // smtp.Credentials = from;
+ smtp.EnableSsl = true;
+
+ try
+ {
+ smtp.Send(mail);
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Email error " + ex);
+ }
+
+
+ }
+
+ ///
+ /// Send email with new password
+ ///
+ ///
+ public void SendMailWithNewPassword(Host host)
+ {
+ // Manager manager = new Manager();
+ // manager.MailAddress = "dotnetproject2020@gmail.com";
+ var rand = new Random();
+ int password = rand.Next(10000000, 99999999);
+ host.PasswordKey = KeyForPassword(password);
+
+ MailMessage mail = new MailMessage();
+ mail.To.Add(host.MailAddress);
+ // mail.From = new MailAddress("ipewzner@g.jct.ac.il");
+ mail.From = new MailAddress(" dotnetproject2020 @gmail.com");
+
+ mail.Subject = "New password - do not replay!";
+ mail.Body = "You'r new password is: " + password +
+ "Please change your password after the next login
" +
+ "You can change your password in the Host updata section
";
+ mail.IsBodyHtml = true;
+
+ SmtpClient smtp = new SmtpClient();
+ smtp.Host = "smtp.gmail.com";
+ smtp.Credentials = new System.Net.NetworkCredential("dotnetproject2020@gmail.com", "kuku4ever");
+ smtp.EnableSsl = true;
+
+ try
+ {
+ smtp.Send(mail);
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Email error " + ex);
+ }
+
+ }
+
+ ///
+ /// Checke if password is curect
+ ///
+ ///
+ ///
+ ///
+ public bool CheckePassword(double key, int password)
+ {
+ // return Math.Sin(password) * Math.Sqrt(password) == key;
+ return true;
+ }
+
+ ///
+ /// Make key for password
+ ///
+ ///
+ ///
+ public double KeyForPassword(int password)
+ {
+ return Math.Sin(password) * Math.Sqrt(password);
+ }
+
+
+
+ ///
+ /// GetBankInfoFromTheWeb
+ ///
+ public void GetBankInfoFromTheWeb()
+ {
+ //C:\Users\ipewz\Documents\GitHub\Mini_project_Windows_system
+ //const string xmlLocalPath = @"atm.xml";
+ const string xmlLocalPath = @"ATM.xml";
+ WebClient wc = new WebClient();
+ try
+ {
+ string xmlServerPath =
+ @"http://www.boi.org.il/he/BankingSupervision/BanksAndBranchLocations/Lists/BoiBankBranchesDocs/atm.xml";
+ wc.DownloadFile(xmlServerPath, xmlLocalPath);
+ }
+ catch (Exception)
+ {
+ string xmlServerPath = @"http://www.jct.ac.il/~coshri/atm.xml";
+ wc.DownloadFile(xmlServerPath, xmlLocalPath);
+ }
+ finally
+ {
+ wc.Dispose();
+ }
+
+ }
+
+ public double averageOrdersPerClient()
+ {
+ double sum = 0;
+ foreach (var guestRequest in GuestRequestBy())
+ {
+ sum += OrdersPerClient(guestRequest);
+ }
+ return sum;
+ }
+
+ }
}
\ No newline at end of file
diff --git a/DAL/BE_Extensions.cs b/DAL/BE_Extensions.cs
index cf8c594..28b804e 100644
--- a/DAL/BE_Extensions.cs
+++ b/DAL/BE_Extensions.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -6,23 +6,160 @@
using BE;
using System.Xml.Linq;
using System.Reflection;
+using System.Xml.Serialization;
+using System.IO;
namespace DAL
{
public static class BE_Extensions
{
-
+
+ #region Clones
+ ///
+ /// Clone
+ ///
+ ///
+ ///
+ public static Order Clone(this Order order)
+ {
+ return new Order
+ {
+ OrderKey = order.OrderKey,
+ Status = order.Status,
+ CreateDate = order.CreateDate,
+ GuestRequestKey = order.GuestRequestKey,
+ HostingUnitKey = order.HostingUnitKey,
+ OrderDate = order.OrderDate
+ };
+ }
+ ///
+ /// Clone
+ ///
+ ///
+ ///
+ public static Host Clone(this Host host)
+ {
+ return new Host
+ {
+ HostKey = host.HostKey,
+ PrivateName = host.PrivateName,
+ FamilyName = host.FamilyName ,
+ PhoneNumber = host.PhoneNumber,
+ MailAddress = host.MailAddress,
+ BankAccount = host.BankAccount.Clone(),
+ CollectionClearance = host.CollectionClearance
+ };
+ }
+ ///
+ /// Clone
+ ///
+ ///
+ ///
+ public static BankAccount Clone(this BankAccount bankAccount)
+ {
+ return new BankAccount
+ {
+ BankNumber = bankAccount.BankNumber,
+ BankName = bankAccount.BankName,
+ BranchNumber = bankAccount.BranchNumber,
+ BranchAddress = bankAccount.BranchAddress,
+ BranchCity = bankAccount.BranchCity,
+ BankAccountNumber = bankAccount.BankAccountNumber
+ };
+ }
+
+
+ //To-Do
+ public static HostingUnit Clone(this HostingUnit hostingUnit)
+ {
+ return new HostingUnit
+ {
+ //To-Do
+ };
+ }
+ public static requirement Clone(this requirement requirement)
+ {
+ return new requirement
+ {
+ //To-Do
+ };
+ }
+ public static GuestRequest Clone(this GuestRequest guestRequest)
+ {
+ return new GuestRequest
+ {
+ //To-Do
+ };
+ }
+
+
+
+
+ #endregion Clones
+
+
+
public static XElement ToXML(this Order d)
+
{
return new XElement("Order",
new XElement("OrderKey", d.OrderKey.ToString()),
new XElement("HostingUnitKey", d.HostingUnitKey.ToString()),
new XElement("GuestRequestKey", d.GuestRequestKey.ToString()),
- new XElement("CreateDate", d.CreateDate.ToString()),
- new XElement("OrderDate", d.OrderDate.ToString()),
+ new XElement("CreateDate", d.CreateDate.ToString("o")),
+ new XElement("OrderDate", d.OrderDate.ToString("o")),
new XElement("Status", d.Status.ToString())
);
}
-
+
+ //public static XElement ToXML(this BattlePlayer b)
+ //{
+ // return new XElement("BattlePlayer",
+ // new XElement("Name", b.Name.ToString()),
+ // new XElement("Board",
+ // (from v in b.Board.ToString()
+ // select v).ToArray(),
+ // (from v in b.OpponentBoard.ToString()
+ // select v).ToArray()
+ // )
+ // );
+ //}
+
+ public static void SaveToXML(T source, string path)
+ {
+ FileStream file = new FileStream(path, FileMode.Create);
+ XmlSerializer xmlSerializer = new XmlSerializer(source.GetType());
+ xmlSerializer.Serialize(file, source);
+ file.Close();
+ }
+
+ public static T LoadFromXML(string path)
+ {
+ FileStream file = new FileStream(path, FileMode.Open);
+ XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
+ T result = (T)xmlSerializer.Deserialize(file);
+ file.Close();
+ return result;
+ }
+
+ public static string ToXMLstring(this T toSerialize)
+ {
+ using (StringWriter textWriter = new StringWriter())
+ {
+ XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
+ xmlSerializer.Serialize(textWriter, toSerialize);
+ return textWriter.ToString();
+ }
+ }
+ public static T ToObject(this string toDeserialize)
+ {
+ using (StringReader textReader = new StringReader(toDeserialize))
+ {
+ XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
+ return (T)xmlSerializer.Deserialize(textReader);
+ }
+ }
+
+
}
}
\ No newline at end of file
diff --git a/DAL/DAL.csproj b/DAL/DAL.csproj
index a4a4df1..4fa4a01 100644
--- a/DAL/DAL.csproj
+++ b/DAL/DAL.csproj
@@ -44,6 +44,8 @@
+
+
diff --git a/DAL/DalXML.cs b/DAL/DalXML.cs
new file mode 100644
index 0000000..a343493
--- /dev/null
+++ b/DAL/DalXML.cs
@@ -0,0 +1,402 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+using BE;
+using DataSource;
+
+namespace DAL
+{
+ public class DalXML : IDAL
+ {
+ private static int serialGuestRequest;
+ private static int serialOrder;
+ // private static double commision; //10 shekels -- zol meod public DalXML()
+ // private static string serialHostingUnit;
+
+ public DalXML()
+ {
+ serialOrder = Int32.Parse(DataSource.DataSourceXML.Orders.Element("lastSerial").Value);
+ serialGuestRequest = Int32.Parse(DataSource.DataSourceXML.GuestRequests.Element("lastSerial").Value);
+ // TO DO
+ }
+
+ public bool addGuestRequest(GuestRequest gr)
+ {
+ XElement guestRequestElement = XElement.Parse(gr.ToXMLstring());
+ DataSource.DataSourceXML.GuestRequests.Element("lastSerial").Value = guestRequestElement.Element("GuestRequestKey").Value;
+ DataSource.DataSourceXML.SaveGuestRequests();
+ DataSource.DataSourceXML.GuestRequests.Add(guestRequestElement);
+ DataSource.DataSourceXML.SaveGuestRequests();
+ return true;
+ }
+
+ public bool addHost(Host host)
+ {
+ DataSource.DataSourceXML.Hosts.Add(XElement.Parse(host.ToXMLstring()));
+ DataSource.DataSourceXML.SaveHosts();
+ //DataSource.DataSourceXML.Hosts.Element("lastSerial").Value = host.HostKey.ToXMLstring();
+ DataSource.DataSourceXML.SaveHosts();
+ return true;
+ }
+
+ public bool addHostingUnit(HostingUnit HostingUnit)
+ {
+ DataSource.DataSourceXML.HostingUnits.Add(XElement.Parse(HostingUnit.ToXMLstring()));
+ DataSource.DataSourceXML.SaveHosts();
+ //DataSource.DataSourceXML.HostingUnits.Element("lastSerial").Value = HostingUnit.HostingUnitKey.ToXMLstring();
+ DataSource.DataSourceXML.SaveHostingUnits();
+ return true;
+ }
+
+ public bool addOrder(Order neworder)
+ {
+ // XElement findOrder = (from o in DataSource.DataSourceXML.Orders.Elements("Order")
+ // where Int32.Parse(o.Element("OrderKey").Value) == neworder.OrderKey
+ // select o).FirstOrDefault();
+ //if(findOrder!=null)
+ //{
+ // //throw new Exception("order alraedy exist");
+ // return false;
+ //}
+ serialOrder = Int32.Parse(DataSource.DataSourceXML.Orders.Element("lastSerial").Value);
+ neworder.OrderKey = ++serialOrder;
+ DataSource.DataSourceXML.Orders.Add(neworder.ToXML());
+ DataSource.DataSourceXML.SaveOrders();
+ DataSource.DataSourceXML.Orders.Element("lastSerial").Value = neworder.OrderKey.ToString();
+ DataSource.DataSourceXML.SaveOrders();
+ return true;
+ }
+
+ public List getAllGuestRequests()
+ {
+ return (from o in DataSource.DataSourceXML.GuestRequests.Elements("GuestRequest")
+ select o.ToString().ToObject()).ToList();
+ }
+
+ public List getAllHostingUnits()
+ {
+ return (from o in DataSource.DataSourceXML.HostingUnits.Elements("HostingUnit")
+ select o.ToString().ToObject()).ToList();
+ }
+
+ public List getAllHosts()
+ {
+ return (from o in DataSource.DataSourceXML.Hosts.Elements("Host")
+ select o.ToString().ToObject()).ToList();
+ }
+
+ public List getAllorders()
+ {
+ return (from o in DataSource.DataSourceXML.Orders.Elements("Order")
+ select o.ToString().ToObject()).ToList();
+ }
+
+ public GuestRequest getGuestRequest(int id)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Host getHost(int id)
+ {
+ throw new NotImplementedException();
+ }
+
+ public HostingUnit getHostingUnit(int id)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Order getOrder(int id)
+ {
+ Order result = null;
+ XElement findOrder = (from o in DataSource.DataSourceXML.Orders.Elements("Order")
+ where Int32.Parse(o.Element("OrderKey").Value) == id
+ select o).FirstOrDefault();
+ if (findOrder != null)
+ {
+ result = findOrder.ToString().ToObject();
+ }
+
+ return result;
+
+ }
+
+ public string getserialGuestRequest()
+ {
+ String result = DataSource.DataSourceXML.GuestRequests.Element("lastSerial").Value;
+ return result;
+ }
+
+ public bool updateGuestRequest(GuestRequest guestRequest)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool updateHost(Host host)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool updateOrder(Order updateorder)
+ {
+ XElement findOrder = (from o in DataSource.DataSourceXML.Orders.Elements("Order")
+ where Int32.Parse(o.Element("OrderKey").Value) == updateorder.OrderKey
+ select o).FirstOrDefault();
+
+ if (findOrder == null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public void UpdateOrder(int OrderKey, OrderStatus status)
+ {
+ throw new NotImplementedException();
+ }
+
+
+ #region ///// Order /////
+
+ ///
+ /// Add Order To List
+ ///
+ ///
+ ///
+ public bool AddOrderToList(Order order)
+ {
+ try
+ {
+ DataSourceList.Orders.Add(Cloning.Copy(order));
+ return true;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Fail to add Order to the list " + ex);
+ }
+ }
+
+
+ ///
+ /// Returen Orders from list using predicate for filtering
+ ///
+ ///
+ ///
+ public IEnumerable ReturenAllOrders(Func predicate = null)
+ {
+ try
+ {
+ if (predicate == null)
+ return Cloning.Clone(getAllorders().AsEnumerable());
+ return Cloning.Clone(getAllorders().Where(predicate));
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Fail to retrieve the Orders from the list " + ex);
+ }
+ }
+
+ #endregion
+
+ #region ///// HosingUnit /////
+
+ ///
+ /// Add Hosting Unit To List
+ ///
+ ///
+ ///
+ public bool AddHostingUnitToList(HostingUnit hostingUnit)
+ {
+ try
+ {
+ foreach (var currentHostingUnit in DataSourceList.HostingUnits)
+ {
+ if (currentHostingUnit.Equals(hostingUnit)) return false;
+ }
+ DataSourceList.HostingUnits.Add(Cloning.Copy(hostingUnit));
+ return true;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Fail to add the Hosting-Unit to the list " + ex);
+ }
+ }
+
+ ///
+ /// Delete Hosting Unit from list
+ ///
+ ///
+ ///
+ public bool DeleteHostingUnit(HostingUnit hu)
+ {
+ try
+ {
+ return DataSourceList.HostingUnits.Remove(hu);
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Fail to delete the Hosting-Unit " + ex);
+ }
+ }
+
+ ///
+ /// Update Hosting Unit
+ ///
+ ///
+ ///
+ public bool UpdateHostingUnit(HostingUnit hostingUnit)
+ {
+ //Remove old
+ try
+ {
+ try
+ {
+ DataSourceList.HostingUnits.Remove(DataSourceList.HostingUnits.Find(x => x.HostingUnitKey == hostingUnit.HostingUnitKey));
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("can't remove the old Hosting-Unit " + ex);
+ }
+
+ //insert new
+ try
+ {
+ DataSourceList.HostingUnits.Add(Cloning.Copy(hostingUnit));
+ return true;
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("can't add the new Hosting-Unit " + ex);
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Fail to update Hosting-Unit becuse it " + ex);
+ }
+ }
+
+ ///
+ /// Returen Hosting Unit from list using predicate for filtering
+ ///
+ ///
+ ///
+ public IEnumerable ReturnHostingUnitList(Func predicate = null)
+ {
+ try
+ {
+ if (predicate == null)
+ return Cloning.Clone(getAllHostingUnits().AsEnumerable());
+ return Cloning.Clone(getAllHostingUnits().Where(predicate));
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Fail to retrieve the Hosting-Units from the list " + ex);
+ }
+ }
+
+ #endregion
+
+ #region ///// Host /////
+
+ ///
+ /// Add Host To List
+ ///
+ ///
+ public void AddHostToList(Host host)
+ {
+ try
+ {
+ DataSourceList.Hosts.Add(Cloning.Copy(host));
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Fail to add the Host to the list " + ex);
+ }
+ }
+
+ ///
+ /// Returen Hosts from list using predicate for filtering
+ ///
+ ///
+ ///
+ public IEnumerable returnHostList(Func predicate = null)
+ {
+ try
+ {
+ if (predicate == null)
+ return Cloning.Clone(getAllHosts().AsEnumerable());
+ return Cloning.Clone(getAllHosts().Where(predicate));
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Fail to retrieve the Hosts from the list " + ex);
+ }
+ }
+ #endregion Host
+
+ #region ///// GuestRequest /////
+
+ ///
+ /// Returen Guest Request from list using predicate for filtering
+ ///
+ ///
+ ///
+ public IEnumerable ReturnGuestRequestList(Func predicate = null)
+ {
+ try
+ {
+ if (predicate == null)
+ return Cloning.Clone(getAllGuestRequests().AsEnumerable());
+ return Cloning.Clone(getAllGuestRequests().Where(predicate));
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Fail to retrieve the Guest-Request from the list " + ex);
+ }
+ }
+
+ ///
+ ///Add Guest Request To List
+ ///
+ ///
+ public void AddGuestRequestToList(GuestRequest gr)
+ {
+ try
+ {
+ DataSourceList.GuestRequests.Add(Cloning.Copy(gr));
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Fail to add the Guest Request to the list " + ex);
+ }
+ }
+ #endregion GuestRequest
+
+ #region ///// Bank /////
+
+ ///
+ /// Return All Locel Bank
+ ///
+ ///
+ public IEnumerable ReturnAllLocelBank()
+ {
+ try
+ {
+ return new List { "poelim", "marcntil", "laomi", "disceunt", "pagi" };
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Fail to return the Locel-Bank list " + ex);
+ }
+ }
+
+ #endregion
+
+
+
+ }
+}
diff --git a/DAL/Dal_XML_imp.cs b/DAL/Dal_XML_imp.cs
new file mode 100644
index 0000000..c49cd9c
--- /dev/null
+++ b/DAL/Dal_XML_imp.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DAL
+{
+ class Dal_XML_imp
+ {
+
+ }
+}
diff --git a/DAL/FactorySingletonDal.cs b/DAL/FactorySingletonDal.cs
index 29afb9c..8fd010d 100644
--- a/DAL/FactorySingletonDal.cs
+++ b/DAL/FactorySingletonDal.cs
@@ -1,4 +1,5 @@
-using System;
+using DataSource;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,17 +9,21 @@ namespace DAL
{
public static class FactorySingletonDal
{
+
private static IDAL instance = null;
static FactorySingletonDal() { }
public static IDAL Instance
{
+
get
{
+
if (instance == null)
{
- instance = new DALImp();
+ instance = new DalXML();
+
}
return instance;
}
diff --git a/DataSource/DataSource.csproj b/DataSource/DataSource.csproj
index 49a65d0..240910b 100644
--- a/DataSource/DataSource.csproj
+++ b/DataSource/DataSource.csproj
@@ -42,6 +42,7 @@
+
@@ -50,5 +51,12 @@
BE
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DataSource/DataSourceList.cs b/DataSource/DataSourceList.cs
index 9841104..364e620 100644
--- a/DataSource/DataSourceList.cs
+++ b/DataSource/DataSourceList.cs
@@ -4,14 +4,39 @@
using System.Text;
using System.Threading.Tasks;
using BE;
+using System.Xml.Serialization;
+using System.IO;
namespace DataSource
{
- public static class DataSourceList
+ static public class DataSourceList
{
+
+ //static void con()
+ //{
+ // Stream stream = File.OpenRead(Environment.CurrentDirectory + "\\hosts.xml");
+ // XmlSerializer xmlser = new XmlSerializer(typeof(List));
+ // var x = xmlser.Deserialize(stream);
+ // Console.WriteLine(x);
+
+ //}
+
+ //static void des()
+ //{
+ // Stream stream = File.OpenWrite(Environment.CurrentDirectory + "\\hosts.xml");
+ // XmlSerializer xmlser = new XmlSerializer(typeof(List));
+ // xmlser.Serialize(stream, Hosts);
+ // stream.Close();
+ //}
+
+
+
public static List Hosts = new List();
+
public static List HostingUnits = new List();
+
public static List Orders = new List();
+
public static List GuestRequests = new List();
}
}
diff --git a/DataSource/DataSourceXML.cs b/DataSource/DataSourceXML.cs
new file mode 100644
index 0000000..5c88075
--- /dev/null
+++ b/DataSource/DataSourceXML.cs
@@ -0,0 +1,149 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+using System.Xml.Serialization;
+
+namespace DataSource
+{
+ public static class DataSourceXML
+ {
+ //private static string currentDirectory = Directory.GetCurrentDirectory();
+ private static string solutionDirectory = Directory.GetParent(Directory.GetParent(Directory.GetParent(Directory.GetCurrentDirectory()).FullName).FullName).FullName;
+
+ private static string filePath = System.IO.Path.Combine(solutionDirectory, "DataSource", "DataXML");
+
+
+ private static XElement orderRoot = null;
+ private static XElement guestRequestRoot = null;
+ private static XElement hostRoot = null;
+ private static XElement hostingUnitRoot = null;
+
+
+ private static string orderPath = Path.Combine(filePath, "OrderXml.xml");
+ private static string guestRequestPath = Path.Combine(filePath, "GuestRequestXml.xml");
+ private static string hostPath = Path.Combine(filePath, "HostXml.xml");
+ private static string hostingUnitPath = Path.Combine(filePath, "HostingUnitXml.xml");
+
+
+
+ static DataSourceXML()
+ {
+ bool exists = Directory.Exists(filePath);
+ if (!exists)
+ {
+ Directory.CreateDirectory(filePath);
+ }
+
+ if (!File.Exists(orderPath))
+ {
+ CreateFile("Orders", orderPath);
+
+ }
+ orderRoot = LoadData(orderPath);
+
+ if (!File.Exists(hostPath))
+ {
+ CreateFile("Hosts", hostPath);
+
+ }
+ hostRoot = LoadData(hostPath);
+
+ if (!File.Exists(hostingUnitPath))
+ {
+ CreateFile("HostingUnits", hostingUnitPath);
+
+ }
+ hostingUnitRoot = LoadData(hostingUnitPath);
+
+
+ if (!File.Exists(guestRequestPath))
+ {
+ CreateFile("GuestRequests", guestRequestPath);
+
+ }
+ guestRequestRoot = LoadData(guestRequestPath);
+
+ }
+ private static void CreateFile(string typename, string path)
+ {
+ XElement root = new XElement(typename);
+ root.Save(path);
+ }
+
+ public static void SaveOrders()
+ {
+ orderRoot.Save(orderPath);
+ }
+
+ public static void SaveHostingUnits()
+ {
+ hostingUnitRoot.Save(hostingUnitPath);
+ }
+
+ public static void SaveHosts()
+ {
+ hostRoot.Save(hostPath);
+ }
+
+ public static void SaveGuestRequests()
+ {
+ guestRequestRoot.Save(guestRequestPath);
+ }
+
+ public static XElement Orders
+ {
+ get
+ {
+ orderRoot = LoadData(orderPath);
+ return orderRoot;
+ }
+ }
+
+ public static XElement Hosts
+ {
+ get
+ {
+ hostRoot = LoadData(hostPath);
+ return hostRoot;
+ }
+ }
+
+ public static XElement HostingUnits
+ {
+ get
+ {
+ hostingUnitRoot = LoadData(hostingUnitPath);
+ return hostingUnitRoot;
+ }
+ }
+
+ public static XElement GuestRequests
+ {
+ get
+ {
+ guestRequestRoot = LoadData(guestRequestPath);
+ return guestRequestRoot;
+ }
+ }
+
+ private static XElement LoadData(string path)
+ {
+ XElement root;
+ try
+ {
+ root = XElement.Load(path);
+ }
+ catch
+ {
+ throw new Exception("File upload problem");
+ }
+ return root;
+ }
+
+
+ }
+}
diff --git a/DataSource/DataXML/GuestRequestXml.xml b/DataSource/DataXML/GuestRequestXml.xml
new file mode 100644
index 0000000..d0fec14
--- /dev/null
+++ b/DataSource/DataXML/GuestRequestXml.xml
@@ -0,0 +1,100 @@
+
+
+ 10000005
+
+ Jerusalem
+ old city
+ Hotel
+ 2
+ 1
+ Necessary
+ NotNecessary
+ NotNecessary
+ Necessary
+ NotNecessary
+ Necessary
+ Possible
+ Necessary
+ Possible
+ 10000000
+ zareh
+ parz
+ penhes@gmail.com
+ Open
+ 0001-01-01T00:00:00
+ 0001-01-01T00:00:00
+ 0001-01-01T00:00:00
+
+
+ North
+ tabrios
+ Zimmer
+ 4
+ 0
+ Necessary
+ Necessary
+ Necessary
+ NotNecessary
+ Necessary
+ Necessary
+ Necessary
+ Possible
+ Possible
+ 10000001
+ kalmen
+ kalmenovitz
+ kalmenovitz@gmail.com
+ Open
+ 0001-01-01T00:00:00
+ 0001-01-01T00:00:00
+ 0001-01-01T00:00:00
+
+
+ Center
+ tal aviv
+ RentingRoom
+ 2
+ 2
+ NotNecessary
+ NotNecessary
+ NotNecessary
+ Necessary
+ NotNecessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ 10000003
+ afreim
+ cohn
+ cohn@gmail.com
+ Open
+ 0001-01-01T00:00:00
+ 0001-01-01T00:00:00
+ 0001-01-01T00:00:00
+
+
+ Jerusalem
+ old city
+ Hotel
+ 2
+ 5
+ Possible
+ Possible
+ NotNecessary
+ Necessary
+ NotNecessary
+ Necessary
+ Possible
+ Necessary
+ Possible
+ 10000006
+ aser
+ golomb
+ golomb@gmail.com
+ Open
+ 0001-01-01T00:00:00
+ 0001-01-01T00:00:00
+ 0001-01-01T00:00:00
+
+
\ No newline at end of file
diff --git a/DataSource/DataXML/HostXml.xml b/DataSource/DataXML/HostXml.xml
new file mode 100644
index 0000000..e2ce053
--- /dev/null
+++ b/DataSource/DataXML/HostXml.xml
@@ -0,0 +1,67 @@
+
+
+
+ 11111111
+ david
+ cohn
+ 054-5555555
+ sale@gmai.com
+
+ 123
+ poalim
+ 432
+ jefo 121
+ jeruselm
+ 11111111
+
+
+
+
+ 22222222
+ moses
+ levi
+ 054-6666666
+ hotel@gmai.com
+
+ 123
+ poalim
+ 432
+ jefo 121
+ jeruselm
+ 11111112
+
+
+
+
+ 33333333
+ dan
+ danon
+ 054-1010101
+ zimer@gmai.com
+
+ 525
+ laomi
+ 852
+ gargmel 1010
+ heifa
+ 1152582
+
+
+
+
+ 0
+ manster
+ frankinstin
+ 666
+ hall
+ 0
+
+ 852
+
+ 852
+
+
+ 85
+
+
+
\ No newline at end of file
diff --git a/DataSource/DataXML/HostingUnitXml.xml b/DataSource/DataXML/HostingUnitXml.xml
new file mode 100644
index 0000000..0acd880
--- /dev/null
+++ b/DataSource/DataXML/HostingUnitXml.xml
@@ -0,0 +1,367 @@
+
+
+
+ North
+ Zimmer
+ 0
+ 0
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ 10000000
+
+ 11111111
+ david
+ cohn
+ 054-5555555
+ sale@gmai.com
+
+ 123
+ poalim
+ 432
+ jefo 121
+ jeruselm
+ 11111111
+
+
+
+ hotel clifornia
+
+
+ North
+ Zimmer
+ 0
+ 0
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ 10000001
+
+ 11111111
+ david
+ cohn
+ 054-5555555
+ sale@gmai.com
+
+ 123
+ poalim
+ 432
+ jefo 121
+ jeruselm
+ 11111111
+
+
+
+ hotel hong-kong
+
+
+ North
+ Zimmer
+ 0
+ 0
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ 10000003
+
+ 11111111
+ david
+ cohn
+ 054-5555555
+ sale@gmai.com
+
+ 123
+ poalim
+ 432
+ jefo 121
+ jeruselm
+ 11111111
+
+
+
+ hotel paris
+
+
+ Center
+ Zimmer
+ 0
+ 0
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ 10000006
+
+ 22222222
+ moses
+ levi
+ 054-6666666
+ hotel@gmai.com
+
+ 123
+ poalim
+ 432
+ jefo 121
+ jeruselm
+ 11111112
+
+
+
+ hotel tal-aviv
+
+
+ Jerusalem
+ Zimmer
+ 0
+ 0
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ 10000010
+
+ 22222222
+ moses
+ levi
+ 054-6666666
+ hotel@gmai.com
+
+ 123
+ poalim
+ 432
+ jefo 121
+ jeruselm
+ 11111112
+
+
+
+ hotel jeruselm
+
+
+ North
+ Zimmer
+ 0
+ 0
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ 10000015
+
+ 22222222
+ moses
+ levi
+ 054-6666666
+ hotel@gmai.com
+
+ 123
+ poalim
+ 432
+ jefo 121
+ jeruselm
+ 11111112
+
+
+
+ hotel tavriea
+
+
+ North
+ Zimmer
+ 0
+ 0
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ 10000021
+
+ 22222222
+ moses
+ levi
+ 054-6666666
+ hotel@gmai.com
+
+ 123
+ poalim
+ 432
+ jefo 121
+ jeruselm
+ 11111112
+
+
+
+ hotel hifa
+
+
+ North
+ Zimmer
+ 0
+ 0
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ 10000028
+
+ 33333333
+ dan
+ danon
+ 054-1010101
+ zimer@gmai.com
+
+ 525
+ laomi
+ 852
+ gargmel 1010
+ heifa
+ 1152582
+
+
+
+ zimer of the north
+
+
+ Jerusalem
+ Zimmer
+ 0
+ 0
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ 10000036
+
+ 33333333
+ dan
+ danon
+ 054-1010101
+ zimer@gmai.com
+
+ 525
+ laomi
+ 852
+ gargmel 1010
+ heifa
+ 1152582
+
+
+
+ zimer of the Jerusalem
+
+
+ South
+ Zimmer
+ 0
+ 0
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+ 10000045
+
+ 33333333
+ dan
+ danon
+ 054-1010101
+ zimer@gmai.com
+
+ 525
+ laomi
+ 852
+ gargmel 1010
+ heifa
+ 1152582
+
+
+
+ zimer of the South
+
+
+ North
+ vc
+ Zimmer
+ 0
+ 0
+ Necessary
+ Necessary
+ Necessary
+ Possible
+ Possible
+ Possible
+ Necessary
+ Possible
+ Necessary
+ 10000040
+
+ 33333333
+ dan
+ danon
+ 054-1010101
+ zimer@gmai.com
+
+ 525
+ laomi
+ 852
+ gargmel 1010
+ heifa
+ 1152582
+
+
+
+vvvv
+
+
\ No newline at end of file
diff --git a/DataSource/DataXML/OrderXml.xml b/DataSource/DataXML/OrderXml.xml
new file mode 100644
index 0000000..9a6920c
--- /dev/null
+++ b/DataSource/DataXML/OrderXml.xml
@@ -0,0 +1,28 @@
+
+
+ 10000009
+
+ 10000007
+ 10000003
+ 10000001
+ 2020-01-27T20:40:58.9922545+02:00
+ 2020-01-27T20:40:58.9922545+02:00
+ MailSent
+
+
+ 10000008
+ 10000003
+ 10000001
+ 2020-01-27T20:41:17.1073695+02:00
+ 2020-01-27T20:41:17.1073695+02:00
+ MailSent
+
+
+ 10000009
+ 10000021
+ 10000003
+ 2020-01-27T21:34:06.2123047+02:00
+ 2020-01-27T21:34:06.2123047+02:00
+ MailSent
+
+
\ No newline at end of file
diff --git a/DataSource/DataXML1/GuestRequestXml.xml b/DataSource/DataXML1/GuestRequestXml.xml
new file mode 100644
index 0000000..7b866a5
--- /dev/null
+++ b/DataSource/DataXML1/GuestRequestXml.xml
@@ -0,0 +1,42 @@
+
+
+ 1000001
+
+ 1000000
+ ASDA
+ ASDAS
+ AS@HH.KK
+ NotYetApproved
+ 0001-01-01T00:00:00
+ 2020-01-19T11:52:17.9355397+02:00
+ 2020-01-21T11:52:17.9355397+02:00
+ Jerusalem
+ ASD
+ Zimmer
+ 2
+ 3
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+
+
+ 1000001
+ dxs
+ EFG
+ GR@GG.GG
+ NotYetApproved
+ 0001-01-01T00:00:00
+ 2020-01-19T11:53:23.7121693+02:00
+ 2020-01-21T11:53:23.7121693+02:00
+ Jerusalem
+ asd
+ Zimmer
+ 55
+ 54
+ Necessary
+ Necessary
+ Necessary
+ Necessary
+
+
\ No newline at end of file
diff --git a/DataSource/DataXML1/HostXml.xml b/DataSource/DataXML1/HostXml.xml
new file mode 100644
index 0000000..9dfb370
--- /dev/null
+++ b/DataSource/DataXML1/HostXml.xml
@@ -0,0 +1,30 @@
+
+
+
+ 123
+ d ca suffit
+ qwere
+ 3324
+ daas@hhh.jjj
+ 3123
+ Yes
+
+
+ 5555
+ qwre
+ adsa
+ 232
+ fdsf
+ 12321
+ Yes
+
+
+ 1424
+ buffalo
+ Falery Chisqkar Destin
+ 052
+ aaaa@gmail.com
+ 15141
+ Maybe
+
+
\ No newline at end of file
diff --git a/DataSource/DataXML1/HostingUnitXml.xml b/DataSource/DataXML1/HostingUnitXml.xml
new file mode 100644
index 0000000..d28178a
--- /dev/null
+++ b/DataSource/DataXML1/HostingUnitXml.xml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/DataSource/DataXML1/OrderXml.xml b/DataSource/DataXML1/OrderXml.xml
new file mode 100644
index 0000000..00457dc
--- /dev/null
+++ b/DataSource/DataXML1/OrderXml.xml
@@ -0,0 +1,28 @@
+
+
+ 25
+
+ 23
+ 10000010
+ 10000025
+ 30/12/2019 16:52:25
+ 02/01/2020 16:52:25
+ NotYetApproved
+
+
+ 24
+ 12123
+ 10000005
+ 30/12/2019 16:52:25
+ 02/01/2020 16:52:25
+ NotYetApproved
+
+
+ 25
+ 12123
+ 10000005
+ 30/12/2019 16:52:25
+ 02/01/2020 16:52:25
+ NotYetApproved
+
+
\ No newline at end of file
diff --git a/PL/Program.cs b/PL/Program.cs
index 0d6a3c6..6892b34 100644
--- a/PL/Program.cs
+++ b/PL/Program.cs
@@ -208,10 +208,10 @@ void siteMangerScreen()
}
- bool deleteHustingUnit()
+ void deleteHustingUnit()
{
Console.WriteLine("Enter hosting unit key");
- return newBL.UnitRemove(inputSarielNumber(10000000));
+ newBL.UnitRemove(inputSarielNumber(10000000));
}
void updateHustingUnit()
diff --git a/PL/preCode.cs b/PL/preCode.cs
index b0a33da..a9975e4 100644
--- a/PL/preCode.cs
+++ b/PL/preCode.cs
@@ -5,7 +5,7 @@
namespace PL
{
-
+
public class preCode
{
BL.MyBl mybl = new MyBl();
@@ -209,8 +209,6 @@ public void initialize()
mybl.AddGuestRequest(gr);
#endregion kalmen_request
-
-
#region afreim_request
gr = new GuestRequest();
diff --git a/PLWPF/HostUpdateWindow.xaml b/PLWPF/HostUpdateWindow.xaml
new file mode 100644
index 0000000..d9aef88
--- /dev/null
+++ b/PLWPF/HostUpdateWindow.xaml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PLWPF/HostUpdateWindow.xaml.cs b/PLWPF/HostUpdateWindow.xaml.cs
new file mode 100644
index 0000000..557046d
--- /dev/null
+++ b/PLWPF/HostUpdateWindow.xaml.cs
@@ -0,0 +1,30 @@
+using BE;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace PLWPF
+{
+ ///
+ /// Interaction logic for HostUpdateWindow.xaml
+ ///
+ public partial class HostUpdateWindow : Window
+ {
+ public HostUpdateWindow(Host host)
+ {
+ InitializeComponent();
+ UpdateHostFrame.Content = new HostUserControl(host,false);
+ DeleteHostFrame.Content = new HostUserControl(host,true);
+ }
+ }
+}
diff --git a/PLWPF/HostUserControl.xaml b/PLWPF/HostUserControl.xaml
new file mode 100644
index 0000000..de55241
--- /dev/null
+++ b/PLWPF/HostUserControl.xaml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PLWPF/HostUserControl.xaml.cs b/PLWPF/HostUserControl.xaml.cs
new file mode 100644
index 0000000..0bb3693
--- /dev/null
+++ b/PLWPF/HostUserControl.xaml.cs
@@ -0,0 +1,157 @@
+using BE;
+using BL;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PLWPF
+{
+ ///
+ /// Interaction logic for HostUserControl.xaml
+ ///
+ public partial class HostUserControl : UserControl
+ {
+ MyBl myBL = new MyBl();
+ bool newHost, deleteHost;
+ Host host;
+ BankAccount bankAccount;
+
+ public HostUserControl(Host hosts, bool deleteHost)
+ {
+ InitializeComponent();
+
+ if (hosts != null)
+ {
+ host = hosts;
+ bankAccount = host.BankAccount;
+ FillTheFeilds();
+ }
+ else { newHost = true; }
+
+ this.deleteHost = deleteHost;
+
+
+ ContinueButton.Content = (deleteHost==true)?"Delete":"Save";
+
+
+ }
+
+ private void FillTheFeilds()
+ {
+ FamilyNameTextBox.Text= host.FamilyName;
+ PrivateName.Text= host.PrivateName;
+ PhoneNumber.Text= host.PhoneNumber ;
+ MailAddress.Text= host.MailAddress ;
+
+ Bank_ComboBox.Text=bankAccount.BankName;
+ BranchCity_ComboBox.Text= bankAccount.BranchCity;
+ BranchAddress_ComboBox.Text= bankAccount.BranchAddress;
+ BankNumber.Text= bankAccount.BankNumber .ToString() ;
+ BranchNumber.Text= bankAccount.BranchNumber .ToString() ;
+ BankAccountNumber.Text=bankAccount.BankAccountNumber.ToString() ;
+ }
+
+///
+/// check password Match
+///
+///
+///
+private void PasswordChanged(object sender, RoutedEventArgs e)
+ {
+ if ((FirstPassword.PasswordHidden.Password) != (SecundPassword.PasswordHidden.Password))
+ {
+ passwordMatchError.Visibility = Visibility.Visible;
+ }
+ else
+ {
+ passwordMatchError.Visibility = Visibility.Hidden;
+ }
+ }
+
+
+ private void CancelChanges_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ if (!newHost) FillTheFeilds();
+ else {
+ FamilyNameTextBox.Text =null;
+ PrivateName.Text = null;
+ PhoneNumber.Text = null;
+ MailAddress.Text = null;
+
+ Bank_ComboBox.Text = null;
+ BranchCity_ComboBox.Text = null;
+ BranchAddress_ComboBox.Text =null;
+ BankNumber.Text = null;
+ BranchNumber.Text = null;
+ BankAccountNumber.Text = null;
+ }
+ }
+
+ private void Continue_Click(object sender, RoutedEventArgs e)
+ {
+ if (deleteHost)
+ {
+ try { myBL.RemoveHost(host); }
+ catch (Exception ex) { throw new Exception(""+ex); }
+ MessageBox.Show("Host remove seccessfully");
+ }
+ else
+ {
+ try
+ {
+ if (newHost)
+ {
+ host = new Host();
+ bankAccount = new BankAccount();
+ host.FamilyName = FamilyNameTextBox.Text;
+
+ }
+
+ host.PrivateName = PrivateName.Text;
+ host.PhoneNumber = PhoneNumber.Text;
+ host.MailAddress = MailAddress.Text;
+ if (FirstPassword.PasswordHidden.Password != null)
+ {
+ host.PasswordKey = myBL.KeyForPassword(Int32.Parse(FirstPassword.PasswordHidden.Password));
+ }
+
+ bankAccount.BankName = Bank_ComboBox.Text;
+ bankAccount.BranchCity = BranchCity_ComboBox.Text;
+ bankAccount.BranchAddress = BranchAddress_ComboBox.Text;
+ bankAccount.BankNumber = Convert.ToInt32(BankNumber.Text);
+ bankAccount.BranchNumber = Convert.ToInt32(BranchNumber.Text);
+ bankAccount.BankAccountNumber = Convert.ToInt32(BankAccountNumber.Text);
+
+ host.BankAccount = bankAccount;
+
+ if (newHost)
+ {
+ if (myBL.AddHost(host))
+ MessageBox.Show("Recived Seccessfully");
+ else MessageBox.Show("Error! Make sure you dont miss any field!");
+ }
+ else
+ {
+ try { myBL.UpdateHost(host); }
+ catch (Exception ex) { throw new Exception("" + ex); }
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Fail! "+ex);
+ }
+ }
+ }
+ }
+}
diff --git a/PLWPF/MainWindow.xaml.cs b/PLWPF/MainWindow.xaml.cs
index 8a72c84..9f79caf 100644
--- a/PLWPF/MainWindow.xaml.cs
+++ b/PLWPF/MainWindow.xaml.cs
@@ -19,8 +19,8 @@ public MainWindow()
myBL.bootingUp();
InitializeComponent();
- preCode preCode = new preCode();
- preCode.initialize();
+ //preCode preCode = new preCode();
+ //preCode.initialize();
}
private void AddRequest_Click(object sender, RoutedEventArgs e)
@@ -37,6 +37,8 @@ private void HostingUnit_Click(object sender, RoutedEventArgs e)
{
Window win = new HostingUnitWindow(host);
win.Show();
+ Window win2 = new HostUpdateWindow(host);
+ win2.Show();
}
else MessageBox.Show("Select User Or Sign Up");
}
diff --git a/PLWPF/PLWPF.csproj b/PLWPF/PLWPF.csproj
index 9eb040a..1849ebb 100644
--- a/PLWPF/PLWPF.csproj
+++ b/PLWPF/PLWPF.csproj
@@ -59,7 +59,19 @@
MSBuild:Compile
Designer
+
+ HostUpdateWindow.xaml
+
+
+ HostUserControl.xaml
+
+
+ Password.xaml
+
+
+ HostingUnitUserControl.xaml
+
GuestRequestQueryPage.xaml
@@ -93,6 +105,22 @@
UpdateOrderWindow.xaml
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -109,7 +137,7 @@
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
@@ -124,7 +152,7 @@
App.xaml
Code
-
+
HostingUnitWindow.xaml
diff --git a/PLWPF/Password.xaml b/PLWPF/Password.xaml
new file mode 100644
index 0000000..6304cfa
--- /dev/null
+++ b/PLWPF/Password.xaml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/PLWPF/Password.xaml.cs b/PLWPF/Password.xaml.cs
new file mode 100644
index 0000000..619a25a
--- /dev/null
+++ b/PLWPF/Password.xaml.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PLWPF
+{
+ ///
+ /// Interaction logic for Password.xaml
+ ///
+ public partial class Password : UserControl
+ {
+
+ ///
+ /// c-tor
+ ///
+ public Password()
+ {
+ InitializeComponent();
+ }
+
+ #region ShowPassword
+
+ ///
+ /// The event call to ShowPasswordFunction
+ ///
+ ///
+ ///
+ private void ShowPassword_PreviewMouseDown(object sender, MouseButtonEventArgs e) => ShowPasswordFunction();
+
+ ///
+ /// The event call to HidePasswordFunction
+ ///
+ ///
+ ///
+ private void ShowPassword_PreviewMouseUp(object sender, MouseButtonEventArgs e) => HidePasswordFunction();
+
+ ///
+ /// The event call to HidePasswordFunction
+ ///
+ ///
+ ///
+ private void ShowPassword_MouseLeave(object sender, MouseEventArgs e) => HidePasswordFunction();
+
+ ///
+ /// make the password visible
+ ///
+ private void ShowPasswordFunction()
+ {
+ ShowPassword.Content = "Hide";
+ PasswordUnmask.Visibility = Visibility.Visible;
+ PasswordHidden.Visibility = Visibility.Hidden;
+ PasswordUnmask.Text = PasswordHidden.Password;
+ }
+
+ ///
+ /// make the password unvisible
+ ///
+ private void HidePasswordFunction()
+ {
+ ShowPassword.Content = "Show";
+ PasswordUnmask.Visibility = Visibility.Hidden;
+ PasswordHidden.Visibility = Visibility.Visible;
+ }
+
+ ///
+ /// update the password unmask
+ ///
+ ///
+ ///
+ private void Password_PasswordChanged(object sender, RoutedEventArgs e)
+ {
+ PasswordUnmask.Text = PasswordHidden.Password;
+ }
+
+ #endregion ShowPassword
+ }
+}
diff --git a/PLWPF/Windows/HostingUnitWindow.xaml.cs b/PLWPF/Windows/HostingUnitWindow.xaml.cs
deleted file mode 100644
index 45d8aab..0000000
--- a/PLWPF/Windows/HostingUnitWindow.xaml.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-using BE;
-using BL;
-using PLWPF.Windows;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
-
-namespace PLWPF
-{
- ///
- /// Interaction logic for HostingUnitWindow.xaml
- ///
- public partial class HostingUnitWindow : Window
- {
- MyBl myBL = new MyBl();
- Host host;
- HostingUnit hostingUnit;
-
- public HostingUnitWindow(Host host)
- {
- InitializeComponent();
- this.host = host;
- hostName.Text = host.FamilyName;
- hostId.Text = host.HostKey.ToString();
- HostingUnitKeyComboBox.ItemsSource = myBL.HustingUnitsBy(x => x.Owner.HostKey == host.HostKey);
- HostingUnitKeyComboBox.DisplayMemberPath = "HostingUnitName";
-
-
- AreaComboBox.ItemsSource = Enum.GetValues(typeof(BE.Area)).Cast();
- ComboBoxPool.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
- ComboBoxJacuzzi.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
- ComboBoxAttrac.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
- ComboBoxSpredBads.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
- ComboBoxAirCondsner.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
- ComboBoxGarden.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
- ComboBoxSingog.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
- ComboBoxTrensp.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
- }
-
-
- private void HostingUnitKeyComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- hostingUnit = HostingUnitKeyComboBox.SelectedItem as HostingUnit;
- InitialHostingUnit(hostingUnit);
- }
-
- private void InitialHostingUnit(HostingUnit unit)
- {
- AreaComboBox.SelectedItem = unit.Area;
- SubArea.Text = unit.SubArea;
- ComboBoxPool.SelectedItem = unit.Pool;
- ComboBoxJacuzzi.SelectedItem = unit.Jacuzzi;
- ComboBoxAttrac.SelectedItem = unit.ChildrensAttractions;
- ComboBoxSpredBads.SelectedItem = unit.SpredBads;
- ComboBoxAirCondsner.SelectedItem = unit.AirCondsner;
- ComboBoxGarden.SelectedItem = unit.Garden;
- ComboBoxSingog.SelectedItem = unit.SingogNaerBy;
- ComboBoxTrensp.SelectedItem = unit.NaerPublicTrensportion;
- }
-
- private void button_Click(object sender, RoutedEventArgs e)
- {
- hostingUnit.SubArea = SubArea.Text;
- hostingUnit.Area = (Area)AreaComboBox.SelectedItem;
- hostingUnit.Pool = (Requirements)ComboBoxPool.SelectedItem;
- hostingUnit.Jacuzzi = (Requirements)ComboBoxJacuzzi.SelectedItem;
- hostingUnit.ChildrensAttractions = (Requirements)ComboBoxAttrac.SelectedItem;
- hostingUnit.SpredBads = (Requirements)ComboBoxSpredBads.SelectedItem;
- hostingUnit.AirCondsner = (Requirements)ComboBoxAirCondsner.SelectedItem;
- hostingUnit.Garden = (Requirements)ComboBoxGarden.SelectedItem;
- hostingUnit.SingogNaerBy = (Requirements)ComboBoxSingog.SelectedItem;
- hostingUnit.NaerPublicTrensportion = (Requirements)ComboBoxTrensp.SelectedItem;
-
- try
- {
- myBL.UnitRemove(hostingUnit.HostingUnitKey);
- myBL.AddHostingUnit(hostingUnit);
- MessageBox.Show($"Hosting unit: {hostingUnit.HostingUnitName} updated Seccessfuly!");
- this.Close();
-
- }
- catch (Exception)
- {
- MessageBox.Show($"Error during Update {hostingUnit.HostingUnitName} please try again later!");
- this.Close();
-
- }
-
-
- }
- }
-}
diff --git a/PLWPF/Windows/HostingUnitWindow.xaml b/PLWPF/Windows/HostingUnitWindows/HostingUnitUserControl.xaml
similarity index 54%
rename from PLWPF/Windows/HostingUnitWindow.xaml
rename to PLWPF/Windows/HostingUnitWindows/HostingUnitUserControl.xaml
index 42d78f4..52ea922 100644
--- a/PLWPF/Windows/HostingUnitWindow.xaml
+++ b/PLWPF/Windows/HostingUnitWindows/HostingUnitUserControl.xaml
@@ -1,21 +1,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
-
-
@@ -36,9 +38,16 @@
-
+
+
+
+
+
+
+
+
-
+
diff --git a/PLWPF/Windows/HostingUnitWindows/HostingUnitUserControl.xaml.cs b/PLWPF/Windows/HostingUnitWindows/HostingUnitUserControl.xaml.cs
new file mode 100644
index 0000000..1bb530b
--- /dev/null
+++ b/PLWPF/Windows/HostingUnitWindows/HostingUnitUserControl.xaml.cs
@@ -0,0 +1,193 @@
+using BE;
+using BL;
+using System;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace PLWPF.Windows.HostingUnitWindows
+{
+
+ ///
+ /// Interaction logic for HostingUnitUserControl.xaml
+ ///
+ public partial class HostingUnitUserControl : UserControl
+ {
+ MyBl myBL = new MyBl();
+ Host host;
+ HostingUnit hostingUnit;
+ bool newUnit, deleteUnit;
+
+ ///
+ /// c-tor
+ ///
+ ///
+ ///
+ ///
+ public HostingUnitUserControl(Host host, bool newUnit, bool deleteUnit)
+ {
+ this.newUnit = newUnit;
+ this.deleteUnit = deleteUnit;
+ InitializeComponent();
+
+ //Initialize host
+ this.host = host;
+ hostName.Text = host.FamilyName;
+ hostId.Text = host.HostKey.ToString();
+
+ //depend on what page you in
+ button.Content = (deleteUnit == false) ? "Save" : "Delete";
+
+ //if you add new unit you need to change the comboBox to TextBox
+ if (newUnit == true)
+ {
+ HostingUnitKeyTextBox.Visibility = Visibility.Visible;
+ HostingUnitKeyComboBox.Visibility = Visibility.Hidden;
+ hostingUnit = new HostingUnit();
+ }
+ else
+ {
+ HostingUnitKeyTextBox.Visibility = Visibility.Hidden;
+ HostingUnitKeyComboBox.Visibility = Visibility.Visible;
+
+ HostingUnitKeyComboBox.ItemsSource = myBL.HustingUnitsBy(x => x.Owner.HostKey == host.HostKey);
+ HostingUnitKeyComboBox.DisplayMemberPath = "HostingUnitName";
+ }
+
+ //ComboBox Items Source
+ ComboBoxHostingType.ItemsSource= Enum.GetValues(typeof(BE.HostingType)).Cast();
+ AreaComboBox.ItemsSource = Enum.GetValues(typeof(BE.Area)).Cast();
+ ComboBoxPool.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
+ ComboBoxJacuzzi.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
+ ComboBoxAttrac.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
+ ComboBoxSpredBads.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
+ ComboBoxAirCondsner.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
+ ComboBoxGarden.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
+ ComboBoxSingog.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
+ ComboBoxTrensp.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
+
+ }
+
+ ///
+ /// Selection of Hosting Unit in the ComboBox Changed event
+ ///
+ ///
+ ///
+ private void HostingUnitKeyComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ hostingUnit = HostingUnitKeyComboBox.SelectedItem as HostingUnit;
+ InitialHostingUnit(hostingUnit);
+ }
+
+ ///
+ /// Feel the Textbox & ComboBox with the Unit details
+ ///
+ ///
+ private void InitialHostingUnit(HostingUnit unit)
+ {
+ ComboBoxHostingType.SelectedItem = unit.HostingType;
+ Adults.Text = unit.Adults.ToString();
+ Children.Text = unit.Children.ToString();
+ AreaComboBox.SelectedItem = unit.Area;
+ SubArea.Text = unit.SubArea;
+ ComboBoxPool.SelectedItem = unit.Pool;
+ ComboBoxJacuzzi.SelectedItem = unit.Jacuzzi;
+ ComboBoxAttrac.SelectedItem = unit.ChildrensAttractions;
+ ComboBoxSpredBads.SelectedItem = unit.SpredBads;
+ ComboBoxAirCondsner.SelectedItem = unit.AirCondsner;
+ ComboBoxGarden.SelectedItem = unit.Garden;
+ ComboBoxSingog.SelectedItem = unit.SingogNaerBy;
+ ComboBoxTrensp.SelectedItem = unit.NaerPublicTrensportion;
+ }
+
+ ///
+ /// button_Click will save the changes, or will delete the unit, depende the page.
+ ///
+ ///
+ ///
+ private void button_Click(object sender, RoutedEventArgs e)
+ {
+ if (deleteUnit == true)
+ {
+ MessageBoxResult result = MessageBox.Show("Are you sure\n?", "Delete unit", MessageBoxButton.YesNo, MessageBoxImage.Warning);
+ if (result == MessageBoxResult.Yes)
+ {
+ try
+ {
+ myBL.UnitRemove(hostingUnit.HostingUnitKey);
+ MessageBox.Show("Unit deleted");
+ }
+ catch (Exception ex)
+ {
+ throw new Exception("Fail to delete unit \n " + ex);
+ }
+ }
+ }
+
+ else
+ {
+ if (newUnit == true)
+ {
+ hostingUnit.HostingUnitName = HostingUnitKeyTextBox.Text;
+ hostingUnit.Owner = host;
+ }
+ hostingUnit.HostingType = (HostingType)ComboBoxHostingType.SelectedItem;
+ hostingUnit.Children = Int32.Parse(Children.Text);
+ hostingUnit.Adults = Int32.Parse(Adults.Text);
+ hostingUnit.SubArea = SubArea.Text;
+ hostingUnit.Area = (Area)AreaComboBox.SelectedItem;
+ hostingUnit.Pool = (Requirements)ComboBoxPool.SelectedItem;
+ hostingUnit.Jacuzzi = (Requirements)ComboBoxJacuzzi.SelectedItem;
+ hostingUnit.ChildrensAttractions = (Requirements)ComboBoxAttrac.SelectedItem;
+ hostingUnit.SpredBads = (Requirements)ComboBoxSpredBads.SelectedItem;
+ hostingUnit.AirCondsner = (Requirements)ComboBoxAirCondsner.SelectedItem;
+ hostingUnit.Garden = (Requirements)ComboBoxGarden.SelectedItem;
+ hostingUnit.SingogNaerBy = (Requirements)ComboBoxSingog.SelectedItem;
+ hostingUnit.NaerPublicTrensportion = (Requirements)ComboBoxTrensp.SelectedItem;
+
+ try
+ {
+ if (newUnit == false)
+ myBL.UpdateUnit(hostingUnit);
+ else
+ myBL.AddHostingUnit(hostingUnit);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("" + ex);
+ }
+
+ }
+ }
+
+ ///
+ /// Cancel the Changes thet you do
+ ///
+ ///
+ ///
+ private void CancelChanges_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ if (newUnit == true)
+ {
+ HostingUnitKeyTextBox.Clear();
+ ComboBoxHostingType.SelectedItem = null;
+ Adults.Text = null;
+ Children.Text = null;
+ AreaComboBox.SelectedItem = null;
+ SubArea.Text = null;
+ ComboBoxPool.SelectedItem = null;
+ ComboBoxJacuzzi.SelectedItem = null;
+ ComboBoxAttrac.SelectedItem = null;
+ ComboBoxSpredBads.SelectedItem = null;
+ ComboBoxAirCondsner.SelectedItem = null;
+ ComboBoxGarden.SelectedItem = null;
+ ComboBoxSingog.SelectedItem = null;
+ ComboBoxTrensp.SelectedItem = null;
+ }
+ else
+ {
+ InitialHostingUnit(hostingUnit);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/PLWPF/Windows/HostingUnitWindows/HostingUnitWindow.xaml b/PLWPF/Windows/HostingUnitWindows/HostingUnitWindow.xaml
new file mode 100644
index 0000000..c41fb28
--- /dev/null
+++ b/PLWPF/Windows/HostingUnitWindows/HostingUnitWindow.xaml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PLWPF/Windows/HostingUnitWindows/HostingUnitWindow.xaml.cs b/PLWPF/Windows/HostingUnitWindows/HostingUnitWindow.xaml.cs
new file mode 100644
index 0000000..fd13796
--- /dev/null
+++ b/PLWPF/Windows/HostingUnitWindows/HostingUnitWindow.xaml.cs
@@ -0,0 +1,20 @@
+using BE;
+using PLWPF.Windows.HostingUnitWindows;
+using System.Windows;
+
+namespace PLWPF
+{
+ ///
+ /// Interaction logic for HostingUnitWindow.xaml
+ ///
+ public partial class HostingUnitWindow : Window
+ {
+ public HostingUnitWindow(Host host)
+ {
+ InitializeComponent();
+ AddNewUnitFrame.Content = new HostingUnitUserControl(host,true, false);
+ UpdateUnitFrame.Content = new HostingUnitUserControl(host, false, false);
+ DeleteUnitFrame.Content = new HostingUnitUserControl(host, false, true);
+ }
+ }
+}
diff --git a/PLWPF/Windows/LogInWindow.xaml b/PLWPF/Windows/LogInWindow.xaml
index c1de0ea..79ccc55 100644
--- a/PLWPF/Windows/LogInWindow.xaml
+++ b/PLWPF/Windows/LogInWindow.xaml
@@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PLWPF.Windows"
+ xmlns:plwpf="clr-namespace:PLWPF"
mc:Ignorable="d"
Title="LogInWindow" Height="450" Width="800">
@@ -13,19 +14,11 @@
-
-
-
-
+
diff --git a/PLWPF/Windows/LogInWindow.xaml.cs b/PLWPF/Windows/LogInWindow.xaml.cs
index 054f6d4..eda048a 100644
--- a/PLWPF/Windows/LogInWindow.xaml.cs
+++ b/PLWPF/Windows/LogInWindow.xaml.cs
@@ -65,8 +65,9 @@ private void ENTER_Click(object sender, RoutedEventArgs e)
{
try
{
- if (myBL.CheckePassword(host.PasswordKey, Int32.Parse(PasswordHidden.Password)))
+ if (myBL.CheckePassword(host.PasswordKey, Int32.Parse(Password.PasswordHidden.Password)))
{
+ //DialogResult is return to main window
DialogResult = true;
Close();
}
@@ -87,7 +88,7 @@ private void Worker_SendMailWithNewPassword(object sender, DoWorkEventArgs e)
}
///
- /// The event call to ShowPasswordFunction
+ /// The event call to Worker_SendMailWithNewPassword
///
///
///
@@ -99,7 +100,6 @@ private void ForgetYourPassword_PreviewMouseDown(object sender, MouseButtonEvent
{
try
{
-
if (worker.IsBusy != true) worker.RunWorkerAsync();
MessageBox.Show("Email was sent!","Massage", MessageBoxButton.OK, MessageBoxImage.Information);
}
@@ -113,61 +113,6 @@ private void ForgetYourPassword_PreviewMouseDown(object sender, MouseButtonEvent
}
- #region ShowPassword
-
- ///
- /// The event call to ShowPasswordFunction
- ///
- ///
- ///
- private void ShowPassword_PreviewMouseDown(object sender, MouseButtonEventArgs e) => ShowPasswordFunction();
-
- ///
- /// The event call to HidePasswordFunction
- ///
- ///
- ///
- private void ShowPassword_PreviewMouseUp(object sender, MouseButtonEventArgs e) => HidePasswordFunction();
-
- ///
- /// The event call to HidePasswordFunction
- ///
- ///
- ///
- private void ShowPassword_MouseLeave(object sender, MouseEventArgs e) => HidePasswordFunction();
-
- ///
- /// make the password visible
- ///
- private void ShowPasswordFunction()
- {
- ShowPassword.Text = "HIDE";
- PasswordUnmask.Visibility = Visibility.Visible;
- PasswordHidden.Visibility = Visibility.Hidden;
- PasswordUnmask.Text = PasswordHidden.Password;
- }
-
- ///
- /// make the password unvisible
- ///
- private void HidePasswordFunction()
- {
- ShowPassword.Text = "SHOW";
- PasswordUnmask.Visibility = Visibility.Hidden;
- PasswordHidden.Visibility = Visibility.Visible;
- }
-
- ///
- /// update the password unmask
- ///
- ///
- ///
- private void Password_PasswordChanged(object sender, RoutedEventArgs e)
- {
- lll.Content = PasswordHidden.Password;
- PasswordUnmask.Text = PasswordHidden.Password;
- }
-
- #endregion ShowPassword
+
}
}
diff --git a/PLWPF/Windows/NewOrder/GuestRequestPage.xaml b/PLWPF/Windows/NewOrder/GuestRequestPage.xaml
index a997dd6..b83b392 100644
--- a/PLWPF/Windows/NewOrder/GuestRequestPage.xaml
+++ b/PLWPF/Windows/NewOrder/GuestRequestPage.xaml
@@ -44,12 +44,12 @@
-
+
-
+
-
+
@@ -74,6 +74,6 @@
-
+
-
+
\ No newline at end of file
diff --git a/PLWPF/Windows/NewOrder/NewOrderWindow.xaml.cs b/PLWPF/Windows/NewOrder/NewOrderWindow.xaml.cs
index 1a79cdd..90f1f90 100644
--- a/PLWPF/Windows/NewOrder/NewOrderWindow.xaml.cs
+++ b/PLWPF/Windows/NewOrder/NewOrderWindow.xaml.cs
@@ -1,18 +1,9 @@
using BL;
using BE;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
+using System.ComponentModel;
namespace PLWPF.Windows
{
@@ -23,6 +14,11 @@ public partial class NewOrderWindow : Window
{
MyBl myBL = new MyBl();
Host host;
+
+ ///
+ /// c-tor
+ ///
+ ///
public NewOrderWindow(Host host )
{
InitializeComponent();
@@ -61,6 +57,18 @@ private void HostingUnitKeyComboBox_SelectionChanged(object sender, SelectionCha
Left.Content = new HostingUnitPage(HostingUnitKeyComboBox.SelectedItem as HostingUnit);
}
+ BackgroundWorker worker = new BackgroundWorker();
+
+ private void Worker_SendMailWithNewOffer(object sender, DoWorkEventArgs e)
+ {
+ myBL.SendMail(e.Argument as Order);
+ }
+
+ ///
+ /// Make Order send email and change status
+ ///
+ ///
+ ///
private void button_Click(object sender, RoutedEventArgs e)
{
Order order = new Order()
@@ -71,15 +79,31 @@ private void button_Click(object sender, RoutedEventArgs e)
OrderDate = DateTime.Now,
Status = OrderStatus.MailSent,
OrderKey = Configuration.serialOrder++
-
};
try
{
myBL.AddOrder(order);
+ worker.DoWork += Worker_SendMailWithNewOffer;
+ worker.RunWorkerAsync(order);
try
{
- myBL.SendMail(order);
+ if (worker.IsBusy != true) worker.RunWorkerAsync();
+ MessageBox.Show("Email was sent!", "Massage", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Fail to send the Email\n" + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+
+
+
+
+
+
+ try
+ {
+ myBL.SendMail(order);
}
catch(Exception ex)
{
diff --git a/PLWPF/Windows/Register.xaml b/PLWPF/Windows/Register.xaml
index 880d9a7..50662b4 100644
--- a/PLWPF/Windows/Register.xaml
+++ b/PLWPF/Windows/Register.xaml
@@ -5,46 +5,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PLWPF.Windows"
mc:Ignorable="d"
- Title="Register" Height="413.098" Width="565.262">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Title="Register" Height="470" Width="565.262">
+
+
diff --git a/PLWPF/Windows/Register.xaml.cs b/PLWPF/Windows/Register.xaml.cs
index ed5ad50..59be5ed 100644
--- a/PLWPF/Windows/Register.xaml.cs
+++ b/PLWPF/Windows/Register.xaml.cs
@@ -21,43 +21,11 @@ namespace PLWPF.Windows
///
public partial class Register : Window
{
- MyBl myBL = new MyBl();
public Register()
{
InitializeComponent();
-
- }
-
- private void Register_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- Host host = new Host();
- BankAccount bankAccount = new BankAccount();
-
- host.PrivateName = PrivateName.Text;
- host.FamilyName = FamilyName.Text;
- host.PhoneNumber = PhoneNumber.Text;
- host.MailAddress = MailAddress.Text;
-
- bankAccount.BankName = Bank_ComboBox.Text;
- bankAccount.BranchCity = BranchCity_ComboBox.Text;
- bankAccount.BranchAddress = BranchAddress_ComboBox.Text;
- bankAccount.BankNumber = Convert.ToInt32(BankNumber.Text);
- bankAccount.BranchNumber = Convert.ToInt32(BranchNumber.Text);
- bankAccount.BankAccountNumber = Convert.ToInt32(BankAccountNumber.Text);
-
- host.BankAccount = bankAccount;
-
- myBL.AddHost(host);
- MessageBox.Show("Recived Seccessfully");
- this.Close();
- }
- catch (Exception)
- {
- MessageBox.Show("Error! Make sure you dont miss any field!");
- }
+ Host_UserControl.Content = new HostUserControl(null,false);
}
}
-}
+}
\ No newline at end of file
diff --git a/PLWPF/Windows/Statistics/GuestRequestQueryPage.xaml.cs b/PLWPF/Windows/Statistics/GuestRequestQueryPage.xaml.cs
index 44ed07f..c562ad7 100644
--- a/PLWPF/Windows/Statistics/GuestRequestQueryPage.xaml.cs
+++ b/PLWPF/Windows/Statistics/GuestRequestQueryPage.xaml.cs
@@ -18,7 +18,6 @@ public GuestRequestQueryPage()
InitializeComponent();
LevelOfDemand_ComboBox.ItemsSource = Enum.GetValues(typeof(BE.Requirements)).Cast();
PerArea.Content = new ShowPerArea(myBL.GuestRequestPerArea());
-
}
@@ -42,9 +41,4 @@ private void LevelOfDemand_ComboBox_SelectionChanged(object sender, SelectionCha
}
}
-
-/*
-
- var v = myBL.GuestRequestOrderBy_Location();
- var t = v.Where(x => x.Key == Area.Jerusalem).FirstOrDefault().ToList().Count;
- */
+