public void Initialize(BusinessLayer.Person kunde, BusinessLayer.Transaction transaction, BusinessLayer.Position position, BusinessLayer.Artikel artikel)
        {
            _kunde = kunde;
            _transaction = transaction;
            _tempPosition = position;
            _article = artikel;

            // set the modus
            if (position == null)
                this._modus = EditMode.INSERT;
            else
                this._modus = EditMode.UPDATE;
            
        }
        /// <summary>
        /// Fill Artikel control, Einheit, Waehrung
        /// </summary>
        /// <param name="country">The Country to fill the controls.</param>
        public void UpdateArtikel(BusinessLayer.Artikel artikel)
        {
            if (artikel == null)
                return;

            // Set the insert modus
            this._modus = EditMode.INSERT;
            this._tempPosition = BusinessLayer.Position.Create();

            string CompleteString = "";
            if (artikel.Bez2 != "")
                CompleteString = artikel.Bez2;

            if (artikel.Bez3 != "")
            {
                if (CompleteString != "")
                    CompleteString += " / " + artikel.Bez3;
                else
                    CompleteString = artikel.Bez3;
            }

            if (artikel.Bez4 != "")
            {
                if (CompleteString != "")
                    CompleteString += " / " + artikel.Bez4;
                else
                    CompleteString = artikel.Bez4;
            }

            if (artikel.Bez5 != "")
            {
                if (CompleteString != "")
                    CompleteString += " / " + artikel.Bez5;
                else
                    CompleteString = artikel.Bez5;
            }

            if (artikel.Bez6 != "")
            {
                if (CompleteString != "")
                    CompleteString += " / " + artikel.Bez6;
                else
                    CompleteString = artikel.Bez6;
            }

            if (artikel.Version != "")
            {
                if (CompleteString != "")
                    CompleteString += " / " + artikel.Version ;
                else
                    CompleteString = artikel.Version ;
            }

            TxtArtikel.Text = artikel.Nummer + " - " + artikel.Bez1 + " " + CompleteString;

            // Set the default VkMenge
            if (artikel.VkMenge == "0")
                TxtMenge.Text = "1";
            else
                TxtMenge.Text = artikel.VkMenge;

            // set the global member for the selected Artikel
            _article = artikel;

            // fill the other controls
            LblEinheit.Text = artikel.Einheit;
            LblPositionWertEin.Text = artikel.Waehrung;
            LblGesamtWertEinheit.Text = artikel.Waehrung;

            // Calculate the price for this article
            CalculateItemPrice();
        }
        public TBPositionEdit (BusinessLayer.Transaction transaction, BusinessLayer.Position position) : base ( )
        {
            _transaction = transaction;
            _tempPosition = position;

        }
        public void CalculateTransactionPositionPrice()
        {
            // First get the values
            string kundeID;
            if (TxtArtikel.Text == "")
                return;


            if (_kunde == null)
                kundeID = "0";
            else
                kundeID = _kunde.ID;

            float floatMenge = 0;
            var canConvert = float.TryParse(TxtMenge.Text, out floatMenge);
            if (!canConvert)
                TxtMenge.Text = "0";

            if (TxtMenge.Text.Trim() == "" || TxtMenge.Text == "0")
                return;
            
            // Get the price for the the item and the whole transition
            if (_tempPosition.ID == null || _tempPosition.ID == "" || _tempPosition.ID == "0")
            {
                
                _tempPosition.Preis = TxtPreis.Text;
                _tempPosition.Rabatt1 = TxtRabatt.Text;
                _tempPosition.PreisMenge = TxtMengePreis.Text;
                _tempPosition = _transaction.GetPreisBeforeCommit(_tempPosition, kundeID, _article, TxtLieferDatum.Text, TxtMenge.Text, Language.GetLanguageCode(), ref Application._user);

            }
            else
            {

                _tempPosition.Preis = TxtPreis.Text;
                _tempPosition.Rabatt1 = TxtRabatt.Text;
                _tempPosition.PreisMenge = TxtMengePreis.Text;

                _tempPosition = _transaction.GetPreisBeforeCommit(_tempPosition, kundeID, _article, TxtLieferDatum.Text, TxtMenge.Text, Language.GetLanguageCode(), ref Application._user);

            }

            // Insert the price data in the controls
            TxtGesamtWert.Text = _tempPosition.KpfWert;
            TxtPositionWert.Text = _tempPosition.Wert;


        }
