Пример #1
0
        public DataPointHistoryData FindBy(string id)
        {
            DataPointHistoryData dataPointHistoryData = new DataPointHistoryData();
            DataTable            dataTable;

            MySqlParameter[] mySqlPrarameters = { new MySqlParameter("@DataPointHistoryDataId", id) };
            string           sqlQuery         = baseSelectQuery +
                                                "where DataPointHistoryDataId=@DataPointHistoryDataId;";

            try
            {
                dataTable = dbUtility.ExecuteDataTable(sqlQuery, CommandType.Text, mySqlPrarameters);
                if (null != dataTable)
                {
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        dataPointHistoryData = DataMapperFactory.GetDataMapper <DataPointHistoryData>().ConverFrom(dataTable.Rows, i);
                    }
                }
            }
            catch (Exception ex)
            {
                string message = "查询失败!" + ex.Message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(dataPointHistoryData);
            }

            return(dataPointHistoryData);
        }
Пример #2
0
        public IEnumerable <Module> FindBy(Query query)
        {
            List <Module> modules = new List <Module>();
            DataTable     dataTable;

            string baseSelectQuery = "select ModuleId,Number,Name,Description " +
                                     "from numericalcontrolsystem.module;";

            List <MySqlParameter> parametersrarameters = new List <MySqlParameter>();

            string resultQuery = query.TranslateIntoSqlString <DataPoint>(baseSelectQuery, parametersrarameters);

            try
            {
                dataTable = dbUtility.ExecuteDataTable(resultQuery, CommandType.Text, parametersrarameters.ToArray());
                if (null != dataTable)
                {
                    Module module;
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        module = DataMapperFactory.GetDataMapper <Module>().ConverFrom(dataTable.Rows, i);
                        modules.Add(module);
                    }
                }
            }
            catch (Exception ex)
            {
                string message = "查询失败!" + ex.Message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(modules);
            }

            return(modules);
        }
Пример #3
0
        /// <see cref="IEmployeeRepository.GetById(int)"/>
        public Employee GetById(int employeeId)
        {
            var context    = DataMapperFactory.GetDataContext();
            var returnList = context.Employees.Where(e => e.EmployeeId == employeeId).FirstOrDefault();

            return(returnList);
        }
Пример #4
0
        public Module FindBy(int id)
        {
            Module    module = new Module();
            DataTable dataTable;

            MySqlParameter[] mySqlPrarameters = { new MySqlParameter("@Id", id) };

            string moduleQuery = "select ModuleId,Number,Name,Description " +
                                 "from numericalcontrolsystem.module " +
                                 "where ModuleId=@Id;";

            try
            {
                dataTable = dbUtility.ExecuteDataTable(moduleQuery, CommandType.Text, mySqlPrarameters);
                if (null != dataTable)
                {
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        module = DataMapperFactory.GetDataMapper <Module>().ConverFrom(dataTable.Rows, i);
                    }
                }
            }
            catch (Exception ex)
            {
                string message = "查询失败!" + ex.Message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(module);
            }

            return(module);
        }
Пример #5
0
        public IEnumerable <Module> FindAll()
        {
            List <Module> modules = new List <Module>();
            DataTable     dataTable;

            string query = "select ModuleId,Number,Name,Description " +
                           "from numericalcontrolsystem.module;";

            try
            {
                dataTable = dbUtility.ExecuteDataTable(query, CommandType.Text);
                if (null != dataTable)
                {
                    Module module;
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        module = DataMapperFactory.GetDataMapper <Module>().ConverFrom(dataTable.Rows, i);
                        modules.Add(module);
                    }
                }
            }
            catch (Exception ex)
            {
                string message = "查询失败!" + ex.Message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(modules);
            }

            return(modules);
        }
