예제 #1
0
        public void Add(LigneTicket m)
        {
            try
            {
                cnx = ConnexionCoffe.GetInstance();
                MySqlCommand cmd = new MySqlCommand("insert into tligneticket values(@id,  @idprod,@idticket,@nomprod, @qteprod,@prixprod,@totalprod)", cnx);
                cmd.Parameters.Add("@id", m.Id);//
                cmd.Parameters.Add("@idprod", m.Idprod.Id);
                cmd.Parameters.Add("@idticket", m.Idticket.Id);
                cmd.Parameters.Add("@nomprod", m.NomProd);
                cmd.Parameters.Add("@qteprod", m.QteProd);
                cmd.Parameters.Add("@prixprod", m.PrixProd);
                cmd.Parameters.Add("@totalprod", m.TotalProd);


                int n = cmd.ExecuteNonQuery();
                if (n != 0)
                {
                    MessageBox.Show("LigneTicket ajouter avec succée \n ", "Attention");
                }
                cnx.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Pb de la requete de l'ajout\n " + ex.Message, "Attention");
            }
        }
예제 #2
0
        private void btnConfirme_Click(object sender, EventArgs e)
        {
            EmployerDAO empd = new EmployerDAO();
            Employer    emp2 = empd.Find(user);
            DateTime    auj  = DateTime.Now.Date;
            string      d    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            DateTime    auj2 = DateTime.Parse(d);


            // Employer emp = new Employer(0,"","","","","","","","","", auj,auj,null);
            decimal total, don, ret;

            total = Convert.ToDecimal(txtTotal.Text);
            don   = Convert.ToDecimal(txtmtdonne.Text);
            ret   = Convert.ToDecimal(txtmtretourne.Text);
            metiers.Ticket m = new metiers.Ticket(idTick, emp2, total, don, ret, auj2);
            //metiers.Ticket m2 = new metiers.Ticket(emp2, total, don, ret, auj);

            TicketDAO bd = new TicketDAO();

            bd.Add(m);
            //  bd.Add2(m2);

            metiers.Ticket m2 = bd.Find(Convert.ToInt32(txtnumtick.Text));
            foreach (DataGridViewRow Row in dgvProd.Rows)
            {
                try
                {
                    LigneTicketDAO ltb             = new LigneTicketDAO();
                    int            ProductId       = Convert.ToInt32(Row.Cells["id"].Value);
                    string         ProductName     = Row.Cells["Nomproduit"].Value.ToString();
                    decimal        ProductPrice    = Convert.ToDecimal(Row.Cells["prix"].Value);
                    int            ProductQuantity = Convert.ToInt32(Row.Cells["qte"].Value);
                    decimal        ProductTotal    = Convert.ToDecimal(Row.Cells["totalProduit"].Value);
                    ProduitDAO     pb = new ProduitDAO();
                    Produit        p  = pb.Find(ProductId);
                    LigneTicket    l  = new LigneTicket(0, p, m2, ProductName, ProductQuantity, ProductPrice, ProductTotal);
                    ltb.Add(l);
                }
                catch
                {
                    //means Rows are ended
                }
            }



            new Ticket(txtTotal.Text, txtmtdonne.Text, txtmtretourne.Text).ShowDialog();
            this.Hide();
            UIEmployer f1 = new UIEmployer(user);

            f1.Show();
        }
예제 #3
0
        public List <LigneTicket> FindAllbyTicket(int idTick)
        {
            ProduitDAO     bdProd   = new ProduitDAO();
            List <Produit> produits = bdProd.FindAll();
            Produit        p        = null;

            TicketDAO     bdtick  = new TicketDAO();
            List <Ticket> tickets = bdtick.FindAll();
            Ticket        t       = null;


            List <LigneTicket> res = new List <LigneTicket>();

            try
            {
                cnx = ConnexionCoffe.GetInstance();
                MySqlCommand cmd = new MySqlCommand("select * from tligneticket where idticket=@idtick ", cnx);
                cmd.Parameters.Add("@idtick", idTick);

                MySqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    foreach (Produit prod in produits)
                    {
                        if (prod.Id.Equals(reader.GetInt32(1)))
                        {
                            p = prod; break;
                        }
                    }

                    foreach (Ticket tick in tickets)
                    {
                        if (tick.Id.Equals(reader.GetInt32(2)))
                        {
                            t = tick; break;
                        }
                    }

                    LigneTicket m = new LigneTicket(reader.GetInt32("id"), p, t, reader.GetString(3), reader.GetInt32(4), reader.GetDecimal(5), reader.GetDecimal(6));
                    res.Add(m);
                }
                reader.Close();
                cnx.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ligne ticket : Pb de FindAll \n " + ex.Message, "Attention");
            }
            return(res);
        }