Le module ci-après offre les fonctionnalités suivantes : au départ d'un bouton ajouté dans la fiche "Articles", pouvoir gérer les couleurs sans devoir les paramétrer dans "Outils / Paramètres / Gammes énumérés".
Il convient d'ajouter un bouton dans le signalétique articles lié à la commande do bouton_gamme.FXP.
Le bouton en question effectue les opérations suivantes :
- vérification si le type de gamme pour cette gamme d'articles existe
- le cas échéant, le type de gamme est créé avec un libellé identique à S_CLE1
- affichage de l'écran des énumérés de gammes pour ce type de gamme.
L'exemple est donné pour un Mercator client-server.
Pour la version Aruba, voici l'exemple à utiliser.
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using MercatorApi;
using MercatorController;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Windows.Forms;
using System.ComponentModel;
namespace MercatorUi.MovableControls.ButtonsCodes
{
public static class Script
{
public static void Exec(MercatorUi.MovableControls.MovableButton clickedButton)
{
MercatorUi.Forms.Sig. SigForm sigForm = (MercatorUi.Forms.Sig. SigForm ) clickedButton.Form;
string Cle1 = sigForm.DataSource.Rows[0][ "s_cle1" ].ToString().Trim();
string GamTyp = xFunctions.xLookUp( "GAMTYP" , "LIB" , Cle1, "ID" ).ToString();
if (GamTyp == "" )
{
if (Api.Answer( "Créer la gamme pour cet article ?" ))
{
GamTyp = Api.Ident();
// Ajout de la nouvelle gamme
SqlCommand oCommand = new SqlCommand ( string .Format( "insert into gamtyp(id,lib) values ('{0}','{1}')" , GamTyp, Cle1));
if (Api.SqlExec(MercatorUi.Globals.RepData, oCommand))
{
if (sigForm.DataSource.Rows[0][ "s_gamtyp2" ].ToString().Trim() != GamTyp.Trim())
{
List < Control > l = sigForm.FindMovableControlsBySource( "S_GAMTYP2" );
if (l.Count > 0)
{
// Mise à jour des combos affichant les gammes
foreach (MercatorUi.MovableControls.MovableComboBox cboGamEnum in l)
{
BindingList <MercatorUi._BaseClasses.MercatorComboItem> LCbo = ( BindingList <MercatorUi._BaseClasses.MercatorComboItem>) cboGamEnum.DataSource;
MercatorUi._BaseClasses.MercatorComboItem item = new MercatorUi._BaseClasses.MercatorComboItem(Cle1.Trim(), GamTyp.Trim());
LCbo.Add(item);
}
// Mise à jour de la valeur dans la fiche article
sigForm.DataSource.Rows[0][ "s_gamtyp2" ] = GamTyp;
}
}
// Afficher la liste de gamme
Globals.Main.ShowExternalForm( "" , "MercatorUi.Forms.Param.ParamGamEnumsForm" , "ParamGamEnumsForm" );
// Se positionner sur la bonne gamme
List < Form > lGam = MercatorUi._Divers.OpenFormsByType( typeof (MercatorUi.Forms.Param.ParamGamEnumsForm));
if (lGam.Count > 0)
{
MercatorUi.Forms.Param.ParamGamEnumsForm GamEnumForm = (MercatorUi.Forms.Param.ParamGamEnumsForm) lGam[0];
GamEnumForm.ComboBoxType.SelectedValue = GamTyp.Trim();
}
}
}
}
}
}
}
A télécharger :
0000000779.zip (1 Kb - 11/02/2004)