Пример #6
0
        public IEnumerable <DataPoint> FindAll()
        {
            List <DataPoint> dataPoints = new List <DataPoint>();
            DataTable        dataTable;

            string dataPointQuery = this.baseSelectQuery;

            try
            {
                dataTable = dbUtility.ExecuteDataTable(dataPointQuery, CommandType.Text);
                if (null != dataTable)
                {
                    DataPoint dataPoint;
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        dataPoint = DataMapperFactory.GetDataMapper <DataPoint>().ConverFrom(dataTable.Rows, i);
                        dataPoints.Add(dataPoint);
                    }
                }
            }
            catch (Exception ex)
            {
                string message = "查询失败!" + ex.Message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(dataPoints);
            }

            return(dataPoints);
        }
Пример #7
0
        public IEnumerable <DataPoint> FindBy(Query query)
        {
            List <DataPoint> dataPoints = new List <DataPoint>();
            DataTable        dataTable;

            List <MySqlParameter> parametersrarameters = new List <MySqlParameter>();

            string resultQuery = query.TranslateIntoSqlString <DataPoint>(this.baseSelectQuery, parametersrarameters);

            try
            {
                dataTable = dbUtility.ExecuteDataTable(resultQuery, CommandType.Text, parametersrarameters.ToArray());
                if (null != dataTable)
                {
                    DataPoint dataPoint;
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        dataPoint = DataMapperFactory.GetDataMapper <DataPoint>().ConverFrom(dataTable.Rows, i);
                        dataPoints.Add(dataPoint);
                    }
                }
            }
            catch (Exception ex)
            {
                string message = "查询失败!" + ex.Message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(dataPoints);
            }

            return(dataPoints);
        }
Пример #8
0
        /// <see cref="IEmployeeRepository.GetAll"/>
        public List <Employee> GetAll()
        {
            var temp       = GetAllExternal();
            var context    = DataMapperFactory.GetDataContext();
            var returnList = context.Employees.ToList <Employee>();

            return(returnList);
        }
Пример #9
0
        public void DataMapperFactory()
        {
            //---------------Set up test pack-------------------
            IDataMapperFactory dataMapperFactory = new DataMapperFactory();

            //---------------Execute Test ----------------------
            GlobalRegistry.DataMapperFactory = dataMapperFactory;
            //---------------Test Result -----------------------
            Assert.AreSame(dataMapperFactory, GlobalRegistry.DataMapperFactory);
        }
 public virtual void Finalise()
 {
     QueryParameterFactory.Finalise();
     DataMapperResolverFactory.Finalise();
     DataMapperFactory.Finalise();
     ConfigurationResolverFactory.Finalise();
     ObjectConstructionFactory.Finalise();
     ObjectSavingFactory.Finalise();
     ConfigurationMapFactory.Finalise();
 }
Пример #11
0
        public void GetDataMapper_ShouldReturnIntDataMapper_WhenTargetTypeIsInt()
        {
            //---------------Set up test pack-------------------
            var factory    = new DataMapperFactory();
            var targetType = typeof(int);
            //---------------Execute Test ----------------------
            var dataMapper = factory.GetDataMapper(targetType);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf <IntDataMapper>(dataMapper);
        }
Пример #12
0
        public void SetDataMapper_ShouldSetMapperForType()
        {
            //---------------Set up test pack-------------------
            var factory            = new DataMapperFactory();
            var targetType         = typeof(Image);
            var expectedDataMapper = new GuidDataMapper();

            //---------------Execute Test ----------------------
            factory.SetDataMapper(targetType, expectedDataMapper);
            //---------------Test Result -----------------------
            Assert.AreSame(expectedDataMapper, factory.GetDataMapper(targetType));
        }
