Пример #1
0
        /// <summary>
        /// Add trip function
        /// </summary>
        /// <param name="dateoftrip">Date of trip</param>
        /// <param name="days">Days of trip</param>
        /// <param name="numberofplaces">Number of places</param>
        /// <param name="pilotid">ID of pilot</param>
        /// <param name="priceperperson">Price per person</param>
        /// <returns></returns>
        public bool AddTrip(int priceperperson, int numberofplaces, string dateoftrip, int days, string pilotid, string city)
        {
            return(CallStoredProcedure(TravelAgencyStoredProcedures.spAddTrip,

                                       new List <Parameter> {
                new Parameter {
                    Name = spAddTripParameters.pPPP.ToString(), Value = priceperperson
                },
                new Parameter {
                    Name = spAddTripParameters.pNOP.ToString(), Value = numberofplaces
                },
                new Parameter {
                    Name = spAddTripParameters.pTrips_date.ToString(), Value = dateoftrip
                },
                new Parameter {
                    Name = spAddTripParameters.pDays.ToString(), Value = days
                },
                new Parameter {
                    Name = spAddTripParameters.pPilot_id.ToString(), Value = DatabasetablesHelpers.ConvertNameToInt(pilotid)
                },
                new Parameter {
                    Name = spAddTripParameters.pCity.ToString(), Value = city
                },
            }));
        }
Пример #2
0
        /// <summary>
        /// Update trip function
        /// </summary>
        /// <param name="columnName">Name of updateing column</param>
        /// <param name="id">ID of updating trip</param>
        /// <param name="value">Value of updating column</param>
        public bool UpdateTrip(string columnName, int id, object value)
        {
            if (columnName == TripsColumn.name.ToString())
            {
                value = DatabasetablesHelpers.ConvertNameToInt((string)value);
            }
            if (columnName == TripsColumn.pilot.ToString())
            {
                value = DatabasetablesHelpers.ConvertNameToInt((string)value);
            }

            return(CallStoredProcedure(TravelAgencyStoredProcedures.spUpdateTrip,

                                       new List <Parameter> {
                new Parameter {
                    Name = spUpdateTripParameters.pColumnName.ToString(), Value = columnName
                },
                new Parameter {
                    Name = spUpdateTripParameters.pId.ToString(), Value = id
                },
                new Parameter {
                    Name = spUpdateTripParameters.pValue.ToString(), Value = value
                },
            }));
        }
Пример #3
0
        /// <summary>
        /// Updates <see cref="CurrentInvoice"/> property
        /// </summary>
        /// <param name="invoice"></param>
        /// <returns></returns>
        public bool UpdateCurrentInvoice(string invoice)
        {
            CurrentInvoice.Clear();

            foreach (DataRow row in Table.Rows)
            {
                if (int.Parse(row[0].ToString()) == DatabasetablesHelpers.ConvertNameToInt(invoice))
                {
                    for (int i = 0; i < Table.Columns.Count; i++)
                    {
                        if (i == 3 || i == 4)
                        {
                            string date  = row[i].ToString();
                            string date2 = "";

                            for (int k = 0; date[k] != ' '; k++)
                            {
                                date2 += date[k];
                            }

                            CurrentInvoice.Add(date2);
                            continue;
                        }

                        CurrentInvoice.Add(row[i].ToString());
                    }

                    break;
                }
            }

            return(true);
        }
Пример #4
0
        /// <summary>
        /// Get list of places for specified trip as <see cref="List{int}<"/>
        /// </summary>
        /// <param name="tripId">Trip ID</param>
        /// <returns></returns>
        public List <int> BookedPlacesToList(string tripId)
        {
            List <int> places = new List <int>();

            for (int i = 1; i <= GetBookedPlaces(DatabasetablesHelpers.ConvertNameToInt(tripId)); i++)
            {
                places.Add(i);
            }
            return(places);
        }
Пример #5
0
        /// <summary>
        /// Add order function
        /// </summary>
        /// <param name="bookedplaces">Number of booked places</param>
        /// <param name="clientid">ID of client</param>
        /// <param name="tripid">ID of trip</param>
        /// <returns></returns>
        public bool AddOrder(string clientid, int bookedplaces, string tripid)
        {
            return(CallStoredProcedure(TravelAgencyStoredProcedures.spAddOrder,

                                       new List <Parameter> {
                new Parameter {
                    Name = spAddOrderParameters.pClient_id.ToString(), Value = DatabasetablesHelpers.ConvertNameToInt(clientid)
                },
                new Parameter {
                    Name = spAddOrderParameters.pBooked_places.ToString(), Value = bookedplaces
                },
                new Parameter {
                    Name = spAddOrderParameters.pTrip_id.ToString(), Value = DatabasetablesHelpers.ConvertNameToInt(tripid)
                }
            }));
        }
