Пример #1
0
        public static Bon_Cmd GetBonCmd(int PretID)
        {
            Bon_Cmd       bon_cmd       = new Bon_Cmd();
            SqlConnection sqlConnection = new SqlConnection(constr);

            sqlConnection.Open();
            String     Command    = "SELECT * FROM " + table + " WHERE pretsID = @id ;";
            SqlCommand sqlCommand = new SqlCommand(Command, sqlConnection);

            using (sqlCommand)
            {
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.Parameters.AddWithValue("@id", PretID);
                SqlDataReader dataReader = sqlCommand.ExecuteReader();
                if (dataReader.Read())
                {
                    bon_cmd.setId((int)dataReader[0]);
                    bon_cmd.setNum((int)dataReader[1]);
                    bon_cmd.setDate((DateTime)dataReader[5]);
                    int id = (int)dataReader[2];
                    bon_cmd.setFournisseur(ConnectionFournisseur.GetFournisseur(id));

                    bon_cmd.setProduit((String)dataReader[3]);
                    bon_cmd.setPrix(Convert.ToDouble(dataReader[4]));
                    bon_cmd.setdemand_id((int)dataReader[7]);
                    bon_cmd.setprets_id((int)dataReader[6]);
                }
                dataReader.Close();
            }
            sqlCommand.Dispose();
            sqlConnection.Close();
            return(bon_cmd);
        }
Пример #2
0
        public static void DeleteBonCmd(Bon_Cmd facture)
        {
            SqlConnection sqlConnection = new SqlConnection(constr);

            sqlConnection.Open();
            String     command    = "DELETE FROM " + table + " WHERE Id=@id ;";
            SqlCommand sqlCommand = new SqlCommand(command, sqlConnection);

            using (sqlCommand)
            {
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.Parameters.AddWithValue("@id", facture.getId());
                sqlCommand.ExecuteNonQuery();
            }
            sqlCommand.Dispose();
            sqlConnection.Close();
        }
Пример #3
0
        public static void AddBonCmd(Bon_Cmd bon_Cmd)
        {
            SqlConnection sqlConnection = new SqlConnection(constr);

            sqlConnection.Open();
            String command = "INSERT INTO " + table + " VALUES(@Id , @num  ,@fournisseur " +
                             ",@produit ,@prix,@date, @pretID" +
                             ",@Demand);";
            SqlCommand sqlCommand = new SqlCommand(command, sqlConnection);

            using (sqlCommand)
            {
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.Parameters.AddWithValue("@Id", bon_Cmd.getId());
                sqlCommand.Parameters.AddWithValue("@num", bon_Cmd.getNum());
                sqlCommand.Parameters.AddWithValue("@date", bon_Cmd.getDate());
                sqlCommand.Parameters.AddWithValue("@fournisseur", bon_Cmd.GetFournisseur().Id);
                if (bon_Cmd.getprets_id() != 0)
                {
                    sqlCommand.Parameters.AddWithValue("@pretID", bon_Cmd.getprets_id());
                }
                else
                {
                    sqlCommand.Parameters.AddWithValue("pretID", DBNull.Value);
                }
                sqlCommand.Parameters.AddWithValue("@produit", bon_Cmd.getproduit());
                if (bon_Cmd.getdemand_id() != 0)
                {
                    sqlCommand.Parameters.AddWithValue("@Demand", bon_Cmd.getdemand_id());
                }
                else
                {
                    sqlCommand.Parameters.AddWithValue("@Demand", DBNull.Value);
                }
                sqlCommand.Parameters.AddWithValue("@prix", bon_Cmd.getPrix());
                sqlCommand.ExecuteNonQuery();
            }
            sqlCommand.Dispose();
            sqlConnection.Close();
        }
Пример #4
0
 /*--------------------
  *
  *
  * --------------------------**/
 public void setBon_cmd(Bon_Cmd bon_Cmd)
 {
     this.BonCmd = bon_Cmd;
 }