Пример #13
0
        public void GetDataMapper_ShouldReturnSameGeneralDataMapperEachTime_WhenSameTypeIsAskedFor()
        {
            //---------------Set up test pack-------------------
            var factory            = new DataMapperFactory();
            var targetType         = typeof(TestDataMapperFactory);
            var expectedDataMapper = factory.GetDataMapper(targetType);
            //---------------Execute Test ----------------------
            var dataMapper = factory.GetDataMapper(targetType);

            //---------------Test Result -----------------------
            Assert.AreSame(expectedDataMapper, dataMapper);
        }
        private void Btn_Connecter_Click(object sender, RoutedEventArgs e)
        {
            //UtilisateurConnecte utilisateurConnecte2 = UtilisateurConnecte.Instance;
            //utilisateurConnecte2.Identifiant = "login";
            //utilisateurConnecte2.Role = "role";
            //RC otherWindow2 = new RC();
            //otherWindow2.Show();
            //this.Close();
            //return;

            // on cherche si c'est un client
            IClientMapper lClientMapper = (IClientMapper)DataMapperFactory.GetDataMapperFactory().GetClientMapper();
            DataTable     clients       = lClientMapper.FindAll();

            foreach (DataRow row in clients.Rows)
            {
                if (TextBox_Identifiant.Text == row["pseudo"].ToString() &&
                    TextBox_Motdepasse.Password == row["mot_de_passe"].ToString())
                {
                    // un client s'est connecté
                    UtilisateurConnecte utilisateurConnecte = UtilisateurConnecte.Instance;
                    utilisateurConnecte.Identifiant = TextBox_Identifiant.Text;
                    utilisateurConnecte.Role        = "Client";
                    FenetreClient otherWindow = new FenetreClient();
                    otherWindow.Show();
                    this.Close();
                    return;
                }
            }

            // on cherche si c'est un employé
            IEmployeMapper lEmployeMapper = (IEmployeMapper)DataMapperFactory.GetDataMapperFactory().GetEmployeMapper();
            DataTable      employes       = lEmployeMapper.FindAll();

            foreach (DataRow row in employes.Rows)
            {
                if (TextBox_Identifiant.Text == row["pseudo"].ToString() &&
                    TextBox_Motdepasse.Password == row["mot_de_passe"].ToString())
                {
                    // un employé RC s'est connecté
                    UtilisateurConnecte utilisateurConnecte = UtilisateurConnecte.Instance;
                    utilisateurConnecte.Identifiant = TextBox_Identifiant.Text;
                    utilisateurConnecte.Role        = row["fonction"].ToString();
                    RC otherWindow = new RC();
                    otherWindow.Show();
                    this.Close();
                    return;
                }
            }

            MessageBox.Show("Identifiant ou mot de passe incorrect.");
        }
Пример #15
0
        public void GetDataMapper_ShouldReturnDifferentGeneralDataMapper_WhenDifferentTypeIsAskedFor()
        {
            //---------------Set up test pack-------------------
            var factory            = new DataMapperFactory();
            var targetType         = typeof(TestDataMapperFactory);
            var expectedDataMapper = factory.GetDataMapper(typeof(DataMapper));
            //---------------Execute Test ----------------------
            var dataMapper = factory.GetDataMapper(targetType);

            //---------------Test Result -----------------------
            Assert.IsInstanceOf <GeneralDataMapper>(dataMapper);
            Assert.AreNotSame(expectedDataMapper, dataMapper);
        }
Пример #16
0
        public void GetDataMapper_ShouldBeThreadSafeForNonStandardTypes()
        {
            //---------------Set up test pack-------------------
            var enumType = typeof(TestEnum);
            var sut      = new DataMapperFactory();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            Assert.DoesNotThrow(() => Parallel.For(0, 1000, i => sut.GetDataMapper(enumType)));

            //---------------Test Result -----------------------
        }
        private void Btn_CreerCompteProg_Click(object sender, RoutedEventArgs e)
        {
            if (TextBox_Numero.Text.Length < 1)
            {
                MessageBox.Show("Veuillez choisir un numéro.");
                return;
            }
            if (TextBox_Solde.Text.Length < 1)
            {
                MessageBox.Show("Veuillez choisir un solde.");
                return;
            }
            ICompteMapper lCompteMapper = (ICompteMapper)DataMapperFactory.GetDataMapperFactory().GetCompteMapper();
            Compte        compte        = new Compte();

            compte.IDClient            = RCCreerCompteContext.Instance.GuidClient.ToString();
            compte.Mode_de_facturation = ComboBox_Mode.Text;
            Random rnd = new Random();
            int    numero;

            if (Int32.TryParse(TextBox_Numero.Text, out numero))
            {
                compte.Numero = numero;
            }
            else
            {
                compte.Numero = rnd.Next(1, 1000);
            }
            float solde;

            if (float.TryParse(TextBox_Solde.Text.Replace(',', '.'), out solde))
            {
                compte.Solde = solde;
            }
            else
            {
                compte.Solde = 0;
            }
            lCompteMapper.Insert(compte);

            MessageBox.Show("Compte créé avec succès.\n\nVeuillez choisir une date d'installation.");
            if (NavigationService.CanGoBack)
            {
                NavigationService.GoBack();
            }
            //return;
            //RCProgrammerInstallation page = new RCProgrammerInstallation();
            //NavigationService.Navigate(page);
        }