Ejemplo n.º 5
0
        async public Task CalculateTransactionPositionPriceAsync()
        {
            // First get the values
            string kundeID;
            if (tvArtikel.Text == "")
                return;


            if (_person == null)
                kundeID = "0";
            else
                kundeID = _person.ID;

            float floatMenge = 0;
            var canConvert = float.TryParse(edMenge.Text, out floatMenge);
            if (!canConvert)
                edMenge.Text = "0";

            if (edMenge.Text.Trim() == "" || edMenge.Text == "0")
                return;

            // Get the price for the the item and the whole transition
            if (_tempPosition.ID == null || _tempPosition.ID == "" || _tempPosition.ID == "0")
            {

                _tempPosition.Preis = edArtikelPrice.Text;
                _tempPosition.Rabatt1 = edRabatt.Text;
                _tempPosition.PreisMenge = edPerPrice.Text;
                _tempPosition = await _transaction.GetPreisBeforeCommitAsync(_tempPosition, kundeID, _artikel, edLiefDatum.Text, edMenge.Text, Utilities.GetCurrentLanguage(MainActivity._mainActivity), MainActivity.User);               

            }
            else
            {

                _tempPosition.Preis = edArtikelPrice.Text;
                _tempPosition.Rabatt1 = edRabatt.Text;
                _tempPosition.PreisMenge = edPerPrice.Text;
                _tempPosition = await _transaction.GetPreisBeforeCommitAsync(_tempPosition, kundeID, _artikel, edLiefDatum.Text, edMenge.Text,  Utilities.GetCurrentLanguage(MainActivity._mainActivity), MainActivity.User);               

            }

            // Insert the price data in the controls
            tvTotalWert.Text = _tempPosition.KpfWert;
            tvPositionsWert.Text = _tempPosition.Wert;


        }
        /// <summary>
        /// Calculates the price of the current position
        /// </summary>
        public void CalculateItemPrice()
        {
            // First get the values
            string kundeID;
            if (TxtArtikel.Text == "")
                return;

            if (TxtMenge.Text.Trim() == "")
                TxtMenge.Text = "0";

            if (_kunde == null)
                kundeID = "0";
            else
                kundeID = _kunde.ID;

            float floatMenge = 0;
            var canConvert = float.TryParse(TxtMenge.Text, out floatMenge);
            if (!canConvert)
                TxtMenge.Text = "0";

            // Get the price from the DB
            // If we are updating a transaction, we should save our global _tempPosition that contains the ID (otherwise the ID will be reseted to 0)
            BusinessLayer.Position tempPos;
            if (_tempPosition.ID == null || _tempPosition.ID == "" || _tempPosition.ID == "0")
            {
                _tempPosition = _transaction.GetPositionPreis(kundeID, _article, TxtLieferDatum.Text, TxtMenge.Text, Language.GetLanguageCode(), ref Application._user);               
            }
            else
            {
                tempPos = _transaction.GetPositionPreis(kundeID, _article, TxtLieferDatum.Text, TxtMenge.Text, Language.GetLanguageCode(), ref Application._user);
                _tempPosition.Preis = tempPos.Preis;
                _tempPosition.PreisMenge = tempPos.PreisMenge;
                _tempPosition.Rabatt1 = TxtRabatt.Text;
            }

            // Insert the price data in the controls
            if (_tempPosition.Preis != "0,00")
                TxtPreis.Text = _tempPosition.Preis;
            LblGesamtWertEinheit.Text = _tempPosition.Waehrung;
            LblPositionWertEin.Text = _tempPosition.Waehrung;
            TxtMengePreis.Text = _tempPosition.PreisMenge;
            LblMengePreisEinheit.Text = _tempPosition.PreisMengeEinheit;

            // Calculate transaction and position price if there is an item price
            if (TxtPreis.Text != "0")
                this.CalculateTransactionPositionPrice();

        }
Ejemplo n.º 7
0
        async public Task CalculateItemPriceAsync()
        {
            // First get the values
            string kundeID;
            if (tvArtikel.Text == "")
                return;

            if (edMenge.Text.Trim() == "")
                edMenge.Text = "0";

            if (_person == null)
                kundeID = "0";
            else
                kundeID = _person.ID;

            float floatMenge = 0;
            var canConvert = float.TryParse(edMenge.Text, out floatMenge);
            if (!canConvert)
                edMenge.Text = "0";

            // Get the price from the DB
            // If we are updating a transaction, we should save our global _position that contains the ID (otherwise the ID will be reseted to 0)
            BusinessLayer.Position tempPos;
            if (_tempPosition.ID == null || _tempPosition.ID == "" || _tempPosition.ID == "0")
            {
                _tempPosition = await _transaction.GetPositionPreisAsync(kundeID, _artikel, edLiefDatum.Text, edMenge.Text,  Utilities.GetCurrentLanguage(MainActivity._mainActivity), MainActivity.User);               
            }
            else
            {
                tempPos = await _transaction.GetPositionPreisAsync(kundeID, _artikel, edLiefDatum.Text, edMenge.Text, Utilities.GetCurrentLanguage(MainActivity._mainActivity), MainActivity.User);               
                _tempPosition.Preis = tempPos.Preis;
                _tempPosition.PreisMenge = tempPos.PreisMenge;
                _tempPosition.Rabatt1 = edRabatt.Text;
            }

            // Insert the price data in the controls
            if (_tempPosition.Preis != "0,00")
                edArtikelPrice.Text = _tempPosition.Preis;
            tvTotalWertEinheit.Text = _tempPosition.Waehrung;
            tvPositionsWertEinheit.Text = _tempPosition.Waehrung;
            edPerPrice.Text = _tempPosition.PreisMenge;
            tvPerPriceEinheit.Text = _tempPosition.PreisMengeEinheit;

            // Calculate transaction and position price if there is an item price
            if (edArtikelPrice.Text != "0")
                await this.CalculateTransactionPositionPriceAsync();

        }
