Beispiel #1
0
    /// <summary>
    /// Crée une commande associée à un club (si elle n'as pas déjà été créée) dont le détail correspond aux informations de chaque membre
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void BT_Generer_Orders_Click(object sender, EventArgs e)
    {
        List <Club>  clubs     = DataMapping.ListClubs(club_type: "rotary");
        List <Order> commandes = DataMapping.ListOrderByPayment(HF_id.Value);

        foreach (Club club in clubs)
        {
            bool dejacommande = false;
            foreach (Order commande in commandes)
            {
                if (commande.cric == club.cric)
                {
                    dejacommande = true;
                    break;
                }
            }
            if (!dejacommande)
            {
                List <Member> membres = DataMapping.ListMembers(cric: club.cric, sort: "name ASC");

                Order commande = new Order();
                commande.cric       = club.cric;
                commande.club       = club.name;
                commande.dt         = DateTime.Now;
                commande.id_payment = HF_id.Value;
                commande.rule       = "N";
                commande.rule_dt    = Const.NO_DATE;
                commande.rule_info  = "";
                commande.rule_par   = "";
                commande.rule_type  = "";
                commande.amount     = (float)TXT_montant1.Value * membres.Count;

                foreach (Member membre in membres)
                {
                    Order.Detail detail = new Order.Detail();
                    detail.wording   = membre.surname + " " + membre.name + " (" + membre.nim + ")";
                    detail.amount    = (float)TXT_montant1.Value;
                    detail.quantity  = 1;
                    detail.unitary   = (float)TXT_montant1.Value;
                    detail.id_parent = 0;
                    commande.Details.Add(detail);
                }


                if (DataMapping.UpdateOrder(commande))
                {
                    TXT_Result.Text += "<br/>" + club.name + " commande pour " + membres.Count + " membres";
                }
                else
                {
                    TXT_Result.Text += "<br/>Erreur commande : " + club.name;
                }
            }
        }

        Check_Buttons();
    }
Beispiel #2
0
 public Order(int ID, Detail detail)
 {
     this.ID     = ID;
     this.detail = detail;
 }
Beispiel #3
0
    protected void BT_Valider_Click(object sender, EventArgs e)
    {
        if (montant_total <= 0)
        {
            return;
        }

        Club club = Functions.CurrentClub;

        if (club == null)
        {
            return;
        }

        List <Member> membres = DataMapping.ListMembers(cric: club.cric, sort: "name ASC");

        Order commande = new Order();

        commande.cric       = club.cric;
        commande.club       = club.name;
        commande.dt         = DateTime.Now;
        commande.id_payment = HF_id.Value;
        commande.rule       = "N";
        commande.rule_dt    = Const.NO_DATE;
        commande.rule_info  = "";
        commande.rule_par   = "";
        commande.rule_type  = "";
        commande.amount     = montant_total;

        foreach (Member membre in membres)
        {
            foreach (KeyValuePair <string, string> membre_invite in membres_invites)
            {
                if (membre_invite.Key.Equals("" + membre.id))
                {
                    Order.Detail detail = new Order.Detail();
                    detail.wording   = membre.surname + " " + membre.name + " (" + membre.nim + ")";
                    detail.amount    = float.Parse(TXT_montant1.Text);
                    detail.quantity  = 1;
                    detail.unitary   = float.Parse(TXT_montant1.Text);
                    detail.id_parent = 0;
                    commande.Details.Add(detail);

                    string[] invites = membre_invite.Value.Split(new string[] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string st in invites)
                    {
                        string invite = st.Trim();
                        if (!invites.Equals(""))
                        {
                            detail           = new Order.Detail();
                            detail.wording   = invite + " (invité par " + membre.surname + " " + membre.name + ")";
                            detail.amount    = float.Parse(TXT_montant2.Text);
                            detail.quantity  = 1;
                            detail.unitary   = float.Parse(TXT_montant2.Text);
                            detail.id_parent = membre.nim;
                            commande.Details.Add(detail);
                        }
                    }
                }
            }
        }


        if (DataMapping.UpdateOrder(commande))
        {
            Panel4.Visible = false;
            Panel2.Visible = true;
            RefreshGrid2(GridView1, 0);
        }
        else
        {
            TXT_Result.Text    = "Erreur de validation de la commande, veuillez contacter <a href='mailto:[email protected]'>[email protected]</a>";
            TXT_Result.Visible = true;
            BT_Valider.Visible = false;
        }
    }