Пример #18
0
        // GetDataPage
        public DataPage <T> GetDataPage <T>(SqlCommand command, int pageIndex, int pageSize) where T : class
        {
            SqlDataReader reader = null;
            DataPage <T>  page   = new DataPage <T>();

            page.PageIndex = pageIndex;
            page.PageSize  = pageSize;
            try
            {
                if (command.Connection.State != ConnectionState.Open)
                {
                    command.Connection.Open();
                }
                reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    IDataMapper mapper = new DataMapperFactory().GetMapper(typeof(T));
                    while (reader.Read())
                    {
                        // get the data for this row
                        T dto = null;
                        dto = (T)mapper.GetData(reader);
                        page.Data.Add(dto);
                        // If we haven't set the RecordCount yet then set it
                        if (page.RecordCount == 0)
                        {
                            page.RecordCount = mapper.GetRecordCount(reader);
                        }
                    }
                    reader.Close();
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error populating data", e);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (_trans == null)
                {
                    command.Connection.Close();
                }
            }
            return(page);
        }
        private void Btn_Cloturer_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Etes vous sur?", "Confirmation de clôturation", System.Windows.MessageBoxButton.YesNo);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                ICompteMapper lCompteMapper = (ICompteMapper)DataMapperFactory.GetDataMapperFactory().GetCompteMapper();
                Compte        compte        = new Compte();
                compte.ID = RCModifierCompteContext.Instance.GuidCompte;
                lCompteMapper.Delete(compte);

                MessageBox.Show("Facture envoyé.\n\nCompte clôturé.");
                SelectionnerCompte inputDialog = new SelectionnerCompte();
                if (inputDialog.ShowDialog() == true && !String.IsNullOrEmpty(inputDialog.NumeroStr))
                {
                    //Compte sélectionné
                    RCModifierCompteContext.Instance.Mode         = inputDialog.Mode;
                    RCModifierCompteContext.Instance.Solde        = inputDialog.Solde;
                    RCModifierCompteContext.Instance.GuidCompte   = inputDialog.GuidCompte;
                    RCModifierCompteContext.Instance.Numero       = inputDialog.Numero;
                    RCModifierCompteContext.Instance.GuidClient   = inputDialog.GuidClient;
                    RCModifierCompteContext.Instance.NomRaison    = inputDialog.Client;
                    RCModifierCompteContext.Instance.GridVisible  = Visibility.Visible;
                    RCModifierCompteContext.Instance.Grid2Visible = Visibility.Collapsed;

                    //données du client
                    RCModifierClientContext.Instance.ID            = inputDialog.GuidClient;
                    RCModifierClientContext.Instance.Nom           = inputDialog.ClientNom;
                    RCModifierClientContext.Instance.Prenom        = inputDialog.ClientPrenom;
                    RCModifierClientContext.Instance.RaisonSociale = inputDialog.ClientRaisonSociale;
                    RCModifierClientContext.Instance.Adresse       = inputDialog.ClientAdresse;
                    RCModifierClientContext.Instance.Telephone     = inputDialog.ClientTelephone;
                    RCModifierClientContext.Instance.Pseudo        = inputDialog.ClientPseudo;
                    RCModifierClientContext.Instance.MotDePasse    = inputDialog.ClientMotDePasse;
                }
                else
                {
                    //Compte non sélectionné
                    RCModifierCompteContext.Instance.Mode         = 0;
                    RCModifierCompteContext.Instance.Solde        = 0;
                    RCModifierCompteContext.Instance.GuidCompte   = Guid.Empty;
                    RCModifierCompteContext.Instance.Numero       = 0;
                    RCModifierCompteContext.Instance.GuidClient   = Guid.Empty;
                    RCModifierCompteContext.Instance.NomRaison    = "Non defini";
                    RCModifierCompteContext.Instance.GridVisible  = Visibility.Collapsed;
                    RCModifierCompteContext.Instance.Grid2Visible = Visibility.Visible;
                }
            }
        }
