C# programme probleme
Forum Programmation : C# programme probleme
Bonjour, j'essaye d'executer ce programme en c#
/*
* Created by SharpDevelop.
* User: Zip
* Date: 03/11/2004
* Time: 00:56
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
namespace aaaaa
{
/// <summary>
/// Description of MainForm.
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txb_ded;
private System.Windows.Forms.Label lbl_ded;
private System.Windows.Forms.Label lbl_rti;
private System.Windows.Forms.Button btn_rec;
private System.Windows.Forms.Label lbl_puiss;
private System.Windows.Forms.TextBox txb_puiss;
private System.Windows.Forms.TextBox txb_rest;
private System.Windows.Forms.Label lbl_rni;
private System.Windows.Forms.Button btn_quit;
private System.Windows.Forms.RadioButton rdb_fr;
private System.Windows.Forms.TextBox txb_dis;
private System.Windows.Forms.Label lbl_rest;
private System.Windows.Forms.Label lbl_abat;
private System.Windows.Forms.Button btn_calc;
private System.Windows.Forms.RadioButton rdb_forf;
private System.Windows.Forms.Label lbl_dis;
private System.Windows.Forms.GroupBox grp_ded;
private System.Windows.Forms.TextBox txb_rni;
private System.Windows.Forms.TextBox txb_rti;
private System.Windows.Forms.TextBox txb_abat;
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
[STAThread]
public static void Main(string[] args)
{
Application.Run(new MainForm());
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
this.txb_abat = new System.Windows.Forms.TextBox();
this.txb_rti = new System.Windows.Forms.TextBox();
this.txb_rni = new System.Windows.Forms.TextBox();
this.grp_ded = new System.Windows.Forms.GroupBox();
this.lbl_dis = new System.Windows.Forms.Label();
this.rdb_forf = new System.Windows.Forms.RadioButton();
this.btn_calc = new System.Windows.Forms.Button();
this.lbl_abat = new System.Windows.Forms.Label();
this.lbl_rest = new System.Windows.Forms.Label();
this.txb_dis = new System.Windows.Forms.TextBox();
this.rdb_fr = new System.Windows.Forms.RadioButton();
this.btn_quit = new System.Windows.Forms.Button();
this.lbl_rni = new System.Windows.Forms.Label();
this.txb_rest = new System.Windows.Forms.TextBox();
this.txb_puiss = new System.Windows.Forms.TextBox();
this.lbl_puiss = new System.Windows.Forms.Label();
this.btn_rec = new System.Windows.Forms.Button();
this.lbl_rti = new System.Windows.Forms.Label();
this.lbl_ded = new System.Windows.Forms.Label();
this.txb_ded = new System.Windows.Forms.TextBox();
this.grp_ded.SuspendLayout();
this.SuspendLayout();
//
// txb_abat
//
this.txb_abat.Location = new System.Drawing.Point(168, 288);
this.txb_abat.Name = "txb_abat";
this.txb_abat.ReadOnly = true;
this.txb_abat.TabIndex = 15;
this.txb_abat.Text = "";
//
// txb_rti
//
this.txb_rti.Location = new System.Drawing.Point(176, 16);
this.txb_rti.Name = "txb_rti";
this.txb_rti.Size = new System.Drawing.Size(88, 20);
this.txb_rti.TabIndex = 7;
this.txb_rti.Text = "";
//
// txb_rni
//
this.txb_rni.Location = new System.Drawing.Point(168, 320);
this.txb_rni.Name = "txb_rni";
this.txb_rni.ReadOnly = true;
this.txb_rni.TabIndex = 17;
this.txb_rni.Text = "";
//
// grp_ded
//
this.grp_ded.Controls.Add(this.txb_dis);
this.grp_ded.Controls.Add(this.txb_puiss);
this.grp_ded.Controls.Add(this.lbl_dis);
this.grp_ded.Controls.Add(this.lbl_puiss);
this.grp_ded.Controls.Add(this.rdb_fr);
this.grp_ded.Controls.Add(this.rdb_forf);
this.grp_ded.Location = new System.Drawing.Point(40, 56);
this.grp_ded.Name = "grp_ded";
this.grp_ded.Size = new System.Drawing.Size(328, 160);
this.grp_ded.TabIndex = 8;
this.grp_ded.TabStop = false;
this.grp_ded.Text = "Déduction";
//
// lbl_dis
//
this.lbl_dis.Location = new System.Drawing.Point(88, 120);
this.lbl_dis.Name = "lbl_dis";
this.lbl_dis.TabIndex = 3;
this.lbl_dis.Text = "Distance";
this.lbl_dis.Visible = false;
//
// rdb_forf
//
this.rdb_forf.Location = new System.Drawing.Point(40, 24);
this.rdb_forf.Name = "rdb_forf";
this.rdb_forf.TabIndex = 0;
this.rdb_forf.Text = "Forfaitaire";
this.rdb_forf.CheckedChanged += new System.EventHandler(this.Rdb_forfCheckedChanged);
//
// btn_calc
//
this.btn_calc.Location = new System.Drawing.Point(200, 360);
this.btn_calc.Name = "btn_calc";
this.btn_calc.TabIndex = 9;
this.btn_calc.Text = "Calculer";
this.btn_calc.Click += new System.EventHandler(this.Btn_calcClick);
//
// lbl_abat
//
this.lbl_abat.Location = new System.Drawing.Point(48, 288);
this.lbl_abat.Name = "lbl_abat";
this.lbl_abat.Size = new System.Drawing.Size(112, 23);
this.lbl_abat.TabIndex = 14;
this.lbl_abat.Text = "Abattement de 20%";
//
// lbl_rest
//
this.lbl_rest.Location = new System.Drawing.Point(48, 256);
this.lbl_rest.Name = "lbl_rest";
this.lbl_rest.TabIndex = 12;
this.lbl_rest.Text = "Reste Net";
//
// txb_dis
//
this.txb_dis.Location = new System.Drawing.Point(200, 120);
this.txb_dis.Name = "txb_dis";
this.txb_dis.TabIndex = 5;
this.txb_dis.Text = "";
this.txb_dis.Visible = false;
//
// rdb_fr
//
this.rdb_fr.Location = new System.Drawing.Point(40, 56);
this.rdb_fr.Name = "rdb_fr";
this.rdb_fr.TabIndex = 1;
this.rdb_fr.Text = "Frais réels";
this.rdb_fr.CheckedChanged += new System.EventHandler(this.Rdb_frCheckedChanged);
//
// btn_quit
//
this.btn_quit.Location = new System.Drawing.Point(304, 360);
this.btn_quit.Name = "btn_quit";
this.btn_quit.TabIndex = 19;
this.btn_quit.Text = "Quitter";
this.btn_quit.Click += new System.EventHandler(this.Btn_quitClick);
//
// lbl_rni
//
this.lbl_rni.Location = new System.Drawing.Point(48, 320);
this.lbl_rni.Name = "lbl_rni";
this.lbl_rni.Size = new System.Drawing.Size(120, 23);
this.lbl_rni.TabIndex = 16;
this.lbl_rni.Text = "Revenu Net Imposable";
//
// txb_rest
//
this.txb_rest.Location = new System.Drawing.Point(168, 256);
this.txb_rest.Name = "txb_rest";
this.txb_rest.ReadOnly = true;
this.txb_rest.TabIndex = 13;
this.txb_rest.Text = "";
//
// txb_puiss
//
this.txb_puiss.Location = new System.Drawing.Point(200, 88);
this.txb_puiss.Name = "txb_puiss";
this.txb_puiss.TabIndex = 4;
this.txb_puiss.Text = "";
this.txb_puiss.Visible = false;
//
// lbl_puiss
//
this.lbl_puiss.Location = new System.Drawing.Point(88, 88);
this.lbl_puiss.Name = "lbl_puiss";
this.lbl_puiss.TabIndex = 2;
this.lbl_puiss.Text = "Puissance";
this.lbl_puiss.Visible = false;
//
// btn_rec
//
this.btn_rec.Location = new System.Drawing.Point(88, 360);
this.btn_rec.Name = "btn_rec";
this.btn_rec.Size = new System.Drawing.Size(88, 24);
this.btn_rec.TabIndex = 18;
this.btn_rec.Text = "Recommencer";
this.btn_rec.Click += new System.EventHandler(this.Btn_recClick);
//
// lbl_rti
//
this.lbl_rti.Location = new System.Drawing.Point(40, 16);
this.lbl_rti.Name = "lbl_rti";
this.lbl_rti.Size = new System.Drawing.Size(128, 23);
this.lbl_rti.TabIndex = 0;
this.lbl_rti.Text = "Revenu Total Imposable";
//
// lbl_ded
//
this.lbl_ded.Location = new System.Drawing.Point(48, 224);
this.lbl_ded.Name = "lbl_ded";
this.lbl_ded.TabIndex = 10;
this.lbl_ded.Text = "Déduction 10%";
//
// txb_ded
//
this.txb_ded.Location = new System.Drawing.Point(168, 224);
this.txb_ded.Name = "txb_ded";
this.txb_ded.ReadOnly = true;
this.txb_ded.TabIndex = 11;
this.txb_ded.Text = "";
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(472, 398);
this.Controls.Add(this.btn_quit);
this.Controls.Add(this.btn_rec);
this.Controls.Add(this.txb_rni);
this.Controls.Add(this.lbl_rni);
this.Controls.Add(this.txb_abat);
this.Controls.Add(this.lbl_abat);
this.Controls.Add(this.txb_rest);
this.Controls.Add(this.lbl_rest);
this.Controls.Add(this.txb_ded);
this.Controls.Add(this.lbl_ded);
this.Controls.Add(this.btn_calc);
this.Controls.Add(this.grp_ded);
this.Controls.Add(this.txb_rti);
this.Controls.Add(this.lbl_rti);
this.Name = "MainForm";
this.Text = "Calcul d\'impôt";
this.grp_ded.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
void Btn_calcClick(object sender, System.EventArgs e)
{
//Calcul d'impôt déduction forfaitaire
const double tauxfor=0.1;
int ded=0, rest=0, abat=0, rni=0, rti=0;
if (rdb_forf.Checked == true)
{
//Calcul de la déduction de 10%
rti = (int)(Convert.ToInt32(txb_rti.Text));
ded = (int)(rti * tauxfor);
txb_ded.Text = Convert.ToString( ded );
//Calcul du reste net
rest = (int)(rti - ded);
txb_rest.Text = Convert.ToString(rest);
//Calcul Abattement de 20 %
abat = (int)(rest * 0.2);
txb_abat.Text = Convert.ToString(abat);
//Calcul Revenu Net Imposable
rni = (int)(rest - abat);
txb_rni.Text = Convert.ToString(rni);
}
else
{
if (Convert.ToInt32(txb_puiss.Text) <= 7)
{
if (Convert.ToInt32(txb_dis.Text) <= 5000)
{
//Calcul du taux de frais réels
ded = (int)(Convert.ToInt32(txb_dis.Text) * 0.469);
txb_ded.Text = Convert.ToString ( ded);
//Calcul du reste net
rest = ((Convert.ToInt32(txb_rti.Text)) - (Convert.ToInt32(txb_ded.Text)));
txb_rest.Text = Convert.ToString(rest);
//Calcul Abattement de 20 %
abat = ((int)(Convert.ToInt32(txb_rest.Text) * 0.2));
txb_abat.Text = Convert.ToString(abat);
//Calcul Revenu Net Imposable
rni = ((Convert.ToInt32(txb_rest.Text) - Convert.ToInt32(txb_abat.Text)));
txb_rni.Text = Convert.ToString(rni);
}
if (Convert.ToInt32(txb_dis.Text) <= 20000 && (Convert.ToInt32(txb_dis.Text) > 5000 ))
{
//Calcul du taux de frais réels
ded = (int)(1060 + (Convert.ToInt32(txb_dis.Text) * 0.257));
txb_ded.Text = Convert.ToString ( ded);
//Calcul du reste net
rest = ((Convert.ToInt32(txb_rti.Text)) - (Convert.ToInt32(txb_ded.Text)));
txb_rest.Text = Convert.ToString(rest);
//Calcul Abattement de 20 %
abat = ((int)(Convert.ToInt32(txb_rest.Text) * 0.2));
txb_abat.Text = Convert.ToString(abat);
//Calcul Revenu Net Imposable
rni = ((Convert.ToInt32(txb_rest.Text) - Convert.ToInt32(txb_abat.Text)));
txb_rni.Text = Convert.ToString(rni);
}
if (Convert.ToInt32(txb_dis.Text) > 20000 )
{
//Calcul du taux de frais réels
ded = (int)(Convert.ToInt32(txb_dis.Text) * 0.310);
txb_ded.Text = Convert.ToString ( ded);
//Calcul du reste net
rest = ((Convert.ToInt32(txb_rti.Text)) - (Convert.ToInt32(txb_ded.Text)));
txb_rest.Text = Convert.ToString(rest);
//Calcul Abattement de 20 %
abat = ((int)(Convert.ToInt32(txb_rest.Text) * 0.2));
txb_abat.Text = Convert.ToString(abat);
//Calcul Revenu Net Imposable
rni = ((Convert.ToInt32(txb_rest.Text) - Convert.ToInt32(txb_abat.Text)));
txb_rni.Text = Convert.ToString(rni);
}
}
}
{
if (Convert.ToInt32(txb_puiss.Text) > 7)
{
if (Convert.ToInt32(txb_dis.Text) <= 5000)
{
//Calcul du taux de frais réels
ded = (int)(Convert.ToInt32(txb_dis.Text) * 0.598);
txb_ded.Text = Convert.ToString ( ded);
//Calcul du reste net
rest = ((Convert.ToInt32(txb_rti.Text)) - (Convert.ToInt32(txb_ded.Text)));
txb_rest.Text = Convert.ToString(rest);
//Calcul Abattement de 20 %
abat = ((int)(Convert.ToInt32(txb_rest.Text) * 0.2));
txb_abat.Text = Convert.ToString(abat);
//Calcul Revenu Net Imposable
rni = ((Convert.ToInt32(txb_rest.Text) - Convert.ToInt32(txb_abat.Text)));
txb_rni.Text = Convert.ToString(rni);
}
if (Convert.ToInt32(txb_dis.Text) <= 20000 && (Convert.ToInt32(txb_dis.Text) > 5000 ))
{
//Calcul du taux de frais réels
ded = (int)(1280 + (Convert.ToInt32(txb_dis.Text) * 0.342));
txb_ded.Text = Convert.ToString ( ded);
//Calcul du reste net
rest = ((Convert.ToInt32(txb_rti.Text)) - (Convert.ToInt32(txb_ded.Text)));
txb_rest.Text = Convert.ToString(rest);
//Calcul Abattement de 20 %
abat = ((int)(Convert.ToInt32(txb_rest.Text) * 0.2));
txb_abat.Text = Convert.ToString(abat);
//Calcul Revenu Net Imposable
rni = ((Convert.ToInt32(txb_rest.Text) - Convert.ToInt32(txb_abat.Text)));
txb_rni.Text = Convert.ToString(rni);
}
if (Convert.ToInt32(txb_dis.Text) > 20000 )
{
//Calcul du taux de frais réels
ded = (int)(Convert.ToInt32(txb_dis.Text) * 0.406);
txb_ded.Text = Convert.ToString ( ded);
//Calcul du reste net
rest = ((Convert.ToInt32(txb_rti.Text)) - (Convert.ToInt32(txb_ded.Text)));
txb_rest.Text = Convert.ToString(rest);
//Calcul Abattement de 20 %
abat = ((int)(Convert.ToInt32(txb_rest.Text) * 0.2));
txb_abat.Text = Convert.ToString(abat);
//Calcul Revenu Net Imposable
rni = ((Convert.ToInt32(txb_rest.Text) - Convert.ToInt32(txb_abat.Text)));
txb_rni.Text = Convert.ToString(rni);
}
}
}
}
void Rdb_forfCheckedChanged(object sender, System.EventArgs e)
{
lbl_puiss.Visible = false;
lbl_dis.Visible = false;
txb_puiss.Visible = false;
txb_dis.Visible = false;
}
void Rdb_frCheckedChanged(object sender, System.EventArgs e)
{
lbl_puiss.Visible = true;
lbl_dis.Visible = true;
txb_puiss.Visible = true;
txb_dis.Visible = true;
}
void Btn_recClick(object sender, System.EventArgs e)
{
txb_rti.Text = "";
txb_dis.Text = "";
txb_puiss.Text = "";
txb_rest.Text = "";
txb_abat.Text = "";
txb_rni.Text = "";
txb_ded.Text = "";
}
void Btn_quitClick(object sender, System.EventArgs e)
{
Application.Exit();
}
}
}
Mais, lorsque je fais un calcul forfaitaire, il me dit qu'il y a une erreur, une exception non gérée ......
Sa fait des heures que je suis dessus alors une petite aide me ferait pas de mal ....
T'aurais pas une idée d'ou se situerai l'erreur?
Car vu l'immensité du code, je risque pas de la trouver sans perdre un oeil.
lol mdrr, bon j'ai réussi tout seul à trouver l'erreur enfin je ne l'ai pas retrouver j'ai fait un peu de rangement, puis un copier coller avec moderation pour tester le programme au fur à mesure...
Je pense que j'ai du faire une gaffe mais franchement je sais pas c'est quoi mais maintenant sa marche merci quand même...
Oki ;-).
Si t'as un problème lors de la compilation, met quelques infos dans ton programme qui t'informes du déroulement de celui ci.
Genre il t'affiche la valeur de chaque variable au fur et a mesure, meme si les debug sont la pour ça.
Et tant mieux si ta trouver d'ou sa venait, on auras pas a chercher ;-)
Il y a 2383 utilisateurs connus et inconnus. Pour voir la liste des connectés connus, cliquez ici.
