Пример #1
0
        //modification des boutons des articles
        private void ModifButton(Button ctl, Article cli, Label lbl)
        {
            lbl.Visible = true;
            lbl.Text = cli.Designation;
            ctl.BackgroundImage = (System.Drawing.Image)cli.Image;
            ctl.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
            ctl.Text = "";
            ctl.UseVisualStyleBackColor = true;
            ctl.Visible = true;
            ctl.Font = new System.Drawing.Font("Trebuchet MS", 12F, System.Drawing.FontStyle.Bold,
                System.Drawing.GraphicsUnit.Point, ((byte)(0)));

            ctl.Click += delegate(object sender, EventArgs e)
            {
                contenu = new Contenu();

                if ((fact != null) ? fact.Id < 1 : true)
                {
                    Messages.ShowErreur("Vous devez dabord enregsitrer la facture!");
                    return;
                }
                else
                {
                    //sauvegarde nouveau contenu
                    contenu.Article = BLL.ArticleComBll.One(cli);
                    contenu.Facture = fact;
                    contenu.Prix = cli.Prix;
                    contenu.New_ = true;
                    //qté article
                    Form_Caisse_Quantite f = new Form_Caisse_Quantite(this);
                    f.Text = "Quantité de: " + cli.Designation;
                    f.ShowDialog();
                    if ((contenu.Quantite != 0) || (contenu.Quantite == null))
                    {
                        ctl.BackColor = Color.DarkGray;
                        ctl.Enabled = false;
                        btnReglement.Enabled = true;
                        contenu.PrixTotal = contenu.Quantite * contenu.Prix;
                        //SommSR.Text = Convert.ToString(Convert.ToDouble(SommSR.Text) + contenu.PrixTotal);
                    }
                }

                //contenu.Update=true;
                if (contenu.Control())
                {
                    if (!contenu.Update)
                    {
                        contenu.DateContenu = DateTime.Now;
                        Contenu c_ = new BLL.ContenuBll(contenu).Insert();
                        if ((c_ != null) ? c_.Id > 0 : false)
                        {
                            contenu.Id = c_.Id;
                            contenu.Update = true;
                            fact.Contenus.Add(contenu);
                            AddRowContenu(contenu);
                            contenu.Update = true;
                            Messages.Succes();
                        }
                    }
                    else
                    {
                        if (new BLL.ContenuBll(contenu).Update())
                        {
                            contenu.Update = true;
                            fact.Contenus[fact.Contenus.FindIndex(x => x.Id == contenu.Id)] = contenu;
                            UpdateRowContenu(contenu);

                            contenu.Update = true;
                            Messages.Succes();
                        }
                    }
                    Utils.MontantTotalDoc(fact);
                    configFacture(fact);
                    UpdateCurrentFacture(fact);
                }

            };
        }
Пример #2
0
        private void btn_add_contenu_Click(object sender, EventArgs e)
        {
            Contenu c = RecopieViewContenu();
            if (c.Control())
            {
                if (!c.Update)
                {
                    c.DateContenu = DateTime.Now;
                    Contenu c_ = new BLL.ContenuBll(c).Insert();
                    if ((c_ != null) ? c_.Id > 0 : false)
                    {
                        c.Id = c_.Id;
                        contenu.DateContenu = DateTime.Now;
                        contenu.Id = c_.Id;
                        c.Update = true;
                        facture.Contenus.Add(c);
                        AddRowContenu(c);

                        contenu.Update = true;
                        Messages.Succes();
                    }
                }
                else
                {
                    if (new BLL.ContenuBll(c).Update())
                    {
                        c.Update = true;
                        facture.Contenus[facture.Contenus.FindIndex(x => x.Id == c.Id)] = c;
                        UpdateRowContenu(c);

                        contenu.Update = true;
                        Messages.Succes();
                    }
                }
                Utils.MontantTotalDoc(facture);
                configFacture(facture);
                UpdateCurrentFacture(facture);
                ResetFicheContenu();
            }
        }