Beispiel #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            TicketClient rpt = new TicketClient();

            rpt.Site = this.Site;
            return(rpt);
        }
Beispiel #2
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (ValiderChamps())
            {
                #region //------------------Ticket a imprimer (Begin)----------------///
                if (checkBox1.Checked)
                {
                    this.Enabled = false;
                    wait.Show();
                    TicketClient  ticket  = new TicketClient();
                    TicketPiece   piece   = new TicketPiece();
                    InfoSociete   societe = new InfoSociete();
                    List <ListAF> s       = new List <ListAF>();
                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {
                        DataGridViewRow row = dataGridView1.Rows[i];
                        s.Add(new ListAF());
                        s[i].Code_Article    = (string)row.Cells["Code_Article"].Value;
                        s[i].Libelle_Article = (string)row.Cells["Article_Libelle"].Value;
                        s[i].Libelle_Famille = (string)row.Cells["Famille"].Value;
                        s[i].Operation       = (string)row.Cells["Operation"].Value;
                        s[i].Prix            = decimal.Parse((string)row.Cells["Prix"].Value);
                        s[i].Quantite        = int.Parse((string)row.Cells["Quantite"].Value);
                    }
                    ticket.SetDataSource(s);
                    ticket.SetParameterValue("Code_Facture", facture.Code);
                    ticket.SetParameterValue("CodeClient", comboCodeClient.Text);
                    ticket.SetParameterValue("NomClient", textNomClient.Text);
                    ticket.SetParameterValue("PrenomClient", textPrenomClient.Text);
                    ticket.SetParameterValue("dateLivraison", dateTimePicker2.Value);
                    ticket.SetParameterValue("PrixPayee", numericPrixPayee.Value);
                    ticket.SetParameterValue("Prix_Total", labelTotal.Text);
                    ticket.SetParameterValue("Societe", societe.nom);
                    ticket.SetParameterValue("Tel", societe.tel);
                    ticket.SetParameterValue("Adress", societe.adresse);
                    if (GlobalVars.namePrinter == string.Empty)
                    {
                        MessageBox.Show("Verifier les Option de l'imprimante");
                        return;
                    }
                    //ticket.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)Enum.GetValues(typeof(CrystalDecisions.Shared.PaperSize)).GetValue(int.Parse(GlobalVars.page));
                    //piece.PrintOptions.PaperSize = ticket.PrintOptions.PaperSize;
                    ticket.PrintOptions.PrinterName = GlobalVars.namePrinter;
                    piece.PrintOptions.PrinterName  = GlobalVars.namePrinter;

                    int nb = int.Parse(GlobalVars.nombreCopieTicket);
                    for (int i = 0; i < nb; i++)
                    {
                        ticket.PrintToPrinter(1, true, 1, 1);
                    }


                    foreach (ListAF d in s)
                    {
                        piece.SetParameterValue("Code_Facture", facture.Code);
                        piece.SetParameterValue("Nom", textNomClient.Text + " " + textPrenomClient.Text);
                        piece.SetParameterValue("Date_Liv", dateTimePicker2.Value);
                        int n = (int)d.article.N_Pieces * d.Quantite;
                        if (d.article.Print)
                        {
                            continue;
                        }
                        switch (d.Operation)
                        {
                        case "Pressing":
                            if (GlobalVars.maxPressing != "#")
                            {
                                if (d.Quantite > int.Parse(GlobalVars.maxPressing))
                                {
                                    piece.PrintToPrinter(1, true, 1, 1);
                                }
                            }
                            else
                            {
                                for (int i = 0; i < n; i++)
                                {
                                    piece.PrintToPrinter(1, true, 1, 1);
                                }
                            }
                            break;

                        case "Repassage":
                            if (GlobalVars.maxRepassage != "#")
                            {
                                if (d.Quantite > int.Parse(GlobalVars.maxRepassage))
                                {
                                    piece.PrintToPrinter(1, true, 1, 1);
                                }
                            }
                            else
                            {
                                for (int i = 0; i < n; i++)
                                {
                                    piece.PrintToPrinter(1, true, 1, 1);
                                }
                            }
                            break;

                        case "Tenture":
                            if (GlobalVars.maxTenture != "#")
                            {
                                if (d.Quantite > int.Parse(GlobalVars.maxTenture))
                                {
                                    piece.PrintToPrinter(1, true, 1, 1);
                                }
                            }
                            else
                            {
                                for (int i = 0; i < n; i++)
                                {
                                    piece.PrintToPrinter(1, true, 1, 1);
                                }
                            }
                            break;

                        case "Autre":
                            if (GlobalVars.maxAutre != "#")
                            {
                                if (d.Quantite > int.Parse(GlobalVars.maxAutre))
                                {
                                    piece.PrintToPrinter(1, true, 1, 1);
                                }
                            }
                            else
                            {
                                for (int i = 0; i < n; i++)
                                {
                                    piece.PrintToPrinter(1, true, 1, 1);
                                }
                            }
                            break;
                        }
                    }
                    this.Enabled = true;
                    wait.Close();
                }
                #endregion //------------------Ticket a imprimer (End)----------------///

                #region    //-----------------Enrigstrment de la Facture (Begin)------------------------///
                //client///
                //
                client.Nom     = textNomClient.Text;
                client.Prenom  = textPrenomClient.Text;
                client.Adresse = textAdresseClient.Text;
                client.NTel    = maskedTextTelClient.Text;
                client.Code    = comboCodeClient.Text;
                if (!clientExiste)
                {
                    client.SaveData();
                }
                //Table Facture
                facture.Client         = client;
                facture.Date_livraison = dateTimePicker2.Value;
                facture.Date_Recu      = dateTimePicker1.Value;
                facture.Prix_Total     = double.Parse(labelTotal.Text);
                facture.Prix_Partiel   = (double)numericPrixPayee.Value;
                facture.Mode_Payement  = "Espece";
                facture.Etat           = "Non Reglee";
                facture.Livree         = "Non Livree";
                facture.SaveData();

                //lignes de commandes
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    ListAF sd = new ListAF();
                    sd.Code_Article = (string)row.Cells["Code_Article"].Value;
                    sd.Code_Facture = facture.Code;
                    sd.Operation    = (string)row.Cells["Operation"].Value;
                    sd.Quantite     = int.Parse((string)row.Cells["Quantite"].Value);
                    sd.Prix         = decimal.Parse((string)row.Cells["Prix"].Value);
                    sd.saveData();
                }
                #endregion //-----------------Enrigstrment de la Facture (End)------------------------///

                if (checkBox2.Checked)
                {
                    Payement p = new Payement(facture.Code);
                    p.ShowDialog(this.Owner);
                }
                this.Close();
            }
        }