Esempio n. 1
0
        protected void editLinkButton_Command(object sender, CommandEventArgs e)
        {
            long listicId   = Convert.ToInt64(e.CommandArgument);
            var  linkButton = sender as LinkButton;

            // We want to hide clicked icon in the grid
            // to know which record (row in the grid) is being edited.
            if (linkButton != null)
            {
                linkButton.Visible = false;
            }

            if (e.CommandName == "edit")
            {
                editPanel.Visible = true;
                IsEditMode        = true;

                // Put ListicId in the ToolTip of the text box
                // so it can be used to find record before updating it.
                vrijemeUplateTextBox.ToolTip = listicId.ToString();

                var listic = _listicRepository.GetListic(listicId);
                vrijemeUplateTextBox.Text  = listic.VrijemeUplate.ToString();
                iznosUplateTextBox.Text    = listic.IznosUplate.ToString();
                iznosUplateTextBox.ToolTip = listic.UpdateDate.ToString();
            }
            else if (e.CommandName == "link")
            {
                Response.Redirect($"~/Oklade.aspx?listicId={listicId}");
            }
        }
Esempio n. 2
0
        protected void saveLinkButton_Click(object sender, EventArgs e)
        {
            // Add new record
            var oklada = new Core.UIModel.Oklada
            {
                ListicId = ListicId,
                PonudaId = long.Parse(ponudaDropDownList.SelectedValue)
            };

            var ponuda = _ponudaRepository.GetPonuda(oklada.PonudaId);

            oklada.Koeficient = ponuda.Koeficient;

            try
            {
                var oklade         = _okladaRepository.GetOkladas(ListicId);
                var okladePlusNova = oklade.Concat(new Core.UIModel.Oklada[] { oklada }).ToArray();
                var listic         = _listicRepository.GetListic(ListicId);
                var moguciDobitak  = _listicRepository.CalculateMoguciDobitak(ListicId, listic.IznosUplate, okladePlusNova);
                _listicRepository.ValidateMoguciDobitak(ListicId, moguciDobitak, okladePlusNova);

                _okladaRepository.Add(oklada);
            }
            catch (Exception ex)
            {
                _logger.Error($"Failed to add oklada to listić. Error: {ex.Message}");
                MessageManager.ShowMessage(this, ex.Message);
            }

            try
            {
                _okladaRepository.Save();
                _listicRepository.UpdateMoguciDobitak(ListicId);
                editPanel.Visible = false;
                Search();
            }
            catch
            {
                MessageManager.ShowMessage(this, "Ta oklada je već dodana na ovaj listić!");
            }
        }