Пример #6
0
        /// <summary>
        /// Add client function
        /// </summary>
        /// <param name="bookedplaces">Number of booked places</param>
        /// <param name="clientid">ID of client</param>
        /// <param name="tripid">ID of trip</param>
        /// <returns></returns>
        public bool AddPayment(string invoiceid, double amount, string paymentMethod)
        {
            return(CallStoredProcedure(TravelAgencyStoredProcedures.spAddPayment,

                                       new List <Parameter> {
                new Parameter {
                    Name = spAddPaymentParameters.pInvoice_id.ToString(), Value = DatabasetablesHelpers.ConvertNameToInt(invoiceid)
                },
                new Parameter {
                    Name = spAddPaymentParameters.pAmount.ToString(), Value = amount
                },
                new Parameter {
                    Name = spAddPaymentParameters.pPayment_method.ToString(), Value = DatabasetablesHelpers.ConvertNameToInt(paymentMethod)
                }
            }));
        }
Пример #7
0
        /// <summary>
        /// Update order function
        /// </summary>
        /// <param name="columnName">Name of updating column</param>
        /// <param name="id">ID of updating order</param>
        /// <param name="value">Value of updating column</param>
        public bool UpdateOrder(string columnName, string id, object value)
        {
            if (columnName == OrdersColumn.orders_status.ToString())
            {
                value = DatabasetablesHelpers.ConvertNameToInt((string)value);
            }

            return(CallStoredProcedure(TravelAgencyStoredProcedures.spUpdateOrders,

                                       new List <Parameter> {
                new Parameter {
                    Name = spUpdateOrdersParameters.pColumnName.ToString(), Value = columnName
                },
                new Parameter {
                    Name = spUpdateOrdersParameters.pId.ToString(), Value = DatabasetablesHelpers.ConvertNameToInt(id)
                },
                new Parameter {
                    Name = spUpdateOrdersParameters.pValue.ToString(), Value = value
                },
            }));
        }
Пример #8
0
        /// <summary>
        /// Update employee function
        /// </summary>
        /// <param name="columnName">Name of updating column</param>
        /// <param name="id">ID of updating employee</param>
        /// <param name="value">Value of updating column</param>
        public bool UpdateEmployee(string columnName, string id, object value)
        {
            if (columnName == EmployeesColumn.gender.ToString())
            {
                value = (bool)value == true ? 'M' : 'F';
            }

            return(CallStoredProcedure(TravelAgencyStoredProcedures.spUpdateEmployee,

                                       new List <Parameter> {
                new Parameter {
                    Name = spUpdateEmployeeParameters.pColumnName.ToString(), Value = columnName
                },
                new Parameter {
                    Name = spUpdateEmployeeParameters.pId.ToString(), Value = DatabasetablesHelpers.ConvertNameToInt(id)
                },
                new Parameter {
                    Name = spUpdateEmployeeParameters.pValue.ToString(), Value = value
                },
            }));
        }
Пример #9
0
        /// <summary>
        /// Add employee function
        /// </summary>
        /// <param name="firstName">Name</param>
        /// <param name="lastName">Last name</param>
        /// <param name="phone">Phone number</param>
        /// <param name="email">Email</param>
        /// <param name="birthDate">Birth date</param>
        /// <param name="locality">Locality</param>
        /// <param name="zip">ZIP code</param>
        /// <param name="throughfore">Throughfore</param>
        /// <param name="gender">Gender</param>
        /// <param name="position">Position</param>
        /// <returns></returns>
        public bool AddEmploee(string firstName, string lastName, string phone, string email, string birthDate, string locality, string zip, string throughfore, string gender, string position)
        {
            return(CallStoredProcedure(TravelAgencyStoredProcedures.spAddEmployee,

                                       new List <Parameter> {
                new Parameter {
                    Name = spAddEmployeeParameters.pFirst_name.ToString(), Value = firstName
                },
                new Parameter {
                    Name = spAddEmployeeParameters.pLast_name.ToString(), Value = lastName
                },
                new Parameter {
                    Name = spAddEmployeeParameters.pPhone.ToString(), Value = phone
                },
                new Parameter {
                    Name = spAddEmployeeParameters.pEmail.ToString(), Value = email
                },
                new Parameter {
                    Name = spAddEmployeeParameters.pBirth_date.ToString(), Value = birthDate
                },
                new Parameter {
                    Name = spAddEmployeeParameters.pLocality.ToString(), Value = locality
                },
                new Parameter {
                    Name = spAddEmployeeParameters.pZip.ToString(), Value = zip
                },
                new Parameter {
                    Name = spAddEmployeeParameters.pThoroughfore.ToString(), Value = throughfore
                },
                new Parameter {
                    Name = spAddEmployeeParameters.pGender.ToString(), Value = gender
                },
                new Parameter {
                    Name = spAddEmployeeParameters.pPosition.ToString(), Value = DatabasetablesHelpers.ConvertNameToInt(position)
                }
            }));
        }
Пример #10
0
        /// <summary>
        /// Delete reservation function
        /// </summary>
        /// <param name="reservationId">ID of reservation</param>
        public bool DeleteReservation(string reservationId)
        {
            return(CallStoredProcedure(TravelAgencyStoredProcedures.spDeleteReservation,

                                       new List <Parameter> {
                new Parameter {
                    Name = spDeleteReservationParameters.pOrder_id.ToString(), Value = DatabasetablesHelpers.ConvertNameToInt(reservationId)
                }
            }));
        }