コード例 #1
0
        public void Add(Customer customer)
        {
            AirLineDAOMSSQL ald = new AirLineDAOMSSQL();

            if (ald.ExUserNameInCustomers(customer.USER_NAME) == true)
            {
                Console.WriteLine("The user name is already exist in airline companies department...");
            }
            else
            {
                try
                {
                    using (SqlConnection conn = new SqlConnection(FlightCenterConfig.connectionString))
                    {
                        SqlCommand cmd = new SqlCommand("ADD_INTO_CUSTOMER", conn);
                        cmd.Connection.Open();
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@firstName", customer.FIRST_NAME));
                        cmd.Parameters.Add(new SqlParameter("@lastName", customer.LAST_NAME));
                        cmd.Parameters.Add(new SqlParameter("@userName", customer.USER_NAME));
                        cmd.Parameters.Add(new SqlParameter("@password", customer.PASSWORD));
                        cmd.Parameters.Add(new SqlParameter("@address", customer.ADDRESS));
                        cmd.Parameters.Add(new SqlParameter("@phoneNo", customer.PHONE_NO));
                        cmd.Parameters.Add(new SqlParameter("@creditCardNumber", customer.CREDIT_CARD_NUMBER));
                        cmd.ExecuteNonQuery();
                        cmd.Connection.Close();
                    }
                }
                catch (SqlException e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
コード例 #2
0
        public void Update(Customer customer)
        {
            AirLineDAOMSSQL ald = new AirLineDAOMSSQL();

            if (ald.ExUserNameInCustomers(customer.USER_NAME) == true)
            {
                using (SqlConnection conn = new SqlConnection(FlightCenterConfig.connectionString))
                {
                    SqlCommand cmd = new SqlCommand("UpdateCustomer", conn);
                    cmd.Connection.Open();
                    cmd.Parameters.Add(new SqlParameter("@firstName", customer.FIRST_NAME));
                    cmd.Parameters.Add(new SqlParameter("@lastName", customer.LAST_NAME));
                    cmd.Parameters.Add(new SqlParameter("@userName", customer.USER_NAME));
                    cmd.Parameters.Add(new SqlParameter("@password", customer.PASSWORD));
                    cmd.Parameters.Add(new SqlParameter("@address", customer.ADDRESS));
                    cmd.Parameters.Add(new SqlParameter("@phone_No", customer.PHONE_NO));
                    cmd.Parameters.Add(new SqlParameter("@creaditCardNumber", customer.CREDIT_CARD_NUMBER));
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.ExecuteNonQuery();
                    cmd.Connection.Close();
                }
            }
            else
            {
                Console.WriteLine($"There is no such a company - {customer.FIRST_NAME}");
            }
        }
コード例 #3
0
        public bool DataBaseStatus()
        {
            AirLineDAOMSSQL  alDAO   = new AirLineDAOMSSQL();
            CountryDAOMSSQL  cDAO    = new CountryDAOMSSQL();
            CustomerDAOMSSQL custDAO = new CustomerDAOMSSQL();

            if (alDAO.GetAll().Count() == 0 && cDAO.GetAll().Count() == 0 && custDAO.GetAll().Count() == 0)
            {
                return(true);
            }
            return(false);
        }
コード例 #4
0
        public void Remove(Customer customer)
        {
            AirLineDAOMSSQL ald = new AirLineDAOMSSQL();

            if (ald.ExUserNameInCustomers(customer.USER_NAME) == true)
            {
                using (SqlConnection conn = new SqlConnection(FlightCenterConfig.connectionString))
                {
                    SqlCommand cmd = new SqlCommand("RemoveCustomer", conn);
                    cmd.Connection.Open();
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@password", customer.PASSWORD));
                    cmd.ExecuteNonQuery();
                    cmd.Connection.Close();
                }
            }
            else
            {
                Console.WriteLine($"There is no such a customer - {customer.FIRST_NAME}");
            }
        }