void AjouteUnite(object sender, EventArgs e) { try { if (textBox1.Text.Trim() == string.Empty) { MessageBox.Show("Libellé non valid.", this.Text); return; } RESULT_QUERY res = new RESULT_QUERY(); unite = new DUNITE_ARTICLE(); unite.LIB_UNITE = textBox1.Text; res = CLIENT_APP_PARAM.gcws.ajouteUNITE_ARTICLE(unite); if (res.OK) { unite.CODE_UNITE = Convert.ToDecimal(res.CODE); if (OnSave != null) { OnSave(unite); } Close(); } else { MessageBox.Show(res.MESSAGE, this.Text); return; } } catch (Exception er) { MessageBox.Show(er.Message, this.Text); } }
public CHM_FRM_MAJ_UNITE() { InitializeComponent(); unite = new DUNITE_ARTICLE(); entete_Formulaire_21.btn_refresh.Visible = false; chM_CMP_VALIDATION1.button1.Click += new EventHandler(AjouteUnite); chM_CMP_VALIDATION1.button2.Click += new EventHandler(Fermer); this.Text = entete_Formulaire_21.windows_name.Text = "Nouvelle unité"; }
void f_OnSave(DUNITE_ARTICLE unite) { try { CLIENT_APP_PARAM.ds_param.bsUnite.AddNew(); DataRowView drv = (DataRowView)CLIENT_APP_PARAM.ds_param.bsUnite.Current; drv["CODE_UNITE"] = unite.CODE_UNITE; drv["LIB_UNITE"] = unite.LIB_UNITE; CLIENT_APP_PARAM.ds_param.bsUnite.EndEdit(); (CLIENT_APP_PARAM.ds_param.bsUnite.DataSource as DataTable).AcceptChanges(); cbx_UNITE.SelectedValue = unite.CODE_UNITE; } catch (Exception er) { MessageBox.Show(er.Message, this.Text); } }