Пример #1
0
        public Famille save(Famille famille, SqlConnection conn)
        {
            try
            {
                SqlCommand myCommand;
                if (famille.Id == 0)
                {
                    myCommand = new SqlCommand("INSERT INTO dbo.famille(Nom) values(@Nom)", conn);
                }
                else
                {
                    myCommand = new SqlCommand("UPDATE dbo.article set Nom = @Nom where id = @id", conn);
                    myCommand.Parameters.AddWithValue("@id", famille.Id);
                }

                myCommand.Parameters.AddWithValue("@Nom", famille.Nom);
                CaisseLogger.LogInfo("Triyng to save artice : " + famille.ToString());
                conn.Open();
                myCommand.ExecuteNonQuery();
                CaisseLogger.LogInfo("Article " + famille.ToString() + " saved.");
                conn.Close();
                return(famille);
            }
            catch (Exception ex)
            {
                CaisseLogger.LogError(ex.ToString());
                return(famille);
            }
        }
Пример #2
0
        private void init()
        {
            produit = new Article();
            famille = new Famille();
            SqlDataAdapter articles = new SqlDataAdapter("Select * From dbo.article where id>1", conn);
            DataSet        ds       = new DataSet("articlesDS");
            DataTable      dt       = new DataTable();

            //articles.SelectCommand = new SqlCommand(@"SELECT * FROM FooTable", connString);
            articles.Fill(ds, "dbo.article");
            dt = ds.Tables["dbo.article"];
        }
Пример #3
0
 private void familleFormGlobal_VisibleChanged(object sender, EventArgs e)
 {
     if (!this.familleFormGlobal.Visible)
     {
         try
         {
             this.famille = this.familleFormGlobal.Famille;
             familleRepository.save(this.famille, conn);
         }
         catch (Exception ex)
         {
             CaisseLogger.LogError(ex.ToString());
         }
     }
 }