Exemple #1
0
        protected void btnValideAvance_Click(object sender, EventArgs e)
        {
            #region declaration
            crlPrelevement prelevement = null;
            #endregion

            #region implementation
            if (hfAutorisationDepart.Value != "")
            {
                try
                {
                    if (serviceRecuAD.isValideMontant(double.Parse(TextMontant.Text), hfAutorisationDepart.Value))
                    {
                        prelevement = new crlPrelevement();

                        prelevement.agent          = agent;
                        prelevement.MatriculeAgent = agent.matriculeAgent;
                        try
                        {
                            prelevement.MontantPrelevement = double.Parse(TextMontant.Text);
                        }
                        catch (Exception)
                        {
                        }
                        prelevement.NumAutorisationDepart = hfAutorisationDepart.Value;
                        prelevement.TypePrelevement       = ddlTypeRecuAD.SelectedValue;

                        prelevement.NumPrelevement = servicePrelevement.insertPrelevement(prelevement);

                        if (prelevement.NumPrelevement != "")
                        {
                            this.initialiseFormulaireAvance();
                            this.initialiseGridRecuAD();
                            this.initialiseGridPrelevement();

                            /*hfPrelevement.Value = prelevement.NumPrelevement;
                             * btnModifier.Enabled = true;
                             * btnValideAvance.Enabled = false;*/
                            /*
                             * autorisationDepart = serviceAutorisationDepart.selectAutorisationDepart(hfAutorisationDepart.Value);
                             * autorisationDepart.ResteRegle = autorisationDepart.ResteRegle - prelevement.MontantPrelevement;
                             * serviceAutorisationDepart.updateAutorisationDepart(autorisationDepart);
                             *
                             *
                             * this.afficheAutorisationDepart(hfAutorisationDepart.Value);
                             */


                            this.divIndicationText("Prélèvement N°" + prelevement.NumPrelevement + " bien enregistrer! Montant: " + serviceGeneral.separateurDesMilles(prelevement.MontantPrelevement.ToString("0")) + "Ar", "Black");
                        }
                        else
                        {
                            this.divIndicationText(ReAvanceAutorisationDepart.avanceNonEnregistre, "red");
                        }
                    }
                    else
                    {
                        this.divIndicationText(ReAvanceAutorisationDepart.prixNonValide, "red");
                    }
                }
                catch (Exception)
                {
                    this.divIndicationText(ReAvanceAutorisationDepart.erreurSurMontant, "red");
                }
            }
            else
            {
                this.divIndicationText(ReAvanceAutorisationDepart.autorisatrionDepartNonSelectionner, "red");
            }
            #endregion
        }
Exemple #2
0
        protected void btnValideAvance_Click(object sender, EventArgs e)
        {
            #region declaration
            crlRecuAD             recu               = null;
            crlPrelevement        prelevement        = null;
            crlAutorisationDepart autorisationDepart = null;
            #endregion

            #region implementation
            if (hfPrelevement.Value != "" && hfAutorisationDepart.Value != "")
            {
                if (agent.sessionCaisse != null)
                {
                    autorisationDepart = serviceAutorisationDepart.selectAutorisationDepart(hfAutorisationDepart.Value);
                    prelevement        = servicePrelevement.selectPrelevement(hfPrelevement.Value);
                    if (prelevement != null && autorisationDepart != null)
                    {
                        if (serviceRecuAD.isValideMontant(prelevement.MontantPrelevement, autorisationDepart.NumAutorisationDepart))
                        {
                            recu                = new crlRecuAD();
                            recu.agent          = agent;
                            recu.Date           = DateTime.Now;
                            recu.Libele         = ddlLibelle.Text;
                            recu.MatriculeAgent = agent.matriculeAgent;
                            recu.Montant        = prelevement.MontantPrelevement.ToString("0");
                            recu.NumPrelevement = prelevement.NumPrelevement;

                            recu.NumRecuAD = serviceRecuAD.insertRecuAD(recu);

                            if (recu.NumRecuAD != "")
                            {
                                serviceSessionCaisse.insertAssocSessionCaisseRecuAD(recu.NumRecuAD, agent.sessionCaisse.NumSessionCaisse);

                                this.initialiseGridPrelevement();
                                this.initialiseGridRecuAD();

                                autorisationDepart.ResteRegle = autorisationDepart.ResteRegle - prelevement.MontantPrelevement;
                                serviceAutorisationDepart.updateAutorisationDepart(autorisationDepart);

                                TextMontant.Text         = "";
                                TextType.Text            = "";
                                hfPrelevement.Value      = "";
                                ddlLibelle.SelectedValue = "";
                                this.afficheAutorisationDepart(hfAutorisationDepart.Value);

                                Page.ClientScript.RegisterClientScriptBlock(GetType(), "pdf",
                                                                            string.Format("window.open('{0}','_blank','width={1},height={2},top={3},left={4}');", "../print/print.aspx?param=recuAD&numRecuAD=" + recu.NumRecuAD, 700,
                                                                                          500, 10, 10), true);
                            }
                            else
                            {
                                //
                            }
                        }
                        else
                        {
                            //
                        }
                    }
                }
                else
                {
                    //
                }
            }
            else
            {
                //
            }
            #endregion
        }