Advertisement
ivana_andreevska

АВ2 Задача 6

Mar 10th, 2022
1,091
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.30 KB | None | 0 0
  1. <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="AV2.WebForm1" %>
  2. <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
  3.     <div class="container-fluid">
  4.  
  5.         <div class="row text-center ">
  6.  
  7.             <div class="m-4">
  8.                 Внесете име на валута
  9.                 <br />
  10.                 <asp:TextBox ID="ImeValuta" runat="server"></asp:TextBox>
  11.             </div>
  12.  
  13.             <div class="m-4">
  14.                 Внесете вредност на валута
  15.                 <br />
  16.                 <asp:TextBox ID="VrednostValuta" runat="server"></asp:TextBox>
  17.             </div>
  18.                
  19.             <div class="m-4">
  20.                 <asp:Button ID="DodadiValuta" runat="server" Text="Додади Валута" OnClick="DodadiValuta_Click" />
  21.                 <asp:Button ID="IzbrisiValuta" runat="server" Text="Избриши Валута" OnClick="IzbrisiValuta_Click" />
  22.             </div>
  23.  
  24.             <hr />
  25.  
  26.             <div class="m-4">
  27.                 <asp:RadioButtonList ID="ListaValuti" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ListaValuti_SelectedIndexChanged"></asp:RadioButtonList>
  28.             </div>
  29.               <hr />
  30.              
  31.            
  32.            
  33.             <hr />
  34.              <div class="m-4">
  35.                Вкупно валути: <asp:Label ID="total" runat="server" Text="0"></asp:Label>
  36.             </div>
  37.  
  38.             <br />
  39.             <hr />
  40.  
  41.              <div class="m-4">
  42.                Внесете валута: <asp:TextBox ID="vrednost" runat="server"></asp:TextBox>
  43.             </div>
  44.             <br />
  45.  
  46.             <div class="m-4">
  47.                 Статус:  <asp:Label ID="status" runat="server" Text="0"></asp:Label>
  48.             </div>
  49.  
  50.  
  51.  
  52.         </div>
  53.  
  54.     </div>
  55. </asp:Content>
  56.  
  57.  using System;
  58. using System.Collections.Generic;
  59. using System.Linq;
  60. using System.Web;
  61. using System.Web.UI;
  62. using System.Web.UI.WebControls;
  63.  
  64. namespace AV2
  65. {
  66.     public partial class WebForm1 : System.Web.UI.Page
  67.     {
  68.         protected void Page_Load(object sender, EventArgs e)
  69.         {
  70.  
  71.         }
  72.  
  73.         protected void DodadiValuta_Click(object sender, EventArgs e)
  74.         {
  75.             ListItem item = new ListItem(ImeValuta.Text, VrednostValuta.Text);
  76.             ListaValuti.Items.Add(item);
  77.             ImeValuta.Text = "";
  78.             VrednostValuta.Text = "";
  79.             updateTotal();
  80.         }
  81.  
  82.         protected void IzbrisiValuta_Click(object sender, EventArgs e)
  83.         {
  84.             if(ListaValuti.SelectedIndex!=-1)
  85.             {
  86.                 ListaValuti.Items.Remove(ListaValuti.SelectedItem);
  87.                 updateTotal();
  88.             }
  89.             else
  90.             {
  91.                 status.Text = "Nemate selektirano nitu edna valuta!";
  92.             }
  93.         }
  94.  
  95.         private void updateTotal()
  96.         {
  97.             total.Text = ListaValuti.Items.Count.ToString();
  98.         }
  99.  
  100.         protected void ListaValuti_SelectedIndexChanged(object sender, EventArgs e)
  101.         {
  102.             int value=Convert.ToInt32(ListaValuti.SelectedValue);
  103.             status.Text=Convert.ToString(Convert.ToInt32(vrednost.Text)* value);
  104.         }
  105.     }
  106. }
  107.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement