예제 #1
0
        private void createClient_Click(object sender, EventArgs e)
        {
            DBHandler instance = DBHandler.getInstance();
            selectedClient = new Client();
            selectedReservation = new Reservation();
            fieldsToClient();
            fieldsToReservation();

            //validations goes here
            bool valid = true;
            string msg = "";

            //end validations

            if (valid)
            {
                instance.insertResrvation(selectedClient, trip, selectedReservation);
                if (hasGroup.Checked)
                {
                    instance.insertClientGroup(selectedClient.ID, (int)grpIDs[grpIndex]);
                }
                if (hasBus.Checked)
                {
                    instance.insertClientGroup(selectedClient.ID, (int)busesIDs[busIndex]);
                }
                Prompt.ShowWarningDialog("تم اضافة العميل بنجاح", "تم");
                //updateAutoComplete();
                tripToFields();
                clientsDefaults();
            }
            else
            {
                Prompt.ShowWarningDialog(msg, "تحذير");
            }
        }
예제 #2
0
        private void clientToFields()
        {
            DBHandler instance = DBHandler.getInstance();
            List<Group> tripGrps = trip.tripGroups.Select(tg=>tg.group).ToList();
            List<Group> clientGrps = selectedClient.clientGroups.Select(cg=>cg.group).ToList();
            List<Group> clintTripGrps = tripGrps.Intersect(clientGrps).ToList();
            Group sgrp = clintTripGrps.Where(g=> !g.isBus).FirstOrDefault();
            Group sbus = clintTripGrps.Where(g=> g.isBus).FirstOrDefault();
            selectedReservation = instance.getReservation(selectedClient.ID, trip.ID);

            clientName.Text = selectedClient.name;
            clientPhone.Text = selectedClient.phoneNumber;
            toPay.Text = selectedReservation.priceToPay+"";
            clientPay.Text = selectedReservation.pricePaid+"";
            clientID.Text = selectedReservation.ticketID+"";
            if (sgrp != null)
            {
                hasGroup.Checked = true;
                group.Text = sgrp.name;
            }
            else
            {
                hasGroup.Checked = false;
                group.Text = "";
            }
            if (sbus != null)
            {
                hasBus.Checked = true;
                bus.Text = sbus.name;
            }
            else
            {
                hasBus.Checked = false;
                bus.Text = "";
            }
                group.Enabled = false;
                bus.Enabled = false;
            //hasGroup.Checked =
        }
예제 #3
0
 public bool removeResrvation(Reservation r)
 {
     DB.reservations.Remove(r);
     return DB.SaveChanges() > 0;
 }
예제 #4
0
 public bool updateResrvation(Reservation r)
 {
     DB.reservations.Attach(r);
     DB.Entry(r).State = EntityState.Modified;
     return DB.SaveChanges() > 0;
 }
예제 #5
0
 public bool insertResrvation(Client c, Trip t, Reservation r)
 {
     insertClient(c);
        // Reservation r = new Reservation();
     r.clientID = c.ID;
     r.tripID = t.ID;
     t.nextTicketID++;
     DB.trips.Attach(t);
     DB.Entry(t).State = EntityState.Modified;
     DB.reservations.Add(r);
     return DB.SaveChanges() > 0;
 }