Пример #20
0
        public void ChercherServiceDispo()
        {
            IServiceDiffusionMapper lServiceMapper = (IServiceDiffusionMapper)DataMapperFactory.GetDataMapperFactory().GetServiceDiffusionMapper();
            DataTable services = lServiceMapper.FindAll();

            listeDispo.Clear();
            foreach (DataRow row in services.Rows)
            {
                listeDispo.Add(new ServiceDiffusion
                {
                    Numero = Int32.Parse(row["numero"].ToString()),
                    Nom    = row["nom"].ToString()
                });
            }
        }
Пример #21
0
        // GetList
        public List <T> GetList <T>(SqlCommand command) where T : class
        {
            SqlConnection dbConnect = new SqlConnection(_DBConnectionString);

            command.Connection = dbConnect;

            List <T> dtoList = new List <T>();

            try
            {
                if (command.Connection.State != ConnectionState.Open)
                {
                    command.Connection.Open();
                }
                SqlDataReader reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    IDataMapper mapper = new DataMapperFactory().GetMapper(typeof(T));
                    while (reader.Read())
                    {
                        T dto = null;
                        dto = (T)mapper.GetData(reader);
                        dtoList.Add(dto);
                    }
                    reader.Close();
                    reader.Dispose();
                }
            }
            catch (Exception e)
            {
                LogMessage(TraceLevel.Error, "Error populating data: " + e.ToString() + "; " + BuildQueryInfoForLogging(command), System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, System.Threading.Thread.CurrentThread.ManagedThreadId);
                throw new Exception("Error populating data", e);
            }
            finally
            {
                try
                {
                    dbConnect.Close();
                    command.Connection = null;
                }
                catch { }
                dbConnect.Dispose();
                dbConnect = null;
            }
            // We return either the populated list if there was data,
            // or if there was no data we return an empty list.
            return(dtoList);
        }
Пример #22
0
        public SelectionnerCompteContext()
        {
            ICompteMapper lCompteMapper = (ICompteMapper)DataMapperFactory.GetDataMapperFactory().GetCompteMapper();
            DataTable     comptes       = lCompteMapper.FindAll();

            foreach (DataRow row in comptes.Rows)
            {
                Guid guidCompte;
                if (Guid.TryParse(row["iD"].ToString(), out guidCompte))
                {
                    IClientMapper lClientMapper = (IClientMapper)DataMapperFactory.GetDataMapperFactory().GetClientMapper();
                    Guid          guidClient;
                    if (Guid.TryParse(row["iDClient"].ToString(), out guidClient))
                    {
                        Client client = lClientMapper.Find(guidClient);
                        listeCompte.Add(new CompteSelection
                        {
                            NomRaison  = client.Nom + " " + client.Prenom + " " + client.Raison_sociale,
                            GuidClient = guidClient,
                            Numero     = Int32.Parse(row["numero"].ToString()),
                            GuidCompte = guidCompte,
                            Solde      = float.Parse(row["solde"].ToString()),
                            Mode       = (row["mode_de_facturation"].ToString().Equals("Mensuel") ? 0 : 1),
                            Client     = new Client
                            {
                                Numero         = client.Numero,
                                Pseudo         = client.Pseudo,
                                Mot_de_passe   = client.Mot_de_passe,
                                Nom            = client.Nom,
                                Prenom         = client.Prenom,
                                Raison_sociale = client.Raison_sociale,
                                Adresse        = client.Adresse,
                                Telephone      = client.Telephone
                            }
                        });
                    }
                    else
                    {
                        Debug.WriteLine("Client non trouvé");
                    }
                }
                else
                {
                    Debug.WriteLine("Compte non trouvé");
                }
            }
        }
        public void ChercherEquipDispo()
        {
            IEquipementMapper lEquipementMapper = (IEquipementMapper)DataMapperFactory.GetDataMapperFactory().GetEquipementMapper();
            DataTable         equips            = lEquipementMapper.FindAll();

            listeDispo.Clear();
            foreach (DataRow row in equips.Rows)
            {
                listeDispo.Add(new Equipement
                {
                    Numero = Int32.Parse(row["numero"].ToString()),
                    Nom    = row["nom"].ToString(),
                    Tarif_mensuel_de_location = float.Parse(row["tarif_mensuel_de_location"].ToString(), CultureInfo.InvariantCulture.NumberFormat),
                    IDCompte = ""
                });
            }
        }
Пример #24
0
        public void ChercherInstall()
        {
            IInstallationMapper lInstallMapper = (IInstallationMapper)DataMapperFactory.GetDataMapperFactory().GetInstallationMapper();
            DataTable           installs       = lInstallMapper.FindAll();

            listeInstall.Clear();
            foreach (DataRow row in installs.Rows)
            {
                listeInstall.Add(new Installation
                {
                    Numero             = 123,
                    Date_programmation = row["date_programmation"].ToString(),
                    Date_realisation   = row["date_realisation"].ToString(),
                    Frais    = float.Parse(row["frais"].ToString()),
                    IDClient = ""
                });
            }
        }
Пример #25
0
        public void ChercherChaineDispo()
        {
            IChaineMapper lChaineMapper = (IChaineMapper)DataMapperFactory.GetDataMapperFactory().GetChaineMapper();
            DataTable     chaines       = lChaineMapper.FindAll();

            listeChaine.Clear();
            foreach (DataRow row in chaines.Rows)
            {
                listeChaine.Add(new Chaine
                {
                    Numero = Int32.Parse(row["numero"].ToString()),
                    Sigle  = row["sigle"].ToString(),
                    Nom    = row["nom"].ToString(),
                    Nature = row["nature"].ToString(),
                    Prix   = float.Parse(row["prix"].ToString(), CultureInfo.InvariantCulture.NumberFormat)
                });
            }
        }
Пример #26
0
        private static string FindTableColumnFor <T>(string propertyName)
        {
            string tableColumName = string.Empty;

            Dictionary <string, string> propertyMapToTableColumn =
                DataMapperFactory.GetDataMapper <T>().PropertyMapToTableColumn;

            if (propertyMapToTableColumn.ContainsKey(propertyName))
            {
                tableColumName = propertyMapToTableColumn[propertyName];
            }
            else
            {
                throw new Exception("属性:" + propertyName + "在数据库表中不存在对用的列");
            }

            return(tableColumName);
        }
Пример #27
0
        public static List <Film> rechercher(List <string[]> param)
        {
            DataMapperFactory dataMapper = DataMapperFactory.GetDataMapperFactory();
            IFilmMapper       filmMapper = dataMapper.GetFilmMapper();



            DataTable listFilms = filmMapper.FindWithConditions(param);

            List <Film> result = new List <Film>();

            foreach (DataRow row in listFilms.Rows)
            {
                Film filmAajouter = new Film(row["titre"].ToString(), (int)row["durée"], (int)row["coûtAchat"], (int)row["coûtVisionnement"], row["motsClès"].ToString(), row["réalisateurs"].ToString(), row["acteurs"].ToString(), row["maisonsProduction"].ToString(), row["producteurs"].ToString(), row["synopsis"].ToString());
                result.Add(filmAajouter);
            }
            return(result);
        }
