Esempio n. 1
0
        private void textBox2_Click_1(object sender, EventArgs e)
        {
            int validite = 0;

            if (txtmontant.Text.Equals("Champ montant vide"))
            {
                txtmontant.Text = "";
                validite        = 1;
            }



            string devise1 = "";
            string devise2 = "";
            string code1   = "a";
            string code2   = "";



            if (txtcodecompte1.Text.Equals(""))
            {
                txtcodecompte1.Visible = true;
                txtcodecompte1.Text    = "Remplissez ce champ";
                validite = 1;
            }
            else
            {
                try
                {
                    if (txtcodecompte1.Text.Equals("Remplissez ce champ"))
                    {
                        validite            = 1;
                        txtcodecompte1.Text = "";
                    }
                    else
                    {
                        bool cl = objetcompte.RechercherCompte(txtcodecompte1.Text);
                        devise1 = objetcompte.RecupererDevise();
                        code1   = objetcompte.RecupererNumeroCompte();
                        if (!cl.Equals(null))
                        {
                            string et = objetcompte.RecupererEtat();
                            if (et.Equals("desactiver"))
                            {
                                validite           = 1;
                                lberrorcp1.Visible = true;


                                lberrorcp1.Text = "Compte inactif";
                            }
                            else
                            {
                                lberrorcp1.Visible = true;

                                lberrorcp1.Text  = objetcompte.RecupererSolde() + " " + devise1;
                                lbdevise.Visible = true;
                                lbdevise.Text    = " " + devise1;
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    // MessageBox.Show("Compte inexistant");

                    lberror1.Visible   = true;
                    lberrorcp1.Visible = true;

                    lberrorcp1.Text = "Compte inexistant";
                    validite        = 1;
                }
            }

//////////////////////////////////////////////////////////////////////////////////////////////////////////////



            {
                if (txtcodecompte2.Text.Equals(""))
                {
                    txtcodecompte2.Visible = true;
                    txtcodecompte2.Text    = "Remplissez ce champ";
                    validite = 1;
                }
                else
                {
                    try
                    {
                        if (txtcodecompte2.Text.Equals("Remplissez ce champ"))
                        {
                            txtcodecompte2.Text = "";
                            validite            = 1;
                        }
                        else
                        {
                            bool cl = objetcompte.RechercherCompte(txtcodecompte2.Text);
                            devise2 = objetcompte.RecupererDevise();
                            code2   = objetcompte.RecupererNumeroCompte();
                            if (!cl.Equals(null))
                            {
                                string et = objetcompte.RecupererEtat();
                                if (et.Equals("desactiver"))
                                {
                                    validite           = 1;
                                    lberrorcp2.Visible = true;


                                    lberrorcp2.Text = "Compte inactif";
                                }
                                else
                                {
                                    lberrorcp2.Visible = true;

                                    lberrorcp2.Text = objetcompte.RecupererSolde() + " " + devise2;
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        // MessageBox.Show("Compte inexistant");

                        lberror2.Visible   = true;
                        lberrorcp2.Visible = true;

                        lberrorcp2.Text = "Compte inexistant";
                        validite        = 1;
                    }
                }
            }

            if (code1.Equals(code2))
            {
                MessageBox.Show("Transaction impossible car les comptes sont identiques! ", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.Size = new Size(505, 295);
                validite  = 1;
            }

            if (validite != 1)
            {
                if (devise1 != devise2)
                {
                    this.Size       = new Size(484, 389);
                    lbtaux.Visible  = true;
                    txttaux.Visible = true;
                }
                if (devise1.Equals(devise2))
                {
                    this.Size       = new Size(484, 384);
                    lbtaux.Visible  = false;
                    txttaux.Visible = false;
                }
            }
        }
Esempio n. 2
0
        private void bteffectuer_Click(object sender, EventArgs e)
        {
            int validite = 0;

            try
            {
                if (txtmontant.Text.Equals(""))
                {
                    MessageBox.Show("Le champ montant est vide", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    validite = 1;
                }
                else if (float.Parse(txtmontant.Text) < ((montantcompte * 25) / 100))
                {
                    validite = 1;

                    MessageBox.Show("La valeur du prêt ne doit pas être inferieur à 25% du montant du compte", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            catch
            {
                MessageBox.Show("Le champ montant doit avoir uniquement des valeurs numeriques", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                validite = 1;
            }



            //try
            //{
            //    if (txtmois.Text.Equals(""))
            //    {

            //        MessageBox.Show("Entrer le Nombre de mois", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //        validite = 1;

            //    }
            //    else if (int.Parse(txtmois.Text) <= 0)
            //    {

            //        validite = 1;

            //        MessageBox.Show("Le nombre de mois ne doit pas être inferieur ou egal a 0", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //    }
            //    else if (int.Parse(txtmois.Text) > 60)
            //    {

            //        validite = 1;

            //        MessageBox.Show("Le nombre de mois ne doit pas être superieur à 60\nla cooperative n'autorise pas les prets depassants 5 ans", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //    }
            //}

            //catch
            //{

            //    MessageBox.Show("Le nombre de mois doit avoir uniquement des valeurs numeriques", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            //    validite = 1;
            //}



            try
            {
                double pourcent;
                bool   cl  = objetcompte.RechercherCompte(txtcodecompte.Text);
                float  sol = objetcompte.RecupererSolde();

                pourcent = double.Parse(txtmontant.Text) * (0.15);
                if (sol < pourcent)
                {
                    MessageBox.Show("Le solde du compte est trop faible pour effectuer le pret.", "Impossible", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    validite = 1;
                }

                if (validite != 1)
                {
                    try
                    {
                        if (txttaux.Text.Equals(""))
                        {
                            MessageBox.Show("Entrer l'interet", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            validite = 1;
                        }
                        else if (float.Parse(txttaux.Text) <= 0)
                        {
                            validite = 1;

                            MessageBox.Show("L'interet ne doit pas être inferieur ou egal a 0", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else if (float.Parse(txttaux.Text) > 15)
                        {
                            validite = 1;

                            MessageBox.Show("L'interet ne doit pas être superieur à 15%!", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }

                    catch
                    {
                        MessageBox.Show("Le champ interet doit avoir uniquement des valeurs numeriques", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                        validite = 1;
                    }
                }



                /////////////////se la pouw komanse gade Petit Code Anle yo bon//////////////
                int moispayer = 0;
                if (float.Parse(txtmontant.Text) <= 1000)
                {
                    moispayer = 1;
                }
                else if (float.Parse(txtmontant.Text) <= 5000)
                {
                    moispayer = 2;
                }
                else if (float.Parse(txtmontant.Text) <= 10000)
                {
                    moispayer = 3;
                }
                else if (float.Parse(txtmontant.Text) <= 25000)
                {
                    moispayer = 4;
                }
                else if (float.Parse(txtmontant.Text) <= 50000)
                {
                    moispayer = 5;
                }
                else if (float.Parse(txtmontant.Text) <= 100000)
                {
                    moispayer = 6;
                }
                else if (float.Parse(txtmontant.Text) <= 500000)
                {
                    moispayer = 8;
                }
                else
                {
                    moispayer = 12;
                }
                //DateTime calcul = System.DateTime.Now.AddDays(txtxmois * 30);
                DateTime calcul = System.DateTime.Now.AddDays(moispayer * 30);
                string   dat    = calcul.ToShortDateString();

                //MessageBox.Show("le nombre de mois est: "+moispayer+" "+ dat);


                DateTime dat1 = System.DateTime.Now.Date;

                DateTime dat2   = DateTime.Parse(dat);
                string   datbon = dat2.Date.ToShortDateString();
                //MessageBox.Show(datbon);
                if (validite != 1)
                {
                    int comparaison = DateTime.Compare(dat1.Date, DateTime.Parse(datbon));

                    if (comparaison == 0)
                    {
                        MessageBox.Show("La date de remise ne doit pas être égale à la date actuelle.", "Impossible", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        validite = 1;
                    }
                    else if (comparaison > 0)
                    {
                        MessageBox.Show("La date de remise ne doit pas être antérieure à la date actuelle.", "Impossible", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        validite = 1;
                    }
                }

                bool cp3 = objetcompte.RechercherCompte(objetcompte.RecupererNumeroCompte());

                if (validite != 1)
                {
                    float    a              = float.Parse(txtmontant.Text);
                    string   ag             = null;
                    TimeSpan differencedate = DateTime.Parse(datbon) - dat1.Date;
                    //MessageBox.Show(differencedate.Days+"");
                    //MessageBox.Show(differencedate.Days/30+"");
                    int   jours      = differencedate.Days;
                    float jourenReel = jours / 30;
                    //MessageBox.Show(jourenReel+"");
                    float  pource      = float.Parse(txttaux.Text);
                    double interet     = pource / 100;
                    float  arembourser = (float.Parse(txtmontant.Text) * (jourenReel * pource / 100)) + float.Parse(txtmontant.Text);
                    //MessageBox.Show(arembourser.ToString());

                    float mois       = jourenReel;
                    float repartikob = arembourser / jourenReel;

                    //MessageBox.Show("" + repartikob);
                    DialogResult choix = MessageBox.Show("Nombre de mois:  " + moispayer + "\nDate de Remise: " + dat + "\nMontant à payer:  " + arembourser + " " + objetcompte.RecupererDevise() + "\nMontant de paie mensuel:  " + repartikob + " " + objetcompte.RecupererDevise() + "\n\nVoulez-vous effectuer le pret?", "Confirmation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (choix.Equals(DialogResult.Yes))
                    {
                        ag = objetpret.Pret(txtcodecompte.Text, objetcompte.RecupererNumeroClient(), a, txtdevise.Text, dat1.ToShortDateString(), datbon);

                        objetpret.PretPourRemboursement(txtcodecompte.Text, objetcompte.RecupererNumeroClient(), arembourser, txtdevise.Text, dat1.ToShortDateString(), datbon);
                        objetpret.parmois(txtcodecompte.Text, arembourser);
                        //co.enregistrerKobpeye(txtcodecompte.Text, arembourser);
                        if (ag == null)
                        {
                            MessageBox.Show("Pret non effectué", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Pret effectué avec succès!", "Succès", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Size = new Size(486, 186);
                            txtcodecompte.Focus();
                            txtcodecompte.Clear();
                            //lbdevise.Visible = false;
                            //lbdevise1.Visible = false;
                        }
                    }
                    else if (choix.Equals(DialogResult.No))
                    {
                        this.Close();
                    }
                }
            }
            //}
            catch (Exception) { }
        }