Example #1
0
 void btn_supprimer_Click(object sender, EventArgs e)
 {
     if (bsListe.Current != null)
     {
         DataRowView drv = (DataRowView)bsListe.Current;
         if ((decimal)drv["NB_IMPRIME"] > 0)
         {
             MessageBox.Show("Ce Devis ne peut pas être supprimé!");
         }
         else
         {
             try
             {
                 DDEVIS_CLIENT devis = new DDEVIS_CLIENT();
                 devis.CODE_DC = drv["CODE_DC"].ToString();
                 CLIENT_APP_PARAM.gcws.effaceDEVIS_CLIENT(devis);
             }
             catch (Exception er)
             {
                 MessageBox.Show(er.Message, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Example #2
0
        void button1_Click(object sender, EventArgs e)
        {
            errorProvider1.SetError(txt_REF_CLIENT, "");
            if (txt_REF_CLIENT.Text == string.Empty)
            {
                errorProvider1.SetError(txt_REF_CLIENT, "Veuillez sélectionner le client!");
                PARCOURIR_LISTE_CLIENT.Focus();
                return;
            }
            if (dS_MOUV1.V_LG_DC.Rows.Count > 0)
            {
                if (MessageBox.Show("Etes vous sûres d'enregistrer le devis?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                {
                    try
                    {
                        Devis = new DDEVIS_CLIENT();
                        Devis.DATE_CREATION        = dtp_DATE_DC.Value;
                        Devis.CODE_CLIENT          = (decimal)txt_REF_CLIENT.Tag;
                        Devis.DATE_DC              = dtp_DATE_DC.Value;
                        Devis.DATE_VALIDITE        = nud_DATE_VALIDITE.Value;
                        Devis.MODE_PAIEMENT        = txt_MODE_PAIEMENT.Text;
                        Devis.OBSERVATION          = txt_OBSERVATION.Text;
                        Devis.RESPONSABLE          = txt_Responsable.Text;
                        Devis.UTILISATEUR_CREATION = Convert.ToDecimal(CLIENT_APP_PARAM.Fenetre_principale.code_user);
                        Devis.TIMBRE = TIMBRE.Value;

                        DataTable mydetails = new DataTable("devisDetails");
                        foreach (DataColumn c in dS_MOUV1.V_LG_DC.Columns)
                        {
                            DataColumn col = new DataColumn(c.ColumnName, c.DataType);
                            mydetails.Columns.Add(col);
                        }

                        foreach (DataRow dr in dS_MOUV1.V_LG_DC.Rows)
                        {
                            mydetails.ImportRow(dr);
                        }

                        RESULT_QUERY res = new RESULT_QUERY();
                        res = CLIENT_APP_PARAM.gcws.ajouteDEVIS_CLIENT(Devis, mydetails);
                        if (res.OK)
                        {
                            Devis.CODE_DC = txt_CODE_DC.Text = res.CODE;
                            MessageBox.Show(res.MESSAGE, this.Text);
                            ValidateChanges = true;
                            bsDevis.EndEdit();
                            (bsDevis.DataSource as DataTable).AcceptChanges();
                            if (MessageBox.Show("Voulez vous imprimer le devis?", "Impression Devis", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                            {
                                try
                                {
                                    foreach (DataRow dr in dS_MOUV1.V_LG_DC.Rows)
                                    {
                                        dr["CODE_DC"] = res.CODE;
                                        dS_MOUV1.V_LG_DC.AcceptChanges();
                                    }
                                    this.Cursor = Cursors.WaitCursor;
                                    dS_MOUV1.V_DC.Clear();
                                    dS_MOUV1.V_DC.ImportRow((bsDevis.DataSource as DataTable).Select("CODE_DC like '" + txt_CODE_DC.Text + "'")[0]);

                                    ReportDocument rpt = new CHM_RPT_DEVI_CLIENT();
                                    rpt.SetDataSource(dS_MOUV1);
                                    rpt.SetParameterValue("montantLettre", new NUM_TO_LETTRE.NumberToLetter().ConvertirDinars(NP.Value));
                                    rpt.SetParameterValue("entete", CLIENT_APP_PARAM.entete);
                                    rpt.PrintOptions.PrinterName = CLIENT_APP_PARAM.ReportPrinter;
                                    rpt.PrintToPrinter(1, true, 0, 0);
                                }
                                catch (Exception err)
                                {
                                    MessageBox.Show(err.Message, "Erreur d'impression");
                                }
                                finally
                                {
                                    this.Cursor = Cursors.Default;
                                }
                            }
                            if (OnMaj != null)
                            {
                                OnMaj(res.CODE, ValidateChanges);
                            }
                            Close();
                        }
                        else
                        {
                            MessageBox.Show(res.MESSAGE, this.Text);
                            return;
                        }
                    }
                    catch (Exception er)
                    {
                        MessageBox.Show(er.Message, "Erreur");
                    }
                }
            }
            else
            {
                MessageBox.Show("Devis Vide!");
            }
        }