Beispiel #1
0
        private void RemplirPosteSource()
        {
            try
            {
                if (_listeDesPosteSourceInitiale != null && _listeDesPosteSourceInitiale.Count != 0)
                {
                    Cbo_PosteSource.ItemsSource       = _listeDesPosteSourceInitiale.OrderBy(t => t.LIBELLE).ToList();
                    Cbo_PosteSource.IsEnabled         = true;
                    Cbo_PosteSource.SelectedValuePath = "PK_ID";
                    Cbo_PosteSource.DisplayMemberPath = "LIBELLE";
                    return;
                }
                Galatee.Silverlight.ServiceAccueil.AcceuilServiceClient service = new Galatee.Silverlight.ServiceAccueil.AcceuilServiceClient(Utility.ProtocoleFacturation(), Utility.EndPoint("Accueil"));
                service.ChargerPosteSourceAsync();
                service.ChargerPosteSourceCompleted += (s, args) =>
                {
                    if (args.Error != null && args.Cancelled)
                    {
                        return;
                    }

                    _listeDesPosteSourceInitiale.Clear();

                    List <CsPosteSource> _listeDesPostesExistant = new List <CsPosteSource>();
                    CsPosteSource        st = null;
                    foreach (ServiceAccueil.CsPosteSource item in args.Result)
                    {
                        st         = new CsPosteSource();
                        st.PK_ID   = item.PK_ID;
                        st.CODE    = item.CODE;
                        st.LIBELLE = item.LIBELLE;

                        _listeDesPostesExistant = _listeDesPosteSourceInitiale.Where(t => t.LIBELLE == st.LIBELLE).ToList();

                        if (_listeDesPostesExistant == null || _listeDesPostesExistant.Count == 0)
                        {
                            _listeDesPosteSourceInitiale.Add(st);
                        }
                    }
                    Cbo_PosteSource.ItemsSource       = _listeDesPosteSourceInitiale.OrderBy(t => t.LIBELLE).ToList();
                    Cbo_PosteSource.IsEnabled         = true;
                    Cbo_PosteSource.SelectedValuePath = "PK_ID";
                    Cbo_PosteSource.DisplayMemberPath = "LIBELLE";

                    if (ObjetSelectionnee != null && ObjetSelectionnee.FK_IDPOSTESOURCE > 0)
                    {
                        Cbo_PosteSource.SelectedItem = _listeDesPosteSourceInitiale.FirstOrDefault(t => t.PK_ID == ObjetSelectionnee.FK_IDPOSTESOURCE);
                    }
                };
                service.CloseAsync();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public bool Insert(CsPosteSource pPosteSource)
 {
     try
     {
         return(Entities.InsertEntity <Galatee.Entity.Model.POSTESOURCE>(Entities.ConvertObject <Galatee.Entity.Model.POSTESOURCE, CsPosteSource>(pPosteSource)));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public UcPosteSource(object[] pObjects, SessionObject.ExecMode[] pExecMode, DataGrid[] pGrid)
        {
            try
            {
                InitializeComponent();
                Translate();
                var categorieClient = new CsPosteSource();
                if (pObjects[0] != null)
                {
                    ObjetSelectionnee = Utility.ParseObject(categorieClient, pObjects[0] as CsPosteSource);
                }
                ModeExecution = pExecMode[0];
                dataGrid      = pGrid[0];
                RemplirCommune();
                if (dataGrid != null)
                {
                    donnesDatagrid = dataGrid.ItemsSource as ObservableCollection <CsPosteSource>;
                }
                if ((SessionObject.ExecMode)ModeExecution == SessionObject.ExecMode.Modification || (SessionObject.ExecMode)ModeExecution == SessionObject.ExecMode.Consultation)
                {
                    if (ObjetSelectionnee != null)
                    {
                        Txt_Code.Text    = ObjetSelectionnee.CODE;
                        Txt_Libelle.Text = ObjetSelectionnee.LIBELLE;
                        btnOk.IsEnabled  = false;

                        //Txt_Code.IsReadOnly = true;
                    }
                }
                if ((SessionObject.ExecMode)ModeExecution == SessionObject.ExecMode.Consultation)
                {
                    AllInOne.ActivateControlsFromXaml(LayoutRoot, false);
                }
                VerifierSaisie();
            }
            catch (Exception ex)
            {
                Message.ShowError(ex.Message, Languages.LibelleCodePoste);
            }
        }
        public bool Delete(CsPosteSource del)
        {
            SqlConnection cn  = new SqlConnection(Session.GetSqlConnexionString());
            SqlCommand    cmd = new SqlCommand();

            cmd.Connection     = cn;
            cmd.CommandTimeout = 1800;
            cmd.CommandType    = CommandType.StoredProcedure;
            cmd.CommandText    = "SPX_ACC_DELETE_POSTESOURCE";
            if (cmd.Parameters != null && cmd.Parameters.Count != 0)
            {
                cmd.Parameters.Clear();
            }

            cmd.Parameters.Add("@PK_ID", SqlDbType.Int).Value = del.PK_ID;

            DBBase.SetDBNullParametre(cmd.Parameters);
            try
            {
                if (cn.State == ConnectionState.Closed)
                {
                    cn.Open();
                }
                SqlDataReader reader = cmd.ExecuteReader();
                return(!reader.HasRows);
            }
            catch (Exception ex)
            {
                throw new Exception(cmd.CommandText + ":" + ex.Message);
            }
            finally
            {
                if (cn.State == ConnectionState.Open)
                {
                    cn.Close(); // Fermeture de la connection
                }
                cmd.Dispose();
            }
        }
        private List <CsPosteSource> GetInformationsFromScreen()
        {
            var listObjetForInsertOrUpdate = new List <CsPosteSource>();

            try
            {
                if ((SessionObject.ExecMode)ModeExecution == SessionObject.ExecMode.Creation)
                {
                    var CodePoste = new CsPosteSource
                    {
                        CODE         = Txt_Code.Text,
                        LIBELLE      = Txt_Libelle.Text,
                        DATECREATION = DateTime.Now,
                        USERCREATION = UserConnecte.matricule,
                        FK_IDCOMMUNE = (Cbo_Commune.SelectedItem as CsCommune).PK_ID
                    };
                    if (!string.IsNullOrEmpty(Txt_Code.Text) && donnesDatagrid.FirstOrDefault(p => p.CODE == CodePoste.CODE) != null)
                    {
                        throw new Exception(Languages.CetElementExisteDeja);
                    }
                    listObjetForInsertOrUpdate.Add(CodePoste);
                }
                if ((SessionObject.ExecMode)ModeExecution == SessionObject.ExecMode.Modification)
                {
                    ObjetSelectionnee.CODE             = Txt_Code.Text;
                    ObjetSelectionnee.LIBELLE          = Txt_Libelle.Text;
                    ObjetSelectionnee.DATEMODIFICATION = DateTime.Now;
                    ObjetSelectionnee.USERMODIFICATION = UserConnecte.matricule;
                    ObjetSelectionnee.FK_IDCOMMUNE     = (Cbo_Commune.SelectedItem as CsCommune).PK_ID;
                    listObjetForInsertOrUpdate.Add(ObjetSelectionnee);
                }
                return(listObjetForInsertOrUpdate);
            }
            catch (Exception ex)
            {
                Message.ShowError(ex.Message, Languages.LibelleCodePoste);
                return(null);
            }
        }
 private void UpdateParentList(CsPosteSource pCodePoste)
 {
     try
     {
         if ((SessionObject.ExecMode)ModeExecution == SessionObject.ExecMode.Creation)
         {
             GetDataNew();
             //donnesDatagrid.Add(pCodePoste);
         }
         if ((SessionObject.ExecMode)ModeExecution == SessionObject.ExecMode.Modification)
         {
             GetDataNew();
             //var nationalite = donnesDatagrid.First(p => p.PK_ID == pCodePoste.PK_ID);
             //donnesDatagrid.Remove(nationalite);
             //donnesDatagrid.Add(pCodePoste);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }