Duckvader

calculateur de taxe

2 messages dans ce sujet

Petite application pratique pour calculer la taxe :)

58d842518cc5f_Screenshot(5).png.fe26214a5d61b41c4e7b4e61fd96ed82.png

CODE C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TaxCalc
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    /// 
    //variable glocal


    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void btnCalcul_Click(object sender, RoutedEventArgs e)
        {
            bool vrai = false;
            while (vrai == false)

            {
                //enter montant achat             
                string montant = txbPrix.Text;
                if (montant.ToString() == "")
                {
                    lbl_1.Text = "*";
                }
                else
                {
                    vrai = true;
                }

                //entree tps 5%
                string tps = txbTPS.Text;
                if (tps.ToString() == "")
                {
                    lbl_2.Text = "*";
                }
                else
                {
                    vrai = true;
                }

                //entree tvq 9.975%
                string tvq = txbTVQ.Text;
                if (tvq.ToString() == "")
                {
                    lbl_3.Text = "*";

                }
                else
                {
                    vrai = true;
                }

                try
                {
                    double total = Convert.ToDouble(montant) * Convert.ToDouble(tps) / 100 + Convert.ToDouble(montant) * Convert.ToDouble(tvq) / 100 + Convert.ToDouble(montant);

                    txbTotal.Text = (total + "$");
                    txbPrix.Text = "";
                    txbTPS.Text = "";
                    txbTVQ.Text = "";
                }
                catch (Exception)
                {
                    MessageBox.Show("Erreur veuillez remplir les *");
                    vrai = true;
                }
            }
        }

        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Le signe décimal en anglais est le (.) ex 49.99 Le signe décimal en français est la (,) ex 49,99");
        }
    }
}

CODE XAML :

<Window x:Class="TaxCalc.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Currency_taxe"
        mc:Ignorable="d"
        Title="TaxCalc" Height="240" Width="205" Background="#FF2C2C2C" ResizeMode="NoResize">
    <Window.Resources>
        <Style x:Key="style" TargetType="Control">
            <Setter Property="FontSize" Value="11"/>
            <Setter Property="Foreground" Value="White" />
            <Setter Property="FontFamily" Value="Segoe UI" />
        </Style>

        <Style x:Key="style2" TargetType="Control">
            <Setter Property="Background" Value="GhostWhite" />

        </Style>

    </Window.Resources>


    <Grid x:Name="LabelTxbox">
        <Label x:Name="lblPrix" Content="Prix" HorizontalAlignment="Left" Margin="10,39,0,0" VerticalAlignment="Top" Style="{StaticResource style}"/>
        <Label x:Name="lblTotal" Content="Total :" HorizontalAlignment="Left" Margin="7,138,0,0" VerticalAlignment="Top" Style="{StaticResource style}"/>
        <Label x:Name="lblTVQ" Content="TVQ" HorizontalAlignment="Left" Margin="10,95,0,0" VerticalAlignment="Top" Style="{StaticResource style}"/>
        <Label x:Name="lblTPS" Content="TPS" HorizontalAlignment="Left" Margin="10,67,0,0" VerticalAlignment="Top" Style="{StaticResource style}"/>

        <TextBox x:Name="txbPrix" HorizontalAlignment="Left" Height="23" Margin="53,42,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" Style="{StaticResource style2}"/>
        <TextBox x:Name="txbTPS" HorizontalAlignment="Left" Height="23" Margin="53,70,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="38" Style="{StaticResource style2}"/>
        <TextBox x:Name="txbTVQ" HorizontalAlignment="Left" Height="23" Margin="53,98,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="38" Style="{StaticResource style2}"/>
        <TextBlock x:Name="txbTotal" HorizontalAlignment="Left" Margin="53,143,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="112" Text="______________________" Foreground="White"/>


        <Grid x:Name="grid2">
            <Rectangle Fill="#FF2B9FD4" HorizontalAlignment="Left" Height="11" Margin="0,128,0,0" Stroke="#FF2B9FD4" VerticalAlignment="Top" Width="199" RenderTransformOrigin="0.5,0.5" Opacity="0.5"/>

            <Button x:Name="btnCalcul" Content="Calculer" HorizontalAlignment="Left" Margin="53,164,0,0" VerticalAlignment="Top" Width="75" Click="btnCalcul_Click"/>
            <Menu x:Name="menu" HorizontalAlignment="Stretch" Height="19" VerticalAlignment="Top" >
                <MenuItem Header="Fichier">
                    <MenuItem Header="Fermer" ToolTip="fermer l'app" Click="MenuItem_Click"/>
                </MenuItem>
                <MenuItem Header="aide" ToolTip="aide sur l'apps" Click="MenuItem_Click_1"/>
            </Menu>
            <TextBlock x:Name="lbl_3" HorizontalAlignment="Left" Margin="95,101,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="33" Foreground="#FFFB0000"/>
            <TextBlock x:Name="lbl_2" HorizontalAlignment="Left" Margin="95,73,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="33" Foreground="#FFFB0000"/>
            <TextBlock x:Name="lbl_1" HorizontalAlignment="Left" Margin="176,46,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="23" Foreground="#FFFB0000"/>
        </Grid>
    </Grid>
</Window>

 

1

Partager ce message


Lien à poster
Partager sur d’autres sites

Créer un compte ou se connecter pour commenter

Vous devez être membre afin de pouvoir déposer un commentaire

Créer un compte

Créez un compte sur notre communauté. C’est facile !


Créer un nouveau compte

Se connecter

Vous avez déjà un compte ? Connectez-vous ici.


Connectez-vous maintenant