Ejemplo n.º 8
0
        async public void UpdateArtikelAsync(BusinessLayer.Artikel artikel)
        {
            if (artikel == null)
                return;

            // set the insert modus
            this._modus = EditMode.INSERT;
            this._tempPosition = BusinessLayer.Position.Create();

            string CompleteString = "";
            if (artikel.Bez2 != "")
                CompleteString = artikel.Bez2;

            if (artikel.Bez3 != "")
            {
                if (CompleteString != "")
                    CompleteString += " / " + artikel.Bez3;
                else
                    CompleteString = artikel.Bez3;
            }

            if (artikel.Bez4 != "")
            {
                if (CompleteString != "")
                    CompleteString += " / " + artikel.Bez4;
                else
                    CompleteString = artikel.Bez4;
            }

            if (artikel.Bez5 != "")
            {
                if (CompleteString != "")
                    CompleteString += " / " + artikel.Bez5;
                else
                    CompleteString = artikel.Bez5;
            }

            if (artikel.Bez6 != "")
            {
                if (CompleteString != "")
                    CompleteString += " / " + artikel.Bez6;
                else
                    CompleteString = artikel.Bez6;
            }

            if (artikel.Version != "")
            {
                if (CompleteString != "")
                    CompleteString += " / " + artikel.Version ;
                else
                    CompleteString = artikel.Version ;
            }

            tvArtikel.Text = artikel.Nummer + " - " + artikel.Bez1 + " " + CompleteString;

            // Set the default VkMenge
            if (artikel.VkMenge == "0")
                edMenge.Text = "1";
            else
                edMenge.Text = artikel.VkMenge;

            // set the global member for the selected Artikel
            _artikel = artikel;

            // fill the other controls
            tvQuantityEinheit.Text = artikel.Einheit;
            tvPositionsWertEinheit.Text = artikel.Waehrung;
            tvTotalWertEinheit.Text = artikel.Waehrung;

            // Calculate the price for this article
            await CalculateItemPriceAsync();
        }
Ejemplo n.º 9
0
        void _lvPositions_ItemClick (object sender, AdapterView.ItemClickEventArgs e)
        {
            try
            {
                if (MainActivity.User.NetworkStatus == NetworkState.Disconnected)
                    return ;
                
                _lvPositions.ChoiceMode = ChoiceMode.Single;
                _lvPositions.SetItemChecked (e.Position ,true);
                _adapter.SelectedPosition = _transaction.Positions[e.Position];
               _tempPosition = _transaction.Positions[e.Position];

                for(int i = 0 ; i < _transaction.Positions.Count; i++)
                {
                    if (i != e.Position)
                        _transaction.Positions[e.Position].Clicked = false;
                    else
                        _transaction.Positions[e.Position].Clicked = true;

                }

                this.RunPositionEditDlg(EditMode.UPDATE);
            }
            catch(Exception ex)
            {
                ExceptionWriter.WriteLogFile(ex);
            }

        }
Ejemplo n.º 10
0
        private void OfflineDataYesClicked (object sender, DialogClickEventArgs e)
        {
            try
            {
                int index = _transaction.Positions.FindIndex(x => x.ID == _tempPosition.ID);
                if (_transaction.DeletePosition(index,MainActivity.User))
                {       
                    Toast.MakeText (_context, _context.Resources.GetString(Resource.String.DeletedSuccessfully),ToastLength.Short);

                    tvWert.Text = _transaction.Wert;

                    // refresh the listview 
                    _adapter = new PositionViewAdapter (_context, _transaction.Positions);
                    _lvPositions.Adapter = _adapter;

                    _tempPosition = null;

                    // something has changed 
                    // sometimes I am confused if I am an genius or an human 
                    // if you ain't asking that yourself, you understand a shit about my code 
                    bChanged = true;

                }
            }
            catch(Exception ex)
            {
                ExceptionWriter.WriteLogFile(ex);
            }

        }
Ejemplo n.º 11
0
        void _lvPositions_ItemLongClick (object sender, AdapterView.ItemLongClickEventArgs e)
        {
            try
            {
                
                // show the delete button
                BtnDeletePosition.Visibility = ViewStates.Visible;

                // set the currect selectedItem -> PositionViewAdapter.GetView makes the background to grey #DBDBDB
                _lvPositions.ChoiceMode = ChoiceMode.Single;
                _lvPositions.SetItemChecked (e.Position ,true);
                _adapter.SelectedPosition = _transaction.Positions[e.Position];
                _tempPosition = _transaction.Positions[e.Position];

                for(int i = 0 ; i < _transaction.Positions.Count; i++)
                {
                    if (i != e.Position)
                        _transaction.Positions[e.Position].Clicked = false;
                    else
                        _transaction.Positions[e.Position].Clicked = true;

                } 
            }
        
            catch(Exception ex)
            {
                ExceptionWriter.WriteLogFile(ex);
            }

        //
        }