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!"); } }
void button1_Click(object sender, EventArgs e) { #region Verfification champs errorProvider1.SetError(PARCOURIR_LISTE_CLIENT, ""); if (txt_REF_CLIENT.Text.Trim() == string.Empty) { errorProvider1.SetError(PARCOURIR_LISTE_CLIENT, "Veuillez sélectioner le client propriétaire de l'équipement!"); PARCOURIR_LISTE_CLIENT.Focus(); return; } errorProvider1.Clear(); errorProvider1.SetError(txtLibelle, ""); if (txtLibelle.Text.Trim() == string.Empty) { errorProvider1.SetError(txtLibelle, "Veuillez saisir un libellé pour l'équipement!"); txtLibelle.Focus(); return; } errorProvider1.Clear(); #endregion if (mode == 0) { equipement = new DEQUIPEMENT(); equipement.CODE_CLIENT = (decimal)txt_REF_CLIENT.Tag; equipement.DATE_FAB_EQP = dtpDateFabrication.Value; equipement.DATE_MISE_SERVICE_EQP = dtpDateService.Value; equipement.FABRIQUANT = txtFabriquant.Text; equipement.LIBELLE_EQP = txtLibelle.Text; equipement.NUM_SERIE = txtSerie.Text; try { CLIENT_APP_PARAM.gcws.ajouteEQUIPEMENT(equipement); MessageBox.Show("Equipement enregistré avec succes."); valide = true; Close(); } catch (Exception er) { valide = false; MessageBox.Show(er.Message, this.Text); return; } } else { equipement = new DEQUIPEMENT(); equipement.CODE_EQP = Convert.ToDecimal(lbCode.Text); equipement.CODE_CLIENT = (decimal)txt_REF_CLIENT.Tag; equipement.DATE_FAB_EQP = dtpDateFabrication.Value; equipement.DATE_MISE_SERVICE_EQP = dtpDateService.Value; equipement.FABRIQUANT = txtFabriquant.Text; equipement.LIBELLE_EQP = txtLibelle.Text; equipement.NUM_SERIE = txtSerie.Text; try { CLIENT_APP_PARAM.gcws.modifieEQUIPEMENT(equipement); MessageBox.Show("Equipement enregistré avec succes."); valide = true; Close(); } catch (Exception er) { valide = false; MessageBox.Show(er.Message, this.Text); return; } } }