private void btn_OK_Click(object sender, EventArgs e)
 {
     try
     {
         Tour_Agency a = new Tour_Agency {
             AgencyID      = uint.Parse(agencyIDTextBox.Text),
             Name          = nameTextBox.Text,
             ContactPerson = contactPersonTextBox.Text,
             Type          = (AgencyType)typeListBox.SelectedItem
         };
         if (add)
         {
             if (!myBL.AddAgency(a))
             {
                 throw new Exception();
             }
         }
         else
         {
             if (!myBL.UpdateAgency(a.AgencyID, a.Name, a.ContactPerson))
             {
                 throw new Exception();
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show("I am Error");
     }
 }
        private void btn_OK_Click(object sender, EventArgs e)
        {
            try
            {
                Tour_Agency a = new Tour_Agency {
                    AgencyID = uint.Parse(agencyIDTextBox.Text),
                    Name = nameTextBox.Text,
                    ContactPerson = contactPersonTextBox.Text,
                    Type = (AgencyType)typeListBox.SelectedItem
                };
                if (add)
                {
                    if (!myBL.AddAgency(a)) throw new Exception();
                }
                else
                {
                    if (!myBL.UpdateAgency(a.AgencyID, a.Name, a.ContactPerson)) throw new Exception();
                }

            }
            catch (Exception)
            {
                MessageBox.Show("I am Error");
            }
        }
        public static Reservation ToReservation(this XElement item, Func <uint, Tour_Agency> intToAgency, Func <uint, Room> intToRoom)
        {
            uint     id, agencyID, Days;
            DateTime ArrivalDate, ReservationDate;

            uint.TryParse(item.Element("id").Value, out id);
            uint.TryParse(item.Element("AgencyID").Value, out agencyID);
            uint.TryParse(item.Element("Days").Value, out Days);
            DateTime.TryParse(item.Element("ArrivalDate").Value, out ArrivalDate);
            DateTime.TryParse(item.Element("ReservationDate").Value, out ReservationDate);
            Tour_Agency agency = intToAgency(agencyID);

            if (item.Element("roomID") != null)
            {
                uint roomID;
                uint.TryParse(item.Element("roomID").Value, out roomID);
                Room room = intToRoom(roomID);
                return((Reservation) new Single_Reservation(id, agency, ArrivalDate, room, Days, ReservationDate));
            }
            if (item.Element("rooms") != null)
            {
                List <Room> rooms = new List <Room>();
                foreach (XElement XroomID in item.Element("rooms").Elements("id"))
                {
                    uint roomID;
                    uint.TryParse(XroomID.Value, out roomID);
                    rooms.Add(intToRoom(roomID));
                }
                return((Reservation) new Group_Reservation(id, agency, ArrivalDate, rooms, Days, ReservationDate));
            }
            return(null);
        }
예제 #4
0
 /// <summary>
 /// add an agency to the collection
 /// </summary>
 /// <param name="agency">agency</param>
 /// <returns>true if success, false else</returns>
 public bool AddAgency(Tour_Agency agency)
 {
     if (Agencies.Contains(agency))
     {
         return(false);
     }
     Agencies.Add(agency);
     return(Agencies.Contains(agency));
 }
 public static XElement ToXML(this Tour_Agency src)
 {
     return(new XElement("agency",
                         new XElement("id", src.AgencyID),
                         new XElement("Name", src.Name),
                         new XElement("ContactPerson", src.ContactPerson),
                         new XElement("Type", (uint)src.Type)
                         ));
 }
 public bool AddAgency(Tour_Agency Agency)
 {
     if (Agency.AgencyID < nextAgencyNumber || !myDal.AddAgency(Agency))
     {
         return(false);
     }
     nextAgencyNumber = Agency.AgencyID + 1;
     return(true);
 }
예제 #7
0
        /// <summary>
        /// remove an agency from the collection
        /// </summary>
        /// <param name="ID">agency's ID</param>
        /// <returns>true if success, false else</returns>
        public bool RemoveAgency(uint ID)
        {
            Tour_Agency agency = Agencies.SingleOrDefault(item => item.AgencyID == ID);

            if (agency == null)
            {
                return(false);
            }
            Agencies.Remove(agency);
            return(true);
        }
        public bool UpdateAgency(Tour_Agency agency)
        {
            IEnumerable <Tour_Agency> oldAgencies = agencies.Where(item => item.AgencyID == agency.AgencyID);

            if (oldAgencies.Count() != 1)
            {
                return(false);
            }
            oldAgencies.Select(item => agency);
            return(true);
        }
예제 #9
0
 /// <summary>
 /// add an agency to the collection
 /// </summary>
 /// <param name="agency">agency</param>
 /// <returns>true if success, false else</returns>
 public bool AddAgency(Tour_Agency agency)
 {
     if (agency.AgencyID < nextAgencyNumber)
     {
         if (!myDal.AddAgency(agency))
         {
             return(false);
         }
     }
     nextAgencyNumber = agency.AgencyID + 1;
     return(true);
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="BLin"></param>
 /// <param name="a"></param>
 public Agency_edit(BL_ServiceReference.BL_SOAPClient BLin, Tour_Agency a)
 {
     myBL = BLin;
     add = false;
     InitializeComponent();
     agencyIDTextBox.Text = a.AgencyID.ToString();
     agencyIDTextBox.Enabled = false;
     nameTextBox.Text = a.Name;
     typeListBox.DataSource = Enum.GetValues(typeof(AgencyType));
     typeListBox.SelectedItem = a.Type;
     typeListBox.Enabled = false;
     contactPersonTextBox.Text = a.ContactPerson;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="BLin"></param>
 /// <param name="a"></param>
 public Agency_edit(BL_ServiceReference.BL_SOAPClient BLin, Tour_Agency a)
 {
     myBL = BLin;
     add  = false;
     InitializeComponent();
     agencyIDTextBox.Text      = a.AgencyID.ToString();
     agencyIDTextBox.Enabled   = false;
     nameTextBox.Text          = a.Name;
     typeListBox.DataSource    = Enum.GetValues(typeof(AgencyType));
     typeListBox.SelectedItem  = a.Type;
     typeListBox.Enabled       = false;
     contactPersonTextBox.Text = a.ContactPerson;
 }
 public bool UpdateAgency(Tour_Agency Agency)
 {
     if (!myDal.UpdateAgency(Agency))
     {
         return(false);
     }
     myDal.Reservations.ForEach(delegate(Reservation item) {
         if (item.Agency.AgencyID == Agency.AgencyID)
         {
             item.Agency = Agency;
         }
     });
     return(true);
 }
 /// <summary>
 /// add an agency to the collection
 /// </summary>
 /// <param name="agency">agency</param>
 /// <returns>true if success, false else</returns>
 public bool AddAgency(Tour_Agency agency)
 {
     if ((from item in Xagencies.Elements() where (item.Element("id").Value == agency.AgencyID.ToString()) select item).Count() > 0)
     {
         return(false);
     }
     try {
         Xagencies.Add(agency.ToXML());
         Xagencies.Save(agenciesFile);
     } catch {
         return(false);
     }
     return(true);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="agency"></param>
 /// <returns></returns>
 public bool AddAgency(Tour_Agency agency)
 {
     return(base.Channel.AddAgency(agency));
 }