Пример #28
0
        private void Btn_Continuer_Click(object sender, RoutedEventArgs e)
        {
            if ((TextBox_Nom.Text.Length >= 1 || TextBox_Prenom.Text.Length >= 1) &&
                TextBox_Raison.Text.Length >= 1)
            {
                MessageBox.Show("Veuillez choisir entre les champs \"particulier\" et \"entreprise\".");
            }
            else if (((TextBox_Nom.Text.Length >= 1 && TextBox_Prenom.Text.Length >= 1) ||
                      TextBox_Raison.Text.Length >= 1) &&
                     TextBox_Adr1.Text.Length >= 1 &&
                     TextBox_Tel.Text.Length >= 1 &&
                     TextBox_Identifiant.Text.Length >= 1 &&
                     TextBox_MotDePasse.Text.Length >= 1)
            {
                Client lClient = new Client();
                lClient.ID = RCModifierClientContext.Instance.ID;
                if (TextBox_Nom.Text.Length >= 1 && TextBox_Prenom.Text.Length >= 1)
                {
                    lClient.Nom    = TextBox_Nom.Text;
                    lClient.Prenom = TextBox_Prenom.Text;
                }
                else
                {
                    lClient.Raison_sociale = TextBox_Raison.Text;
                }
                lClient.Adresse      = TextBox_Adr1.Text;
                lClient.Telephone    = TextBox_Tel.Text;
                lClient.Pseudo       = TextBox_Identifiant.Text;
                lClient.Mot_de_passe = TextBox_MotDePasse.Text;

                IClientMapper lClientMapper = (IClientMapper)DataMapperFactory.GetDataMapperFactory().GetClientMapper();
                lClientMapper.Update(lClient);

                MessageBox.Show("Enregistré !");
                if (NavigationService.CanGoBack)
                {
                    NavigationService.GoBack();
                }
            }
            else
            {
                MessageBox.Show("Veuillez remplir tous les champs.");
            }
        }
Пример #29
0
        public DataPoint FindBy(int id)
        {
            DataPoint dataPoint = new DataPoint();
            DataTable dataTable;

            MySqlParameter[] mySqlPrarametersForDataPointQuery = { new MySqlParameter("@Id", id) };
            string           dataPointQuery = this.baseSelectQuery +
                                              "where DataPointId=@Id;";

            //string moduleQuery = "select ModuleId,Number,Name,Description " +
            //                     "from numericalcontrolsystem.module " +
            //                     "where ModuleId=@Id;";

            try
            {
                dataTable = dbUtility.ExecuteDataTable(dataPointQuery, CommandType.Text, mySqlPrarametersForDataPointQuery);
                if (null != dataTable)
                {
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        dataPoint = DataMapperFactory.GetDataMapper <DataPoint>().ConverFrom(dataTable.Rows, i);
                    }
                }

                //MySqlParameter[] mySqlPrarametersForModuleQuery = { new MySqlParameter("@Id", dataPoint.ModuleBelongTo.Id) };
                //dataTable = dbUtility.ExecuteDataTable(moduleQuery, CommandType.Text, mySqlPrarametersForDataPointQuery);
                //if (null != dataTable)
                //{
                //    for (int i = 0; i < dataTable.Rows.Count; i++)
                //    {
                //        dataPoint.ModuleBelongTo = DataMapperFactory.GetDataMapper<Module>().ConverFrom(dataTable.Rows, i);
                //    }
                //}
            }
            catch (Exception ex)
            {
                string message = "查询失败!" + ex.Message;
                LoggingFactory.GetLogger().WriteDebugLogger(message);

                return(dataPoint);
            }

            return(dataPoint);
        }
Пример #30
0
        // GetList
        public List <T> GetList <T>(SqlCommand command) where T : class
        {
            List <T>      dtoList = new List <T>();
            SqlDataReader reader  = null;

            try
            {
                if (command.Connection.State != ConnectionState.Open)
                {
                    command.Connection.Open();
                }
                reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    IDataMapper mapper = new DataMapperFactory().GetMapper(typeof(T));
                    while (reader.Read())
                    {
                        T dto = null;
                        dto = (T)mapper.GetData(reader);
                        dtoList.Add(dto);
                    }
                    reader.Close();
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error populating data", e);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (_trans == null)
                {
                    command.Connection.Close();
                }
            }
            // We return either the populated list if there was data,
            // or if there was no data we return an empty list.
            return(dtoList);
        }