コード例 #1
0
        int ChangePriceLuggage(Helper.Luggage oldLuggage, Helper.Luggage newLuggage)
        {
            int change = 0;

            int priceOld = ReserveTickets_2.getLuggagePrice(oldLuggage.Lenght, oldLuggage.Height, oldLuggage.Width);
            int priceNew = ReserveTickets_2.getLuggagePrice(newLuggage.Lenght, newLuggage.Height, newLuggage.Width);

            if (oldLuggage.IsDangerous && !newLuggage.IsDangerous)
            {
                change -= 50;
            }

            if (!oldLuggage.IsDangerous && newLuggage.IsDangerous)
            {
                change += 50;
            }

            return(change - (priceOld - priceNew));
        }
コード例 #2
0
        private void Valid_and_update(View row, int groudPosition)
        {
            if (_actualClick == groudPosition && !_hasClicked)
            {
                _hasClicked = true;
                var result = _DataList.luggages.Find(s => s.UserToken == _DataList.details.client[groudPosition].UserToken);
                if (result != null)
                {
                    if (Valid_luggage_field(row))
                    {
                        if (!Valid_luggage_field_if_change(row, result))
                        {
                            GlobalMemory._menuPage.setAlert("Brak zmian. ");
                        }
                        else
                        {
                            var newLuggage = Get_New_luggage(row, result);
                            // Zmieniono parametry bagazu
                            Helper.MySQLHelper.UpdateLuggage(newLuggage, _obj.connection);
                            Helper.MySQLHelper.UpdatePrice((_DataList.KosztRezerwacji + ChangePriceLuggage(result, newLuggage)).ToString(), _DataList.ReservationID.ToString(), _obj.connection);


                            GlobalMemory._menuPage.setAlert("Zmieniono parametry baga¿u pomyœlnie. ");
                            _obj.Finish();
                        }
                    }
                    else
                    {
                        // usunieto bagaz
                        float newPrice = _DataList.KosztRezerwacji;
                        if (result.IsDangerous)
                        {
                            newPrice -= 50;
                        }
                        newPrice -= ReserveTickets_2.getLuggagePrice(result.Lenght, result.Height, result.Width);
                        _DataList.details.client[groudPosition].UserToken = "brak";
                        string newJSON = JsonConvert.SerializeObject(new ClientShortJSON()
                        {
                            users = _DataList.details.client.ToArray()
                        });

                        Helper.MySQLHelper.DeleteLuggageAndChangePrice(result.LuggageID.ToString(), newJSON, newPrice.ToString(), _DataList.ReservationID.ToString(), _obj.connection);
                        GlobalMemory._menuPage.setAlert("Baga¿ zosta³ usuniêty dla klienta " + _DataList.details.client[groudPosition].ToStringWithoutToken() + ".");
                        _obj.Finish();
                    }
                }
                else
                {
                    // dodano bagaz
                    if (Valid_luggage_field(row))
                    {
                        string Token = Helper.GlobalHelper.generateIdentify();
                        _DataList.details.client[groudPosition].UserToken = Token;
                        string newJSON = JsonConvert.SerializeObject(new ClientShortJSON()
                        {
                            users = _DataList.details.client.ToArray()
                        });
                        Helper.Luggage newLuggage = Create_Luggage(row, Token);
                        Helper.MySQLHelper.InsertLuggage(newLuggage, newLuggage.ReservationID, _obj.connection);
                        float newPrice = _DataList.KosztRezerwacji + ReserveTickets_2.getLuggagePrice(newLuggage.Lenght, newLuggage.Height, newLuggage.Width);
                        if (newLuggage.IsDangerous)
                        {
                            newPrice += 50;
                        }
                        Helper.MySQLHelper.UpdateJSONAndPrice(newJSON, newPrice.ToString(), _DataList.ReservationID.ToString(), _obj.connection);
                        GlobalMemory._menuPage.setAlert("Baga¿ zosta³ dodany dla klienta " + _DataList.details.client[groudPosition].ToStringWithoutToken() + ".");
                        _obj.Finish();
                    }
                    else
                    {
                        GlobalMemory._menuPage.setAlert("Brak zmian. ");
                        _obj.Finish();
                    }
                }
            }
        }